← Back to pithhEvery prompt has two better versions
A leaner one, and a more detailed one. Here's how we compute both.
Most token counters stop at the number. pithh goes further: the moment you see the cost, you also see two rewrites of your own prompt — Lean, which says the same thing for fewer tokens, and Extended, which spends more tokens on structure a model can actually use. Both are deterministic, with no sampling and no hidden prompt: Extended runs entirely in your browser, and Lean runs two of its three stages there too, with the third scored by a small language model we host ourselves — never a paid rewriting service.
That constraint shaped the whole design: instead of asking a large model to rewrite your prompt (which costs money and is a black box), we built two small, deterministic pipelines directly on published prompt-compression and prompt-engineering research. Nothing here is secret or magic — every technique is cited below.
Lean engineThree stages, in order
Each stage removes a different kind of waste. They run in sequence, and each one is conservative by design — we'd rather under-compress than hand back a sentence that no longer parses.
- Cooperative-pruning. Grice's Cooperative Principle says a speaker shouldn't say more than the exchange requires — the Maxim of Quantity [1]. Politeness padding and hedges ("if possible", "I would like you to", "kindly") carry social softening, not instruction — a model doesn't need to be asked nicely. This stage strips a curated list of them.
- Redundancy collapse. People often restate the same request across two sentences for emphasis. We split the prompt into sentences and compare them with the same signal LexRank [2] uses to rank sentence importance: cosine similarity between term-frequency vectors. When two sentences overlap heavily, we keep only the more informative one.
- Self-information pruning. LLMLingua [3] and Selective Context [4] compress prompts by running a small causal language model over the text and dropping the tokens it finds most predictable — lowest self-information, in the information-theoretic sense. We run the exact lightweight model LLMLingua's own paper validates for this — GPT2-small — on our own server, and score every word by how many bits of self-information it carries given what came before it. LLMLingua's own output is read by another model, so it can prune aggressively; ours is shown to you, so we cap it at roughly the lowest-scoring 12% of words and never touch the first or last word of a sentence, keeping the result readable instead of telegraphic.
The token count you see for the Lean version is not an estimate of the savings — it's the same real tokenizer call used for the original prompt, so the delta is measured, not guessed.
Extended engineClassify, then apply the right pattern
A generic "act as an expert and think carefully" wrapper helps a little, always. A wrapper chosen for what your prompt is actually asking helps a lot more. So the Extended engine reads your prompt, guesses its task type from surface patterns — code, creative writing, reasoning/analysis, or general — and injects only the patterns that fit, drawn from the Prompt Pattern Catalog [6]:
- A persona pattern matched to the task (a senior engineer for code, a domain expert for analysis, a writer for creative work) instead of a one-size role.
- An output-format pattern that tells the model how to shape its answer for that task type.
- For prompts we classify as reasoning or analysis, an explicit chain-of-thought trigger — "think step by step before answering". Kojima et al. showed this single line, added to a zero-shot prompt, measurably improves reasoning accuracy without any worked examples [7], building on Wei et al.'s earlier finding that spelling out intermediate steps helps at all [8]. We only add it where the task benefits — a creative-writing prompt doesn't need it.
The last step is model-aware formatting: change the model in the selector and the wrapper structure itself changes. Anthropic publishes explicit guidance that Claude models respond better to prompts structured with XML tags [9], so Extended output for a Claude model comes wrapped in <role>, <task>, <output_format>. OpenAI's own prompting guide instead recommends Markdown headers [10], so every other model gets # Role, # Task, # Output format instead. Switch the model in the selector and the Extended card regenerates in that model's preferred shape — try it.
Why this, and not just calling an LLM
The obvious way to rewrite a prompt is to ask a bigger model to do it. We didn't want pithh to cost money to save you money, and we didn't want a black box sitting between you and your own words. Every stage above is a plain function you can read, re-run, and get the same output from every time — no sampling randomness, no hidden system prompt, no per-request bill. The trade-off is honest: a fine-tuned rewriting model would likely compress harder and expand smarter than curated rules can. What you get instead is a method you can fully audit, that runs in milliseconds, and that never sends your prompt anywhere just to reformat it.
References
- H.P. Grice (1975). "Logic and Conversation." In Syntax and Semantics, Vol. 3: Speech Acts, Cole & Morgan (eds.).
- G. Erkan & D.R. Radev (2004). "LexRank: Graph-based Lexical Centrality as Salience in Text Summarization." Journal of Artificial Intelligence Research, 22, 457–479. Semantic Scholar
- H. Jiang, Q. Wu, C.-Y. Lin, Y. Yang, L. Qiu (2023). "LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Models." EMNLP 2023. arXiv:2310.05736
- Y. Li, B. Dong, F. Guerin, C. Lin (2023). "Compressing Context to Enhance Inference Efficiency of Large Language Models." EMNLP 2023. arXiv:2310.06201
- Z. Pan et al. (2024). "LLMLingua-2: Data Distillation for Efficient and Faithful Task-Agnostic Prompt Compression." arXiv:2403.12968
- J. White, Q. Fu, S. Hays, M. Sandborn, C. Olea, H. Gilbert, A. Elnashar, J. Spencer-Smith, D.C. Schmidt (2023). "A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT." arXiv:2302.11382
- T. Kojima, S.S. Gu, M. Reid, Y. Matsuo, Y. Iwasawa (2022). "Large Language Models are Zero-Shot Reasoners." NeurIPS 2022. arXiv:2205.11916
- J. Wei, X. Wang, D. Schuurmans, M. Bosma, B. Ichter, F. Xia, E. Chi, Q. Le, D. Zhou (2022). "Chain-of-Thought Prompting Elicits Reasoning in Large Language Models." NeurIPS 2022. arXiv:2201.11903
- Anthropic. "Use XML tags to structure your prompts," Claude Docs — prompt engineering guide. platform.claude.com
- OpenAI. "Prompt engineering," OpenAI API guide — Markdown structuring recommendation. developers.openai.com
Each technique above is cited for the specific idea it inspired, not as a claim that pithh reproduces the full method from the paper — where we simplified something (running rules instead of a language model, pairwise similarity instead of full graph centrality), it's called out above.