Temporal Reasoning: Understanding Time in Text
Module: Natural Language Processing | Difficulty: Advanced
Temporal Expression
Event Ordering
Time-Aware Model
Benchmarks
| Task | Metric | Score | |------|--------|-------| | TimeX | F1 | 72.3 | | TempEval | Acc | 68.5 | | TimeBank | F1 | 75.1 |
import torch
import torch.nn as nn
class TemporalReasoner(nn.Module):
def __init__(self, bert_model):
super().__init__()
self.bert = bert_model
self.time_encoder = nn.Linear(8, 768)
self.relation_classifier = nn.Linear(768*3, 3)
def forward(self, event1_repr, event2_repr, time_repr):
time_emb = self.time_encoder(time_repr)
combined = torch.cat([event1_repr, event2_repr, time_emb], dim=-1)
return self.relation_classifier(combined)
Research Insight: Temporal reasoning requires understanding both explicit time expressions and implicit temporal relations. Time-aware language models that incorporate temporal information improve performance by 10-15% on temporal benchmarks.