Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
imagewidth (px)
882
2.56k
End of preview. Expand in Data Studio

SAE Locality Data

Raw experimental artefacts and summary figures for sparse-autoencoder (SAE) feature-locality experiments across six base language models.

This README mirrors DATASET.md in the source repository lccqqqqq/sae-analysis. See that repository for the analysis pipelines that produce the artefacts documented below.

This document describes the on-disk layout and per-file schemas for the HuggingFace dataset lccqqqqq/sae-locality-data, which mirrors the data/ tree produced by the sae-analysis pipelines.

It is the single source of truth for the dataset; the HuggingFace dataset README is generated from this file. For how the artefacts are produced, see the main repository README.

Format note. .pt files are PyTorch pickles. Loading them executes arbitrary code via pickle; only load on a trusted machine. torch.load(..., weights_only=True) will not work for these files because they contain Python dicts/lists, not tensors.

Presets and hookpoints

<preset> is one of: pythia-70m, gpt2-small, qwen2-0.5b, llama-3.2-1b, gemma-2-2b, llama-3-8b.

<site> is the hookpoint name (resid_post, resid, resid_out, …) and varies per preset; the canonical site and SAE for each preset are set in scripts/analysis/presets.py in the source repository.

<dataset> is one of wikitext, gsm8k, code-python β€” the corpus a per-preset entropy-vs-depth run drew its windows from; window-acceptance filters are defined per dataset in scripts/analysis/window_filters.py. The dictionary-scale strands run on Pile text instead: topact_all_features/ slices the shared token tensors under corpora/, while feature_autocorr/ streams per-document monology/pile-uncopyrighted tokens (feature_autocorr/pile_corpus_tokens.pt).

Pipeline & experiment logic

The central question is how localised each SAE feature's dependence on preceding context is: does a feature fire on a narrow local window (localised / syntactic) or on broad long-range context (topical / semantic)? Two complementary measurement axes attack it:

  • (A) Influence / entropy axis β€” H_pos. For an activation event of feature a at position t, the per-position influence J_a(t') over the preceding token positions is normalised to a distribution and its entropy taken: H_pos(a, t) = entropy(J_a(t')/Ξ£_t' J_a(t'), base 2). Low H_pos β‡’ the activation is driven by a narrow window of preceding tokens (localised); high H_pos β‡’ broad dependence.
  • (B) Autocorrelation axis β€” G_c(Ο„). The connected autocorrelation G_c(Ο„) = ⟨x(t) x(t+Ο„)⟩ βˆ’ xΜ„Β² of a feature's activation time series measures how long activations stay correlated; its integrated correlation length ΞΎ (and a bi-exponential split into a fast local scale and a slow topical scale) quantifies the same locality from the time-series side.

Strand β†’ artefact-family map (experiment specifics live in the per-folder sections below):

  1. Entropy-vs-depth across presets Γ— corpora Γ— layers β†’ <preset>/<dataset>/ + figures/.
  2. Context-length sweeps β†’ ctxlen_xmodel/ (WikiText, seed-based) and ctxlen_xmodel_fineweb/ (FineWeb-Edu, fixed prompt).
  3. Per-feature H_pos case studies β†’ cherry_picked_feature_entropy/, feature_case_studies/, feature_geometry_vs_entropy/, backed by neuronpedia_cache/.
  4. Dictionary-scale H_pos over all 16k features β†’ corpora/ + topact_all_features/.
  5. Activation autocorrelation β†’ feature_autocorr/.
  6. Linking the two axes β†’ autocorr_vs_entropy/.

Top-level layout

