docs/guides/agent/agent_component_reference/retrieval.mdx
A component that retrieves information from specified datasets.
A Retrieval component is essential in most RAG scenarios, where information is extracted from designated datasets before being sent to the LLM for content generation. A Retrieval component can operate either as a standalone workflow module or as a tool for an Agent component. In the latter role, the Agent component has autonomous control over when to invoke it for query and retrieval.
The following screenshot shows a reference design using the Retrieval component, where the component serves as a tool for an Agent component. You can find it from the Report Agent Using Knowledge Base Agent template.
Ensure you have properly configured your target dataset(s).
The corresponding configuration panel appears to the right of the canvas. Use this panel to define and fine-tune the Retrieval component's search behavior.
The Retrieval component depends on query variables to specify its queries.
:::caution IMPORTANT
By default, you can use sys.query, which is the user query and the default output of the Begin component. All global variables defined before the Retrieval component can also be used as query statements. Use the (x) button or type / to show all the available query variables.
You can specify one or multiple datasets to retrieve data from. If selecting multiple, ensure they use the same embedding model.
By default, a combination of weighted keyword similarity and weighted vector cosine similarity is used for retrieval. If a rerank model is selected, a combination of weighted keyword similarity and weighted reranking score will be used instead.
As a starter, you can skip this step to stay with the default retrieval method.
:::caution WARNING Using a rerank model will significantly increase the system's response time. :::
If your user query is different from the languages of the datasets, you can select the target languages in the Cross-language search dropdown menu. The model will then translates queries to ensure accurate matching of semantic meaning across languages.
Click the Run button on the top of canvas to test the retrieval results.
When necessary, click the + button on the Retrieval component to choose the next component in the workflow from the dropdown list.
Mandatory
Select the query source for retrieval. Defaults to sys.query, which is the default output of the Begin component.
The Retrieval component relies on query variables to specify its queries. All global variables defined before the Retrieval component can also be used as queries. Use the (x) button or type / to show all the available query variables.
Select the dataset(s) or memory to retrieve data from.
RAGFlow employs a combination of weighted keyword similarity and weighted vector cosine similarity during retrieval. This parameter sets the threshold for similarities between the user query and chunks stored in the datasets. Any chunk with a similarity score below this threshold will be excluded from the results.
Defaults to 0.2.
This parameter sets the weight of vector similarity in the composite similarity score. The total of the two weights must equal 1.0. Its default value is 0.3, which means the weight of keyword similarity in a combined search is 1 - 0.3 = 0.7.
This parameter selects the "Top N" chunks from retrieved ones and feed them to the LLM.
Defaults to 8.
Optional
If a rerank model is selected, a combination of weighted keyword similarity and weighted reranking score will be used for retrieval.
:::caution WARNING Using a rerank model will significantly increase the system's response time. :::
:::caution WARNING If you do not specify a dataset, you must leave this field blank; otherwise, an error would occur. :::
Select one or more languages for cross‑language search. If no language is selected, the system searches with the original query.
:::caution IMPORTANT Before enabling this feature, ensure you have properly constructed a knowledge graph from each target dataset. :::
Whether to use knowledge graph(s) in the specified dataset(s) during retrieval for multi-hop question answering. When enabled, this would involve iterative searches across entity, relationship, and community report chunks, greatly increasing retrieval time.
Whether to use the page index structure generated by the large model to enhance retrieval. This approach mimics human information-searching behavior in books.
The global variable name for the output of the Retrieval component, which can be referenced by other components in the workflow.
Go through the checklist below for best performance: