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
| base_model: Qwen/Qwen2.5-7B-Instruct | |
| datasets: | |
| - MaxChess/nla-affect-10k | |
| library_name: transformers | |
| license: apache-2.0 | |
| tags: | |
| - natural-language-autoencoder | |
| - activation-reconstructor | |
| - interpretability | |
| - affect | |
| # Qwen2.5-7B NLA Affect AR | |
| Experimental activation reconstructor (AR): explanation text to a 3,584-dimensional | |
| Qwen2.5-7B-Instruct layer-20 activation direction. The backbone is truncated to 21 | |
| transformer blocks and uses a separately saved `value_head.safetensors`. | |
| ## Evaluation on 200 AR-held-out teacher explanations | |
| - Directional FVE: 0.34277. | |
| - Bootstrap 95% CI: [0.30129, 0.37560]. | |
| - Mean cosine similarity: 0.76460. | |
| - Shuffled FVE: -0.77740. | |
| Targets and predictions are independently L2-normalized. FVE is | |
| `1 - mean(||h-h_hat||^2) / mean(||h-mean(h)||^2)` on normalized directions. | |
| ## Training | |
| - 5,000 examples, one epoch, 209 optimizer steps. | |
| - Direction-only normalized MSE, scale `sqrt(3584)`. | |
| - Effective global batch: 24 on three V100-32GB GPUs. | |
| - PyTorch SDPA. | |
| This AR score measures reconstruction from teacher explanations. The current full | |
| AV -> AR cycle is substantially weaker (FVE 0.03765), indicating that AV is the main | |
| bottleneck. See `MaxChess/nla-affect-10k` for exact splits and source code. | |