Retrieval QA
Retrieval QA answers a question with the information in your knowledge base: it finds the passages of your documents related to the question and asks an AI model to answer from them. It can add the references of the documents used at the end of the answer.
Use it to build a question-and-answer system over your manuals, policies or catalogues.
When to use it
- Answering customer questions with the information in the product manuals.
- Answering staff questions about the company’s internal policies.
- Looking things up in contracts or data sheets and knowing which document each answer comes from.
Configuration
| Field | What it does |
|---|---|
| Input (required) | The question. You can type it or connect it, for example, to a Chat Input. |
| Return Source Documents | Adds the references of the documents used at the end of the answer. Default: off. |
| Connection | What to connect |
|---|---|
| Model (required) | An AI model component, for example OpenAI. |
| Retriever (required) | The knowledge base to search: the Retriever output of a component such as Chroma DB or PGVector. |
| Memory | Optional. The Memory output of Chat Memory, to save the questions and answers in the conversation history. |
Advanced options
| Field | What it does |
|---|---|
| Chain Type | How the passages found are handed to the model. Default: Stuff. |
Chain Type options:
- Stuff: all passages are sent together in a single request. It is the fastest option and the right one in most cases.
- Map Reduce: the model reads each passage separately and then combines what it got from all of them into one answer.
- Refine: the model answers with the first passage and improves the answer with each of the following ones.
- Map Rerank: the model answers with each passage separately, scores each answer and keeps the best one.
The options other than Stuff ask the model several times, so they take longer.
Output
- Text: the answer, with the references at the end if you turned on Return Source Documents. Connect it to a Chat Output to show it in the chat.
- Runnable: the component ready to be run by another one. Connect it to Runnable As Tool so an agent can use it as a tool.
Example
Clima Ribera wants its technicians to look up the air-conditioning manuals from the chat:
- Load the manuals into a knowledge base, for example Chroma DB, and connect its Retriever output to Retriever.
- Connect a Chat Input to Input and a model to Model.
- Turn on Return Source Documents and connect Text to a Chat Output.
When a technician asks “what does error code E4 mean?”, they get the explanation taken from the manuals and the reference of the document it comes from.
Good practices
- Keep the knowledge base up to date: answers can only be based on what your documents contain.
- If you want to give the model instructions or have it understand follow-up questions, use Retrieval QA History.