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.

Read the code Run it free in Colab

An open-source Python package. Built with PyTorch and Hugging Face Transformers on Qwen3-4B, with GLiNER, a Gemini fact checker and Modal GPUs.

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

    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

    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.

    A drop-in detector for SHARS

    Each dot is one detector setting, run on all 182 of SHARS's test people with Qwen3-4B on one L4 GPU. A false claim is one the fact checker couldn't 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.

    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.

    Their Qwen2.5-7B results reproduce

    published AUROC of their Qwen2.5-7B linear probe on LongFact
    the same released probe, run through this pipeline

    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

    trained only on the paper's data, which other models wrote
    adapted to Qwen3-4B's own fact-checked writing

    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]" # 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.