Embedding controller

Embedding controller is a game-playing policy interface proposed by Hei on 2026-10-20. Every input on a game controller is assigned an embedding from a shared embedding model. At play time the policy computes one state embedding and its cosine similarity with every input's embedding. That is the entire policy: one encoder pass and one matrix-vector product per tick.
The idea grew out of the EmbeddingGemma-2 Doom experiments in area51/doom-embeddinggemma2. Their best inference-only agent turned out to be a special case of it.
The idea
Take an embedding model E that accepts several modalities. EmbeddingGemma-2 embeds text, images, video and audio into the same 768-dimensional space.
- Action vectors. Each controller input k gets an embedding ek = E(xk). The input xk can be anything E accepts, chosen by whoever builds the controller:
- the text "jump";
- a picture of a ladder;
- a clip of a melee hit landing;
- the sound of a gunshot.
- State vectors. Each tick the sensory stream becomes one state embedding s. It can come from a screenshot, a short video chunk with its audio, or a centroid over the last few frames.
- Inference. Compute ck = cos(s, ek) for every input. With K inputs this is one K × 768 matrix-vector product, about 14,000 multiply-adds for a full pad. The encoder pass costs far more than the controller itself.
Input types
A pad has three kinds of input, and each reads its value from its cosine in a different way.
| Kind | Examples | Value | Readout from cosine |
|---|---|---|---|
| Discrete over time | △ ○ ✕ □, D-pad, L1/R1, create, options | pressed / released, per tick | Press while σ((ck − bk)/T) > ½. Mutually exclusive groups (the four D-pad directions) take a softmax instead. Tap and hold are a pattern over consecutive ticks, not a separate input. |
| Continuous, bounded 1-D | L2, R2 | a ∈ [0, 1] | a = clip((ck − lo)/(hi − lo), 0, 1) |
| Continuous, bounded 2-D | left stick, right stick, touchpad | (x, y) in the unit disk | Axis form or direction form, below |
Sticks: one vector or several?
A cosine is a single signed number in [−1, 1], so a stick can be built in three ways.
- Axis form (two vectors). Use eright and eforward, so that x = cos(s, eright) and y = cos(s, eforward). This is the cheapest form, and the sign of a cosine already behaves like an axis. Pushing a stick left means being anti-aligned with "right". Whether E's geometry actually puts "left" opposite "right" is an empirical question, and for text prompts it usually does not.
- Direction form (N vectors). Use e0° … e315°, with (x, y) = Σk softmaxk(ck/T) · (cos θk, sin θk). This form is more robust, because each direction has its own prototype and no geometry is assumed.
- One vector per stick. A single cosine can only say how much the stick is used, not where it points. A one-vector stick therefore gives a magnitude or gate, and direction has to come from elsewhere. The alternative is to treat the stick's embedding as a 2-D plane (two orthonormal vectors) and project s onto it, which is the axis form under another name.
Where the action vectors come from
"Parameterized by the input data we so choose" is where the design work happens. Each choice of xk is a different prior:
- Description (zero-shot), for example E("jump"). This needs no data and is exactly as good as the model's grounding of the word.
- Exemplar, for example E(the HUD icon of an item slot), or E(the sound the weapon makes).
- Consequence, for example E(a clip of what happens after the press). This encodes the effect rather than the name.
- Centroid of demonstrations: the mean state embedding over every frame where a player pressed k. This is a nearest-class-mean classifier built from recordings, with no gradient.
- Learned: treat the matrix Ê of all ek as a linear head and train it with behaviour cloning or RL. Any of the options above is then its initialization, not its ceiling.
The last option is why the idea is more than a party trick. Ê is a classifier head that starts out zero-shot. In the EmbeddingGemma-2 Doom work a text-built head of this shape was written as the starting point for test-time training (text_head.py). Training only the head fits in 1–3 GB of VRAM. LoRA or full fine-tuning of the encoder behind it fits in roughly 2–12 GB, depending on batch size and gradient checkpointing (measured on an RTX 3090).
Evidence so far
Results from the Doom experiments, all inference-only with EmbeddingGemma-2:
- A restricted embedding controller works. The "pure" Doom agent has these parts:
- its state is not one vector but eight: seven screen strips plus a crosshair crop;
- its action vectors are text prompts for "enemy" and for "background";
- its pad has three kinds of action: turn toward a strip, fire, or scan.
- It has no thresholds beyond nearest-prompt argmax. It averaged 15.9 kills over 10 episodes of ViZDoom
defend_the_center. The hand-tuned bearing controller averaged 16.4–17.3.
- One whole-frame vector is too coarse for direction. Asked whether the enemy is left, centre or right from a single pooled frame embedding, EmbeddingGemma-2 scored 0.634 on left-versus-right. That is exactly the always-"right" majority rate, with balanced accuracy of 0.25–0.35 over four classes. Spatial information survives in crops and token grids and is mostly averaged out of the pooled vector.
- Pooled embeddings barely see the agent's own actions. In Astra's probe, actions were classified from embedding deltas. The pooled vector sat near chance in all five games (Doom 0.093 against chance 0.111). Raw pixels and the EmbeddingGemma-2 token grid did better.
So the honest reading is this. The controller head is cheap and works when the state embedding actually carries the information the action needs. "One state embedding" will often have to mean several: crops, a token grid, or a short clip. Whether a single vector suffices for something like Super Smash Bros., where spacing and frame timing are the game: who knows. That is the next experiment.
Sources
~/ht/area51/doom-embeddinggemma2/README.md: Doom A/B tables, encoder swap, probe table, VRAM tiers.~/ht/area51/doom-embeddinggemma2/agent.py:--purenearest-prompt policy.~/ht/area51/doom-embeddinggemma2/text_head.py: the policy written as a text-initialized linear head.~/ht/area51/doom-embeddinggemma2/probe_pure.py,probe_knn.py: the whole-frame direction test and Astra's action probe.~/ht/area51/doom-embeddinggemma2/paper/make_controller_figure.py: the figure.
See also
- EmbeddingGemma-2
- Astra