CoolFace
Apppublic

Jasmineame/detect-LLM-tokens

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
4likes
App README

StatDetectLLM

An interactive Streamlit demo for token-level detection of human-AI-coauthored text. Paste a passage and the app highlights individual tokens that exhibit statistical signatures consistent with machine generation.

⚠️ This is a research demo, not a production content verifier. The highlighted tokens are statistical evidence, not ground-truth attribution.

What the demo shows

  • —Binary mode — tokens classified as likely machine-generated are highlighted in a soft rose color; human-likely tokens are left unmarked.
  • —Score mode — each token is shaded along a rose gradient; darker shading indicates stronger statistical evidence of machine generation.
  • —LLM-generated proportion — the fraction of tokens that the current binary clustering labels as LLM-generated.

The visualization is produced by a token-level statistical detector. It scores every token using a local context window and then calibrates the scores into a per-text binary split.


Demo controls

ControlDescription
Context windowSets how many tokens on each side of the current token are used to score it. Larger is not always better: a very wide window dilutes local signals, while a very narrow window makes the score unstable. Choose Auto to let the Lepski selector pick a width automatically, or pick a fixed width from 1 to 64.
KernelWeighting kernel for the local window. Triangular kernel gives higher weight to tokens closer to the target token and lower weight to distant tokens; Uniform kernel treats all tokens in the window equally. Triangular kernel generally performs better in our experiments.
ScanRun the detector on the input text.
Display modeSwitch between Binary (final token labels) and Score (underlying detection strength).

Run locally

bash
pip install -r requirements.txt
streamlit run src/app.py

Environment notes

  • —The app uses CUDA when available and falls back to CPU otherwise.
  • —On Hugging Face Space the app runs on CPU and caches downloaded models under /tmp/huggingface_cache.

Citation

If you use the underlying method in your research, please consider citing the related paper: