Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
1
70
eye
eyes
nose
face
mouth
ear
head
person
human
apple
cat
ship
spider
ant
0
zero
1
one
2
two
3
three
4
four
5
five
6
six
7
seven
8
eight
9
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
thirty
forty
fifty
sixty
seventy
eighty
ninety
Brazil
Mars
basketball
China
Christmas
Michigan
Kansas
gold
iron
copper
mercury
Earth
March
Seattle
Spain
bear
moon
Friday
Saturn
oxygen
nitrogen
carbon
calcium
heart
kidney
May
violin
third
Russia
Vatican
Indonesia
Italy
July
December
October
February
January
east
up
down
south
India
France
night
day
H
O
C
End of preview. Expand in Data Studio

Modoomlation lens: playing Doom by reading Qwen3.6-27B's Focus lens

This repo plays Doom with Qwen3.6-27B without generating a single token. Each frame goes through one forward pass. The action is read out of the model's residual stream with a Focus (directed-modulation) lens, in the style of a typed, Jev-like decision model: every decision field ("head") is a small classification over natural-language options.

screen frame ──► Qwen3.6-27B (one forward, per-head prompts sharing a cached prefix)
                    │ residual stream at layers 18–51, final prompt position
                    ▼
     walk:   [move forward | move backward | stand still]   ┐
     turn:   [turn left | turn right | keep facing ahead]   │ each option = a Focus reader direction;
     strafe: [strafe left | strafe right | no sidestep]     │ calibrated scores, lowest mean rank over
     fire:   [fire | hold fire]                             │ the head's layer band wins
     door:   [open it | leave it]                           ┘
                    ▼
            buttons of all heads pressed together, held for 4 tics

How it works

  1. Option directions (Focus lens, focus_lens.py). For an option phrase x, run 25 prompts like Keep x in your thoughts. Write "<neutral carrier sentence>" Don't write anything else. The carrier is teacher-forced as the reply. Average the residual stream over the carrier tokens: this is the model's state while holding x in mind but writing something unrelated. Subtract the Focus center, the same mean over many concepts. Then whiten with the Focus within-concept covariance C: D = P v / sqrt(vᵀ P v), where P = (C + 0.01·mean_eig·I)⁻¹.
  2. Query state. The prompt is the 320×240 screen, the task description, then one question per head, e.g. "Should you turn right now, and which way? Options: turn left, turn right, keep facing ahead." It uses Qwen's chat template, and the assistant turn is prefilled with Action:. The readout is the final-position residual at layers 18–51. The heads' prompts share the image and situation prefix, which runs once with a KV cache; only the short questions run per head.
  3. Contextual calibration. On 240 frames of random play, the query is centred on the mean state, and each option's score D·(h − center) is standardized by its mean and std. Without this, a static option prior dominates: the first-listed option wins on every frame.
  4. Layer band per head. This uses 240 labelled frames of random play from separate seeds. The labels come from ViZDoom's object-label buffer: turn toward the nearest enemy, fire if an enemy covers the crosshair. Each head with labels gets the 8-layer window with the best dev ROC AUC; heads without labels use all of L18–51.
  5. Decision. Per head, rank the options in every layer of the band and take the lowest mean rank. There are no thresholds and no task-specific rules. Playing never uses the labels.

The model sees only pixels and the prompt. Labels are used only to pick layer bands.

Versions (--version)

Version Change
v0 one head over all actions, one prompt
v1 movement head (incl. "stay still") + fire head ("shoot / hold fire"), one shared prompt
v2 two-option heads: no "stay still", so turning and shooting can happen together
v3 Jev wording "fire / hold fire"
v4 one prompt per head (shared situation + head-specific question); the biggest single improvement
v4s / v5 + a default "strategy" sentence (v5 also adds a weapon head); hurt every time
v4w + weapon head (deathmatch)
v4x + "explore" movement head and a fight/explore gate head
v7 one comprehensive prompt for both heads (worse than v4)
v8 / v8n building maps: door head + 90° turn options (+/− gate); mostly spins
v9 building maps: walk / turn / strafe as independent heads (+ fire, door)
v9b v9 without the 90° turns: the best building agent

Scenarios (--scenarios)

Name What Notes
defend_the_center ViZDoom arena; turn + shoot built into ViZDoom
deadly_corridor ViZDoom corridor built into ViZDoom
deathmatch ViZDoom arena with weapons and pickups built into ViZDoom
freedoom_map02 Freedoom: Phase 2 MAP02, a building with 56 monsters; shotgun via cheats; 3-min timeout freedoom2.wad ships with ViZDoom
freedoom_map02_nc MAP02 with corpses removed (mods/nocorpse.pk3) no measurable effect
e1m1 Doom E1M1 Hangar, skill 4 needs the shareware doom1.wad in wads/ (not included)

Setup

hf download verysweatydog/modoomlation-lens --repo-type dataset --local-dir modoomlation-lens
cd modoomlation-lens

You need one GPU with ≥ 80 GB, e.g. an H100 80 GB or RTX PRO 6000. Qwen3.6-27B in bf16 is about 54 GB.

pip install -r requirements.txt   # tested: torch 2.9.1+cu128, transformers 5.19.0, vizdoom 1.3.1
# optional but much faster gated-DeltaNet kernels: pip install flash-linear-attention fla-core
export QWEN_MODEL_PATH=Qwen/Qwen3.6-27B   # or a local copy

Focus statistics

