Downloads · 30 days
10
7% of all-time downloads
wisent-ai/qwen2.5-coder-7b-wisent-caa
qwen2.5-coder-7b-wisent-caa is a text generation model from wisent-ai. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is an enhanced version of Qwen2.5-Coder-7B-Instruct that integrates Contrastive Activation Addition (CAA) steering directly into the model architecture. The steering parameters have been optimized using Optuna to…
Downloads · 30 days
10
7% of all-time downloads
All-time downloads
145
Public
Repo size
11.4 MB
Likes
0
Public
Click a slice to open those files.
.json14.2 MB · 89%
From the Hugging Face model README
This is an enhanced version of Qwen2.5-Coder-7B-Instruct that integrates Contrastive Activation Addition (CAA) steering directly into the model architecture. The steering parameters have been optimized using Optuna to improve code generation quality on the MBPP Plus benchmark.
pip install transformers torch safetensors
# Or install from requirements.txt
pip install -r requirements.txt
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model - CAA steering is automatically applied!
model = AutoModelForCausalLM.from_pretrained("./huggingface_qwen25-7b-coder-caa", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("./huggingface_qwen25-7b-coder-caa")
# Generate code
prompt = "Write a Python function to calculate the factorial of a number"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.2)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
# Increase steering strength for stronger safety alignment
model.set_caa_alpha(1.2)
# Decrease for more creative outputs
model.set_caa_alpha(0.5)
# Disable CAA to get baseline model behavior
model.set_caa_enabled(False)
# Re-enable CAA
model.set_caa_enabled(True)
print(f"CAA Layer: {model.caa_layer_id}")
print(f"CAA Alpha: {model.caa_alpha}")
print(f"Steering Method: {model.steering_method}")
The model uses a trait-based organization for steering vectors:
vectors/
├── mbpp_plus/ # Current: Optimized for MBPP Plus benchmark
├── safety/ # Future: Safety-aligned behavior
├── creativity/ # Future: Enhanced creative outputs
├── helpfulness/ # Future: Improved helpfulness
└── reasoning/ # Future: Enhanced logical reasoning
To switch traits, simply update the configuration:
{
"steering_vector_path": "./vectors/safety/steering_vector.safetensors"
}
./vectors/mbpp_plus/steering_vector.safetensorsvectors/{trait}/)The CAA parameters were optimized using:
WisentQwen2ForCausalLM
├── Base: Qwen2.5-Coder-7B-Instruct
├── CAA Integration: Layer 24
├── Steering Vector: ./vectors/mbpp_plus/steering_vector.safetensors
└── Auto-applied during generation
huggingface_qwen25-7b-coder-caa/
├── config.json # Model configuration with CAA params
├── modeling_wisent_qwen.py # Custom model class
├── tokenizer files # Standard Qwen tokenizer
├── wisent_config.json # Optimization results
└── vectors/ # Trait-based steering vectors
└── mbpp_plus/
└── steering_vector.safetensors # MBPP Plus optimized steering vector
The model has been optimized using Optuna on MBPP Plus tasks. For reliable performance metrics, evaluation should be conducted on the complete MBPP Plus dataset (378 problems) using the evalplus/mbppplus dataset.
# Use with bigcode-evaluation-harness
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
"./huggingface_qwen25-7b-coder-caa",
trust_remote_code=True
)
# CAA steering is automatically applied during evaluation!
# No manual hooks or modifications needed
If you use this model, please cite:
@software{wisent_qwen_caa_2025,
title={Wisent-Qwen2.5-Coder with CAA Steering},
author={Wisent AI},
year={2025},
url={https://github.com/wisent-ai/wisent-guard}
}
This model inherits the license from the base Qwen2.5-Coder-7B-Instruct model. Please refer to the original model's license for usage terms.