How to use from
SGLang
Install from pip and serve model
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
    --model-path "andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av" \
    --host 0.0.0.0 \
    --port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av",
		"messages": [
			{
				"role": "user",
				"content": "What is the capital of France?"
			}
		]
	}'
Use Docker images
docker run --gpus all \
    --shm-size 32g \
    -p 30000:30000 \
    -v ~/.cache/huggingface:/root/.cache/huggingface \
    --env "HF_TOKEN=<secret>" \
    --ipc=host \
    lmsysorg/sglang:latest \
    python3 -m sglang.launch_server \
        --model-path "andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av" \
        --host 0.0.0.0 \
        --port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av",
		"messages": [
			{
				"role": "user",
				"content": "What is the capital of France?"
			}
		]
	}'
Quick Links

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
151
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
(1863)
this model