Jdice27 commited on
Commit
7f6e981
Β·
verified Β·
1 Parent(s): 8cae25f

Comprehensive model card with full results and documentation

Browse files
Files changed (1) hide show
  1. README.md +203 -42
README.md CHANGED
@@ -7,57 +7,159 @@ tags:
7
  - time-series
8
  - llm-reprogramming
9
  - gpt2
 
 
10
  datasets:
11
  - petchthwr/ATFMTraj
12
  pipeline_tag: time-series-forecasting
13
  ---
14
 
15
- # LLM4AirTrack: LLM-Driven Aircraft Trajectory Prediction
16
 
17
- Adapts the [LLM4STP](https://github.com/Joker-hang/LLM4STP) framework from maritime AIS to aviation ADS-B.
18
- Uses a **frozen GPT-2 backbone** with lightweight trainable adapters (~2.4% of params).
 
 
 
19
 
20
  ## Architecture
21
 
22
  ```
23
- ADS-B Features (9-dim) β†’ RevIN β†’ Patch Tokenizer β†’ Patch Embedder
24
- β†’ Cross-Attention Reprogrammer (learned text prototypes)
25
- β†’ Prompt-as-Prefix β†’ Frozen GPT-2 Backbone
26
- β†’ Trajectory Head (future xyz) + Classification Head (STAR/runway)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  ```
28
 
29
  ### Key Components
30
- 1. **9-dim Kinematic Features**: Position (x,y,z ENU) + Direction (ux,uy,uz) + Polar (r, sinΞΈ, cosΞΈ)
31
- 2. **Patch Tokenization**: Overlapping temporal patches (len=8, stride=4)
32
- 3. **Cross-Attention Reprogramming**: 256 learned text prototypes, 8-head attention
33
- 4. **Frozen GPT-2**: 124M params frozen, only ~3.1M trainable
34
- 5. **Dual Heads**: Trajectory prediction (Smooth L1) + Route classification (CE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  ## Training
37
 
38
- - **Dataset**: [ATFMTraj](https://huggingface.co/datasets/petchthwr/ATFMTraj) - RKSIa
39
- - **Source**: OpenSky ADS-B, Incheon International Airport arrivals (2018-2023)
40
- - **Context**: 60 timesteps (1s intervals)
41
- - **Prediction**: 30 timesteps ahead
42
- - **Optimizer**: AdamW, lr=0.0005, cosine annealing
43
- - **Epochs**: 5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  ## Results
46
 
47
- | Metric | Value |
48
- |--------|-------|
49
- | ADE (normalized) | 0.010258 |
50
- | Best Epoch | 3 |
51
- | Route Classification Acc | 0.3649 |
 
 
 
 
 
 
 
 
52
 
53
  ## Usage
54
 
 
 
55
  ```python
56
- import torch, json
57
- from train_full import LLM4AirTrack
 
58
 
59
- # Load
60
- with open("config.json") as f:
 
 
 
 
 
 
61
  cfg = json.load(f)
62
 
63
  model = LLM4AirTrack(
@@ -65,29 +167,88 @@ model = LLM4AirTrack(
65
  context_len=cfg["context_len"],
66
  pred_len=cfg["pred_len"],
67
  n_classes=cfg["n_classes"],
 
 
 
68
  )
69
- state = torch.load("adapter_weights.pt", map_location="cpu")
70
  model.load_state_dict(state, strict=False)
71
  model.eval()
72
 
73
- # Predict (input: 60 timesteps of 9-dim kinematic features)
74
- context = torch.randn(1, 60, 9)
75
- out = model(context)
76
- future_xyz = out["pred_trajectory"] # (1, 30, 3)
77
- route_class = out["pred_class"].argmax(-1) # (1,)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  ```
79
 
80
  ## Downstream Tasks
81
 
82
- - **Track Activity Classification**: Route/procedure identification from trajectory embeddings
83
- - **Anomaly Detection**: Flag deviations from predicted trajectory
84
- - **Conflict Detection**: Multi-aircraft trajectory forecasting
85
- - **ETA Prediction**: Time-to-threshold from trajectory state
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  ## References
88
 
89
- - [LLM4STP](https://github.com/Joker-hang/LLM4STP) - Original maritime framework
90
- - [Time-LLM](https://arxiv.org/abs/2310.01728) - Foundational reprogramming approach
91
- - [ATFMTraj](https://huggingface.co/datasets/petchthwr/ATFMTraj) - Aviation trajectory dataset
92
- - [ATSCC](https://arxiv.org/abs/2407.20028) - Self-supervised trajectory representation
93
- - [LLM4Delay](https://arxiv.org/abs/2510.23636) - Cross-modality LLM adaptation for aviation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  - time-series
8
  - llm-reprogramming
9
  - gpt2
10
+ - air-traffic-management
11
+ - spatiotemporal
12
  datasets:
13
  - petchthwr/ATFMTraj
14
  pipeline_tag: time-series-forecasting
15
  ---
16
 
17
+ # LLM4AirTrack: LLM-Driven Multi-Feature Fusion for Aircraft Trajectory Prediction
18
 
19
+ ## Overview
20
+
21
+ **LLM4AirTrack** adapts the [LLM4STP](https://github.com/Joker-hang/LLM4STP) (Large Language Model for Ship Trajectory Prediction) framework from maritime AIS to aviation ADS-B domain. The core insight is that pre-trained LLMs encode powerful sequential pattern recognition that transfers to spatiotemporal trajectory data through lightweight reprogramming β€” without full fine-tuning.
22
+
23
+ The framework uses a **frozen GPT-2 backbone** with trainable adapter modules (~2.4% of total parameters) to predict future aircraft positions and classify flight routes/procedures.
24
 
25
  ## Architecture
26
 
27
  ```
28
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
29
+ β”‚ LLM4AirTrack Framework β”‚
30
+ β”‚ β”‚
31
+ β”‚ ADS-B Features (9-dim: xyz + direction + polar) β”‚
32
+ β”‚ β”‚ β”‚
33
+ β”‚ β–Ό β”‚
34
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
35
+ β”‚ β”‚ RevIN Normalizer β”‚ Instance normalization per feature β”‚
36
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
37
+ β”‚ β”‚ β”‚
38
+ β”‚ β–Ό β”‚
39
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
40
+ β”‚ β”‚ Patch Tokenizer β”‚ Overlapping temporal patches (8Γ—9=72) β”‚
41
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
42
+ β”‚ β”‚ β”‚
43
+ β”‚ β–Ό β”‚
44
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
45
+ β”‚ β”‚ Patch Embedder β”‚ β”‚ Text Prototype Bank β”‚ β”‚
46
+ β”‚ β”‚ (72 β†’ 768) β”‚ β”‚ (256 learned protos) β”‚ β”‚
47
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
48
+ β”‚ β”‚ β”‚ β”‚
49
+ β”‚ β–Ό β–Ό β”‚
50
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
51
+ β”‚ β”‚ Cross-Attention Reprogrammer β”‚ β”‚
52
+ β”‚ β”‚ Q=patches, K=V=prototypes (8-head) β”‚ β”‚
53
+ β”‚ β”‚ Maps trajectory β†’ LLM text space β”‚ β”‚
54
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
55
+ β”‚ β”‚ β”‚
56
+ β”‚ β–Ό β”‚
57
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
58
+ β”‚ β”‚ Prompt-as-Prefix β”‚ Aviation context prompt prepended β”‚
59
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
60
+ β”‚ β”‚ β”‚
61
+ β”‚ β–Ό β”‚
62
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
63
+ β”‚ β”‚ Frozen GPT-2 β”‚ 124M params frozen, language knowledge β”‚
64
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
65
+ β”‚ β”‚ β”‚
66
+ β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€οΏ½οΏ½οΏ½β”€β”€β” β”‚
67
+ β”‚ β–Ό β–Ό β”‚
68
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
69
+ β”‚ β”‚ Traj Headβ”‚ β”‚ Classification β”‚ β”‚
70
+ β”‚ β”‚ (xyz) β”‚ β”‚ Head (route/rwy) β”‚ β”‚
71
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
72
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
73
  ```
74
 
75
  ### Key Components
76
+
77
+ 1. **9-Dimensional Kinematic Features** (from [ATSCC](https://arxiv.org/abs/2407.20028)):
78
+ - Position: (x, y, z) in East-North-Up coordinates
79
+ - Directional unit vectors: (ux, uy, uz) β€” velocity direction
80
+ - Polar components: (r, sin ΞΈ, cos ΞΈ) β€” angular position
81
+
82
+ 2. **Patch Tokenization**: Overlapping temporal windows (patch_len=8, stride=4) β†’ 14 patches from 60-step context
83
+
84
+ 3. **Cross-Attention Reprogramming** (from [Time-LLM](https://arxiv.org/abs/2310.01728)): 256 learned text prototypes serve as a "translation dictionary" between trajectory and language domains
85
+
86
+ 4. **Frozen GPT-2 Backbone**: 124M frozen parameters preserve pre-trained language understanding while keeping training efficient
87
+
88
+ 5. **Dual Output Heads**:
89
+ - **Trajectory Prediction**: Future (x, y, z) positions via Smooth L1 loss
90
+ - **Route Classification**: STAR/IAF/Runway procedure via Cross-Entropy loss
91
+
92
+ ### Parameter Efficiency
93
+
94
+ | Component | Parameters | Trainable |
95
+ |-----------|-----------|-----------|
96
+ | GPT-2 Backbone | 124,439,808 | 0 (frozen) |
97
+ | Patch Embedder | 57,600 | 57,600 |
98
+ | Cross-Attention Reprogrammer | 2,560,512 | 2,560,512 |
99
+ | Trajectory Head | 329,946 | 329,946 |
100
+ | Classification Head | 150,543 | 150,543 |
101
+ | **Total** | **127,543,059** | **3,103,251 (2.43%)** |
102
 
103
  ## Training
104
 
105
+ ### Dataset
106
+ - **Source**: [ATFMTraj](https://huggingface.co/datasets/petchthwr/ATFMTraj) β€” RKSIa (Incheon International Airport arrivals)
107
+ - **Origin**: OpenSky ADS-B recordings, 2018-2023
108
+ - **Preprocessing**: Raw lat/lon/alt β†’ ENU coordinates β†’ normalized to [-1,1] by r_max=120km
109
+ - **Trajectories**: 8,091 training + 8,092 test (16,183 total flights)
110
+ - **Windows**: 282,191 training + 20,000 evaluation sliding windows
111
+ - **Context**: 60 timesteps (1-second intervals = 1 minute of flight)
112
+ - **Prediction**: 30 timesteps ahead (30 seconds)
113
+ - **Classes**: 39 route labels (STAR Γ— IAF Γ— Runway combinations)
114
+
115
+ ### Hyperparameters
116
+ | Parameter | Value |
117
+ |-----------|-------|
118
+ | LLM Backbone | `openai-community/gpt2` (768 hidden, 12 layers) |
119
+ | Optimizer | AdamW (β₁=0.9, Ξ²β‚‚=0.999) |
120
+ | Learning Rate | 5Γ—10⁻⁴ with cosine annealing warm restarts |
121
+ | Weight Decay | 1Γ—10⁻⁡ |
122
+ | Batch Size | 128 |
123
+ | Epochs | 5 |
124
+ | Gradient Clipping | max_norm=1.0 |
125
+ | Multi-task Weight | Ξ»_traj=1.0, Ξ»_cls=0.1 |
126
+ | Loss (trajectory) | Smooth L1 (Huber) |
127
+ | Loss (classification) | Cross-Entropy |
128
+ | Hardware | NVIDIA T4 (16GB VRAM, used ~1.4GB) |
129
 
130
  ## Results
131
 
132
+ | Epoch | Train Loss | ADE | FDE | Route Accuracy |
133
+ |-------|-----------|-----|-----|----------------|
134
+ | 1 | 0.2335 | 0.01500 | 0.02047 | 34.7% |
135
+ | 2 | 0.2110 | 0.01200 | 0.01635 | 36.1% |
136
+ | **3** | **0.2033** | **0.01026** | **0.01426** | **36.3%** |
137
+ | 4 | 0.2037 | 0.01345 | 0.01858 | 34.9% |
138
+ | 5 | 0.2003 | 0.01518 | 0.02043 | 36.5% |
139
+
140
+ **Best model (epoch 3)**:
141
+ - **ADE: 0.01026** (normalized ENU scale; with r_max=120km β†’ ~1.23km average displacement)
142
+ - **FDE: 0.01426** (~1.71km final displacement error at 30s horizon)
143
+ - **Route Classification: 36.3%** accuracy over 39 classes (14Γ— above random baseline of 2.6%)
144
+ - **RMSE**: x=0.00957, y=0.00942, z=0.00072 (altitude prediction is very accurate)
145
 
146
  ## Usage
147
 
148
+ ### Quick Inference
149
+
150
  ```python
151
+ import torch
152
+ import json
153
+ from huggingface_hub import hf_hub_download
154
 
155
+ # Download model files
156
+ config_path = hf_hub_download("Jdice27/LLM4AirTrack", "config.json")
157
+ weights_path = hf_hub_download("Jdice27/LLM4AirTrack", "adapter_weights.pt")
158
+
159
+ # You can use the self-contained train_full.py or the modular llm4airtrack package
160
+ from llm4airtrack.model import LLM4AirTrack
161
+
162
+ with open(config_path) as f:
163
  cfg = json.load(f)
164
 
165
  model = LLM4AirTrack(
 
167
  context_len=cfg["context_len"],
168
  pred_len=cfg["pred_len"],
169
  n_classes=cfg["n_classes"],
170
+ n_prototypes=cfg["n_prototypes"],
171
+ patch_len=cfg["patch_len"],
172
+ patch_stride=cfg["patch_stride"],
173
  )
174
+ state = torch.load(weights_path, map_location="cpu")
175
  model.load_state_dict(state, strict=False)
176
  model.eval()
177
 
178
+ # Input: 60 timesteps Γ— 9 kinematic features
179
+ # Features: [x, y, z, ux, uy, uz, r, sin_ΞΈ, cos_ΞΈ] in ENU coordinates
180
+ context = torch.randn(1, 60, 9) # Replace with real data
181
+ outputs = model(context, task="both")
182
+
183
+ future_xyz = outputs["pred_trajectory"] # (1, 30, 3) β€” future ENU positions
184
+ route_probs = outputs["pred_class"].softmax(-1) # (1, 39) β€” route probabilities
185
+ ```
186
+
187
+ ### Data Pipeline
188
+
189
+ ```python
190
+ from llm4airtrack.data import download_atfm_dataset, load_atfm_raw, compute_kinematic_features
191
+
192
+ # Download and load ATFMTraj
193
+ download_atfm_dataset("RKSIa", cache_dir="./data")
194
+ data, labels = load_atfm_raw("RKSIa", "TEST", "./data")
195
+
196
+ # Get kinematic features for a single trajectory
197
+ traj = data[0] # (T_max, 3) ENU coordinates
198
+ valid = ~np.isnan(traj[:, 0])
199
+ features = compute_kinematic_features(traj[valid]) # (T, 9)
200
  ```
201
 
202
  ## Downstream Tasks
203
 
204
+ The model produces rich trajectory representations suitable for:
205
+
206
+ | Task | How to Use |
207
+ |------|-----------|
208
+ | **Track Activity Classification** | Use `pred_class` output β€” identifies STAR/IAF/runway procedure |
209
+ | **Trajectory Prediction** | Use `pred_trajectory` β€” 30-second position forecast |
210
+ | **Anomaly Detection** | Compare `pred_trajectory` vs actual β€” large deviations flag anomalies |
211
+ | **Conflict Detection** | Run on multiple aircraft, check predicted trajectory intersections |
212
+ | **ETA Prediction** | Extract LLM hidden states as features for regression head |
213
+ | **Transfer to New Airports** | Fine-tune adapter weights on new airport data (ESSA, LSZH included in ATFMTraj) |
214
+
215
+ ## Design Decisions & Adaptation from Maritime (LLM4STP) to Aviation (ADS-B)
216
+
217
+ | Aspect | LLM4STP (Maritime AIS) | LLM4AirTrack (Aviation ADS-B) |
218
+ |--------|----------------------|-------------------------------|
219
+ | Dimensionality | 2D (lat, lon) | **3D (lat, lon, altitude β†’ ENU xyz)** |
220
+ | Features | SOG, COG, ROT | Ground speed β†’ directional vectors; vertical rate β†’ uz |
221
+ | Update Rate | ~10s intervals | **1s intervals** (higher resolution) |
222
+ | Route Structure | Free navigation | **Defined STARs/SIDs** (structured procedures) |
223
+ | Context | Port/strait proximity | Airport/procedure context (encoded in prompt) |
224
+ | Phase Segmentation | Anchoring/transiting | Climb/cruise/descent/approach |
225
+ | Classification | Vessel type | **Route procedure (39 STARΓ—IAFΓ—RWY classes)** |
226
+ | Spatial Encoding | Lat/lon directly | **ENU Cartesian + polar components** |
227
 
228
  ## References
229
 
230
+ ### Foundational Work
231
+ - **LLM4STP**: [GitHub](https://github.com/Joker-hang/LLM4STP) β€” Original maritime trajectory prediction framework
232
+ - **Time-LLM**: [arXiv 2310.01728](https://arxiv.org/abs/2310.01728) β€” LLM reprogramming for time series (ICLR 2024)
233
+
234
+ ### Aviation Domain
235
+ - **ATSCC**: [arXiv 2407.20028](https://arxiv.org/abs/2407.20028) β€” Self-supervised trajectory representation, 9-dim feature engineering
236
+ - **LLM4Delay**: [arXiv 2510.23636](https://arxiv.org/abs/2510.23636) β€” Cross-modality LLM for aviation delay prediction
237
+ - **ATFMTraj**: [HuggingFace Dataset](https://huggingface.co/datasets/petchthwr/ATFMTraj) β€” Aircraft trajectory classification data
238
+
239
+ ### Related Approaches
240
+ - **Flight2Vec**: [arXiv 2412.16581](https://arxiv.org/abs/2412.16581) β€” Behavior-adaptive patching for flight trajectories
241
+ - **H3+CLM**: [arXiv 2405.09596](https://arxiv.org/abs/2405.09596) β€” Spatial tokenization for trajectory prediction
242
+ - **SKETCH**: [arXiv 2601.18537](https://arxiv.org/abs/2601.18537) β€” Semantic key-point conditioning
243
+
244
+ ## Citation
245
+
246
+ ```bibtex
247
+ @misc{llm4airtrack2026,
248
+ title={LLM4AirTrack: LLM-Driven Multi-Feature Fusion for Aircraft Trajectory Prediction},
249
+ author={Jdice27},
250
+ year={2026},
251
+ url={https://huggingface.co/Jdice27/LLM4AirTrack},
252
+ note={Adapted from LLM4STP for aviation ADS-B domain}
253
+ }
254
+ ```