Catch an AI making things up while it writes
HalluStream reads a language model's hidden states as each word is generated and flags the names, dates and titles it is likely making up. Nothing extra is generated and nothing is looked up, so it adds only 3–7% to generation time.
An open-source Python package. Built with PyTorch and Hugging Face Transformers on Qwen3-4B, with GLiNER, a Gemini fact checker and Modal GPUs.
The model's own hidden state gives it away
When a model writes a detail it doesn't really know, its internal state looks different from when it does. Obeso et al. (2025) showed that a simple linear probe can read that difference token by token in long answers, and released their probes and data. HalluStream turns the idea into a tool that works while the model writes: retrained for Qwen3-4B on about 20,000 fact-checked answers, adapted to its own writing, and packaged so anyone can run it.
The model writes
Qwen3-4B generates normally. Nothing extra is generated or looked up.
One layer is read
Each new token's hidden state, 2,560 numbers, is taken from layer 21 of 36, the layer a sweep over all of them found best.
The probe scores it
One dot product per token. When a sentence ends, each name, date and title in it gets a risk from its tokens.
Risky details light up
Details above the threshold are flagged while the answer is still being written.
Tested on writing it had never seen
Choose how cautious it is
It catches of made-up details, wrongly flags of true ones, and of its flags are right.
Stated risk against how often those details were actually false. On the diagonal means the risk can be taken at face value.
What building on the paper showed
HalluStream started as a reproduction of Obeso et al. (2025), and their released code, probes and annotated answers made each comparison below possible. Every choice was made on validation data, and each test set was scored once.
The signal peaks in the middle of the model
A probe on the unchanged model comes close to fine-tuning
The model's own writing needs its own training
Run it
A pip package with a command line and a Python API. It needs a GPU or an Apple Silicon Mac for Qwen3-4B, or the free Colab notebook.
hallustream chatThe same, in a conversation.
hallustream score "question" answer.txtCheck an answer the model already wrote.
hallustream batch prompts.jsonlCheck a whole file and get JSON lines back.
Detector.from_pretrained("qwen3-4b")Or from Python: generate, score or stream.