Skip to page content
SAVRN
Search Plan a project

Open-weight model

template-lens-qwen3-4b

by Andy Xu andyx10/template-lens-qwen3-4b

template-lens-qwen3-4b is an open-weight model from Andy Xu, released under MIT License. Its published files total 7.3 GB.

An implementation of the template lens from appendix A.9.1 of Gurnee et al. (2026), Verbalizable Representations Form a Global Workspace in Language Models (transformer-circuits.pub, The template lens reads a residual-stream direction against a vocabulary of…

Parameters—
Context—
Weights6.9 GB
Licensemit
AccessOpen weights
Monthly Downloads—

Model Card

By Andy Xu, published under mit, revision 258460d66936.

An implementation of the template lens from appendix A.9.1 of Gurnee et al. (2026), Verbalizable Representations Form a Global Workspace in Language Models (transformer-circuits.pub, The template lens reads a residual-stream direction against a vocabulary of whole words rather than single tokens, which is what lets it name concepts the logit lens and J-lens can only show as fragments — blackmail instead of black, Equestrian instead of E/quest/rian. For a word w at layer l, collect passages each ending at the exact point where w would naturally come next, run the model over them, and average the residual stream at the final position to get muw(l). Then centre and whiten: tw is the linear…

Read Andy Xu's full model card

Template lens for Qwen3-4B

An implementation of the template lens from appendix A.9.1 of Gurnee et al. (2026), Verbalizable Representations Form a Global Workspace in Language Models (transformer-circuits.pub, arXiv:2607.15495), fitted for Qwen/Qwen3-4B.

The template lens reads a residual-stream direction against a vocabulary of whole words rather than single tokens, which is what lets it name concepts the logit lens and J-lens can only show as fragments — blackmail instead of black, Equestrian instead of E/quest/rian.

Status: this repository currently holds the passage corpus and vocabulary only. The fitted lens itself — per-layer template tensors and the whitening moments — is still being built and will be added here. Nothing in this repo is a lens yet; it is what a lens gets fitted from.

What the method does

For a word w at layer l, collect passages each ending at the exact point where w would naturally come next, run the model over them, and average the residual stream at the final position to get mu_w(l). Then centre and whiten:

t_w(l) = (Sigma_l + lambda*I)^-1 (mu_w(l) - mu(l))

t_w is the linear discriminant direction separating "about to say w" from "not about to say w", and is used exactly like a J-lens vector minus the unembedding step: project a direction onto it and rank over the vocabulary.

The whitening is the method. Unwhitened, mu_w - mu is an ordinary difference-in-means steering vector; multiplying by the inverse activation covariance is what puts it in the J-lens's metric, via Stein's lemma (E[grad g(x)] = Sigma^-1 E[g(x)(x - mu)], derived in the paper's appendix).

Contents

file what it is
passages.jsonl 1,183,980 generated passages, ~99 per vocabulary word
vocab.json the 12,744-word vocabulary, with per-word Zipf frequency and token count
coverage.json how much of the evaluation cohort's topic vocabulary is covered
ceiling_vocab.json full topic strings, held apart — see Leakage below

passages.jsonl is one JSON object per line:

{"w": "equestrian", "s": "equestrian", "t": "...requiring every young officer to master basic"}

w is the target word (lowercased, the vocabulary key), s its surface form, and t the passage — which ends exactly where w would follow, and never contains w.

How the passages were made

Generated with DeepSeek V4 Pro via OpenRouter, ~100 per word, at a total cost of roughly $50. The paper uses Claude and gives no passage count beyond "a few hundred forward passes per word".

The generator was chosen by a bake-off against Gemini 2.5 Flash Lite and a corpus-mined baseline, scored on the paper's own next-word diagnostic. DeepSeek won by ~2.2x at every passage count and was the only generator to cover the whole vocabulary.

Two constraints are enforced on every passage, because both change what the template measures:

  • The passage never contains the target word. A context that has already said equestrian makes the continuation a copy rather than a prediction, and its activation reflects a primed model instead of one poised to say the word for the first time.
  • Passage counts are balanced (~99/word). The paper describes mu as the mean of all other words' vectors in prose, and as the mean over the same passage set in the formula gloss. Under balanced counts those are the same object, so the ambiguity does not arise. Where counts do vary, both moments should be taken with per-word weights 1/P_w, keeping mu and Sigma over one reweighted population — mixing estimators breaks both the Stein and linear-discriminant readings.

Vocabulary

12,744 words: the top 12,700 English words by frequency (wordfreq), plus 44 content words from the evaluation cohort's topics that fell below that cut. 1,609 entries (13%) are multi-token under the Qwen3-4B tokenizer — those are the entries the logit lens cannot express at all.

The paper's own ~12,700-word list is not published, so this is a reconstruction rather than a copy.

Leakage

The vocabulary is built topic-blind: it comes from a published frequency list, and topic words enter only if they clear the frequency cut or are added as individual common words. equestrian is present because it is a common English word (Zipf 3.2), and the lens must still find it among 12,744 candidates.

Full topic strings are a different matter and are kept in ceiling_vocab.json, never merged into the vocabulary. Templates for them would let a readout surface an exact answer, which is straightforward leakage in open-ended evaluation. They exist only as a ceiling — separating "the vocabulary could not express the answer" from "the lens could not find it", which are different failures.

Intended use and limitations

Intended for interpretability research: fitting template-lens directions for Qwen3-4B, and as an N=1 non-parametric slice of the dictionary an oracle-lens reconstructor learns to amortise.

  • English only, and frequency-weighted toward common words.
  • A topic can only be read out if its words are in the vocabulary. Coverage against the evaluation cohort is in coverage.json.
  • The method has known pathologies the paper reports and this corpus does not fix: readouts can "skip to the answer" in early layers (a tuned-lens pathology), and a small set of words top readouts regardless of relevance. On the latter, the cause appears to be template norm — rare words have noisy mu_w, so ||t_w|| inflates and wins the dot product against anything. Scoring by cosine rather than raw projection addresses it at the source.
  • Passages are model-generated and carry that model's stylistic and factual biases.

Citation

The method is from:

@article{gurnee2026workspace,
  title  = {Verbalizable Representations Form a Global Workspace in Language Models},
  author = {Gurnee, Wes and Sofroniew, Nicholas and Pearce, Adam and Piotrowski, Mateusz
            and Kauvar, Isaac and Chen, Runjin and Soligo, Anna and Bogdan, Paul
            and Ong, Euan and Wang, Rowan and Thompson, Ben and Abrahams, David
            and Kantamneni, Subhash and Ameisen, Emmanuel and Batson, Joshua
            and Lindsey, Jack},
  journal = {arXiv preprint arXiv:2607.15495},
  year    = {2026}
}

This repository is an independent reimplementation and is not affiliated with the authors.

Identity and Version

Repository
andyx10/template-lens-qwen3-4b
Publisher
Andy Xu
Task
Not stated by the source
Modality
Other
Library
Not stated by the source
Parameters
Not stated by the source
Languages
en
Revision
258460d66936033785655597eb976a07f8ce01cc
First published
2026-09-20
Last updated
2026-09-24

Files and Weights

64 files, 7.3 GB in total. The weights are 37 files totalling 6.9 GB in pt.

Weights37 files · 6.9 GB
Configuration14 files · 179.6 KB
Tokenizer5 files · 1.1 MB
Documentation1 file · 6.7 KB
Other6 files · 371.7 MB
Repository1 file · 2.3 KB
Every file
FileTypeSizeSHA-256
content-v1/moments.ptWeights3.9 GB de9ccda8529b
content-v1/templates-c3/layer_00.ptWeights83.0 MB ac16d852f780
content-v1/templates-c3/layer_01.ptWeights83.0 MB 73c890190860
content-v1/templates-c3/layer_02.ptWeights83.0 MB a19b1c65d00f
content-v1/templates-c3/layer_03.ptWeights83.0 MB b358c3ddbc51
content-v1/templates-c3/layer_04.ptWeights83.0 MB c7bc2d19a2df
content-v1/templates-c3/layer_05.ptWeights83.0 MB 17c610c8d470
content-v1/templates-c3/layer_06.ptWeights83.0 MB 2b6988896a74
content-v1/templates-c3/layer_07.ptWeights83.0 MB c71683892050
content-v1/templates-c3/layer_08.ptWeights83.0 MB a9e3b4623e6d
content-v1/templates-c3/layer_09.ptWeights83.0 MB bca55a592099
content-v1/templates-c3/layer_10.ptWeights83.0 MB 49961ddc3f4c
content-v1/templates-c3/layer_11.ptWeights83.0 MB c6594775d6aa
content-v1/templates-c3/layer_12.ptWeights83.0 MB 7e4bf70678e1
content-v1/templates-c3/layer_13.ptWeights83.0 MB 15de2a2e64f8
content-v1/templates-c3/layer_14.ptWeights83.0 MB 4bf378ad0096
content-v1/templates-c3/layer_15.ptWeights83.0 MB e8c73bbab21d
content-v1/templates-c3/layer_16.ptWeights83.0 MB ca8eccee8713
content-v1/templates-c3/layer_17.ptWeights83.0 MB 68b5cb365668
content-v1/templates-c3/layer_18.ptWeights83.0 MB 3f133f8efc83
content-v1/templates-c3/layer_19.ptWeights83.0 MB 01d5793727b5
content-v1/templates-c3/layer_20.ptWeights83.0 MB 078837697ad0
content-v1/templates-c3/layer_21.ptWeights83.0 MB 0e04c71d450d
content-v1/templates-c3/layer_22.ptWeights83.0 MB 02198345859c
content-v1/templates-c3/layer_23.ptWeights83.0 MB 1db8fe14e207
content-v1/templates-c3/layer_24.ptWeights83.0 MB 8a5612a96bff
content-v1/templates-c3/layer_25.ptWeights83.0 MB f6dba358a813
content-v1/templates-c3/layer_26.ptWeights83.0 MB b449462b7991
content-v1/templates-c3/layer_27.ptWeights83.0 MB b984c895d570
content-v1/templates-c3/layer_28.ptWeights83.0 MB b1153891c0de
content-v1/templates-c3/layer_29.ptWeights83.0 MB bf4b780b97c8
content-v1/templates-c3/layer_30.ptWeights83.0 MB a43435abc8c2
content-v1/templates-c3/layer_31.ptWeights83.0 MB 52bd80a8339c
content-v1/templates-c3/layer_32.ptWeights83.0 MB 702c30f91c3e
content-v1/templates-c3/layer_33.ptWeights83.0 MB 636313a3ef6a
content-v1/templates-c3/layer_34.ptWeights83.0 MB 86325c0cf9ea
content-v1/templates-c3/layer_35.ptWeights83.0 MB 16d6759c4d21
bakeoff/vocab/ceiling_vocab.jsonConfiguration2.6 KB —
bakeoff/vocab/coverage.jsonConfiguration297 B —
ceiling_vocab.jsonConfiguration2.5 KB —
content-v1/filter_report.jsonConfiguration67.6 KB —
content-v1/generate.jsonConfiguration90.4 KB —
content-v1/templates-c3/meta.jsonConfiguration130 B —
coverage.jsonConfiguration281 B —
k12700-covered/vocab/ceiling_vocab.jsonConfiguration2.6 KB —
k12700-covered/vocab/coverage.jsonConfiguration299 B —
pilot-k12700-mined/ceiling_vocab.jsonConfiguration3.3 KB —
pilot-k12700-mined/coverage.jsonConfiguration984 B —
pilot-k12700-mined/gate-next-word-sweep-sampled.jsonConfiguration4.5 KB —
pilot-k12700-mined/gate-next-word-sweep.jsonConfiguration4.0 KB —
pilot-k12700-mined/shortfall.jsonConfiguration129 B —
README.mdDocumentation6.7 KB —
content-v1/logs/chain.logOther472 B —
content-v1/logs/gen.logOther10.4 KB —
content-v1/passages-deepseekpro.jsonlOther55.5 MB ce787330eed5
passages.jsonlOther173.9 MB 7a480cdc3113
pilot-k12700-mined/held_out.jsonlOther98.4 MB 38d44943fa34
pilot-k12700-mined/passages.jsonlOther43.8 MB 286adbc0a536
.gitattributesRepository2.3 KB —
bakeoff/vocab/vocab.jsonTokenizer28.6 KB —
content-v1/vocab.jsonTokenizer326.4 KB —
k12700-covered/vocab/vocab.jsonTokenizer251.7 KB —
pilot-k12700-mined/vocab.jsonTokenizer250.2 KB —
vocab.jsonTokenizer251.7 KB —

License and Download

License
mit
Access
Open weights, no gate
Download size
6.9 GB
Download from Andy Xu

Released by Andy Xu through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published6.9 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About template-lens-qwen3-4b

Can I use template-lens-qwen3-4b commercially?

Yes. template-lens-qwen3-4b is released under MIT License. The MIT License is a short permissive license. It permits commercial use, modification and redistribution, provided the copyright notice and permission notice are included.