Downloads · 30 days
5
12% of all-time downloads
haorandai/deepseek-r1-llama-8b-strongest-vector
deepseek-r1-llama-8b-strongest-vector 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 uniform adaptive steering using the strongest single vector applied to all layers.
Downloads · 30 days
5
12% of all-time downloads
All-time downloads
43
Public
Parameters
8B
16.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README
This repository contains a teacher model enhanced with uniform adaptive steering using the strongest single vector applied to all layers.
Unlike layer-wise steering where each layer has a different vector, this model uses:
This creates more consistent, predictable steering behavior across the entire model.
steering_config.json with strategy detailsinjection = (1 - lambda_t) * alpha_max * vectoralpha_max: 50.0 (maximum steering strength)max_entropy: 10.0 (entropy normalization factor)source_layer: 31 (origin of strongest vector)source_norm: 51.352 (original vector magnitude)pip install torch transformers huggingface_hub
The standalone_steering_inference.py module is included in this repository.
from transformers import AutoModelForCausalLM, AutoTokenizer
from huggingface_hub import snapshot_download
import sys
from pathlib import Path
# Download repository (includes standalone_steering_inference.py)
repo_path = snapshot_download(repo_id="YOUR_HF_USERNAME/deepseek-r1-llama-8b-strongest-vector-50.0")
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/deepseek-r1-llama-8b-strongest-vector-50.0",
torch_dtype="auto",
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(
"YOUR_HF_USERNAME/deepseek-r1-llama-8b-strongest-vector-50.0",
trust_remote_code=True
)
# Load steering components from repository
model_path = Path(repo_path)
steering_vectors, _ = load_steering_vectors(
str(model_path / "steering_vectors"),
device="cpu"
)
gate = load_gate(str(model_path / "adaptive_gate.pt"), device="cpu")
entropy_tracker = EntropyTracker(max_entropy=10.0)
# Create multi-layer steering hook (uses uniform vector for all layers)
lm_head = model.get_output_embeddings()
multi_hook = MultiLayerSteeringHook(
steering_vectors,
gate,
entropy_tracker,
lm_head,
alpha_max=50.0
)
# Register hooks on ALL model layers
layers = model.model.layers
hook_handles = []
for layer_idx in range(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)} hooks with uniform steering vector")
# 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()
✅ Consistency: Same steering signal across all layers ensures uniform behavior ✅ Simplicity: Easier to understand and debug ✅ Efficiency: Single vector computation and storage ✅ Predictability: More consistent teacher model behavior for distillation
If you use this steered model, please cite:
@misc{uniform_steered_teacher_model,
title={Uniform Adaptive Steering for Language Models: Strongest Single Vector Approach},
author={Your Name},
year={2026},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/YOUR_USERNAME/deepseek-r1-llama-8b-strongest-vector-50.0}}
}
This model inherits the license from the base model: deepseek-ai/DeepSeek-R1-Distill-Llama-8B
Built with the TRL library's experimental GOLD framework. Steering strategy: Strongest single vector with uniform application.