Instructions to use andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av") model = AutoModelForCausalLM.from_pretrained("andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/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
docker model run hf.co/andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av
- SGLang
How to use andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av with 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?" } ] }' - Docker Model Runner
How to use andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av with Docker Model Runner:
docker model run hf.co/andyx10/Qwen2.5-1.5B-Instruct-NLA-L18-av
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