What you’ll learn
- How to format your documents properly?
- Examples: How to Format Your Documents
- How to update your prompt for best knowledge-base search?
How RAG (Retrieval Augmented Generation) Works?
Retrieval Augmented Generation (RAG) enhances large language models (LLMs) by supplementing them with external knowledge. When a query is asked, the system retrieves relevant chunks of information from the knowledge base and feeds them into the model alongside the query. This ensures responses are more accurate, grounded, and contextually relevant.How to Format Your Documents?
- Use clear structure: Organize content with headings, subheadings, and bullet points to improve navigation.
- Keep it simple: Write in plain, jargon-free language so users with minimal technical knowledge can understand.
- Optimize for retrieval: Ensure important information is stated explicitly in text. Avoid burying key details in images or tables without descriptive text.
- Supported formats: Most common formats like DOCX, Markdown, Excel, and PDF are supported. Arrange and format text according to your file system for consistency.
Examples: How to Format Your Documents
Here are some concrete examples to help you apply the best practices:Example 1: Clear Structure
Bad:Example 2: Simple, Jargon-Free Language
Bad:Example 3: Optimize for Retrieval
Bad:Important Note on Table Retrieval
While text-based tables (Markdown, CSV, Excel) are far better than images for retrieval, they still require careful design for best performance:- Keep headers clear and descriptive: Avoid abbreviations that may confuse the search. For example, use
Storage (GB)
instead of justStor.
- Use consistent units: Always specify units in the header or the value (e.g.,
10 GB
vs just10
). - Avoid merging cells: Complex merged cells in spreadsheets make retrieval harder. Keep one value per cell.
- Add context in surrounding text: Before or after the table, explain what the table contains. For example: “The following table shows pricing plans and their features.”
Example 4: Supported Formats
Bad:How to Update Your Prompts for Best Knowledge-Base Search?
- Clarify tool usage: In your system prompt, explicitly state under which conditions the knowledge-base search tool should be triggered.
- Language consistency: Always specify that the query language must match the document language. For example, if documents are in English, include: “The knowledge-base-search tool query must be in English.”
- Be explicit: Provide clear instructions for how the retrieval tool should parse and interpret queries.
- Context matters: Tailor prompts to explain how retrieved knowledge should be used in the response (e.g., grounding answers, summarizing docs, or citing evidence).