data/
β”œβ”€β”€ <preset>/<dataset>/<timestamp>/      # entropy-vs-depth runs (6 presets Γ— 3 corpora)
β”œβ”€β”€ ctxlen_xmodel/<ts>/                  # WikiText cross-model ctx-len sweep (6 presets)
β”œβ”€β”€ ctxlen_xmodel_fineweb/<ts>/          # FineWeb-Edu fixed-prompt ctx-len sweep
β”œβ”€β”€ cherry_picked_feature_entropy/<ts>_<variant>/  # curated-feature H_pos runs (current)
β”œβ”€β”€ feature_case_studies/<ts>_<set>/     # HTML card views of picked features
β”œβ”€β”€ feature_geometry_vs_entropy/<ts>/    # decoder geometry vs |Ξ”H_pos|
β”œβ”€β”€ topact_all_features/<run>/           # top-act contexts + H_pos, all 16k features
β”œβ”€β”€ feature_autocorr/<run>/              # connected ACF G_c(Ο„)
β”œβ”€β”€ autocorr_vs_entropy/<run>/           # ΞΎ/var vs mean H_pos cross-analysis
β”œβ”€β”€ corpora/                             # shared Pile token tensors
β”œβ”€β”€ neuronpedia_cache/<model>/<sae>/     # raw Neuronpedia per-feature responses
β”œβ”€β”€ figures/                             # cross-model entropy-vs-depth summaries
└── legacy/                              # superseded artefacts kept for provenance

Per-folder contents and schemas

<preset>/<dataset>/ β€” entropy-vs-depth runs

Artefact of the cross-model entropy-vs-depth experiment: at every layer of a preset, per-feature influence entropies (vs a token-vector baseline) are computed over batches of corpus windows, asking how feature locality varies with depth across model families. One timestamped run per preset Γ— corpus, for all six presets Γ— {wikitext, gsm8k, code-python}; each preset uses its canonical hookpoint and SAEs from scripts/analysis/presets.py. E.g. gemma-2-2b/wikitext/20260427_105933/ sweeps layers 0–25 of google/gemma-2-2b with the GemmaScope jumprelu residual SAEs loaded via sae_lens, 50 random batches of 64 windows at threshold 0.0; the gsm8k/code-python runs (e.g. gemma-2-2b/gsm8k/20260512_030419/) use 50 batches of dataset-filtered 64-token windows.

Contents per run directory:

  • run_config.json β€” preset, model_id, sae_loader/sae_arch, layers, threshold, num_batches, batch/window sizing, seed, host/device.
  • bench.json β€” wallclock + memory bench.
  • entropy_comparison_<site>_layer<L>.pt β€” one per layer:
{
  "batch_results": [
    {
      "batch_idx": int,
      "start_idx": int,                              # offset into the loader's text stream
      "feature_entropies": {feat_idx: float},        # per-feature entropy in bits
      "token_vector_entropy": float,
      "num_active_features": int,
      "feature_influences": {feat_idx: np.ndarray},  # length-N influence vector per feature
      "feature_activations": {feat_idx: np.ndarray},
      "token_vector_influence": np.ndarray,
    },
    ...                                               # one entry per batch (50 by default)
  ],
  "summary": {"site": str, "preset": str, "dataset": str, "timestamp": str, "layer": int, ...},
  "config":  {"preset": str, "threshold": float, "total_features": int, ...},
  "plots_dir": str,                                   # absolute path on the originating machine
  "batch_start_indices": [int, ...],
}
  • entropy_plots_<site>_layer<L>/ β€” per-layer plot dir (batch_<NNN>.png), regenerable from the .pt.

ctxlen_xmodel/ β€” WikiText cross-model context-length sweep

Artefact of the context-length sweep experiment: how a layer's feature-entropy distribution changes as the available context grows from 8 to max_context_len tokens, across all six presets on shared WikiText source text. Windows are drawn from WikiText-2 raw train via data_loader.load_wikitext_train_text under a fixed seed (42) over a char-space budget (char_budget_per_max_ctx = 12 chars per max-context token), so the same source window is reused across presets with different tokenizers. The full runs (20260429_122008, 20260429_123805, 20260429_171607) cover all six presets with max_context_len 2048 / step 128 (except gpt2-small at 1024/64); 20260429_120626 is a pythia-70m-only smoke.

