Downloads · 30 days
4
13% of all-time downloads
haorandai/qwen3-8b-gold-steered-teacher
qwen3-8b-gold-steered-teacher is a machine learning model from haorandai. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a teacher model enhanced with adaptive steering vectors and an MLP gate for controlled generation behavior.
Downloads · 30 days
4
13% of all-time downloads
All-time downloads
31
Public
Parameters
8.2B
16.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16.4 GB · 100%
From the Hugging Face model README
This repository contains a teacher model enhanced with adaptive steering vectors and an MLP gate for controlled generation behavior.
steering_config.json with default parametersThis model implements adaptive steering through:
alpha_max: 50.0 (maximum steering strength)max_entropy: 10.0 (entropy normalization factor)pip install torch transformers huggingface_hub
The standalone_steering_inference.py module is included in this repository.
from transformers import AutoModelForCausalLM, AutoTokenizer
# Download the repository (includes standalone_steering_inference.py)
from huggingface_hub import snapshot_download
import sys
repo_path = snapshot_download(repo_id="YOUR_HF_USERNAME/qwen3-8b-gold-steered-teacher")
sys.path.insert(0, repo_path)
from standalone_steering_inference import (
load_steering_vectors,
load_gate,
EntropyTracker,
MultiLayerSteeringHook
)
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
"YOUR_HF_USERNAME/qwen3-8b-gold-steered-teacher",
torch_dtype="auto",
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(
"YOUR_HF_USERNAME/qwen3-8b-gold-steered-teacher",
trust_remote_code=True
)
# Load steering components from the repository
model_path = model.config._name_or_path # Or your local path
steering_vectors, _ = load_steering_vectors(
f"{model_path}/steering_vectors",
device="cpu"
)
gate = load_gate(f"{model_path}/adaptive_gate.pt", device="cpu")
entropy_tracker = EntropyTracker(max_entropy=10.0)
# Create multi-layer steering hook
lm_head = model.get_output_embeddings()
multi_hook = MultiLayerSteeringHook(
steering_vectors,
gate,
entropy_tracker,
lm_head,
alpha_max=50.0
)
# Register hooks on model layers
layers = model.model.layers
hook_handles = []
for layer_idx in steering_vectors.keys():
if layer_idx < len(layers):
hook_fn = multi_hook.create_hook(layer_idx)
handle = layers[layer_idx].register_forward_hook(hook_fn)
hook_handles.append(handle)
print(f"Registered {len(hook_handles)} steering hooks")
# Generate with steering
prompt = "Solve this problem: What is 2+2?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# Reset entropy tracker for new sequence
entropy_tracker.reset(initial_token_count=inputs["input_ids"].shape[-1])
# Generate
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
do_sample=True
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
# Cleanup hooks when done
for handle in hook_handles:
handle.remove()
# Modify alpha_max to control steering intensity
# Higher values = stronger steering
multi_hook = MultiLayerSteeringHook(
steering_vectors,
gate,
entropy_tracker,
lm_head,
alpha_max=100.0 # Increase for stronger effect
)
The adaptive steering system works in three stages:
(1 - lambda) * alpha_maxThis creates adaptive behavior:
This model was trained using the GOLD (Generative On-policy Learning from Demonstration) framework with:
If you use this steered model, please cite:
@misc{steered_teacher_model,
title={Adaptive Steering with MLP Gate for Language Models},
author={Your Name},
year={2026},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/YOUR_USERNAME/qwen3-8b-gold-steered-teacher}}
}
This model inherits the license from the base model: Qwen/Qwen3-8B
Built with the TRL library's experimental GOLD framework.