ablation¶
experiments.ablation
¶
Base-model ablation study - 4-condition evaluation of the untuned LFM2.5-VL-1.6B.
Runs the base (non-fine-tuned) Liquid VLM through the same 4-condition protocol used by
the fine-tuned evaluation in evaluate. Comparing the two scripts' outputs quantifies
the effect of QLoRA fine-tuning on each input channel.
Conditions:
| ID | Name | Image | Coordinates | Tests |
|---|---|---|---|---|
| A | Full system | Real | Real | Nominal end-to-end accuracy |
| B | Vision only | Real | Stripped | Visual-feature reliance |
| C | Blind LLM | Gaussian noise | Real | Coordinate memorisation |
| D | Sensor conflict | Real | Spoofed | Vision-vs-telemetry trust |
Usage:
cd ground_segment/experiments
uv run ablation.py # test split (default)
uv run ablation.py --file val # validation split
See the validation and ablation studies guide for how to interpret each condition and compare against the fine-tuned results.
extract_json(text)
¶
Extract the first JSON object from VLM output, falling back to an ERROR dict.
Scans text for the outermost {…} pair and attempts json.loads.
If the model produced blank output, hallucinated prose, or malformed JSON,
returns a sentinel {"category": "ERROR", "reason": "…"} so that the
caller always gets a dict with a category key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
Raw decoded string from the VLM's generation output. |
required |
Returns:
| Type | Description |
|---|---|
|
A dict with at least a |
|
|
or |
Source code in ground_segment/experiments/ablation.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
main()
¶
Run the 4-condition ablation protocol on the base (untuned) LFM2.5-VL-1.6B.
Loads the base model from Hugging Face, iterates over every sample in the chosen split, and evaluates each sample under all four conditions (A-D). Prints per-class recall/precision tables for Conditions A-C and a vision-vs-coordinate trust breakdown for Condition D.
Source code in ground_segment/experiments/ablation.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
print_confusion_matrix(truths, preds, condition_name)
¶
Print per-class recall/precision and aggregate accuracy for one condition.
Iterates over the three triage classes (HIGH, MEDIUM, LOW), computing recall and precision for each, then prints overall accuracy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truths
|
List of ground-truth category strings. |
required | |
preds
|
List of predicted category strings (same length as truths). |
required | |
condition_name
|
Human-readable label printed as the section header
(e.g. |
required |
Source code in ground_segment/experiments/ablation.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
run_inference(model, processor, image, prompt)
¶
Run a single image+prompt through the VLM and return parsed JSON plus raw text.
Applies the processor's chat template, runs greedy generation with a
200-token cap, then parses the output via extract_json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Loaded |
required | |
processor
|
Matching |
required | |
image
|
PIL Image (512x512 RGB) to classify. |
required | |
prompt
|
Text prompt including classification instructions and (optionally) GPS coordinates. |
required |
Returns:
| Type | Description |
|---|---|
|
A |
|
|
and raw is the full decoded generation string. |
Source code in ground_segment/experiments/ablation.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |