{"id":"6b08c25038c84264c20274d2","slug":"rag","title":"RAG: answers grounded in your own documents","summary":"Retrieval-Augmented Generation from basics to production – chunking, hybrid search with BM25 and RRF, reranking, cited answers with Claude, evaluation and the cases where RAG is unnecessary.","servedLang":"en","availableLangs":["pl","en"],"topics":["rag","embeddings-vector-db","evals","prompt-engineering"],"techs":["python","typescript","dotnet"],"tags":["rag","retrieval","chunking","hybrid-search","bm25","reranking","citations","pgvector","claude"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":22,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:35:44.262Z","updatedAt":"2026-11-27T13:05:32.204Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"rose","background":"grid","weaveResources":true,"toc":"right"},"seoDescription":"RAG in practice: indexing pipeline, chunking, hybrid BM25 + vector search, Reciprocal Rank Fusion, reranking, Claude API citations, prompt caching, evaluation and GraphRAG.","wordCount":4361,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"A language model does not know Halina's Pierogi menu, the opening hours of the new restaurant or yesterday's change to the delivery terms. "},{"type":"text","text":"RAG","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"Retrieval-Augmented Generation","marks":[{"type":"italic"}]},{"type":"text","text":") is a pattern in which, before generating an answer, the application "},{"type":"text","text":"retrieves","marks":[{"type":"bold"}]},{"type":"text","text":" matching fragments of your own documents and adds them to the prompt. The model then answers from the facts supplied, not from its training memory – and can point to where it got them."}]},{"type":"stats","attrs":{"items":[{"value":"2020","label":"the year of the paper that named RAG","hint":"Lewis et al., Facebook AI Research"},{"value":"k = 60","label":"the constant in Reciprocal Rank Fusion","hint":"score = Σ 1 / (k + rank)"},{"value":"67%","label":"fewer failed retrievals","hint":"Contextual Retrieval + reranking (Anthropic's measurement, 2024)"}]}},{"type":"callout","attrs":{"variant":"info","title":"TL;DR"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"RAG = "},{"type":"text","text":"retrieve","marks":[{"type":"bold"}]},{"type":"text","text":" → "},{"type":"text","text":"augment the prompt","marks":[{"type":"bold"}]},{"type":"text","text":" → "},{"type":"text","text":"generate","marks":[{"type":"bold"}]},{"type":"text","text":". Knowledge lives in your database, not in the model's weights, so you update it like any other data."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"RAG quality is mostly "},{"type":"text","text":"retrieval","marks":[{"type":"bold"}]},{"type":"text","text":" quality: good chunking, hybrid search (words + meaning) and reranking make a bigger difference than the choice of model."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Before you build a pipeline, check whether the corpus would fit whole into a cached prompt – that is often simpler and better."}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"the-problem-40-restaurants-40-menus-and-terms-that-change-every-month"},"content":[{"type":"text","text":"The problem: 40 restaurants, 40 menus and terms that change every month"}]},{"type":"paragraph","content":[{"type":"text","text":"Halina's Pierogi has grown to 40 restaurants. Each has its own menu, opening hours, delivery zones and promotions; on top of that there are FAQs, terms of service, an allergen policy and thousands of customer reviews. The assistant on the website has to answer questions like \"does the Kazimierz restaurant deliver on Sundays?\" or \"do the spinach pierogi contain nuts?\"."}]},{"type":"paragraph","content":[{"type":"text","text":"Three approaches that do "},{"type":"text","text":"not","marks":[{"type":"bold"}]},{"type":"text","text":" work well:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Relying on the model's knowledge","marks":[{"type":"bold"}]},{"type":"text","text":" – it does not have it, so it will make things up (see "},{"type":"text","text":"LLM fundamentals","marks":[{"type":"link","attrs":{"href":"/en/topics/llm-fundamentals"}}]},{"type":"text","text":")."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Fine-tuning","marks":[{"type":"bold"},{"type":"link","attrs":{"href":"/en/topics/fine-tuning"}}]},{"type":"text","text":" – it teaches style and format but memorizes facts poorly, and every menu change would mean retraining."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Pasting everything into the prompt","marks":[{"type":"bold"}]},{"type":"text","text":" – with several million tokens that is expensive, slow and hurts accuracy."}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"RAG solves it the way a person would: first find the right pages in the binder, then answer."}]},{"type":"heading","attrs":{"level":2,"id":"do-you-really-need-rag"},"content":[{"type":"text","text":"Do you really need RAG?"}]},{"type":"paragraph","content":[{"type":"text","text":"An honest question before the first line of code. The menu, FAQ and terms of "},{"type":"text","text":"one","marks":[{"type":"bold"}]},{"type":"text","text":" restaurant are maybe 30,000 tokens. With a context window of around a million tokens and "},{"type":"text","text":"prompt caching","marks":[{"type":"italic"}]},{"type":"text","text":", the simplest solution is to send all of it in a stable prompt prefix – no vector database, no chunking, no retrieval errors."}]},{"type":"codeGroup","attrs":{"title":"Without RAG: the whole small corpus in the cache"},"content":[{"type":"codeBlock","attrs":{"language":"python","filename":"faq_cached.py"},"content":[{"type":"text","text":"import anthropic\nfrom pathlib import Path\n\nclient = anthropic.Anthropic()\n\n# Menu + FAQ + terms of one restaurant: ~30k tokens. Small enough to send whole - no retrieval needed.\ncorpus = \"\\n\\n\".join(p.read_text(encoding=\"utf-8\") for p in sorted(Path(\"knowledge\").glob(\"*.md\")))\n\ndef ask(question: str) -> str:\n    response = client.messages.create(\n        model=\"claude-opus-5-5\",\n        max_tokens=1024,\n        system=[\n            {\"type\": \"text\", \"text\": \"Answer only from the knowledge base below. If it is not there, say so.\"},\n            # Stable prefix -> cached: later calls pay a fraction of the price for these tokens.\n            {\"type\": \"text\", \"text\": corpus, \"cache_control\": {\"type\": \"ephemeral\"}},\n        ],\n        messages=[{\"role\": \"user\", \"content\": question}],  # the variable part goes after the cache breakpoint\n    )\n    u = response.usage\n    print(f\"cache read={u.cache_read_input_tokens} written={u.cache_creation_input_tokens} fresh={u.input_tokens}\")\n    return next(b.text for b in response.content if b.type == \"text\")\n\nprint(ask(\"Do you deliver on Sundays?\"))"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"faq-cached.ts"},"content":[{"type":"text","text":"import Anthropic from \"@anthropic-ai/sdk\";\nimport { readFileSync, readdirSync } from \"node:fs\";\n\nconst client = new Anthropic();\n\n// Menu + FAQ + terms of one restaurant: ~30k tokens. Small enough to send whole.\nconst corpus = readdirSync(\"knowledge\")\n  .filter((f) => f.endsWith(\".md\"))\n  .sort()\n  .map((f) => readFileSync(`knowledge/${f}`, \"utf8\"))\n  .join(\"\\n\\n\");\n\nexport async function ask(question: string): Promise<string> {\n  const response = await client.messages.create({\n    model: \"claude-opus-5-5\",\n    max_tokens: 1024,\n    system: [\n      { type: \"text\", text: \"Answer only from the knowledge base below. If it is not there, say so.\" },\n      // Stable prefix -> cached; keep timestamps and user data out of it.\n      { type: \"text\", text: corpus, cache_control: { type: \"ephemeral\" } },\n    ],\n    messages: [{ role: \"user\", content: question }],\n  });\n  const u = response.usage;\n  console.log(`cache read=${u.cache_read_input_tokens} written=${u.cache_creation_input_tokens}`);\n  return response.content.flatMap((b) => (b.type === \"text\" ? [b.text] : [])).join(\"\");\n}"}]}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Situation"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Better choice"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"corpus up to ~a few hundred thousand tokens, rarely changes"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"everything in the prompt + prompt caching"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"large corpus (millions of tokens) or growing"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"RAG"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"different permissions per document (restaurants, roles, customers)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"RAG with permission filtering"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"data changes every minute (order status, availability)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"tools – "},{"type":"text","text":"tool use","marks":[{"type":"link","attrs":{"href":"/en/topics/tool-use"}}]},{"type":"text","text":" – instead of an index"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Our chain of 40 restaurants with reviews and a history of terms is a classic case for RAG."}]},{"type":"heading","attrs":{"level":2,"id":"architecture-two-paths"},"content":[{"type":"text","text":"Architecture: two paths"}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart TB\n  subgraph Indexing[\"Indexing (offline, whenever documents change)\"]\n    A[\"Sources: menus, FAQ,<br/>terms, reviews\"] --> B[\"Load and clean<br/>HTML/PDF → text + metadata\"]\n    B --> C[\"Chunking<br/>structure + size + overlap\"]\n    C --> D[\"Embeddings + full-text index\"]\n    D --> E[(\"Store: vectors, BM25,<br/>metadata, permissions\")]\n  end\n  subgraph Query[\"Query (online, for every question)\"]\n    Q[\"Customer question\"] --> R[\"Query rewriting<br/>(optional)\"]\n    R --> S[\"Hybrid search<br/>top 20–50 + filters\"]\n    S --> T[\"Reranking → top 5\"]\n    T --> U[\"Prompt: instructions + chunks + question\"]\n    U --> V[\"LLM: answer with citations\"]\n  end\n  E --> S","caption":"RAG: offline indexing and online answering"}},{"type":"paragraph","content":[{"type":"text","text":"The indexing path runs in the background (a job, a queue, a webhook from the CMS). The query path has to fit the latency budget of a conversation – typically tens of milliseconds for search, up to a few hundred for reranking, and the rest for generation."}]},{"type":"heading","attrs":{"level":2,"id":"indexing-garbage-in-hallucinations-out"},"content":[{"type":"text","text":"Indexing: garbage in, hallucinations out"}]},{"type":"paragraph","content":[{"type":"text","text":"Most RAG problems start before the embeddings. Strip navigation, footers and cookie banners from HTML, keep tables (opening hours in a PDF are a common headache), remove duplicates and "},{"type":"text","text":"attach metadata","marks":[{"type":"bold"}]},{"type":"text","text":": restaurant, language, document type, validity date, permissions. Metadata is used for filtering (\"restaurant 7 only\", \"current version of the terms only\") and for showing the source in the answer."}]},{"type":"heading","attrs":{"level":3,"id":"chunking"},"content":[{"type":"text","text":"Chunking"}]},{"type":"paragraph","content":[{"type":"text","text":"A "},{"type":"text","text":"chunk","marks":[{"type":"italic"}]},{"type":"text","text":" is the unit of retrieval and citation. Too big and it \"blurs\" the meaning and wastes context space; too small and it loses sense (\"Delivery takes 45 minutes\" – but at which restaurant?)."}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Strategy"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"How"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"When"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fixed size + overlap"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"windows of e.g. 300–500 tokens, 10–20% overlap"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a starting point, unstructured text"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Recursive by structure"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"headings/paragraphs first, then size"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"documentation, terms, FAQs – the most common choice"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Semantic"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"cut where the topic changes (similarity of neighbouring sentences)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"long narrative texts"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"One record = one chunk"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a menu item, a review, an FAQ entry"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"data already split by nature"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Good practice: prepend the "},{"type":"text","text":"heading path","marks":[{"type":"bold"}]},{"type":"text","text":" (\"Terms > Delivery > Zones\") and the restaurant name to each chunk – then the chunk makes sense on its own. Anthropic described an extension of this idea as "},{"type":"text","text":"Contextual Retrieval","marks":[{"type":"italic"}]},{"type":"text","text":": a model writes a short context from the whole document for each chunk before embedding; in their measurements, combined with BM25 it cut the rate of failed retrievals by 49%, and with reranking by 67%."}]},{"type":"codeGroup","attrs":{"title":"Chunking: structure first, then size"},"content":[{"type":"codeBlock","attrs":{"language":"python","filename":"chunking.py"},"content":[{"type":"text","text":"import re\nfrom dataclasses import dataclass\n\nMAX_CHARS = 1200  # ~250-350 tokens of English, fewer for Polish - measure with your tokenizer\nOVERLAP = 200     # repeated tail so a sentence cut at the border is still findable\n\n@dataclass\nclass Chunk:\n    doc_id: str\n    heading_path: str  # e.g. \"Terms > Delivery > Zones\" - keeps the chunk self-explanatory\n    text: str\n\ndef split_by_headings(markdown: str) -> list[tuple[str, str]]:\n    \"\"\"Structure first: one section per Markdown heading, with the full heading path.\"\"\"\n    sections, path, buf = [], [], []\n    for line in markdown.splitlines():\n        m = re.match(r\"^(#{1,4})\\s+(.*)\", line)\n        if m:\n            if buf:\n                sections.append((\" > \".join(path), \"\\n\".join(buf).strip()))\n                buf = []\n            level = len(m.group(1))\n            path = path[: level - 1] + [m.group(2).strip()]\n        else:\n            buf.append(line)\n    if buf:\n        sections.append((\" > \".join(path), \"\\n\".join(buf).strip()))\n    return [(p, t) for p, t in sections if t]\n\ndef window(text: str) -> list[str]:\n    \"\"\"Size second: long sections become overlapping windows, cut at paragraph or sentence ends.\"\"\"\n    out, start = [], 0\n    while start < len(text):\n        end = min(start + MAX_CHARS, len(text))\n        if end < len(text):\n            cut = max(text.rfind(\"\\n\\n\", start, end), text.rfind(\". \", start, end))\n            end = cut + 1 if cut > start + MAX_CHARS // 2 else end\n        out.append(text[start:end].strip())\n        if end >= len(text):\n            break\n        start = max(end - OVERLAP, start + 1)\n    return out\n\ndef chunk_document(doc_id: str, markdown: str) -> list[Chunk]:\n    return [\n        Chunk(doc_id, path, f\"{path}\\n\\n{piece}\")  # the heading path is embedded together with the text\n        for path, body in split_by_headings(markdown)\n        for piece in window(body)\n    ]"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"chunking.ts"},"content":[{"type":"text","text":"export interface Chunk {\n  docId: string;\n  headingPath: string; // e.g. \"Terms > Delivery > Zones\"\n  text: string;\n}\n\nconst MAX_CHARS = 1200; // measure in tokens for your model and language\nconst OVERLAP = 200;\n\nfunction splitByHeadings(markdown: string): Array<[path: string, body: string]> {\n  const sections: Array<[string, string]> = [];\n  let path: string[] = [];\n  let buf: string[] = [];\n  const flush = () => {\n    const body = buf.join(\"\\n\").trim();\n    if (body) sections.push([path.join(\" > \"), body]);\n    buf = [];\n  };\n  for (const line of markdown.split(\"\\n\")) {\n    const m = /^(#{1,4})\\s+(.*)/.exec(line);\n    if (m) {\n      flush();\n      path = [...path.slice(0, m[1].length - 1), m[2].trim()];\n    } else buf.push(line);\n  }\n  flush();\n  return sections;\n}\n\nfunction windows(text: string): string[] {\n  const out: string[] = [];\n  let start = 0;\n  while (start < text.length) {\n    let end = Math.min(start + MAX_CHARS, text.length);\n    if (end < text.length) {\n      const cut = Math.max(text.lastIndexOf(\"\\n\\n\", end), text.lastIndexOf(\". \", end));\n      if (cut > start + MAX_CHARS / 2) end = cut + 1;\n    }\n    out.push(text.slice(start, end).trim());\n    if (end >= text.length) break;\n    start = Math.max(end - OVERLAP, start + 1);\n  }\n  return out;\n}\n\nexport function chunkDocument(docId: string, markdown: string): Chunk[] {\n  return splitByHeadings(markdown).flatMap(([headingPath, body]) =>\n    windows(body).map((piece) => ({ docId, headingPath, text: `${headingPath}\\n\\n${piece}` })),\n  );\n}"}]},{"type":"codeBlock","attrs":{"language":"csharp","filename":"Chunker.cs"},"content":[{"type":"text","text":"using System.Text.RegularExpressions;\n\nvar terms = \"\"\"\n    # Terms\n    ## Delivery\n    We deliver within 5 km of each restaurant. Orders above 80 PLN are delivered for free.\n    ## Allergens\n    Every dish lists the 14 EU allergens. The walnut sauce contains nuts.\n    \"\"\";\nforeach (var c in Chunker.Chunk(\"terms-v3\", terms))\n    Console.WriteLine($\"[{c.HeadingPath}] {c.Text.Length} chars\");\n\npublic sealed record Chunk(string DocId, string HeadingPath, string Text);\n\npublic static partial class Chunker\n{\n    const int MaxChars = 1200, Overlap = 200;\n\n    [GeneratedRegex(@\"^(#{1,4})\\s+(.*)$\")]\n    private static partial Regex Heading();\n\n    public static IEnumerable<Chunk> Chunk(string docId, string markdown)\n    {\n        var path = new List<string>();\n        var buf = new List<string>();\n        foreach (var line in markdown.Split('\\n').Append(\"# \"))  // sentinel flushes the last section\n        {\n            var m = Heading().Match(line);\n            if (!m.Success) { buf.Add(line); continue; }\n            var body = string.Join('\\n', buf).Trim();\n            var headingPath = string.Join(\" > \", path);\n            foreach (var piece in Windows(body))\n                yield return new Chunk(docId, headingPath, $\"{headingPath}\\n\\n{piece}\");\n            buf.Clear();\n            int level = m.Groups[1].Length;\n            path = [.. path.Take(level - 1), m.Groups[2].Value.Trim()];\n        }\n    }\n\n    static IEnumerable<string> Windows(string text)\n    {\n        for (int start = 0; start < text.Length;)\n        {\n            int end = Math.Min(start + MaxChars, text.Length);\n            if (end < text.Length)\n            {\n                int cut = Math.Max(text.LastIndexOf(\"\\n\\n\", end - 1), text.LastIndexOf(\". \", end - 1));\n                if (cut > start + MaxChars / 2) end = cut + 1;\n            }\n            yield return text[start..end].Trim();\n            if (end >= text.Length) yield break;\n            start = Math.Max(end - Overlap, start + 1);\n        }\n    }\n}"}]}]}]},"toc":[{"id":"the-problem-40-restaurants-40-menus-and-terms-that-change-every-month","text":"The problem: 40 restaurants, 40 menus and terms that change every month","level":2,"locked":false},{"id":"do-you-really-need-rag","text":"Do you really need RAG?","level":2,"locked":false},{"id":"architecture-two-paths","text":"Architecture: two paths","level":2,"locked":false},{"id":"indexing-garbage-in-hallucinations-out","text":"Indexing: garbage in, hallucinations out","level":2,"locked":false},{"id":"chunking","text":"Chunking","level":3,"locked":false},{"id":"hybrid-search-words-and-meaning","text":"Hybrid search: words and meaning","level":2,"locked":true},{"id":"reranking-wide-first-then-precise","text":"Reranking: wide first, then precise","level":2,"locked":true},{"id":"generation-an-answer-with-citations","text":"Generation: an answer with citations","level":2,"locked":true},{"id":"evaluation-measure-retrieval-and-generation-separately","text":"Evaluation: measure retrieval and generation separately","level":2,"locked":true},{"id":"advanced-techniques","text":"Advanced techniques","level":2,"locked":true},{"id":"when-rag-and-when-something-else","text":"When RAG, and when something else","level":2,"locked":true},{"id":"pre-production-checklist","text":"Pre-production checklist","level":2,"locked":true},{"id":"test-yourself","text":"Test yourself","level":2,"locked":true},{"id":"what-s-next","text":"What's next","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":61,"visibleBlocks":23,"resources":[{"id":"6b0857be3c96f2d34d0b4204","type":"article","provider":"web","url":"https://www.anthropic.com/news/contextual-retrieval","embedUrl":null,"title":"Contextual retrieval in AI systems","description":"Contextual retrieval improves how AI systems access and use information, reducing retrieval failures in large knowledge bases.","author":"Anthropic","thumbnailUrl":"https://assets.claude.com/e81642c949d3942e998d6ba331abf4074dd5050a.jpg","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":"2024-09-19T00:00:00.000Z","popularity":75,"verifiedAt":"2026-11-26T11:25:46.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857b23c96f2d34d0b3407","type":"repo","provider":"github","url":"https://github.com/NirDiamant/RAG_Techniques","embedUrl":null,"title":"NirDiamant/RAG_Techniques","description":"This repository showcases various advanced techniques for Retrieval-Augmented Generation (RAG) systems. Each technique has a detailed notebook tutorial.","author":"NirDiamant","thumbnailUrl":"https://opengraph.githubassets.com/1/NirDiamant/RAG_Techniques","durationSec":null,"lang":"en","topics":["rag","embeddings-vector-db","ai-agents","ai-in-python"],"techs":["python"],"tags":["agentic-rag","ai","embeddings","generative-ai","gpt","langchain","databases","machine-learning","llm","llama-index"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2024-07-13T16:08:36.000Z","popularity":87,"verifiedAt":"2026-11-26T11:00:12.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:49.541Z","updatedAt":"2026-11-26T16:00:49.541Z"},{"id":"6b0857c23c96f2d34d0b44e9","type":"article","provider":"web","url":"https://docs.ragas.io/en/stable","embedUrl":null,"title":"Ragas","description":"Evaluation framework for your AI Application","author":"Ragas","thumbnailUrl":"https://docs.ragas.io/en/stable/assets/images/social/index.png","durationSec":null,"lang":"en","topics":["rag","evals"],"techs":["general"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":50,"verifiedAt":"2026-11-26T11:26:44.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:04.995Z","updatedAt":"2026-11-26T16:01:04.995Z"},{"id":"6b0857b23c96f2d34d0b33f9","type":"repo","provider":"github","url":"https://github.com/microsoft/graphrag","embedUrl":null,"title":"microsoft/graphrag","description":"A modular graph-based Retrieval-Augmented Generation (RAG) system","author":"microsoft","thumbnailUrl":"https://opengraph.githubassets.com/1/microsoft/graphrag","durationSec":null,"lang":"en","topics":["rag","llm-fundamentals","ai-in-python"],"techs":["python"],"tags":["gpt","gpt-4","gpt4","graphrag","llm","llms","ai","rag"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2024-03-27T17:57:52.000Z","popularity":88,"verifiedAt":"2026-11-26T10:53:11.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:49.541Z","updatedAt":"2026-11-26T16:00:49.541Z"},{"id":"6b0857bf3c96f2d34d0b433c","type":"article","provider":"web","url":"https://www.pinecone.io/learn/retrieval-augmented-generation","embedUrl":null,"title":"Retrieval-Augmented Generation (RAG) | Pinecone","description":"Explore the limitations of foundation models and how retrieval-augmented generation (RAG) can address these limitations so chat, search, and agentic workflows can all benefit.","author":"Pinecone","thumbnailUrl":"https://www.pinecone.io/api/og/?title=Retrieval-Augmented%20Generation%20(RAG)&category=Learn","durationSec":null,"lang":"en","topics":["rag","embeddings-vector-db"],"techs":["general"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":55,"verifiedAt":"2026-11-26T11:26:43.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857a93c96f2d34d0b3246","type":"repo","provider":"github","url":"https://github.com/run-llama/llama_index","embedUrl":null,"title":"run-llama/llama_index","description":"LlamaIndex is the document processing platform for AI","author":"run-llama","thumbnailUrl":"https://opengraph.githubassets.com/1/run-llama/llama_index","durationSec":null,"lang":"en","topics":["rag","ai-in-python"],"techs":["python"],"tags":[],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"seed","publishedAt":null,"popularity":94,"verifiedAt":"2026-11-26T00:00:00.000Z","curated":true,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:40.963Z","updatedAt":"2026-11-26T16:00:40.963Z"}],"challenges":[],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"ai-path","title":"AI for developers","items":[{"slug":"llm-fundamentals","title":"LLM fundamentals: tokens, context windows and next-token prediction","current":false},{"slug":"prompt-engineering","title":"Prompt engineering: writing instructions a model will actually follow","current":false},{"slug":"embeddings-vector-db","title":"Embeddings and vector databases: searching by meaning","current":false},{"slug":"rag","title":"RAG: answers grounded in your own documents","current":true},{"slug":"tool-use","title":"Tool use: how a language model calls your application's functions","current":false},{"slug":"ai-agents","title":"AI agents: a model in a loop with tools – and when a plain workflow is enough","current":false},{"slug":"mcp","title":"MCP (Model Context Protocol): one standard for connecting AI to tools and data","current":false},{"slug":"evals","title":"Evaluating LLM applications (evals): tests for systems that are not deterministic","current":false},{"slug":"llm-ops","title":"LLMOps: model gateways, caching, limits, observability and costs in production","current":false},{"slug":"ai-guardrails","title":"Guardrails and security for LLM applications: prompt injection, data leaks and tool permissions","current":false},{"slug":"local-llms","title":"Local language models: Ollama, llama.cpp, vLLM, quantization and the real trade-offs","current":false},{"slug":"fine-tuning","title":"Fine-tuning language models: when it pays off, LoRA and QLoRA in practice","current":false},{"slug":"ai-coding-assistants","title":"AI coding assistants: from editor suggestions to an agent that opens pull requests","current":false}]}],"prev":{"slug":"embeddings-vector-db","title":"Embeddings and vector databases: searching by meaning"},"next":{"slug":"tool-use","title":"Tool use: how a language model calls your application's functions"},"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":104,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Authority","articles":90},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Authority","articles":61},{"key":"python","title":"Python","level":5,"levelLabel":"Authority","articles":59},{"key":"java","title":"Java","level":5,"levelLabel":"Authority","articles":46}]}}