How RAG works
- Semantic search: the agent uses your question as a search query. It looks for passages with the same meaning in your data sources, not only the same keywords.
- Retrieval: the agent gets the passages that most likely contain the answer.
- Processing: the model reads these passages, your question, and the agent’s instructions.
- Answer: the model writes an answer based on what it found, with links to its sources.
What RAG does well, and its limits
RAG works like a research partner who quickly scans a large archive and briefs you on the most relevant files. It goes deep on a topic, but it doesn’t read everything. What RAG does well:- Large knowledge bases: it finds information across many documents.
- Meaning, not only keywords: it finds passages that match the meaning of your question.
- Natural answers: it writes clear answers in plain language.
- Relevance, not completeness: it only gets the passages that look the most useful. It doesn’t find every mention of a topic.
- No counting: it can’t count documents or mentions. Questions like “How many documents discuss topic X?” or “How many documents can you access?” don’t get reliable answers.
- No exact figures: for figures and calculations, a query on structured data gives better answers.
Methods for counts and structured data
When you need exact figures or a full review of your data, choose another knowledge lookup method in Configure knowledge when you add knowledge to your agent:- Include all data: the agent loads your documents from the most recent to the oldest, within the period you set, until it fills the model’s context window. This is useful when you care about recent information, but it isn’t made for counting. See Include data.
- Analytics (tables, spreadsheets…): the agent writes and runs SQL queries on your tables, like CSV files, Google Sheets, or Notion databases. Use it for counts and calculations, for example how often customers mentioned an issue last month. See Table queries.
- Advanced processing: the agent extracts structured information from a large set of documents, in a format that you define, over a period that you set. Use it when you need a more complete review than search gives. See Extract data.
Tips to get better answers
- Ask clear, specific questions. Focus on the information you need. Very broad or vague questions return less relevant passages.
- Expect variation. The agent writes a new answer each time, based on what it finds. The wording can change from one answer to the next.
- Iterate. If the answer isn’t right, rephrase your question, add context, or improve the agent’s instructions. See How to write effective instructions.
- Choose the right method. Use Content search for open questions, and Analytics for questions that need exact figures.
Related
Search data sources
Set up the Content search method.
Table queries
Query tables and spreadsheets with SQL.
Understanding LLM Limitations: Counting and Parsing Structured Data
Learn why LLMs struggle with counting.