Qwen2.5-0.5B Natural Language Autoencoder
decoding model hidden activations into text
2 min readupdated
This model replicates a recent method from Anthropic for AI interpretability, trained on the intermediate layer activations of Qwen2.5-0.5B-Instruct. The system consists of two components: an activation verbalizer (translates the internal network state into text items) and a reconstructor (turns the text back into a vector representation). The tool helps researchers examine model "thoughts" in a readable format, although at this scale it tends to generate plausible hallucinations. The release is useful for researchers working in AI safety and Mechanistic Interpretability.
Key features
- Implements the Natural Language Autoencoder approach for translating activation vectors into human-readable language.
- Trained in two stages: supervised warm-start and joint training using GRPO (Group Relative Policy Optimization) and MSE regression.
- Uses activations from the 16th layer of the base Qwen/Qwen2.5-0.5B-Instruct model.
- Shows an improvement in the Fraction of Variance Explained (FVE) metric compared to baseline control values.
What you can do
- Run inference to generate text explanations for hidden activations of text prompts.
- Explore internal layer representations of a compact language model in scientific experiments.
- Use the repository code and weights to customize for your own AI interpretability analysis tasks.
Example
import json, torch
from huggingface_hub import snapshot_download
from transformers import AutoModelForCausalLM, AutoTokenizer
repo_dir = snapshot_download("patelvishwa112/qwen2.5-0.5b-nla")
av_dir = f"{repo_dir}/av_rl"
cfg = json.load(open(f"{av_dir}/nla_av_config.json"))
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if device == "cuda" else torch.float32
target_tok = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
target_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct", dtype=dtype).to(device).eval()
prompt = "In 1969, NASA's Apollo 11 mission landed the Lunar Module Eagle on the Sea of Tranquility"
enc = target_tok(prompt, return_tensors="pt").to(device)
with torch.no_grad():
h16 = target_model(**enc, output_hidden_states=True).hidden_states[16][0, -1].float()
h16_unit = h16 / h16.norm()Read more
DetailsTraining metrics and details:
• Round-Trip Val FVE: 0.180 (4.2x increase vs SFT)
• Round-Trip Cosine Similarity: 0.707
• Hardware: trained in 1 hour on 1x NVIDIA L4 (24 GB, BF16)
• Limitations: tendency to confabulate (make up details) when generating explanations










Comments