Downloads · 30 days
0
F4biian/RAGognizer-Qwen3-4B-Instruct-2507
RAGognizer-Qwen3-4B-Instruct-2507 is a token classification model from F4biian. Use it when you need labels on individual words, such as names. The card lists the license as mit.
<p align="center" <img src="https://github.com/F4biian/RAGognizer/raw/main/media/Logo%202.jpg" alt="RAGognizer logo" style="width: 40%;" </p
Downloads · 30 days
0
Access
Public
Updated Apr 20, 2026
Repo size
1.9 GB
Likes
0
Public
Click a slice to open those files.
.safetensors1.9 GB · 100%
From the Hugging Face model README
RAGognizer is a hallucination-aware fine-tuning approach that integrates a lightweight detection head into an LLM. It allows for the joint optimization of language modeling and hallucination detection.
This model is based on Qwen/Qwen3-4B-Instruct-2507 and has been fine-tuned on the RAGognize dataset to provide token-level hallucination probabilities during generation.
Retrieval-Augmented Generation (RAG) is widely used to augment the input to Large Language Models (LLMs) with external information, such as recent or domain-specific knowledge. Nonetheless, current models still produce closed-domain hallucinations and generate content that is unsupported by the retrieved context. Current detection approaches typically treat hallucination as a post-hoc problem, relying on black-box consistency checks or probes over frozen internal representations. In this work, we demonstrate that hallucination detection based on internal state representation can also serve as a direct training signal. We introduce RAGognize, a dataset of naturally occurring closed-domain hallucinations with token-level annotations, and RAGognizer, a hallucination-aware fine-tuning approach that integrates a lightweight detection head into an LLM, allowing for the joint optimization of language modeling and hallucination detection. This joint objective forces the model to improve the separability of its internal states regarding hallucinations while simultaneously learning to generate well-formed and meaningful responses. Across multiple benchmarks, RAGognizer achieves state-of-the-art token-level hallucination detection while substantially reducing hallucination rates during generation, without degrading language quality or relevance.
This model is designed to be used with the ragognizer library, which handles the loading of the attached detection heads and LoRA adapters.
WARNING: The library enforces old and unmaintained versions of dependencies to ensure reproducibility with the paper.
git clone https://github.com/F4biian/RAGognizer.git
cd RAGognizer/ragognizer
python3 -m venv .venv && . .venv/bin/activate && python -m pip install -U pip && pip install -e .
from ragognizer.detectors.RAGognizer import RAGognizer
# Initialize the detector
# Ensure you are running on CUDA if available
detector = RAGognizer(
ragognizer_repo_name="F4biian/RAGognizer-Qwen3-4B-Instruct-2507",
device="cuda",
use_postprocessor=False # Set to True only for the Qwen3-4B variant
)
# Define a chat / context
chat = [
{"role": "user", "content": "Context: The wall is green. Based solely on the context: What color is the wall?"},
{"role": "assistant", "content": "The color of the wall is gray."},
]
# Get token-level hallucination scores
scores = detector.predict(chat=chat, token_level=True)
# Output contains tokens, probabilities, and potential binary predictions
print(scores)
transformer_heads integration.bfloat16 (recommended).@misc{ridder2026ragognizerhallucinationawarefinetuningdetection,
title={RAGognizer: Hallucination-Aware Fine-Tuning via Detection Head Integration},
author={Fabian Ridder and Laurin Lessel and Malte Schilling},
year={2026},
eprint={2604.15945},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2604.15945},
}