Instructions to use paoloronco/Mistral-7B-Instruct-v0.3-heretic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use paoloronco/Mistral-7B-Instruct-v0.3-heretic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="paoloronco/Mistral-7B-Instruct-v0.3-heretic") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("paoloronco/Mistral-7B-Instruct-v0.3-heretic") model = AutoModelForCausalLM.from_pretrained("paoloronco/Mistral-7B-Instruct-v0.3-heretic") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use paoloronco/Mistral-7B-Instruct-v0.3-heretic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "paoloronco/Mistral-7B-Instruct-v0.3-heretic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paoloronco/Mistral-7B-Instruct-v0.3-heretic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/paoloronco/Mistral-7B-Instruct-v0.3-heretic
- SGLang
How to use paoloronco/Mistral-7B-Instruct-v0.3-heretic 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 "paoloronco/Mistral-7B-Instruct-v0.3-heretic" \ --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": "paoloronco/Mistral-7B-Instruct-v0.3-heretic", "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 "paoloronco/Mistral-7B-Instruct-v0.3-heretic" \ --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": "paoloronco/Mistral-7B-Instruct-v0.3-heretic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use paoloronco/Mistral-7B-Instruct-v0.3-heretic with Docker Model Runner:
docker model run hf.co/paoloronco/Mistral-7B-Instruct-v0.3-heretic
Mistral-7B-Instruct-v0.3-heretic
An abliterated version of mistralai/Mistral-7B-Instruct-v0.3, created with Heretic v1.3.0.
Refusal behavior reduced to 4/100 prompts, with a KL divergence of 0.0606 — original capabilities are largely preserved.
Quick start
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch
model_id = "paoloronco/Mistral-7B-Instruct-v0.3-heretic"
# 4-bit quantization for GPUs with less than 16 GB VRAM
quantization_config = BitsAndBytesConfig(load_in_4bit=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=quantization_config,
device_map="auto"
)
messages = [{"role": "user", "content": "Tell me about yourself."}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Full precision (requires 16+ GB VRAM):
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
What is abliteration
Heretic modifies the weights of a language model to suppress automatic refusals without retraining from scratch. The process:
- Loads the model and runs forward passes on two prompt sets: harmless and harmful
- Analyzes internal activations to find the refusal direction in latent space
- Optimizes parameters with Optuna (Bayesian optimization, 200 trials)
- Applies the correction via LoRA — a lightweight, targeted weight modification
The model is not retrained. Its internal geometry is redirected.
Tool developed by Philipp Emanuel Weidmann (p-e-w), released under AGPL-3.0.
Model details
| Property | Value |
|---|---|
| Base model | mistralai/Mistral-7B-Instruct-v0.3 |
| Tool used | Heretic v1.3.0 |
| Parameters | 7.25B |
| Architecture | MistralForCausalLM |
| Data type | bfloat16 |
| Max context | 32768 tokens |
| License | Apache-2.0 |
Abliteration parameters (Trial 173)
| Parameter | Value |
|---|---|
| direction_index | 16.87 |
| attn.o_proj.max_weight | 1.44 |
| attn.o_proj.max_weight_position | 24.50 |
| attn.o_proj.min_weight | 1.01 |
| attn.o_proj.min_weight_distance | 13.91 |
| mlp.down_proj.max_weight | 1.18 |
| mlp.down_proj.max_weight_position | 20.94 |
| mlp.down_proj.min_weight | 1.16 |
| mlp.down_proj.min_weight_distance | 8.36 |
Results
| Metric | This model |
|---|---|
| KL divergence | 0.0606 |
| Refusals out of 100 prompts | 4/100 |
KL divergence measures deviation from the original model. Lower = better quality preservation. Values above 0.5 indicate significant capability damage.
Hardware used
GPU: NVIDIA GeForce RTX 4090 (48 GB VRAM)
OS: Linux
CUDA: 13.0
Driver: 580.142
Optimization time: 200 Optuna trials in 19 minutes 21 seconds.
Links
- Hugging Face: paoloronco/Mistral-7B-Instruct-v0.3-heretic
- GitHub repo: paoloronco/heretic-models
- Tool used: github.com/p-e-w/heretic
- Base model: mistralai/Mistral-7B-Instruct-v0.3
Disclaimer
This model is intended for research and personal use. It has reduced safety restrictions compared to the base model. Use responsibly and in accordance with applicable laws and regulations.
Author: Paolo Ronco — paoloronco on Hugging Face
- Downloads last month
- 65
Model tree for paoloronco/Mistral-7B-Instruct-v0.3-heretic
Base model
mistralai/Mistral-7B-v0.3