CoolFace
Modelpublic

williyam/hallucination-detector-agent-qwen3-0.6b

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
2likes10downloads
Model Card

๐Ÿง  Hallucination Detector Agent โ€” GRPO Fine-tuned Qwen3-0.6B

A GRPO-fine-tuned LoRA adapter for hallucination detection, classification, and correction.

Quick Start

python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

# Load base model + LoRA adapter
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B", torch_dtype="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(base, "williyam/hallucination-detector-agent-qwen3-0.6b")
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B", trust_remote_code=True)

messages = [
    {"role": "system", "content": "You are a hallucination detector. Given SOURCE and PASSAGE, output JSON with action_type, hallucination_detected, hallucination_type, hallucinated_span, corrected_text, reasoning."},
    {"role": "user", "content": "SOURCE: The Eiffel Tower is in Paris.\nPASSAGE: The Eiffel Tower is in London."}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Model Details

Base model`Qwen/Qwen3-0.6B`
LicenseApache 2.0 (ungated)
MethodGRPO (Group Relative Policy Optimization)
LoRArank=16, alpha=32
Training3 epochs, lr=5e-6, beta=0.04, 2 generations/prompt

Results

TaskBaselineGRPOฮ”
Easy: Factual Error0.20000.8000+0.6000
Medium: Entity+Factual0.22500.2250+0.0000
Hard: Multi-type0.83330.8333+0.0000
Average0.41940.6194+0.2000

Training Plots

[image] [image] [image]

Reproduce

bash
git clone https://github.com/your-username/hallucination-detector-gym
cd hallucination-detector-gym
cp .env.example .env  # Add your HF_TOKEN and HF_USERNAME
pip install -e .
# Open training_hallucination_detector.ipynb and run all cells

Framework

  • โ€”TRL + PEFT + Transformers (latest)
  • โ€”Trained on mps in 42742s