Views
No views yet
Give Transformers a sense of time - not by scaling, but by structure.
| Symbol | Description |
|---|---|
| \( \text{score}_{ij} \) | Attention score between query at position \( i \) and key at position \( j \) |
| \( Q_i \) | Query vector for position \( i \) |
| \( K_j \) | Key vector for position \( j \) |
| \( d_k \) | Dimension of key vectors |
| \( \gamma \) | Learnable time bias strength |
| \( f(\cdot) \) | Time difference function |
| \( t_j - t_i \) | Relative time difference |
1from temporal_attention import TemporalSelfAttention
2
3model = TemporalSelfAttention(
4 embed_dim=64,
5 num_heads=1,
6 bias_type="linear", # or 'gaussian'
7 gamma=1.0,
8 causal=False
9)
10
11# x: (B, T, D), timestamps: (B, T)
12output, weights = model(x, timestamps)