Qwen2.5-1.5B-Instruct NLA L18 Activation Verbalizer

The activation verbalizer of a Natural Language Autoencoder trained on the layer-18 residual stream of Qwen/Qwen2.5-1.5B-Instruct. See https://transformer-circuits.pub/2026/nla/, and https://github.com/kitft/natural_language_autoencoders

Activation Reconstructor:dormantx/Qwen2.5-1.5B-Instruct-NLA-L18-ar.

Usage

import torch, torch.nn.functional as F, yaml
from huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "dormantx/Qwen2.5-1.5B-Instruct-NLA-L18-av"
meta = yaml.safe_load(open(hf_hub_download(repo, "nla_meta.yaml")))
tok = AutoTokenizer.from_pretrained(repo)
av = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16).cuda().eval()

prompt = meta["prompt_templates"]["av"].format(injection_char=meta["tokens"]["injection_char"])
ids = tok(prompt, add_special_tokens=False)["input_ids"]
slot = ids.index(meta["tokens"]["injection_token_id"])
emb = av.get_input_embeddings()(torch.tensor(ids).cuda()[None]).clone()

act = ...  # a raw layer-18 residual-stream activation, i.e. hidden_states[18], shape [1536]
emb[:, slot] = F.normalize(act, dim=-1).to(emb.dtype) * meta["extraction"]["injection_scale"]
out = av.generate(inputs_embeds=emb,
                  attention_mask=torch.ones(emb.shape[:2], device=emb.device),
                  max_new_tokens=32, do_sample=False)
print(tok.decode(out[0], skip_special_tokens=True))

Activations must come from hidden_states[18] of the base model (output of block 18, before the final norm) and be passed raw — the injection step does the normalising and rescaling.

Downloads last month
175
Safetensors
Model size
2B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av

Finetuned
(1813)
this model