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.

Read the code Run it free in Colab

Built with PyTorch and Hugging Face Transformers on Qwen3-4B, GLiNER, Gemini as the fact checker, and Modal GPUs.

Prompt
Writing…
Flagged, and wrong Flagged, but true Wrong, but missed Flagged, not fact-checked

    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.

    Each dot is one detector setting on SHARS's 182 test people, Qwen3-4B on one L4 GPU. A false claim is one the fact checker could not support from the person's Wikipedia page; a person the setting declined to answer counts as zero claims. Down and right is better. Hover or tap a dot for its numbers.

    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.

    Flagged, and wrong Flagged, but true Wrong, but missed

    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.

    Against other detectors

    Across kinds of text

    Compared with the model's own confidence in each word.

    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.

    76%

    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

    The paper reproduced first

    the published AUROC of the paper's Qwen2.5-7B probe on LongFact
    the same probe run through this pipeline

    A fact checker that holds up

    89%balanced accuracy against FActScore's human labels, on 11,049 facts
    84–91%agreement with a stronger model re-checking claims blind against the whole article

    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.

    # install pip install "hallustream[entities] @ git+https://github.com/pranav-sethia/hallustream" # ask, with likely made-up details highlighted as each sentence is checked hallustream "Tell me about A Caribbean Mystery."
    hallustream chat

    The same, in a conversation.

    hallustream score "question" answer.txt

    Check an answer the model already wrote.

    hallustream batch prompts.jsonl

    Check a whole file and get JSON lines back.

    Detector.from_pretrained("qwen3-4b")

    Or from Python: generate, score or stream.