Text Generation
Transformers
Safetensors
qwen2
natural-language-autoencoder
activation-reconstructor
interpretability
affect
conversational
text-generation-inference
Instructions to use MaxChess/qwen2.5-7b-nla-affect-ar with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MaxChess/qwen2.5-7b-nla-affect-ar with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MaxChess/qwen2.5-7b-nla-affect-ar") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MaxChess/qwen2.5-7b-nla-affect-ar") model = AutoModelForCausalLM.from_pretrained("MaxChess/qwen2.5-7b-nla-affect-ar", 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 MaxChess/qwen2.5-7b-nla-affect-ar with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MaxChess/qwen2.5-7b-nla-affect-ar" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MaxChess/qwen2.5-7b-nla-affect-ar", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MaxChess/qwen2.5-7b-nla-affect-ar
- SGLang
How to use MaxChess/qwen2.5-7b-nla-affect-ar 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 "MaxChess/qwen2.5-7b-nla-affect-ar" \ --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": "MaxChess/qwen2.5-7b-nla-affect-ar", "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 "MaxChess/qwen2.5-7b-nla-affect-ar" \ --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": "MaxChess/qwen2.5-7b-nla-affect-ar", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MaxChess/qwen2.5-7b-nla-affect-ar with Docker Model Runner:
docker model run hf.co/MaxChess/qwen2.5-7b-nla-affect-ar
Initialize private AR card
Browse files
README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 3 |
+
datasets:
|
| 4 |
+
- MaxChess/nla-affect-10k
|
| 5 |
+
library_name: transformers
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
tags:
|
| 8 |
+
- natural-language-autoencoder
|
| 9 |
+
- activation-reconstructor
|
| 10 |
+
- interpretability
|
| 11 |
+
- affect
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Qwen2.5-7B NLA Affect AR
|
| 15 |
+
|
| 16 |
+
Experimental activation reconstructor (AR): explanation text to a 3,584-dimensional
|
| 17 |
+
Qwen2.5-7B-Instruct layer-20 activation direction. The backbone is truncated to 21
|
| 18 |
+
transformer blocks and uses a separately saved `value_head.safetensors`.
|
| 19 |
+
|
| 20 |
+
## Evaluation on 200 AR-held-out teacher explanations
|
| 21 |
+
|
| 22 |
+
- Directional FVE: 0.34277.
|
| 23 |
+
- Bootstrap 95% CI: [0.30129, 0.37560].
|
| 24 |
+
- Mean cosine similarity: 0.76460.
|
| 25 |
+
- Shuffled FVE: -0.77740.
|
| 26 |
+
|
| 27 |
+
Targets and predictions are independently L2-normalized. FVE is
|
| 28 |
+
`1 - mean(||h-h_hat||^2) / mean(||h-mean(h)||^2)` on normalized directions.
|
| 29 |
+
|
| 30 |
+
## Training
|
| 31 |
+
|
| 32 |
+
- 5,000 examples, one epoch, 209 optimizer steps.
|
| 33 |
+
- Direction-only normalized MSE, scale `sqrt(3584)`.
|
| 34 |
+
- Effective global batch: 24 on three V100-32GB GPUs.
|
| 35 |
+
- PyTorch SDPA.
|
| 36 |
+
|
| 37 |
+
This AR score measures reconstruction from teacher explanations. The current full
|
| 38 |
+
AV -> AR cycle is substantially weaker (FVE 0.03765), indicating that AV is the main
|
| 39 |
+
bottleneck. See `MaxChess/nla-affect-10k` for exact splits and source code.
|