Text Generation
PEFT
Safetensors
English
natural-language-autoencoder
nla
interpretability
mechanistic-interpretability
gemma
consumer-gpu
lora
Instructions to use Solshine/gemma-4-e2b-nla-L23-ar-v0_1-paraphrase-invariant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Solshine/gemma-4-e2b-nla-L23-ar-v0_1-paraphrase-invariant with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E2B") model = PeftModel.from_pretrained(base_model, "Solshine/gemma-4-e2b-nla-L23-ar-v0_1-paraphrase-invariant") - Notebooks
- Google Colab
- Kaggle
v0.1 paraphrase-invariance AR (model card + LoRA + linear_head + nla_meta)
Browse files- README.md +125 -0
- adapter_config.json +40 -0
- adapter_model.safetensors +3 -0
- linear_head.pt +3 -0
- nla_meta.yaml +22 -0
README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model: google/gemma-4-E2B
|
| 6 |
+
tags:
|
| 7 |
+
- natural-language-autoencoder
|
| 8 |
+
- nla
|
| 9 |
+
- interpretability
|
| 10 |
+
- mechanistic-interpretability
|
| 11 |
+
- gemma
|
| 12 |
+
- consumer-gpu
|
| 13 |
+
- peft
|
| 14 |
+
- lora
|
| 15 |
+
library_name: peft
|
| 16 |
+
pipeline_tag: text-generation
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# Gemma-4-E2B NLA AR (Critic) — v0.1 paraphrase-invariance retrain
|
| 20 |
+
|
| 21 |
+
LoRA adapter for the AR (Critic) half of a Natural Language Autoencoder on Gemma-4-E2B, paired with `Solshine/gemma-4-e2b-nla-L23-av-v0_1_dd-step_250` for the v0.1 NLA pair release.
|
| 22 |
+
|
| 23 |
+
This AR is a 50-step continuation from `Solshine/gemma-4-e2b-nla-L23-ar-v0_0_1` trained with an auxiliary paraphrase-invariance loss:
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
L = MSE(AR(orig), gold) + lambda * MSE(AR(paraphrase), gold)
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
(where `lambda = 0.5` and `paraphrase` is a meaning-preserving rewrite of the explanation text). The original goal was to break the AR's content-blindness diagnosed in source-repo `FINDINGS.md §F72 Addendum 3`. The Phase A result was: the auxiliary loss **made the AR a better structural projector but not a content-reader**. See the "Findings" section below.
|
| 30 |
+
|
| 31 |
+
## Training setup
|
| 32 |
+
|
| 33 |
+
- Base: `google/gemma-4-E2B`
|
| 34 |
+
- AR architecture: first K=18 layers of base + linear head (1536→1536, bias=True)
|
| 35 |
+
- Quantization: NF4 4-bit base + bf16 LoRA
|
| 36 |
+
- LoRA: r=64, alpha=128, target = language-model self-attn (q/k/v/o); inherited from v0.0.1
|
| 37 |
+
- Loss head: linear_head.pt (saved alongside adapter)
|
| 38 |
+
- Resume-from: v0.0.1 AR (`Solshine/gemma-4-e2b-nla-L23-ar-v0_0_1`)
|
| 39 |
+
- Optimizer: AdamW 8-bit, lr=5e-5 (lower than v0.0.1's 1e-4 — continuation training)
|
| 40 |
+
- Batch: micro_batch=1, grad_accum=16 → effective batch 16
|
| 41 |
+
- Steps: 50 SFT (~4.2h on the 4 GB GPU; ~5min/step due to doubled forward pass with paraphrase branch)
|
| 42 |
+
- Max length: 512 tokens
|
| 43 |
+
- Corpus: 696 rows of natural labeler-v1 / auditor-v2 paraphrase pairs from the persona+audit-haiku stage
|
| 44 |
+
- Training script: `experiments/v8_nla_local/stage_ar_sft_v0_1.py` (source repo)
|
| 45 |
+
|
| 46 |
+
## Findings (key)
|
| 47 |
+
|
| 48 |
+
Three converging pieces of evidence for AR structural-projection on this hardware regime, documented in source-repo `FINDINGS.md §F72 Addendum 5`:
|
| 49 |
+
|
| 50 |
+
1. **Loss-domain**: Phase A's `orig` and `para` losses tracked within 0.001-0.013 at *every* step. The v0.0.1 AR was already paraphrase-invariant in the loss domain before training began — the auxiliary `lambda·MSE(AR(paraphrase), gold)` term had nothing differential to attach to.
|
| 51 |
+
|
| 52 |
+
2. **Direct delta_cos test (n=30)**:
|
| 53 |
+
|
| 54 |
+
| Quantity | AR v0.0.1 | AR v0.1 |
|
| 55 |
+
|---|---:|---:|
|
| 56 |
+
| delta_cos = cos(AR(orig), gold) − cos(AR(para), gold) | +0.0008 | +0.0011 |
|
| 57 |
+
| cos(AR(orig), gold) — absolute reconstruction | 0.4257 | 0.4966 (+17%) |
|
| 58 |
+
| cos(AR(orig), AR(paraphrase)) | 0.9929 | 0.9948 |
|
| 59 |
+
|
| 60 |
+
3. **H15 head-to-head (v0.1.dd step_250 AV, two ARs)**:
|
| 61 |
+
|
| 62 |
+
| Input | AR v0.0.1 | AR v0.1 | absolute lift |
|
| 63 |
+
|---|---:|---:|---:|
|
| 64 |
+
| AV_OUT | 0.4221 | 0.4603 | +0.0382 |
|
| 65 |
+
| EMPTY | 0.4048 | 0.4531 | **+0.0483** |
|
| 66 |
+
| RANDOM | 0.4045 | 0.4525 | **+0.0480** |
|
| 67 |
+
| GIBBER | 0.4137 | 0.4562 | +0.0425 |
|
| 68 |
+
| Δ(AV_OUT − EMPTY) | +0.0174 | +0.0072 | shrank |
|
| 69 |
+
|
| 70 |
+
**Phase A's auxiliary loss uniformly lifted reconstruction quality across every input type** — including pure-noise EMPTY/RANDOM/GIBBER. AV_OUT got the *smallest* lift. The content-loaded delta shrank because the AR's "background structural projection" got more accurate faster than its content-loaded reading.
|
| 71 |
+
|
| 72 |
+
The same pattern was re-confirmed on a second AV checkpoint (v0.1.dd step_50) — the structural-projection ceiling is upstream of AV training.
|
| 73 |
+
|
| 74 |
+
## What this AR is good for
|
| 75 |
+
|
| 76 |
+
- **Higher absolute round-trip cosine on the matched v0.1.dd AV**: 0.46 (vs 0.42 with v0.0.1 AR). Comparable to v0.0.1's published 0.438 ± 0.054.
|
| 77 |
+
- **Cleaner structural-projection signature** for researchers studying the AR-side bottleneck. The fact that EMPTY/RANDOM/GIBBER lift MORE than AV_OUT in head-to-head is itself a publishable diagnostic.
|
| 78 |
+
- **Methodology reproduction**: third-party researchers can re-run the Phase A pipeline on their own NLA training data.
|
| 79 |
+
|
| 80 |
+
## What this AR does NOT do
|
| 81 |
+
|
| 82 |
+
- Lift the H15 content-aware delta. The AR is still principally a structural projection at this scale.
|
| 83 |
+
- Differentiate content-bearing AV outputs from gibberish input — the GIBBER vs AV_OUT gap is tiny (+0.004 on v0.1.dd step_250).
|
| 84 |
+
|
| 85 |
+
## Loading
|
| 86 |
+
|
| 87 |
+
```python
|
| 88 |
+
import torch
|
| 89 |
+
import torch.nn as nn
|
| 90 |
+
from peft import PeftModel
|
| 91 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
| 92 |
+
from huggingface_hub import snapshot_download
|
| 93 |
+
|
| 94 |
+
bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16,
|
| 95 |
+
bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True)
|
| 96 |
+
base = AutoModelForCausalLM.from_pretrained("google/gemma-4-E2B", quantization_config=bnb,
|
| 97 |
+
device_map={"": torch.cuda.current_device()})
|
| 98 |
+
ar_path = snapshot_download("Solshine/gemma-4-e2b-nla-L23-ar-v0_1-paraphrase-invariant")
|
| 99 |
+
ar = PeftModel.from_pretrained(base, ar_path)
|
| 100 |
+
head = nn.Linear(1536, 1536, bias=True).to(ar.device).to(torch.float32)
|
| 101 |
+
head.load_state_dict(torch.load(f"{ar_path}/linear_head.pt", weights_only=True))
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
## See also
|
| 105 |
+
|
| 106 |
+
- Matched AV (v0.1.dd): [`Solshine/gemma-4-e2b-nla-L23-av-v0_1_dd-step_250`](https://huggingface.co/Solshine/gemma-4-e2b-nla-L23-av-v0_1_dd-step_250)
|
| 107 |
+
- v0.0.1 AR (baseline / resume-from): [`Solshine/gemma-4-e2b-nla-L23-ar-v0_0_1`](https://huggingface.co/Solshine/gemma-4-e2b-nla-L23-ar-v0_0_1)
|
| 108 |
+
- v0.0.1 AV: [`Solshine/gemma-4-e2b-nla-L23-av-v0_0_1`](https://huggingface.co/Solshine/gemma-4-e2b-nla-L23-av-v0_0_1)
|
| 109 |
+
- Public bundled repo: [`SolshineCode/nla-gemma-4-e2b`](https://github.com/SolshineCode/nla-gemma-4-e2b)
|
| 110 |
+
|
| 111 |
+
## Citation
|
| 112 |
+
|
| 113 |
+
```bibtex
|
| 114 |
+
@misc{gemma4_e2b_nla_ar_v0_1,
|
| 115 |
+
title = {Gemma-4-E2B NLA AR v0.1: paraphrase-invariance auxiliary loss + 3-piece-evidence for AR structural-projection at small-NLA scale},
|
| 116 |
+
author = {DeLeeuw, Caleb},
|
| 117 |
+
year = {2026},
|
| 118 |
+
month = {may},
|
| 119 |
+
url = {https://huggingface.co/Solshine/gemma-4-e2b-nla-L23-ar-v0_1-paraphrase-invariant}
|
| 120 |
+
}
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
Methodology citation:
|
| 124 |
+
|
| 125 |
+
- Fraser-Taliente, K., et al. (2026). *Natural Language Autoencoders*. https://transformer-circuits.pub/2026/nla/
|
adapter_config.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "google/gemma-4-E2B",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 128,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.05,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": null,
|
| 26 |
+
"peft_type": "LORA",
|
| 27 |
+
"peft_version": "0.19.1",
|
| 28 |
+
"qalora_group_size": 16,
|
| 29 |
+
"r": 64,
|
| 30 |
+
"rank_pattern": {},
|
| 31 |
+
"revision": null,
|
| 32 |
+
"target_modules": "model\\.language_model\\.layers\\.\\d+\\.self_attn\\.(q_proj|k_proj|v_proj|o_proj)",
|
| 33 |
+
"target_parameters": null,
|
| 34 |
+
"task_type": "CAUSAL_LM",
|
| 35 |
+
"trainable_token_indices": null,
|
| 36 |
+
"use_bdlora": null,
|
| 37 |
+
"use_dora": false,
|
| 38 |
+
"use_qalora": false,
|
| 39 |
+
"use_rslora": false
|
| 40 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b9dd6915b3fd7a798e230b1b530be979baaaf1ab93eab96906fb02851bbfc61e
|
| 3 |
+
size 85750952
|
linear_head.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4470edf09dae0468699a5ac11ad60955497736be4aac7244110344afaaf6dbac
|
| 3 |
+
size 9445317
|
nla_meta.yaml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind: nla_model
|
| 2 |
+
role: critic
|
| 3 |
+
ar_lora:
|
| 4 |
+
r: 64
|
| 5 |
+
alpha: 128
|
| 6 |
+
target_modules:
|
| 7 |
+
- q_proj
|
| 8 |
+
- k_proj
|
| 9 |
+
- v_proj
|
| 10 |
+
- o_proj
|
| 11 |
+
critic:
|
| 12 |
+
num_hidden_layers: 18
|
| 13 |
+
ar_head_dim_in: 1536
|
| 14 |
+
ar_head_dim_out: 1536
|
| 15 |
+
training:
|
| 16 |
+
version: v0.1_paraphrase_invariant
|
| 17 |
+
resume_from: C:\Users\caleb\AppData\Local\Temp\nla-gemma-4-e2b\weights\v0_0_1\ar
|
| 18 |
+
lr: 5.0e-05
|
| 19 |
+
max_steps: 50
|
| 20 |
+
micro_batch: 1
|
| 21 |
+
grad_accum: 16
|
| 22 |
+
para_lambda: 0.5
|