Views
No views yet
| Sentence | Token | AV verbalization |
|---|---|---|
| Einstein developed the theory of relativity. | instein | Person's name. The text discusses Albert Einstein, a famous physicist. |
| Mount Everest is the highest mountain on Earth. | mountain | The highest mountain in the world. |
| The heart pumps blood throughout the body. | heart | Heart muscle. The text discusses the heart's role in pumping blood and its importance to overall health. |
| Pos | Token | Activation verbalization |
|---|---|---|
| 0 | What | The text discusses the start of a new sentence or paragraph. |
| 1 | 's | The text discusses the speaker's excitement about a new recipe. |
| 2 | the | The semantic content is about the method or technique for making a specific type of beer. |
| 3 | capital | City where the conference will be held. |
| 4 | of | Indicates the start of a location or destination. |
| 5 | the | Indicates the start of a location or region. |
| 6 | country | Country name. The text discusses the country of Japan, specifically mentioning its capital city Tokyo. |
| 7 | containing | Indicates the start of a list or description. |
| 8 | Dallas | City where the event will take place. |
| 9 | ? | Sentence about a location and its weather. |
Qwen/Qwen2.5-1.5B-Instruct. It consists of two LoRA-adapted copies of the base model:vector → text. Injects a residual-stream activation as a single
token embedding into a fixed prompt and generates a free-text description of what it encodes.text → vector. A copy truncated to layers 0…18 plus a
1536→1536 head that reconstructs the activation from the AV's text.av/ — AV LoRA adapter (PEFT, on Qwen/Qwen2.5-1.5B-Instruct).ar/ — AR LoRA adapter (truncated to layers 0…18), paired with the 1536→1536 value head.nla_meta.yaml — configuration sidecar: injection_scale=1.01256,
injection_token_id=151655 (<|image_pad|>), extraction_layer=18, and the prompt template.
Load configuration from this file rather than hardcoding values.1import torch, torch.nn.functional as F, yaml
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5cfg = yaml.safe_load(open("nla_meta.yaml"))
6tok = AutoTokenizer.from_pretrained(cfg["base_model"])
7base = AutoModelForCausalLM.from_pretrained(cfg["base_model"], torch_dtype=torch.bfloat16).cuda()
8av = PeftModel.from_pretrained(base, "av").cuda().eval()
9
10prompt_ids = tok(cfg["prompt_template"], add_special_tokens=False)["input_ids"]
11slot = prompt_ids.index(cfg["injection_token_id"])
12emb = av.get_input_embeddings()(torch.tensor(prompt_ids).cuda()[None]).clone()
13
14act = torch.randn(cfg["hidden_size"]).cuda() # a real L18 residual-stream activation
15emb[:, slot] = F.normalize(act, dim=-1).to(emb.dtype) * cfg["injection_scale"]
16out = av.generate(inputs_embeds=emb,
17 attention_mask=torch.ones(emb.shape[:2], device=emb.device),
18 max_new_tokens=32, do_sample=False)
19print(tok.decode(out[0], skip_special_tokens=True))hidden_states[18] (the output of block 18, before the final norm) and
passed in raw; the injection step normalises and rescales them.