Contents per <ts>/:

  • run_config.json β€” seed, per-preset max_context_len/step/char_budget, min_context_len, loader, git commit, host.
  • <preset>/entropy_vs_context_len_<site>_layer<L>_<ts>{,.pt} β€” per-layer results (.pt) plus a same-named plot dir:
{
  "results_by_context_len": {
    ctx_len: {
      "feature_entropies": {feat_idx: float},
      "token_vector_entropy": float,
      "num_active_features": int,
      ...
    },
    ...                                               # one entry per context length (8, 136, 264, …)
  },
  "summary": {"preset": str, "site": str, "layer": int, "timestamp": str,
              "max_context_len": int, ...},
  "config":  {"preset": str, "threshold": float, "total_features": int,
              "sae_source": str, ...},
  "plots_dir": str,
}

ctxlen_xmodel_fineweb/ β€” FineWeb-Edu fixed-prompt context-length sweep

Same sweep as ctxlen_xmodel/ but holding a single fixed document constant across context lengths: a pre-sampled HuggingFaceFW/fineweb-edu document, trimmed to end on a strong bigram completion, is the prompt at every context length. All four runs (20260505_000436 … 20260505_122012) cover the two presets gemma-2-2b and llama-3-8b at max_context_len 2048 / step 128 (min_context_len 8), one prompt per run (fineweb_edu_001 … fineweb_edu_004_trimmed; e.g. 20260505_122012 uses a 22,987-char document β‰ˆ 5,007 gemma-2-2b tokens).

Contents per <ts>/:

  • run_config.json β€” presets, per-preset max_context_len/step, prompt_file, git commit, host.
  • prompt.txt β€” the prompt held fixed during the sweep.
  • prompt.txt.meta.json β€” FineWeb provenance (dataset, skip, n_chars, per-tokenizer n_tokens) + trim strategy.
  • <preset>/entropy_vs_context_len_<site>_layer<L>_<ts>{,.pt} β€” same schema as the ctxlen_xmodel/ .pt above.

cherry_picked_feature_entropy/ β€” curated-feature H_pos runs

Artefact of the per-feature H_pos case-study experiment on curated feature sets: for each picked feature, per-event H_pos is computed over its top-activating contexts. Both current runs use gemma-2-2b layer 12 with the GemmaScope 16k residual SAE (Neuronpedia ID 12-gemmascope-res-16k), ctx_len 128, top_k 32 events per feature, activations sourced from Neuronpedia (monology/pile-uncopyrighted corpus) via neuronpedia_cache/: 20260505_093925_neuronpedia_embedding (~300 anchor + decoder-cosine-neighbour features, with 3-D embedding figures) and 20260505_102215_anchor6900_dec_top3 (anchor feature 6900 plus its top-3 decoder-cosine neighbours).

