cd /news/artificial-intelligence/rag-in-10-lines-no-vector-database-n… · home topics artificial-intelligence article
[ARTICLE · art-96477] src=pipe-lang.com ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

📚 RAG in ~10 Lines — No Vector Database, No pip install

Pipe, a pipeline-native language, now supports retrieval-augmented generation (RAG) in about 10 lines of code without a vector database, framework, or external dependencies, according to a blog post in the 'Pipe in 30 Lines' series. The implementation uses built-in primitives `embed_batch`, `nearest`, and `ask` to vectorize documents, find top matches by cosine similarity, and answer with retrieved context, working with any provider such as DeepSeek, OpenAI, Anthropic, or Ollama. The post claims the equivalent Python and LangChain pipeline is roughly 80 lines across SDKs, while Pipe achieves it in a dozen lines with a single ~7 MB binary.

read3 min views1 publishedAug 14, 2026
📚 RAG in ~10 Lines — No Vector Database, No pip install
Image: Pipe-Lang (auto-discovered)

← All posts← Alle Beiträge

Semantic search and retrieval-augmented generation without a vector DB, a framework, or a single dependency.

Part of the Pipe in 30 Lines series: Self-healing code · Parallel LLM calls · Your first MCP server

RAG usually means a stack: a vector database, an embedding SDK, a retrieval library, and glue code to hold it together. Pipe collapses that into language primitives. embed_batch

vectorizes your documents, nearest

finds the top matches by meaning, and ask

answers with the retrieved context — all in one binary, zero imports.

ai_provider "deepseek"

docs: ["Pipe is a pipeline-native language where data flows top to bottom.", "The bytecode VM runs compiled programs about 7x faster than the tree-walker.", "Built-in MCP lets Pipe expose its own tools or consume any stdio MCP server.", "Sandbox profiles restrict exec, write_file, and http_get in one declarative block.", "One ~7 MB binary, zero dependencies, on Linux, macOS, Windows, or the browser."]

vectors: embed_batch docs        -- 1. vectorize once
question: "What makes the VM fast?"
q_vec: embed question            -- 2. embed the query
top: nearest q_vec vectors 2     -- 3. top-k by similarity

context: ""
for idx in top
    context: context ++ (at docs idx) ++ "\n---\n"

ask ("Context:\n" ++ context ++ "\nQuestion: " ++ question)
    > print

What happens here:

turns every document into a vector in one call — no vector DB to install, no index to configure.embed_batch

returns the indices of the most relevant documents by cosine similarity. Meaning, not keywords.nearest

  • The top matches are stitched into a context block, and answers grounded in it — classic RAG.ask

In Python + LangChain the same pipeline is roughly 80 lines across SDKs. In Pipe it's a dozen, and it works with every provider: swap "deepseek"

for "openai"

, "anthropic"

, or "ollama"

and nothing else changes.

Want the full version with a web UI, SQLite persistence, and a /search

API? See examples/rag_knowledge_base.pipe — or run the minimal version above with

export DEEPSEEK_API_KEY=... && pipe examples/blog_rag.pipe

.# 📚 RAG in ~10 Zeilen — ohne Vektor-DB, ohne pip install

Semantische Suche und RAG ohne Vektor-DB, ohne Framework und ohne eine einzige Abhängigkeit.

Teil der Serie Pipe in 30 Lines: Selbstheilender Code · Parallele LLM-Calls · Dein erster MCP-Server

RAG bedeutet sonst einen ganzen Stack: eine Vektor-DB, ein Embedding-SDK, eine Retrieval-Bibliothek und Kleber-Code. Pipe reduziert das auf Sprach-Primitives. embed_batch

vektorisiert deine Dokumente, nearest

findet die besten Treffer nach Bedeutung, und ask

antwortet mit dem gelieferten Kontext — alles in einer Binary, null Imports.

ai_provider "deepseek"

docs: ["Pipe ist eine pipeline-native Sprache, in der Daten von oben nach unten fließen.", "Die Bytecode-VM führt Programme etwa 7x schneller aus als der Tree-Walker.", "Eingebautes MCP: Pipe stellt eigene Tools bereit oder nutzt jeden stdio-MCP-Server.", "Sandbox-Profile sperren exec, write_file und http_get in einem deklarativen Block.", "Eine ~7-MB-Binary, null Abhängigkeiten, auf Linux, macOS, Windows oder im Browser."]

vectors: embed_batch docs        -- 1. einmal vektorisieren
question: "Was macht die VM schnell?"
q_vec: embed question            -- 2. Query einbetten
top: nearest q_vec vectors 2     -- 3. Top-K nach Ähnlichkeit

context: ""
for idx in top
    context: context ++ (at docs idx) ++ "\n---\n"

ask ("Context:\n" ++ context ++ "\nQuestion: " ++ question)
    > print

Was hier passiert:

verwandelt jedes Dokument in einen Vektor — keinembed_batch

pip install

, keine Vektor-DB, keine Index-Konfiguration.liefert die Indizes der relevantesten Dokumente per Kosinus-Ähnlichkeit. Bedeutung statt Keywords.nearest

  • Die Treffer werden zu einem Kontext-Block verbunden und antwortet darauf — klassisches RAG.ask

In Python + LangChain ist dieselbe Pipeline ~80 Zeilen über mehrere SDKs. In Pipe sind es ein Dutzend — und es funktioniert mit jedem Provider: Tausche "deepseek"

gegen "openai"

, "anthropic"

oder "ollama"

, sonst ändert sich nichts.

Die Vollversion mit Web-UI, SQLite-Persistenz und /search

-API? Siehe examples/rag_knowledge_base.pipe — oder starte die Minimalversion oben mit

export DEEPSEEK_API_KEY=... && pipe examples/blog_rag.pipe

.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @pipe 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/rag-in-10-lines-no-v…] indexed:0 read:3min 2026-08-14 ·