Vision-Language Models as the decision-maker for time-series clustering of InSAR deformation data
- Overview
- Why Visual Reasoning
- How It Works
- Quick Start
- Ground Truth Data
- Results
- Peer-Review Validation
- Gemini Prompts
- Data & Archives
- Project Structure
- License & Contact
This project treats clustering as a perceptual decision problem. Instead of selecting the number of clusters from internal metrics alone, the pipeline renders each candidate cluster as a plot and asks a Vision-Language Model (VLM) β Google Gemini β to make two judgments:
- Is this cluster homogeneous? If not, it is split.
- Do these clusters describe the same behavior? If so, they are merged.
The VLM acts as the autonomous judge of cluster structure; ground-truth labels are used only to evaluate the final result, never to steer the pipeline. On synthetic InSAR deformation data with four known regimes, this recovers the true cluster count where conventional automatic selection fails β reaching ARI β 0.99 with the strongest backbone, against β 0.13β0.50 for silhouette-based auto-K.
This repository accompanies ongoing research on VLM-guided clustering for InSAR time-series analysis. The complete development history, benchmark runs, and peer-review experiments are archived openly (see Data & Archives).
Two time series can be numerically close yet behave differently β a steady subsidence versus a seasonal oscillation of similar magnitude. Rendered as plots, that difference is immediately visible, and this is precisely what the VLM exploits.
A controlled modality ablation confirms the gain comes from the visual representation, not
merely from using a language model: feeding the model the same series as numeric text β with
model, prompt, and pipeline held fixed β lowers ARI by 0.34β0.44 and destabilizes the
recovered cluster count (visual: K = 4 in 35/36 runs, ARI std β 0.01; text-only: K = 1β9, ARI
std β 0.3). Details in archive/revisions_r1.zip.
|
|
Fully autonomous by design. The VLM's merge decision is applied as-is. The pipeline contains no ground-truth gate β earlier versions kept a merge only if it improved the ground-truth ARI, which is label leakage and unavailable in real deployment. Ground truth now enters only at the final scoring step.
git clone https://github.com/bcankara/vlm-guided-clustering.git
cd vlm-guided-clustering
pip install -r requirements.txtK-Shape (tslearn) needs a compatible stack: Python 3.11 + numba 0.60 + tslearn 0.8. Python 3.13 / numba 0.61 is known to crash the K-Shape backend.
Edit settings.json:
{
"gemini_api_key": "YOUR_GEMINI_API_KEY",
"gemini_model": "gemini-3-flash-preview",
"k_range": [2, 8],
"min_cluster_size": 25,
"merge_viz_mode": "v2"
}π Get a free key at Google AI Studio. Keep it local β a
settings.jsoncontaining a real key should never be committed.
python main.py| Option | Description |
|---|---|
| 1β3 | Baseline algorithms (no VLM) |
| 4β6 | VLM-guided algorithms β |
| 7 | Fixed K = 4 comparison (oracle) |
| 8 | Reproducibility test (repeated runs) |
A synthetic dataset of 10,000 points with four distinct deformation behaviors:
| Cluster | Behavior | Description |
|---|---|---|
| A | Monotonic subsidence | Steady downward linear trend |
| B | Seasonal recovery | Downward trend with seasonal oscillation |
| C | Periodic fast/slow | Alternating yearly deformation rates |
| D | Stabilizing | Initially fast, exponentially slowing |
Gemini 3 Flash, 12 runs per configuration. ARI reported as mean [95 % bootstrap CI].
| Backbone | Auto-K baseline | Oracle (fixed K=4) | VLM-guided | Recovered K |
|---|---|---|---|---|
| K-Means | 0.13 | 0.24 | 0.935 [0.929, 0.940] |
4 |
| Hierarchical | 0.13 | 0.25 | 0.949 [0.930, 0.969] |
4 |
| K-Shape | 0.50 | 0.63 | 0.994 [0.994, 0.994] |
4 |
π― Ground truth: K = 4.
Key findings
- VLM guidance recovers the correct cluster count where silhouette-based auto-K does not.
- Every model Γ backbone configuration significantly exceeds its baseline (Holm-corrected p < 0.005).
- Gemini 3 Flash + K-Shape is the strongest and most stable setting (ARI 0.994, CI width 0.000).
- Full multi-model results (Gemini 2.5 Pro / 3 Flash / 3 Pro Γ three backbones) and the
statistical tests are in
archive/results_final.zip.
Supporting experiments produced during peer review are archived in
archive/revisions_r1.zip β authentic drivers, raw result JSONs, run logs,
and figures.
| Experiment | Question | Headline result |
|---|---|---|
| Modality ablation | Is the gain visual, or just "a language model"? | Visual beats text-only by 0.34β0.44 ARI and is far more stable |
| Sensitivity sweep | Does it hold under overlap, noise, irregular sampling, imbalance? | Lifts ARI from the ~0.13 no-VLM floor to 0.64β0.83; robust to realistic noise |
| Statistical significance | Are the gains real? | Bootstrap CIs + Mann-Whitney / Cliff's Ξ΄, Holm-corrected, across 3 models Γ 3 backbones |
| Reproducibility | Are results stable across runs and deterministic seeds? | Repeated and seed-fixed runs with logged outputs |
1 Β· Homogeneity (split) prompt β analyze_with_gemini()
Input: a 4Γ4 grid of 16 representative series from one cluster.
SAME REGION = consistent deformation behavior, matching shape and trend.
DIFFERENT REGIONS = opposite trends, different shapes, or major shifting peaks.
1. Opposite trends (up vs down) β SPLIT
2. Different shapes (wave vs straight) β SPLIT
3. Peaks/valleys misaligned (large) β SPLIT
4. Indistinguishable β FREEZE
Output: { "is_homogeneous": bool, "should_split": bool, "distinct_groups": int, "confidence": 0-100 }
2 Β· Self-correction (Reflexion) prompt β triggered on a low-confidence split
Triggered when a SPLIT decision has confidence < 80, to suppress false positives:
Are you ABSOLUTELY CERTAIN these are from different regions?
- Minor noise differences are NORMAL
- Small phase shifts are ACCEPTABLE
- Only split on UNDENIABLE evidence
A text-only counterpart, analyze_with_gemini_text_only(), uses the identical schema and
self-correction on numeric input β the basis of the modality ablation.
3 Β· Merge prompt (v2, default) β iterative_merge_with_gemini()
Visual: each cluster mean in its own subplot on a shared Y-axis.
LINEAR TREND DEPTH β differences OK (-60mm vs -120mm = same behavior, different scale)
SEASONAL AMPLITUDE β differences NOT OK (10mm vs 40mm waves = different behavior)
β same wave pattern and comparable seasonal amplitude β merge Β· β one strong wave / one flat, or opposite trends β keep separate.
All experiment data ships via Git LFS in archive/.
| Archive | Size | Contents |
|---|---|---|
archive.zip + .z01 + .z02 |
~2.8 GB (3-part split) | Full development history β baby-steps, baselines, K-sweeps (K = 2β¦30), zone verification, failed runs |
results_final.zip |
~1.8 GB | Final benchmarks β Gemini 2.5 Pro / 3 Flash / 3 Pro Γ three backbones, plus statistics/ |
revisions_r1.zip |
~685 MB | Peer-review supporting experiments (modality ablation, sensitivity, significance, reproducibility) |
A normal clone fetches the LFS data automatically. To skip the large archives and pull them later:
GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/bcankara/vlm-guided-clustering.git
git lfs pull # fetch the archives when you need themDownload all three parts (archive.z01, archive.z02, archive.zip) into the same folder
and extract archive.zip β the parts recombine automatically.
archive.zip results_final.zip revisions_r1.zip
βββ phase_0_baby_steps/ βββ Gemini_2-5_Pro/ βββ R2-01_modality_ablation/
βββ phase_1_baseline/ βββ Gemini_3_Flash/ βββ R2-06_sensitivity_analysis/
βββ phase_2_zone_verification/ βββ Gemini_3_Pro/ βββ R2-11_statistical_significance/
βββ intermediate_results/ βββ statistics/ βββ R2-16-18_reproducibility/
βββ failed_experiments/
vlm-guided-clustering/
βββ main.py # Pipeline + interactive menu (split / merge / VLM logic)
βββ generate_data.py # Synthetic InSAR data generator
βββ run_reproducibility.py # Repeated-run reproducibility harness
βββ config.py # Configuration constants
βββ settings.json # User settings (model, k_range, API key)
βββ requirements.txt # Python dependencies
βββ mit_license.md # MIT license
β
βββ src/
β βββ settings.py # Settings management
β βββ tracker.py # Experiment tracking
β βββ scientific_logger.py # Structured scientific logging
β
βββ docs/ # Logo, workflow diagram, phase & ground-truth figures
β
βββ archive/ # Git-LFS data (development history, results, revision experiments)
βββ archive.zip + .z01 + .z02
βββ results_final.zip
βββ revisions_r1.zip
Released under the MIT License β see mit_license.md.
π¬ VLM-guided clustering for InSAR time-series analysis Β· Β© 2026 Dr. Burak Can KARA




