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 making up. Nothing extra is generated and nothing is looked up; it adds 3–7% to generation time.
Built with PyTorch and Hugging Face Transformers on Qwen3-4B, GLiNER, Gemini as the fact checker, and Modal GPUs.
It beats the probe it builds on, on that paper's own benchmark
HalluStream starts from the probe of Obeso et al. (2025) and leaves the model unchanged. Picking the layer on validation and tuning the training beats the paper's released linear probes on both models it was tried on, and on Qwen2.5-7B even the probe that fine-tunes the model.
Inside SHARS: the same results in a fraction of the time
SHARS (ICML 2026) cuts hallucinations by redoing sentences whose facts look doubtful. Its own detector samples extra answers for every fact. Swapping in HalluStream and changing nothing else, both detectors were run at several settings on all 182 of SHARS's test people. They trace about the same trade-off; HalluStream gets there 4.5–6× faster.
Marked in each answer: the names, places, dates and titles the fact checker checked against Wikipedia. Struck through is made up; dotted underline is verified. Hover a struck detail for the correction.
See it check real answers
Qwen3-4B's own biographies of four test people, exactly as it wrote them, with the flags the library raised (the previous version, v3) and the fact checker's verdicts. Hover or tap a detail for its risk and the correction.
How it reads the model
When a model writes a fact it does not really know, its internal state looks different from when it does. A small linear classifier, trained on about 20,000 fact-checked answers, learns to read that difference from one middle layer.
The model writes
Qwen3-4B generates normally. Nothing extra is generated or looked up.
Layer 21 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, the details in it get a risk from their tokens.
Risky details are flagged
Names, dates, numbers and titles above the threshold light up, while the answer is still being written.
More accurate than the alternatives
How often a made-up detail gets a higher risk than a true one, where 50% is a coin flip.
Choose how cautious it is
A risk is the estimated chance a detail is made up, and it holds up: details given 90–100% risk turned out false 96% of the time. Where to draw the line is a trade-off between catching more errors and wrongly flagging true facts. Measured on new people and subjects, sampled after the detector was frozen.
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.
Built on solid ground
Layer 21 is where the model knows
A fact checker that holds up
Gemini reads each subject's Wikipedia page and labels every claim. It marks made-up details reliably and leans toward accepting doubtful ones.
Tested at scale
- 144,676 details written by five other models
- 1,100 new people and subjects, sampled after the detector was frozen
- 2 models in the head-to-head with the paper
- 182 people and 8 settings inside SHARS
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.