Master token reduction beyond simple prompting—50 practical techniques across prompt engineering, RAG, code context, and data compression.
Where the biggest gains for low cost LLM usage come from?
The biggest gains rarely come from making prompts slightly shorter. They come from context engineering: retrieving only the smallest high-signal context needed for the task, avoiding repeated transmission of the same information, and using structured representations rather than raw text.
Everyone talks about better prompts, but the biggest savings in LLM costs often come from better context engineering.
Graphify
Recently, I shared Graphify, which transforms your codebase into a deterministic knowledge graph. Instead of sending thousands of lines of code to the LLM every time, the AI navigates the graph and loads only what’s relevant.
That’s a great example of structural context optimization—and it’s only one piece of the puzzle.
Here are 50 additional ways to reduce LLM token usage, organized by category:
1. Prompt Engineering
- Remove unnecessary words and explanations.
- Replace paragraphs with bullet points.
- Use consistent abbreviations.
- Remove repeated instructions.
- Move permanent instructions into the system prompt.
- Reference previous answers instead of repeating them.
- Use IDs instead of long names.
- Request structured JSON instead of verbose prose.
- Limit output length explicitly.
- Avoid examples unless necessary.
2. Conversation Management
- Summarize conversations every few turns.
- Keep only the relevant chat history.
- Compress old messages into memory.
- Store conversation state externally.
- Replace long history with structured facts.
- Remove greetings and pleasantries.
- Delete failed attempts.
- Reset context after task completion.
- Split unrelated topics into separate chats.
- Store reusable facts in a profile.
3. RAG Optimization
- Retrieve only the top-ranked chunks.
- Rerank before sending context.
- Merge overlapping chunks.
- Remove duplicate passages.
- Extract only relevant paragraphs.
- Compress retrieved documents.
- Filter by metadata first.
- Retrieve summaries before full documents.
- Use hierarchical retrieval.
- Retrieve only changed documents.
4. Code Context Optimization
- Send ASTs instead of full source files.
- Load only relevant functions.
- Use symbol lookup.
- Send interface definitions only.
- Replace implementations with signatures.
- Send Git diffs instead of entire files.
- Load dependency graphs first.
- Use semantic indexes such as Graphify.
- Reference file paths instead of embedding file contents.
- Cache parsed project metadata.
5. Data Compression
- Use compact data formats.
- Remove unnecessary whitespace.
- Shorten property names.
- Deduplicate repeated values.
- Encode repeated structures once.
- Replace repeated text with references.
- Convert tables to CSV.
- Use domain-specific mini languages (DSLs).
- Send hashes or IDs for unchanged data.
- Store large assets externally and retrieve them only on demand.
Highest ROI
- Graphify / Knowledge Graphs
- AST-based retrieval
- Context summarization
- Prompt caching
- RAG re-ranking
- Conversation compression
- Delta prompting
- Symbol/function retrieval
- Semantic caching
- Structured output
For teams building AI applications, there are even more advanced techniques:
n Prompt cachingn Semantic caching n Delta promptingn Hybrid retrieval (BM25 + embeddings) n Model routingn Multi-stage pipelines n Knowledge graphsn Context deduplication n Entity extractionn Dynamic context windows
Where you’ll usually see the biggest savings
n Graph-based retrieval & knowledge graphsn AST-based code retrieval n Context summarizationn Prompt & semantic caching n Conversation compressionn Delta prompting
`n Function/symbol retrieval
Highest ROI (rough order)
| Technique | Typical Savings |
|---|---|
| Graphify / Knowledge Graph | 10×–70× |
| AST-based retrieval | 5×–30× |
| Context summarization | 3×–20× |
| Prompt caching | 50–95% repeated prompts |
| RAG re-ranking | 30–80% |
| Conversation compression | 50–90% |
| Delta prompting | 70–99% |
| Symbol/function retrieval | 80–99% |
| Semantic cache | 70–100% cache hits |
| Structured output | 20–60% |
One lesson I’ve learned while building AI systems:
The biggest reductions in cost don’t come from writing slightly shorter prompts. They come from sending dramatically less context.
The future of AI isn’t just prompt engineering—it’s context engineering.
What techniques have given you the biggest reduction in token usage?