[{"data":1,"prerenderedAt":157},["ShallowReactive",2],{"term-r\u002Fretrieval-augmented-generation":3,"related-r\u002Fretrieval-augmented-generation":139},{"id":4,"title":5,"acronym":6,"body":7,"category":119,"description":120,"difficulty":121,"extension":122,"letter":123,"meta":124,"navigation":59,"path":125,"related":126,"seo":132,"sitemap":133,"stem":136,"subcategory":137,"__hash__":138},"terms\u002Fterms\u002Fr\u002Fretrieval-augmented-generation.md","Retrieval-Augmented Generation","RAG",{"type":8,"value":9,"toc":113},"minimark",[10,15,19,23,26,30,102,106,109],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"RAG is like giving the AI an open-book exam instead of expecting it to memorize everything. Before answering your question, it first searches through your documents, knowledge base, or database for relevant information. Then it uses what it found to craft an accurate answer. It's the #1 pattern for building AI apps that need to know about YOUR specific data.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"RAG combines information retrieval with language generation. A query is first used to retrieve relevant documents from an external knowledge source (typically via embedding similarity search), then these documents are provided as context to the LLM for generating a grounded response. This reduces hallucinations, enables domain-specific knowledge, and keeps responses up to date without retraining.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Simple RAG pipeline\nquery = \"What's our refund policy?\"\n\n# 1. Retrieve relevant documents\nembedding = embed(query)\ndocs = vector_db.search(embedding, top_k=3)\n\n# 2. Generate grounded response\ncontext = \"\\n\".join([d.text for d in docs])\nresponse = llm.chat(f\"Context: {context}\\n\\nQ: {query}\")\n","python","",[38,39,40,48,54,61,67,73,79,84,90,96],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"# Simple RAG pipeline\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"query = \"What's our refund policy?\"\n",[41,55,57],{"class":43,"line":56},3,[41,58,60],{"emptyLinePlaceholder":59},true,"\n",[41,62,64],{"class":43,"line":63},4,[41,65,66],{},"# 1. Retrieve relevant documents\n",[41,68,70],{"class":43,"line":69},5,[41,71,72],{},"embedding = embed(query)\n",[41,74,76],{"class":43,"line":75},6,[41,77,78],{},"docs = vector_db.search(embedding, top_k=3)\n",[41,80,82],{"class":43,"line":81},7,[41,83,60],{"emptyLinePlaceholder":59},[41,85,87],{"class":43,"line":86},8,[41,88,89],{},"# 2. Generate grounded response\n",[41,91,93],{"class":43,"line":92},9,[41,94,95],{},"context = \"\\n\".join([d.text for d in docs])\n",[41,97,99],{"class":43,"line":98},10,[41,100,101],{},"response = llm.chat(f\"Context: {context}\\n\\nQ: {query}\")\n",[11,103,105],{"id":104},"when-youll-hear-this","When You'll Hear This",[16,107,108],{},"\"RAG lets the chatbot answer questions about our internal docs.\" \u002F \"We moved from fine-tuning to RAG and accuracy went way up.\"",[110,111,112],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":114},[115,116,117,118],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":104,"depth":50,"text":105},"ai","RAG is like giving the AI an open-book exam instead of expecting it to memorize everything.","intermediate","md","r",{},"\u002Fterms\u002Fr\u002Fretrieval-augmented-generation",[127,128,129,130,131],"Embedding","Vector Database","Semantic Search","Grounding","LLM",{"title":5,"description":120},{"changefreq":134,"priority":135},"weekly",0.7,"terms\u002Fr\u002Fretrieval-augmented-generation",null,"-kHiaV6spALkc3hsYKn8TqPxeyJusiVaflV-tfp0yt0",[140,143,146,151,154],{"title":127,"path":141,"acronym":137,"category":119,"difficulty":121,"description":142},"\u002Fterms\u002Fe\u002Fembedding","An embedding is turning words, sentences, or entire documents into lists of numbers (vectors) that capture their meaning.",{"title":130,"path":144,"acronym":137,"category":119,"difficulty":121,"description":145},"\u002Fterms\u002Fg\u002Fgrounding","Grounding is giving the AI real, verified information to base its answers on — so it doesn't just make stuff up.",{"title":131,"path":147,"acronym":148,"category":119,"difficulty":149,"description":150},"\u002Fterms\u002Fl\u002Fllm","Large Language Model","beginner","An LLM is a humongous AI that read basically the entire internet and learned to predict what words come next, really really well.",{"title":129,"path":152,"acronym":137,"category":119,"difficulty":121,"description":153},"\u002Fterms\u002Fs\u002Fsemantic-search","Semantic search finds results based on meaning, not just keyword matching.",{"title":128,"path":155,"acronym":137,"category":119,"difficulty":121,"description":156},"\u002Fterms\u002Fv\u002Fvector-database","A vector database is a special database built to store and search embeddings.",1776518308329]