YUNOVA · AI Agents

Module 4: RAG for agents

Notes for offline study · 30 November 2026

Why a model needs your documents

Key points

  • Model को आपकी company के documents, policies या निजी data की जानकारी नहीं होती।
  • RAG (Retrieval-Augmented Generation) में सवाल से जुड़े हिस्से खोजकर prompt में जोड़े जाते हैं, फिर model जवाब देता है।
  • इससे जवाब आपके असली documents पर आधारित होते हैं और hallucination कम होता है।
  • Documents बदलने पर model को दोबारा train नहीं करना पड़ता, सिर्फ़ index update होता है।

Chunking documents

Key points

  • Chunking मतलब बड़े document को छोटे टुकड़ों (chunks) में बाँटना, ताकि सही हिस्सा खोजा जा सके।
  • बहुत बड़े chunks में फ़ालतू बातें आती हैं, बहुत छोटे chunks में संदर्भ टूट जाता है।
  • Chunks के बीच थोड़ा overlap रखने से वाक्य या विचार बीच में कटने का असर कम होता है।
  • Headings या paragraphs के हिसाब से बाँटना अक्सर सिर्फ़ characters गिनकर बाँटने से बेहतर होता है।

Embeddings and a vector store

Key points

  • Embedding किसी text को संख्याओं की list (vector) में बदलती है, जिसमें मिलते-जुलते अर्थ वाले text पास-पास होते हैं।
  • Vector store इन vectors को save करता है और सवाल के vector के सबसे करीब chunks खोजता है।
  • यह semantic search है: शब्द अलग हों पर अर्थ मिलता हो, तब भी सही chunk मिल सकता है।
  • बड़े data में तेज़ी के लिए ANN (Approximate Nearest Neighbor) search इस्तेमाल होता है।

Retrieving and answering with citations

Key points

  • सवाल आने पर सबसे relevant chunks निकाले जाते हैं और model से सिर्फ़ उन्हीं के आधार पर जवाब माँगा जाता है।
  • हर chunk के साथ source (document का नाम, page या link) रखें, ताकि जवाब में citation दी जा सके।
  • Citation से user खुद जाँच सकता है कि जवाब सही है या नहीं।
  • अगर खोजे गए chunks में जवाब न हो, तो model को साफ़ कहना चाहिए कि जानकारी नहीं मिली।

When RAG is the wrong tool

Key points

  • अगर ज़रूरी जानकारी छोटी है और prompt में पूरी आ जाती है, तो RAG की ज़रूरत नहीं।
  • Model का tone, format या खास व्यवहार बदलना हो तो fine-tuning या बेहतर prompt ज़्यादा सही हो सकता है।
  • गिनती, totals या filters जैसे सवालों के लिए database query (जैसे SQL tool) RAG से बेहतर है।
  • RAG सबसे अच्छा तब है जब बहुत सारे और बदलते documents से जानकारी ढूँढनी हो।

Free on YUNOVA · yunova.in · Sign in to add your own lesson notes to this sheet.