Cis Labs

Prompt Compressor

Shrink long prompts before they reach your LLM. A multilingual token classifier scores every word and the least informative ones are deleted, so you pay for fewer tokens and get answers faster.

Starting…
Runs entirely in your browser. Your text never leaves this page.
Ctrl / ⌘ + Enter to compress
Examples
0.50

Target fraction of tokens to keep (llmlingua rate).

What was kept keptdropped

Use it in code

Already using LLMLingua-2? Only model_name changes. In JavaScript, the same algorithm this page runs is two small files.

Model card: Cis-Labs/prompt-compressor-bert-base-multilingual-cased · code: GitHub

How it works and limitations
  1. The text is split into chunks of up to 512 word pieces, preferably at sentence ends.
  2. A token classifier (mBERT, 178M parameters) gives every word piece a keep probability; a word's score is the mean of its pieces.
  3. Within each chunk, the highest-scoring words that fit the requested rate (measured in GPT-4 tokens) are kept, in their original order. With Keep line breaks and questions ticked, \n and ? are always kept; with Keep numbers ticked, so is every word with a digit.

Everything runs on your device with ONNX Runtime Web, using the int8-quantized ONNX weights on multi-threaded WebAssembly. The model is downloaded once, about 180 MB, and cached by your browser. Because the weights are quantized, a few borderline words can differ from the full-precision model you run in Python. The chunking, word merging and threshold are the same as llmlingua's LLMLingua-2 path, and the original spacing between kept words is restored (llmlingua joins them with single spaces).

The model does not know what you will ask about the text, so it compresses for general informativeness. Check outputs where a dropped negation, unit or qualifier would matter, and do not use it on source code, tables or JSON. Characters outside mBERT's vocabulary (most emoji, some rare symbols) are always dropped.