Contents per run directory:

  • manifest.json β€” preset, layer, sae_id, ctx_len, top_k, corpus, source, git commit, host, and the picked features (id, tier, description).
  • corpus_tokens.pt β€” tokenised window source (virtual corpus assembled from the cached Neuronpedia contexts).
  • top_contexts_layer<L>.json β€” top-k (window, position) table.
  • ctx<N>.csv (named ctx<N>_concept.csv in the embedding run) β€” one row per (feature, top-activating event) with columns feature_id, tier, description, top_act_rank, activation_value, abs_peak, ctx_len, ctx_start, H_pos_bits, n_positions, J_max, J_sum, J_argmax, peak_token_str, status.
  • influences_ctx<N>.npz β€” raw J_a(t') vectors per (feature, event); load with numpy.load.
  • adapter_log.json β€” Neuronpedia-adapter provenance.
  • figures/ β€” feature_continuum_ctx<N>.png, feature_table_ctx<N>.html, plus clusters3d_embedding_xy.{html,png} in the embedding run.

feature_case_studies/ β€” per-feature HTML card views

Artefact of the qualitative case-study experiment: for hand-picked low/mid/high-H_pos features (gemma-2-2b layer 12, 12-gemmascope-res-16k, ctx_len 128), render an HTML card per feature showing its top-5 contexts with tokens tinted by influence J_a(t'). All seven sets are built from the same source run legacy/cherry_picked_feature_entropy/20260501_103201_neuronpedia_full and differ in feature picks and tint scaling (low_mid_high{,_v2,_v3,_sqrt}, set2{,_sqrt,_v3}).

Contents per <ts>_<setname>/: feature_case_studies.html (the card view) and manifest.json (preset/layer/SAE metadata plus per-feature tier, description, mean_h_pos, std_h_pos, n_events, recall_alt).

feature_geometry_vs_entropy/ β€” decoder geometry vs |Ξ”H_pos|

Artefact of the geometry experiment: does decoder-direction geometry predict entropy differences? Pairwise decoder cosine similarity is correlated against |Ξ”H_pos| over the 298 features (44,253 pairs) of the 20260501_103201_neuronpedia_full run β€” gemma-2-2b layer 12, 12-gemmascope-res-16k, ctx_len 128 β€” with primary predictor abs_cosine (Spearman r β‰ˆ βˆ’0.16, 200-shuffle permutation null, z β‰ˆ βˆ’20), a k=10 nearest-neighbour summary, and a Neuronpedia activation cross-check. Two runs: 20260501_121413 and 20260501_121847 (the latter adds an EXPERIMENT.md write-up).

Contents per <ts>/:

  • manifest.json β€” preset/layer/SAE metadata, n_features, n_pairs, primary_predictor, Spearman/Pearson stats per predictor (signed, abs), permutation_null_*/permutation_z, per_feature_neighbour stats, neuronpedia_xcheck deltas.
  • per_feature.csv, pairwise.csv, feature_neighbour_summary.csv, neuronpedia_xcheck.csv β€” flat tables behind the manifest stats.
  • decoder_vectors.pt, cosine_matrix.pt β€” decoder geometry inputs.
  • figures/clusters3d.html, figures/clusters3d_tsne.html β€” interactive 3-D cluster views.

topact_all_features/ β€” dictionary-scale top-act + H_pos

Artefact of the dictionary-scale H_pos experiment: stage 1 (scripts/analysis/top_activating_contexts.py) streams 128-token windows of a shared Pile corpus tensor and keeps the top-k activating (window, position) events per feature; stage 2 (scripts/analysis/topact_entropy.py) computes per-event H_pos. The committed full run 20260607_152747_full16k_k32 covers all 16,384 features of the sae_lens SAE gemma-scope-2b-pt-res-canonical / layer_12/width_16k/canonical (jumprelu) on google/gemma-2-2b, top_k 32, streaming 78,125 windows Γ— 128 tokens = the full corpora/pile10k_gemma2_2b_10M.pt; 20260607_142953_pilot512 is a 512-feature, top_k 16 pilot on the 2M corpus, and smoke/ a tiny smoke run.

Contents per run directory:

  • top_contexts_layer<L>.json β€” top-k (window, position) per feature; .txt pretty-printed companion.
  • ctx<N>.csv (the full run uses ctx128) β€” one row per (feature, top-activating event) with columns feature_id, description, top_act_rank, activation_value, abs_peak, ctx_len, ctx_start, H_pos_bits, n_positions, J_max, J_sum, J_argmax, peak_token_str, status. Same shape as the cherry_picked_feature_entropy CSV (minus tier), scaled to the full dictionary.
  • influences_ctx<N>.npz β€” raw J_a(t') vectors keyed "<feature_id>_<top_act_rank>".
  • feature_hpos_summary.csv β€” per-feature aggregate: feature_id, n_events, H_pos_mean, H_pos_std, H_pos_min, H_pos_max.
  • full.log / pilot.log; DONE β€” zero-byte completion sentinel.

feature_autocorr/ β€” activation autocorrelation

Artefact of the autocorrelation experiment: the connected ACF G_c(Ο„) = ⟨x(t) x(t+Ο„)⟩ βˆ’ xΜ„Β² per feature, computed over same-document (t, t+Ο„) pairs under a strict stride-1 fixed-context scan, out to lag 1024. The committed run full_pile_L12_C1024_lag1024_raw_200kfair (per its run_config.json): gemma-2-2b (bf16) layer 12, SAE sae_lens:gemma-scope-2b-pt-res-canonical/layer_12/width_16k/canonical (16,384 latents, jumprelu), corpus monology/pile-uncopyrighted per-document tokens (255 docs / ~1.96M tokens loaded; the scan covered 31 docs β‰ˆ 225k "fair" tokens against the 200k fair-token budget that names the run), context_len C = 1024, max_lag 1024, --normalize none (raw ACF). Produced by scripts/analysis/feature_autocorr.py (--mode {smoke,full}, --dataset {wikitext,pile-uncopyrighted}, --normalize {none,var}).

Top-level support files: all_active_ids.txt (feature ids that ever fired, one per line), pile_corpus_tokens.pt (per-doc token tensors used by the scan), smoke_mps_validate.log.

Contents per <run>/:

  • autocorr.npz β€” numpy.savez_compressed archive:
{
  "feature_ids": int64[F],     # 0..F-1 (full SAE dictionary)
  "lags":        int64[L+1],   # 0..max_lag
  "G_c":         float32[F, L+1],  # connected ACF; raw (G_c(0)=var) for --normalize none
  "var":         float32[F],   # per-feature variance Οƒ_fΒ²
  "mean":        float32[F],   # per-feature mean xΜ„_f
  "n_pairs":     int64[L+1],   # same-doc pair count per lag (feature-independent)
  "xi":          float32[F],   # integrated length Ξ£_{Ο„β‰₯1} G_c(Ο„) (units follow G_c)
  "status":      str[F],       # "ok" / "silent" (silent β‡’ NaN curves)
}

With --normalize none, G_c is the raw connected ACF in activation² units; the dimensionless coefficient is Ĝ_c = G_c / var (so Ĝ_c(0) = 1), recovered downstream from var.

  • feature_summary.csv β€” per-feature flat table: feature_id, mean, var, xi, G_c_lag1, G_c_lag10, G_c_lag64, status.
  • run_config.json β€” preset, layer, context_len, max_lag, normalize, target_fair_tokens, sae_source, corpus_stats, scan_timing.
  • run.log.
  • figures/ β€” autocorr_top_bot.png (top-/bottom-ΞΎ curves) and xi_histogram.png from the run itself; biexp/ (fast-local + slow-topical bi-exponential fits, currently slow-scale only) from scripts/plot/plot_autocorr_biexp.py; window128/ (restricted-window W=128 views) from plot_autocorr_window.py; normalized/ (dimensionless Ĝ_c views) from plot_autocorr_normalized.py.
  • diagnostics/ β€” heavy-tail report (scripts/diagnostics/build_heavytail_diagnostics.py) plus the between-document variance-partition report (between_doc_autocorr_report.html, from scripts/analysis/between_doc_autocorr_test.py).

autocorr_vs_entropy/ β€” linking the two axes

Artefact of the experiment relating feature autocorrelation to feature entropy: per feature_id, the normalised integrated correlation length ΞΎ/var = Ξ£_{Ο„β‰₯1} G_c(Ο„)/var (from feature_autocorr/full_pile_L12_C1024_lag1024_raw_200kfair) is scattered against mean H_pos (from topact_all_features/20260607_152747_full16k_k32's feature_hpos_summary.csv) β€” i.e. the Gemma-2-2B layer-12 GemmaScope 16k residual SAE on the Pile corpus. Produced by scripts/plot/plot_autocorr_vs_entropy.py and scripts/plot/plot_shortscale_vs_entropy.py.

Contents:

  • 20260608_190300_l12_vs_full16k/ β€” run_config.json (the two source run paths, model, layer), autocorr_vs_entropy_linear.png (linear x), autocorr_vs_entropy_scatter.png (symlog x).
  • shortscale_vs_entropy/shortscale_vs_entropy.png β€” the short-scale (lag-1 / λ₁ / short integrated) vs H_pos counterpart.

corpora/ β€” shared Pile token tensors

Input corpora for the dictionary-scale top-act strand (not an experiment output): pile-10k (NeelNanda/pile-10k) documents tokenised with the gemma-2-2b tokenizer and concatenated (per-doc leading BOS kept; docs shorter than 64 tokens dropped), truncated to the target token count. Built by scripts/utils/build_pile_corpus.py (build_pile_corpus.log). Each .pt is a single 1-D torch.LongTensor of token ids: pile10k_gemma2_2b_2M.pt (2M tokens, used by the topact_all_features pilot), pile10k_gemma2_2b_10M.pt (10M tokens, used by the full 16k run), wikitext_smoke_50k.pt (~50k-token smoke tensor). Both top-act stages consume the same tensor via --corpus-tensor, so they slice identical corpus indices.

neuronpedia_cache/ β€” raw Neuronpedia responses

Support cache for the Neuronpedia-sourced H_pos runs: raw per-feature Neuronpedia API responses (top-activation records on monology/pile-uncopyrighted plus auto-interp descriptions), stored as <model>/<sae>/<fid>.json β€” currently 189 features under gemma-2-2b/12-gemmascope-res-16k/. These are the activation source for the neuronpedia-variant cherry_picked_feature_entropy/ runs (see their adapter_log.json).

figures/ β€” cross-model entropy-vs-depth summaries

Summary plots rendered from the <preset>/<dataset>/ .pt artefacts across all six presets: per-preset entropy_vs_depth__<preset>__<dataset>.png (plus earlier unsuffixed entropy_vs_depth__<preset>.png from the wikitext-only era), and cross-model grids entropy_vs_depth_crossmodel_grid_violin__<dataset>.png for wikitext/gsm8k/code-python plus unsuffixed ..._grid_violin.png and ..._grid_boxplot.png (wikitext-era).

legacy/ β€” superseded artefacts kept for provenance

  • legacy/cherry_picked_feature_entropy/ β€” four tier-faceted runs predating the H_pos pivot of 2026-05-06, all gemma-2-2b layer 12 with 12-gemmascope-res-16k, using the retired token/phrase/concept/abstract tier axis as a complexity proxy. 20260430_235742 draws windows from WikiText train (ctx_len 64/256/512) and stores per-tier ctx<N>_{token,phrase,concept,abstract}.csv + influences_ctx<N>_<tier>.npz plus h_pos_overview*/feature_profile_contrast*/h_pos_vs_ctxlen figures; the three Neuronpedia-sourced runs (20260501_010131_neuronpedia, 20260501_103201_neuronpedia_full β€” the 298-feature source consumed by feature_case_studies/ and feature_geometry_vs_entropy/ β€” and 20260501_155339_anchor6_topk10) use ctx_len 128 on monology/pile-uncopyrighted activations.
  • legacy/figures/entropy_plots_resid_out_layer<L>_20260414_053350/ β€” 2026-04-14 pythia-70m per-batch entropy plots (layers 0–5), superseded by pythia-70m/wikitext/20260427_105943/.

Caveats

  • plots_dir inside each .pt and the host field in run_config.json reflect the originating machine and are not portable.
  • The entropy_plots_*/ PNG directories are derived artefacts and can be regenerated from the corresponding .pt.
  • Symlinks named latest were used locally to point at the most recent run; they are intentionally not included here. The most recent run is the timestamped subdirectory with the largest <timestamp> value.
  • legacy/ contains superseded artefacts kept for provenance; see the legacy/ section above for what supersedes them.

Citation / contact

For questions about specific artefacts or to report issues with the dataset, open an issue on the sae-analysis repository.

Downloads last month
346