Replace your entire RAG pipeline with grep. 100% accuracy, sub-25ms latency, zero infrastructure.
For domain-specific knowledge grounding โ where the vocabulary is predictable and the corpus is bounded โ the entire RAG stack is unnecessary. Retrieval does not need intelligence. The LLM is the intelligence.
๐ Paper v1.1 (Zenodo) ยท Markdown ยท PDF ยท ไธญๆ README
This isn't a research demo. It's running right now, serving 76 LLM agents on a single Mac mini.
| Live system | What's there | Try this query |
|---|---|---|
| ๐ faith.localkin.ai | 37 Christian spiritual masters spanning 1,900 years (Irenaeus 130 AD โ T. Austin-Sparks 1971), with a multi-master debate arena | Click Augustine โ ask "What is the relationship between grace and free will?" โ every quote you'll see is grep-verifiable in his actual writings. |
| ๐ heal.localkin.ai | 39 Traditional Chinese Medicine masters spanning 4,500 years (Yellow Emperor โ living National Grand Masters), with school debates | Click Zhang Zhongjing โ ask "What's the difference between ๆกๆๆฑค and ้บป้ปๆฑค?" โ answers grounded in 18 versions of Shanghan Lun. |
Both subdomains use Knowledge Search (this repo) as their retrieval layer. The examples/ corpus you can grep locally is a public-domain subset of what those agents query against. The architecture, code, and zero-hallucination contract documented in the paper are exactly what serves those URLs.
If anything below seems too good to be true, click those links and break it yourself โ that's why they're live.
| Grep is All You Need | Vector RAG | GraphRAG | |
|---|---|---|---|
| Accuracy | 100% | 85-95% | 90-95% |
| Latency | <25ms (500-file corpus) | 50-200ms | 100-500ms |
| Preprocessing per query | 0 seconds | Hours upfront | Hours upfront |
| Infrastructure | None | Vector DB | Graph DB + Embedding API |
| Adding docs | Drop a file | Re-embed, re-index | Re-extract entities, rebuild graph |
| Output format | Human-readable Markdown | Opaque vectors | Entity triples |
| Lines of code (retrieval) | ~30 bash | 300-500+ Python | 1,000+ Python |
| Cost | $0 | $$$ | $$$$$ |
git clone https://github.com/LocalKinAI/grep-is-all-you-need.git
cd grep-is-all-you-need
# Search the example corpus
./search.sh --keywords "humility" --collection thomas_a_kempis
./search.sh --keywords "ๆฐ่,้ป่ช" --collection sun_simiao
./search.sh --keywords "supreme law" --collection uscisThat's it. No pip install, no docker, no database, no API keys.
| Script | Purpose | Time |
|---|---|---|
./search.sh -k "<query>" |
Layer 1 + Layer 2 grep against examples/ |
<100 ms |
./reproduce_zero_hallucination.sh |
Replay the paper's ยง6.5 case: 0/5 fabricated quotes โ 4/4 grep-verified, with grep running LIVE on your machine |
2 sec |
./benchmark.sh |
grep vs sentence-transformers + FAISS, head-to-head on 30 queries (latency, recall by query type) | ~1 min first run, ~5 sec subsequent |
The last two scripts exist to make the paper's claims falsifiable. If you don't trust 100% retrieval accuracy / 0/5 โ 4/4 / "grep wins", run them yourself; everything is on your machine.
Two-layer retrieval โ both layers are grep:
Layer 1: grep -r -i -C 8 over all .txt and .md raw source files
โ returns raw passages with 8 lines of context
Layer 2: grep -r -i -C 8 also walks _compiled/<file>_concepts.md
and _compiled/<file>_faq.md โ per-source LLM-distilled
concept and FAQ entries that act as a multilingual
semantic bridge back into the literal Layer 1 corpus.
A single grep invocation walks both layers. Your LLM receives both raw passages and structured summaries from the same call. The LLM does the intelligence โ retrieval is just grep.
๐ The full architecture, the concept-bridge framing of Layer 2 (vs the older "fallback" framing), and a documented 0/5 โ 4/4 zero-hallucination reproducibility cycle are in the paper (Zenodo DOI).
The examples/ directory contains three real, public-domain corpora โ
not toy data, real books / real questions / real classical Chinese:
| Domain | Corpus | Size | Source |
|---|---|---|---|
| Spiritual | examples/spiritual/thomas_a_kempis/ โ Thomas ร Kempis, Imitation of Christ (4 books, 114 chapters) |
340 KB | Project Gutenberg #1653 |
| Civics | examples/civics/uscis/ โ USCIS 100 official naturalization questions + answers |
16 KB | uscis.gov (public domain, US Government) |
| TCM | examples/tcm/sun_simiao/ โ Sun Simiao ๅ้้ฃๆฒป (Dietetics, ~652 CE), classical Chinese |
52 KB | Public domain (~1,400 years) |
Each comes with a real _compiled/ Layer 2 directory containing
<source>_concepts.md (5-10 core concepts with verbatim quotes
attributed to chapters) and <source>_faq.md (5-8 Q&A pairs),
all generated by Kimi 2.6 via local Ollama at $0 cost.
# 1. Organize your knowledge base
mkdir -p my_knowledge/topic_a
cp your_documents.txt my_knowledge/topic_a/
# 2. Search it
KNOWLEDGE_BASE=./my_knowledge ./search.sh --keywords "your,terms"For cross-lingual queries and concept jumps that pure keyword search misses, run the autonomous compilation step. Default is free local Ollama (Kimi 2.6); falls back to paid Anthropic Haiku if Ollama is unavailable.
# Free path (recommended) โ local Ollama with kimi-k2.6:cloud
ollama pull kimi-k2.6:cloud # one-time
./compile.sh my_knowledge/topic_a/document.txt
# Paid fallback โ Anthropic Haiku
ANTHROPIC_API_KEY=sk-ant-... ./compile.sh my_knowledge/topic_a/document.txt
# Creates per source file:
# my_knowledge/topic_a/_compiled/document_concepts.md (~3 KB, 5-10 core concepts + verbatim quotes)
# my_knowledge/topic_a/_compiled/document_faq.md (~2.5 KB, 5-8 Q&A pairs)These compiled files are automatically included in search results, giving your LLM pre-structured knowledge alongside raw text โ and crucially providing a bridge for queries in a language different from the source corpus.
your_knowledge_base/
โโโ domain_a/
โ โโโ collection_1/
โ โ โโโ source.txt # Raw text (Layer 1: grep target)
โ โ โโโ source2.md
โ โ โโโ _compiled/ # Optional (Layer 2: per-source concept+FAQ)
โ โ โโโ source_concepts.md
โ โ โโโ source_faq.md
โ โ โโโ source2_concepts.md
โ โ โโโ source2_faq.md
โ โโโ collection_2/
โ โโโ ...
โโโ domain_b/
โโโ ...
- Domain-specific vocabulary (medical terms, legal jargon, religious texts, technical docs)
- Bounded corpus (<10GB, <10K files โ
grepis fast) - Predictable queries (users ask about known topics in the corpus)
- Cross-lingual queries via Layer 2 (Chinese query against English source corpus, or vice versa)
- LLM as consumer (the LLM synthesizes; retrieval just finds passages)
- Truly open-domain semantic search (no concept name in any author's vocabulary matches the query)
- Massive corpus (10GB+ where
greplatency matters) - Entity-relationship traversal (explicit graph queries)
This approach powers LocalKin, a self-hallucination-free, self-improving multi-agent system on a single Mac mini. As of April 2026 it serves as the knowledge backbone for 76 specialized LLM agents spanning two languages and four-and-a-half millennia of human thought:
๐ heal.localkin.ai โ 39 TCM masters
Sample agents (each link goes to a real chat page, free, no signup):
| Master | Era | Try asking |
|---|---|---|
| ้ปๅธ / Yellow Emperor | ~2500 BCE | ไบ่กๅญฆ่ฏด็ๆ นๆบๆฏไปไน๏ผ |
| ๅผ ไปฒๆฏ / Zhang Zhongjing | 150-219 AD | ๆกๆๆฑคไธ้บป้ปๆฑคๅฆไฝ่พจ่ฏ๏ผ |
| ๆๆถ็ / Li Shizhen | 1518-1593 | ้ป่ชๅไบบๅ็่ฏๆงๅบๅซ |
| ๅชๆตทๅฆ / Ni Haixia | 1954-2012 | ็ปๆนๆดพไธๆธฉ็ ๆดพ็ๆฌ่ดจๅๆญง |
๐ faith.localkin.ai โ 37 Christian spiritual masters
| Master | Era | Try asking |
|---|---|---|
| Irenaeus | 130-202 AD | What is your view of apostolic tradition? |
| Augustine | 354-430 AD | What is the relationship between grace and free will? |
| Madame Guyon | 1648-1717 | What does inner prayer look like in daily life? |
| T. Austin-Sparks | 1885-1971 | ๆจไธๅชๆๅฃฐๅจ Honor Oak ้ฝ่ฎจ่ฎบไบไปไน๏ผ |
~500 source texts, 76 agents, 180 MB corpus โ all retrieved by grep.
The _compiled/ Layer 2 files grow nightly via a cron-driven autonomous pipeline (see paper ยง9) at $0/year in API costs, after migrating the compilation LLM from paid Anthropic Haiku to local-Ollama-served Kimi 2.6 in April 2026.
The strongest evidence that "grep is all you need" is not in this repo's search.sh (30 lines look trivial) or even in the paper's tables. It is in those URLs above. Click any one, ask any question, then ask the agent for its source. Every quote you receive is a literal substring of an actual public-domain text in our corpus โ verifiable on your end with the same grep command this repo ships.
The paper documents a one-day failure-and-recovery cycle (ยง6.5) that you can replay locally โ grep runs live on your machine against the included Austin-Sparks corpus:
./reproduce_zero_hallucination.shWhat it does:
- Phase 1: replays a real agent response from 2026-04-25 (5 fabricated quotes attributed to specific chapters), then runs LIVE
grepagainstreproduction/corpus/โ 0/5 found. - Phase 2: shows the actual one-line fix (auto-strip
**"..."**markers + append citation hard-rule). - Phase 3: replays the post-fix agent response (4 quotes attributed), runs LIVE
grepโ 4/4 found.
The script does not call an LLM at runtime โ it replays captured responses then verifies them with grep so the experiment is bit-for-bit reproducible without any API key. To reproduce with a live LLM, see paper ยง6.5 or commit 3e365a9 in LocalKinAI/localkin-core.
./benchmark.shCompares grep vs Vector RAG (sentence-transformers all-MiniLM-L6-v2 + FAISS IndexFlatIP) on 30 hand-graded queries spanning the three example corpora. First run sets up a venv (~2 minutes); subsequent runs take seconds. Output is a benchmark_results.md Markdown report with:
- Median + P99 latency
- Recall@5 per query type (exact / concept / fuzzy)
- Honest tradeoff analysis โ grep wins exact-keyword + tail-latency; vector wins fuzzy/paraphrase. The paper does not deny this (ยง7.2).
- Index build time (vector pays N seconds upfront, grep pays 0).
- Zenodo (canonical, DOI'd): 10.5281/zenodo.19777260
- Markdown source: paper/grep_is_all_you_need.md (bilingual EN + ไธญๆ, 1064 lines)
- PDF: paper/grep_is_all_you_need.pdf (33 pages, 1.6 MB)
- Web version: localkin.dev/papers/grep-is-all-you-need
@misc{localkin2026grep,
author = {{The LocalKin Team}},
title = {Grep is All You Need: Zero-Preprocessing Knowledge
Retrieval for LLM Agents},
year = {2026},
month = apr,
publisher = {Zenodo},
doi = {10.5281/zenodo.19777260},
url = {https://doi.org/10.5281/zenodo.19777260}
}MIT โ use it however you want.
From the creators of LocalKin โ a self-hallucination-free, self-improving 76-agent system running on a single Mac mini.
"Grep is All You Need" is a deliberate homage to Vaswani et al. (2017). We trust the irony is not lost.