Directions need the Focus center and within-concept covariance for each layer in stats/qwen3.6-27b/ (layer_18.pt … layer_51.pt, about 105 MB each).

  • Included in this repo (recommended): the statistics used for all results below. They were extracted from the full Focus-lens build: 14,264 concepts × 25 Focus prompts. Only the center and the focus_within_concept covariance are kept, in fp32.
  • Or rebuild cheaply: python build_focus_stats.py --layers 18-51 uses 1,500 random concepts from concepts.txt, about 6 min on an H100.
    • The cheap statistics reproduce the full lens's dev AUCs closely (within 0.005).
    • But in one test the agent's behaviour differed at a decision boundary (it froze at a level start). Prefer the included statistics when reproducing results.

Run

# directions + calibration + band choice (~5 min per scenario), then play (~0.2 s per decision on an
# RTX PRO 6000, including the game and video)
python heads.py prepare --version v9b --scenarios freedoom_map02
python heads.py play    --version v9b --scenarios freedoom_map02 --episodes 10

# arena with per-head prompts
python heads.py prepare --version v4 --scenarios defend_the_center
python heads.py play    --version v4 --scenarios defend_the_center --episodes 10

# E1M1 has almost no labelled enemies in its dev frames, so reuse the MAP02 bands (same head questions)
python heads.py prepare --version v9b --scenarios e1m1 --bands-from runs/v9b/prepared_freedoom_map02.pt
python heads.py play    --version v9b --scenarios e1m1 --episodes 10

# chance reference (no model): one uniformly random button per decision
python heads.py baseline --scenarios freedoom_map02 --episodes 10

# behaviour metrics from the per-decision logs
python analyze_play.py v9b=runs/v9b/freedoom_map02_lens_v9b.jsonl random=runs/baselines/freedoom_map02_random.jsonl

Outputs go to runs/<version>/:

  • prepared_<scenario>.pt: directions, calibration and bands;
  • diagnostic_<scenario>.json: per-layer dev AUCs and the chosen bands;
  • <scenario>_lens_<version>.mp4: video with a per-option weight panel;
  • .jsonl: a per-decision log with head choices, enemy visibility and position;
  • _results.json: per-episode survival, kills, explored cells and furthest distance.

Useful flags:

  • --turn-tics 2 releases turn keys after 2 of the 4 tics (gentler turning);
  • --no-video;
  • --no-prefix-cache uses the slower batched full prompts.

Results (Qwen3.6-27B, included statistics)

Evaluation seeds are 1000+, episodes end at death or timeout, and n is the number of episodes. Survival is in game seconds.

Scenario Policy n Survival mean Kills (total) Notes
defend_the_center v4 10 14.0 s 54 random: 9.2 s, 13
defend_the_center v0 single head (band L35–42) 10 12.4 s 41
deathmatch v4w (--turn-tics 2) 10 27.3 s 44 random: 19.1 s, 22
deadly_corridor v4 10 10.5 s 12 random: 5.7 s, 7
freedoom_map02 v9b 10 62.8 s 54 18.4 cells explored, 766 units furthest
freedoom_map02 random 10 71.1 s 42 9.5 cells, 381 units furthest
e1m1 (skill 4) v9b, MAP02 bands 5 148.3 s 11 28.8 cells, 974 furthest; random: 158.4 s, 8 kills, 20.6 cells, 653

What worked and what didn't:

  • Per-head prompts (v4) were the largest gain. Arena dev AUC for turning rose from 0.76 to 0.93, and kills roughly tripled.
  • Strategy sentences, a single comprehensive prompt, the explore gate and 90° turn options did not help.
  • Independent walk / turn / strafe heads (v9b) doubled exploration in the building.
  • No policy reached a level exit. Random survives about as long in the building levels, because it barely moves.

Known limitations and later findings (not in this code)

  • Oscillation: independent per-frame decisions flip turn left↔right and walk forward↔back on 20–30% of consecutive decisions, which also gets the agent stuck. Exponential smoothing of the calibrated scores across decisions (α = 0.6) roughly halved the flips and stuck time. Adding the previous frame as a second image helped further.
  • Later layers:
    • On labelled frames, bands in layers 51–63 read fire much better than layers 18–51 (AUC 0.92 vs 0.79 on E1M3).
    • On text classification the same lens recipe matched greedy generation once bands could reach L63 (ag_news 0.90).
  • Band selection by left-vs-right AUC ignores the third "no-op" option. It can pick a band where "keep facing ahead" always wins. Balanced accuracy of the full decision rule is the safer metric.
  • Shot quality: the fire head fires whenever an enemy is visible, not when one is lined up. Only about 20% of shots have an enemy in the crosshair.
  • Small samples: every episode with a given seed starts from the same state, so 5–10 episodes are correlated samples.

Files

File Purpose
focus_lens.py model loading (with a fast exact replacement for the vision patch-embedding Conv3d), residual capture, Focus directions
heads.py versions, prompts, prefix-cached query states, calibration, band selection, decision rule, CLI
doom_env.py scenarios, game loop, video overlay, logging, random baseline
build_focus_stats.py cheap rebuild of the Focus statistics
analyze_play.py turn / walk reversal rate, stuck time, fire precision from the logs
focus_prompts.json the 25 Focus prompts (5 phrasings × 5 carriers)
concepts.txt concept inventory for build_focus_stats.py
mods/ no-corpse DECORATE mod (source + pk3)
stats/qwen3.6-27b/ Focus center + within-concept covariance, L18–51

Credits

The idea comes from Jev by TypeSafe: typed, generation-free decisions from a model's internal state (https://typesafe.ai/blog/introducing-system-one-models-and-jev). The game engine is ViZDoom, and the building level is from Freedoom.

Downloads last month
112