jimchen2's picture
Update README.md
c9b136d verified
|
Raw History Blame Contribute Delete
25.1 kB
---
license: mit
language: en
size_categories: 1K<n<10K
task_categories:
- question-answering
- video-classification
- multiple-choice
tags:
- physics
- pendulum
- causal-reasoning
- causal-interventions
- clevrer
- clevrer-style
- world-model
- cjepa
- video-qa
- vqa
- synthetic
---
# Pendulum C-JEPA 3K + Causal Interventions (`intervened/`)
Combined repository uniting the full **3,000-video Pendulum C-JEPA 3K parental dataset** at the repository root (`pendulum-cjepa-3k-new`) with the **240-video causal intervention subset** under [`intervened/`](intervened/) (`light_shift` and `torque_push` interventions at frame 96 / `t = 8.0 s`, plus v2 intervention-focused CLEVRER-style QA), and the pretrained Videosaur DINOv2 model under [`model/`](model/).
| subset | path | videos | questions | WebDataset shards | description |
| --- | --- | --- | --- | --- | --- |
| **Parental `train`** | root (`videos/train/`, `timeseries/`, `questions/questions_train.json`, `wds/train/`) | 2,400 (`video_00000`–`video_02399`) | 19,200 (8 / video) | 19 shards (`pendulum-train-000000.tar`..`000018.tar`) | In-distribution nonlinear physical pendulum |
| **Parental `val` (OOD)** | root (`videos/val/`, `timeseries/`, `questions/questions_val.json`, `wds/val/`) | 600 (`video_10000`–`video_10599`, 6 regimes × 100) | 4,800 (8 / video) | 5 shards (`pendulum-val-000000.tar`..`000004.tar`) | Out-of-distribution physics validation regimes |
| **Intervened subset** | [`intervened/`](intervened/) (`intervened/videos/train/`, `intervened/timeseries/`, `intervened/questions/questions_train.json`, `intervened/wds/train/`) | 240 (`video_00000, video_00010, …, video_02390`) | 3,360 (14 / video, v2) | 2 shards (`pendulum-train-000000.tar`..`000001.tar`) | Frame-96 (`t = 8.0 s`) `light_shift` (120) & `torque_push` (120) interventions matched to parental `train` IDs |
---
## Repository Layout
```
.
├── videos/
│ ├── train/video_00000.mp4 ... video_02399.mp4 # 2,400 parental train clips
│ └── val/video_10000.mp4 ... video_10599.mp4 # 600 parental OOD val clips
├── timeseries/video_XXXXX.csv # 3,000 frame-aligned label CSVs
├── questions/
│ ├── questions_train.json # 19,200 parental train questions
│ ├── questions_val.json # 4,800 parental OOD val questions
│ └── taxonomy.json # question-type registry
├── wds/
│ ├── train/pendulum-train-000000.tar ... 000018.tar # 19 train WebDataset shards (128/shard)
│ └── val/pendulum-val-000000.tar ... 000004.tar # 5 val WebDataset shards (128/shard)
├── model/ # Videosaur DINOv2 model checkpoints, logs & extracted slots
│ └── pendulum-videosaur-20261022-194905/
│ ├── extraction/
│ │ └── pendulum_videosaur_4slots_step=100000.pkl # Extracted 4-slot embeddings (train + val)
│ └── videosaur_pendulum/20261022-194905_pendulum_dinov2/
│ ├── checkpoints/ # step=34000.ckpt, step=100000.ckpt
│ ├── metrics/ # version_1/metrics.csv, version_2/metrics.csv
│ ├── tb/ # TensorBoard event logs & hparams.yaml
│ └── settings.yaml # training configuration
├── index.csv # per-video params, split, regime (3,000 rows)
├── metadata.json # parental simulation & dataset metadata
├── sample_sheet.png # parental sample overview
├── README_original.md # verbatim parental dataset README
├── scripts/ # generator, QA, wds/cjepa prep, verification scripts
│ ├── pendulum_gen.py
│ ├── questions.py
│ ├── run_generate.py
│ ├── verify_dataset.py
│ ├── audit_answers.py
│ ├── make_preview.py
│ ├── prepare_cjepa_root.sh
│ └── upload_to_hf.py
└── intervened/ # 240-video causal intervention subset
├── videos/train/video_XXXXX.mp4 # 240 intervened videos (every 10th train ID)
├── timeseries/video_XXXXX.csv # 240 intervened frame-aligned CSVs
├── questions/
│ ├── questions_train.json # 3,360 v2 questions (14/video incl. 6 intervention Qs)
│ └── taxonomy.json # extended taxonomy with v2 intervention templates
├── wds/train/pendulum-train-000000.tar .. 01 # 2 WebDataset shards (128 + 112 videos)
├── index_intervention.csv # 240 rows: original params + intervention_type/cut_frame/params
├── intervention_log.json # per-video intervention details + post-cut stats
├── preview_before_after.mp4 # side-by-side original vs intervened preview
├── contact_sheet.png # static pre/post-cut comparison grid
├── README.md # original shift-2 v2 dataset card
└── README_intervention.md # full intervention reproduction notes
```
*(Note: Paths inside `index.csv` and `questions/*.json` at root are relative to the repository root, while paths inside `intervened/index_intervention.csv` and `intervened/questions/questions_train.json` are relative to `intervened/` so either root can be mounted directly as a drop-in dataset directory.)*
---
## Part 1: Parental Dataset (`pendulum-cjepa-3k-new` at Root)
**3,000 silent H.264 MP4s of a nonlinear physical pendulum** (160 frames @ 12 fps = 13.33 s, 196×196 px), with frame-aligned CSV labels and **24,000 CLEVRER-style questions** (descriptive / explanatory / predictive / counterfactual) derived from ground-truth 28 s RK4 simulations.
### OOD Validation Regimes (`videos/val/`)
| regime | what changes vs train | why it is a causal test |
| --- | --- | --- |
| `val_high_damp` | γ ∈ U(0.55, 0.90) s⁻¹ (train: 0.15–0.50) | envelope time-constant τ=2/γ as low as 2.2 s, shorter than anything seen |
| `val_low_damp` | γ ∈ U(0, 0.08) s⁻¹ | near-conservative dynamics; amplitude/energy almost constant |
| `val_large_angle` | θ₀ = ±(45–80)° (train: ±15–40°) | strong nonlinearity: period elongated up to ~30%, visibly non-sinusoidal |
| `val_gravity` | g ∈ {1.62 Moon, 3.71 Mars, 24.79 Jupiter} m/s² | period shifts by up to 2.5× both directions |
| `val_quad_damping` | drag = −β·ω·\|ω\|, β ∈ U(0.10, 0.35); γ = 0 | **new force law**: amplitude envelope decays ~linearly, not exponentially |
| `val_driven` | periodic torque A·cos(2πf t+φ), A ∈ U(0.35, 1.0) rad/s², f ∈ U(0.35, 0.65) Hz | **new causal mechanism**: beats / resonant growth around ~0.5 Hz natural frequency |
### Physics
```
theta'' = -(g/L)·sin(theta) - gamma·theta' - beta·theta'·|theta'| + A·cos(2π f_d t + φ)
```
RK4 at `fps × 8 = 96 Hz`. Train: `g=9.81`, `L=1.0`, `γ ∈ U(0.15, 0.50)`, `β=0`, `A=0`, `θ₀ = ±U(15, 40)°`, `ω₀ = U(−0.2, 0.2)`, light mean `U(70, 110)°`, light amp `U(0, 15)°`, light freq `U(0.04, 0.12)` Hz, random phase. Frame `n` ↔ CSV row `frame=n` ↔ `time_s = n/12`.
---
## Part 2: Causal Intervention Subset (`intervened/`)
For a deterministic subset of **240 parental train videos** (every 10th: `video_00000, video_00010, …, video_02390`), each video was re-simulated and re-rendered with `scripts/pendulum_gen.py` with an intervention applied at **frame 96 (`t = 8.0 s`)** of the 13.3 s clip. Frames 0–95 match the parental videos (`videos/train/video_XXXXX.mp4`) up to pure H.264 encoder noise, allowing direct paired comparison between factual (`videos/train/video_XXXXX.mp4`) and intervened (`intervened/videos/train/video_XXXXX.mp4`) rollouts.
| type | count | what changes | what stays the same |
| --- | --- | --- | --- |
| **`light_shift`** | 120 videos | At frame 96 the light source trajectory smoothly switches (6-frame smoothstep ramp) to a new mean/amplitude/frequency/phase (`Δmean ∈ ±20°`, `amp ∈ [5,30]°`, `f ∈ [0.15,0.40] Hz`). | Pendulum physics byte-identical (`theta_deg` diff = 0.0). |
| **`torque_push`** | 120 videos | External torque impulse `A·exp(−(t−t_push)²/2σ²)` (`σ = 0.15 s`, `A ∈ [2.0, 4.5] rad/s²`, gated for `t ≥ 8.0 s`) alters the bob's motion post-push (`Δθ` up to ~6°, `Δω` up to ~0.34 rad/s). | Light trajectory unchanged. |
### Intervened Questions v2 (`intervened/questions/questions_train.json`)
- **3,360 questions total** (14 per video): 1,920 regenerated standard CLEVRER-style questions + **1,440 intervention-focused questions** (6 per video) probing what changed at frame 96 (`t = 8 s`), which quantities remain invariant, causal mechanisms (`light_shift` vs `torque_push`), and counterfactuals without the intervention.
---
## Part 3: Pretrained Model (`model/`)
Trained **Videosaur** (`dinov2`) object-centric video model on the pendulum dataset (`model/pendulum-videosaur-20261022-194905/videosaur_pendulum/20261022-194905_pendulum_dinov2/`):
- **Checkpoints**: `checkpoints/step=34000.ckpt`, `checkpoints/step=100000.ckpt`
- **Extracted Slots**: `extraction/pendulum_videosaur_4slots_step=100000.pkl` (4-slot embeddings for parental `train` + `val`)
- **Config**: `settings.yaml`
- **Logs**: `metrics/version_1/metrics.csv`, `metrics/version_2/metrics.csv`, and TensorBoard event logs under `tb/`
---
## Part 4: CLEVRER-style Descriptive Questions (v2)
Drop-in replacement for the **descriptive** questions in `jimchen2/temp-jimchen2-pendulum-shift`, covering both the parental dataset (`questions/`) and the causal-intervention subset (`intervened/questions/`). Explanatory / predictive / counterfactual questions are **untouched** — copied byte-identical from the shipped files.
### What changed
The shipped descriptive questions had three defects:
1. **38.8% were multiple choice** despite `info.answer_convention` declaring descriptive = free-form string.
2. **Four phrasings had exactly one possible answer dataset-wide**, including both counting questions (always `"13"`, because `length_m` and `gravity_m_s2` are pinned for all 2,400 train videos).
3. **No `question_subtype` / `question_family_index`**, so CLEVRER tooling cannot group or analyse them.
Result: a model that never watched a video scored **65.6%** on train descriptive.
### Result
| split | n | no-video baseline before | after | families | phrasings |
| --- | --- | --- | --- | --- | --- |
| root/train | 4,800 | 65.6% | **44.3%** | 12 | 36 |
| root/val | 1,200 | 64.0% | **43.0%** | 12 | 36 |
| intervened/train | 1,200 | 59.7% | **49.1%** | 14 | 36 |
| **CLEVRER descriptive (reference)** | 54,990 | — | **41.6%** | — | 7,475 |
### New schema
```json
{ "question_type": "descriptive",
"question_subtype": "query_light",
"question_family_index": 9,
"question_family": "query_light_travel",
"question": "How far does the orange light source travel during the video?",
"answer": "medium",
"question_id": 0 }
```
No `choices`. Every answer is one token from `answer_vocab.json` (44 tokens). Each family carries 3 paraphrases, mirroring CLEVRER's multiple text templates per question family.
### Families
Sub-types follow CLEVRER's (`count` / `exist` / `query_*`):
| family | subtype | answers |
| --- | --- | --- |
| `count_swing_wide` | count | `0`–`15` |
| `count_swing_very_wide` | count | `0`–`13` |
| `count_turning_points` | count | `0`–`22` |
| `query_release_side` | query_side | left / right |
| `query_initial_direction` | query_direction | left / right / still |
| `query_release_amplitude` | query_amplitude | small / medium / large |
| `query_mid_amplitude` | query_amplitude | small / medium / large |
| `query_end_direction` | query_direction | left / right / still |
| `query_end_side` | query_position | left / right |
| `query_light_travel` | query_light | small / medium / large |
| `query_light_direction` | query_direction | left / right |
| `exist_still_swinging` | exist | yes / no |
| `query_intervention_target` | query_type | light / bob *(intervened only)* |
| `query_intervention_invariant` | query_invariant | bob / light *(intervened only)* |
| `query_energy_at_cut` | query_energy | smooth / jumps *(intervened only)* |
#### Dropped
- `q_shadow_direction` — the shadow always moves with the bob. One answer, 652×.
- `q_fastest_point` — the bob is always fastest at the bottom. One answer, 628×.
- `q_bottom_passes` — always `"13"`; the period is fixed because `length_m = 1.0` and `g = 9.81` for every train video. Replaced by `count_swing_wide` / `count_swing_very_wide`, which count swings above an amplitude threshold and therefore **do** vary with damping (13–15 distinct answers).
- `query_energy_end` — every train video loses 86–99.9% of its energy (γ ∈ 0.15–0.50), so the answer is near-constant.
### How it was built
No videos were downloaded or re-rendered. Re-simulating from `index.csv` with the repo's own `pendulum_gen.simulate` reproduces the shipped timeseries CSVs **bit-exactly** (max abs diff `0.0` on `theta_rad`, `theta_deg`, `omega_rad_s`, `light_angle_deg`, `energy_j_per_kg`, `bob_x_world`, `shadow_left_world`, `mid`), so parental facts are exact. For the intervened subset the shipped `intervened/timeseries/*.csv` are used directly, because the `torque_push` impulse could not be reproduced to better than 0.30° from `intervention_params` alone.
Intervention facts are computed on frames **0–95 only** (pre-intervention), and `exist_still_swinging` is gated off for that window — over 8 s the bob is always still swinging, which would make the answer constant.
Answers are balanced by a greedy sampler that prefers the currently least-represented `(family, answer)` pair across the split. Thresholds that produce a binary answer are set at the empirical train median (`OMEGA_STILL = 0.196` rad/s) rather than a round number, which is what makes `exist_still_swinging` exactly 50/50.
A `MARGIN_DEG = 0.25` / `MARGIN_OMEGA = 0.01` gate skips any question whose deciding value sits within the margin of a threshold; without it `video_10595` flipped `count_swing_very_wide` between 4 and 5 at 96 vs 192 Hz.
### Files
```
questions_v2.py family definitions + balanced sampler
regenerate_descriptive.py writes out/**
verify_descriptive.py schema / vocab / balance gates
crosscheck_answers.py answers vs independent ground truth
resolution_check.py answers vs 2x integration resolution
balance_report.json per-family distribution, per split
```
Reproduce:
```bash
python3 regenerate_descriptive.py
python3 verify_descriptive.py
python3 crosscheck_answers.py
python3 resolution_check.py
```
### Verification
| check | result |
| --- | --- |
| question count per video unchanged (8 / 8 / 14) | PASS |
| non-descriptive questions byte-identical | PASS, 0 videos differ |
| no descriptive question has `choices` | PASS (7,200) |
| all answers single-word and in vocabulary | PASS |
| all have `question_subtype` + `question_family_index` | PASS |
| no family 100% guessable | PASS (worst: 54.7%) |
| answers vs independent recomputation from CSVs | 0 mismatches / 1,280 |
| answers vs 2× integration resolution (192 Hz) | 0 changed / 7,200 |
The independent recomputation deliberately does not import `questions_v2`; it derives velocity by finite-differencing the angle series rather than using the integrated `omega_rad_s` column, so agreement is real evidence. It initially disagreed on 69 answers, all off-by-one counts — the checker was wrong, not the generator: a bob released at max displacement with a small outward velocity turns around *inside the first frame interval* (e.g. `video_00150`, turn at frame 0.2, amplitude 33.32°), which a pure-difference detector cannot see.
### Known limitation
The counting questions still cannot reach CLEVRER's answer diversity, because `length_m` and `gravity_m_s2` are constant across train. Fixing that needs a re-render: one line in `pendulum_gen.sample_config` (`cfg.length_m = rng.uniform(0.5, 2.0)` in the `ID` branch) would spread the swing period and therefore every count. Note that `scene_geometry` draws the arm at the constant `DRAW_LENGTH = 8.0` and never reads `length_m`, so the pixels would be unchanged while the labels' `bob_x_m` / `energy_j_per_kg` would acquire an `L` dependence — decide whether to scale `DRAW_LENGTH` too before doing it.
Functional programs (`program` / `my_program`) are still absent. Adding them requires a DSL and executor over pendulum state and is out of scope here.
## Intervention
# Pendulum C-JEPA 3K — Intervention Subset
Data-generating interventions added to **240 videos**
Everything else in the dataset is untouched.
## What was done
For a deterministic subset of 240 train videos (every 10th: `video_00000,
video_00010, … video_02390`), each video was **re-simulated and re-rendered with
the repo's own `pendulum_gen.py`** with an intervention applied at
**frame 96 (t = 8.0 s)** of the 13.3 s clip. Frames 0–95 are identical to the
originals (verified: max pixel diff ≤ 29, i.e. pure H.264 encoder noise), so the
intervention boundary is clean.
Two intervention types, 120 videos each:
| type | what changes | what stays the same |
|---|---|---|
| **`light_shift`** | At frame 96 the light source trajectory is smoothly switched (smoothstep ramp over 6 frames) to a new mean/amplitude/frequency/phase (`Δmean ∈ ±20°`, `amp ∈ [5,30]°`, `f ∈ [0.15,0.40] Hz`). The sun and its shadow sweep differently for the last ~5 s of the video. | Pendulum physics is byte-identical — theta/omega/energy are unchanged (verified: `theta_deg` diff = 0.0). This is the "light moves differently towards the end" intervention. |
| **`torque_push`** | A genuine physical intervention: an external torque impulse `A·exp(−(t−t_push)²/2σ²)` (σ = 0.15 s, `A ∈ [2.0, 4.5] rad/s²`, hard-gated on for `t ≥ 8.0 s`) is applied to the pendulum. The bob's motion genuinely deviates after the push (verified: Δθ up to ~6°, Δω up to ~0.34 rad/s). | The light trajectory is unchanged. |
Per-video intervention parameters (cut frame, new light params / push amplitude)
are stored in `intervention_log.json` and the `intervention_*` columns of
`index_intervention.csv`. All generated videos passed the original scene
validator (`|θ| ≤ 85°`, sun/bob/shadow inside the world bounds).
## Layout
```
intervened/
├── videos/train/video_XXXXX.mp4 240 intervened videos (same ids as originals)
├── timeseries/video_XXXXX.csv 240 frame-aligned labels, same schema as original
├── index_intervention.csv 240 rows: original index + intervention_type/cut_frame/params
├── intervention_log.json per-video intervention details + post-cut stats
├── preview_before_after.mp4 side-by-side original vs intervened (4 examples)
└── contact_sheet.png static pre/post-cut comparison grid
```
The CSVs keep the original schema (`frame,time_s,theta_rad,…,light_angle_deg,
light_x_world,shadow_left_world,shadow_right_world,shade,mid,…`); for
`light_shift` the light/shadow columns change post-cut while physics columns
stay identical, for `torque_push` the physics columns change post-push.
## Reproduce
```bash
python3 intervene.py # regenerates everything (skips existing outputs)
python3 make_preview.py # rebuilds the preview mp4 / contact sheet
```
Selection and intervention parameters are deterministic (`SEED=20261118`,
`EVERY=10`, `CUT_FRAME=96` in `intervene.py`).
## Why this is useful for C-JEPA / Lfuture eval
- `light_shift` is a clean **nuisance-factor intervention**: the observable
video changes (light + shadow motion) while the pendulum state evolution is
exactly the same. A model that predicts future slots must capture the
light→shadow causal link, not just copy the pendulum's dynamics.
- `torque_push` is a **physical intervention**: the future pendulum motion
genuinely deviates from the non-intervened continuation, so Lfuture on the
post-push frames measures whether the model predicts the response to an
external force.
- Because frames 0–95 match the originals exactly, you can train/evaluate on the
pre-intervention prefix and measure prediction quality on the post-intervention
suffix directly.
## Interventions
Each of the 240 videos was re-simulated and re-rendered with the source repo's
own `pendulum_gen.py`, with an intervention applied at **frame 96 (t = 8.0 s)**
of the 13.3 s clip. Frames 0–95 are identical to the originals (verified: max
pixel diff ≤ 29, i.e. pure H.264 encoder noise).
| type | what changes | what stays the same |
|---|---|---|
| **`light_shift`** (120 videos) | At frame 96 the light source trajectory is smoothly switched (smoothstep ramp over 6 frames) to a new mean/amplitude/frequency/phase (`Δmean ∈ ±20°`, `amp ∈ [5,30]°`, `f ∈ [0.15,0.40] Hz`). The sun and its shadow sweep differently for the last ~5 s. | Pendulum physics byte-identical (`theta_deg` diff = 0.0). |
| **`torque_push`** (120 videos) | A physical intervention: an external torque impulse `A·exp(−(t−t_push)²/2σ²)` (σ = 0.15 s, `A ∈ [2.0,4.5] rad/s²`) is applied at 8 s; the bob's motion genuinely deviates afterwards (Δθ up to ~6°, Δω up to ~0.34 rad/s). | Light trajectory unchanged. |
All videos passed the original scene validator (`|θ| ≤ 85°`, sun/bob/shadow
inside world bounds).
## Layout
```
videos/train/video_XXXXX.mp4 240 intervened videos (same ids as originals)
timeseries/video_XXXXX.csv 240 frame-aligned labels, same schema as original
questions/questions_train.json 1,920 CLEVRER-style questions (8 per video), regenerated
from the intervened 28 s simulations (same RNG selection
seed as the source: [20261014, index, 777])
questions/taxonomy.json question-type registry (same as source)
wds/train/pendulum-train-000000.tar WebDataset shard (128 videos: *.video.mp4 + *.meta.json)
wds/train/pendulum-train-000001.tar WebDataset shard (112 videos)
index_intervention.csv 240 rows: original index + intervention_type/cut_frame/params
intervention_log.json per-video intervention details + post-cut stats
README_intervention.md full documentation + reproduction instructions
preview_before_after.mp4 side-by-side original vs intervened (4 examples)
contact_sheet.png static pre/post-cut comparison grid
```
WebDataset shards follow the source format exactly: each tar holds
`video_XXXXX.video.mp4` + `video_XXXXX.meta.json` (`{"split","filename"}`),
128 videos per shard, ordered by video id — drop-in compatible with the
source dataset's wds loader.
CSVs keep the original schema; for `light_shift` the light/shadow columns change
post-cut while physics columns stay identical, for `torque_push` the physics
columns change post-push.
## Use with C-JEPA / VideoSAUR
Run VideoSAUR slot extraction on these videos, then evaluate Lfuture on the
post-cut suffix (frames 96–159). `light_shift` tests prediction of the
light→shadow causal link (nuisance-factor intervention); `torque_push` tests
prediction of the physical response to an external force.
## Reproduce
```bash
python3 intervene.py # regenerates the intervened set (resumable)
python3 make_preview.py # rebuilds preview mp4 / contact sheet
```
Selection and parameters are deterministic (`SEED=20261118`, `EVERY=10`,
`CUT_FRAME=96` in `intervene.py`).
## Questions v2 (intervention-focused)
- **3,360 questions total** (14 per video): the original 1,920 plus **1,440 new
intervention-focused questions** (6 per video).
- New questions ask what changed at **frame 96 / t = 8 s**, which quantities
stay invariant, why the shadow or bob responds, and what would have happened
without the `light_shift` or `torque_push`.
- Corrections to the original questions:
- 19 `light_shift` clips whose “the shadow would settle to one spot” answer
was wrong — the light keeps sweeping, so the shadow keeps moving.
- The “shadow always moves with the bob” and “what mainly causes the shadow
sweep” questions are now explicitly scoped to the first 8 s (before the
light switch), where that answer is true.
- The light-invariance counterfactual now says **ONLY** the light changes.
- New question template IDs are recorded in `questions/taxonomy.json`.
The generation script and the v1 backup are kept in the workspace used to
build this copy, not in the dataset itself.