Skip to content

Commit

Permalink
Added descriptions of the retrieval agent component (#4416)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?



### Type of change


- [x] Documentation Update

---------

Co-authored-by: Jin Hai <[email protected]>
  • Loading branch information
writinwaters and JinHai-CN authored Jan 9, 2025
1 parent d64df4d commit 7bebf4b
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/guides/agent/text2sql_agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ However, traditional Text2SQL solutions often require model fine-tuning, which c
A list of components required:

- [Begin](https://ragflow.io/docs/dev/begin_component)
- Interface
- [Interact](https://ragflow.io/docs/dev/interact_component)
- Retrieval
- Generate
- [Generate](https://ragflow.io/docs/dev/generate_component)
- ExeSQL

## Procedure
Expand Down
6 changes: 4 additions & 2 deletions docs/guides/start_chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ You start an AI conversation by creating an assistant.

:::tip NOTE

Click the light bubble icon above the answer to view the expanded system prompt:
1. Click the light bubble icon above the answer to view the expanded system prompt:

![](https://github.com/user-attachments/assets/515ab187-94e8-412a-82f2-aba52cd79e09)

Scroll down the expanded prompt to view the time consumed for each task:
*The light bubble icon is available only for the current dialogue.*

2. Scroll down the expanded prompt to view the time consumed for each task:

![enlighten](https://github.com/user-attachments/assets/fedfa2ee-21a7-451b-be66-20125619923c)
:::
Expand Down
2 changes: 1 addition & 1 deletion docs/references/agent_component_reference/generate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Click the dropdown menu of **Model** to show the model configuration window.
- If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.

:::tip NOTE
If you are uncertain about the mechanism behind **Temperature**, **Top P**, **Presence penalty**, and **Frequency penalty**, you can simply choose one of the three options of **Freedom**, which defaults to **Precise**.
If you are uncertain about the mechanism behind **Temperature**, **Top P**, **Presence penalty**, and **Frequency penalty**, you can simply choose one of the three options of **Freedom**.
:::

### System prompt
Expand Down
2 changes: 1 addition & 1 deletion docs/references/agent_component_reference/interact.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ A **Interact** component is essential where you need to display the agent's resp

## Examples

You can explore our three-step interpreter agent template, where the **Interact** component is used to display the final translation, or our customer service agent template, where the **Interact** component is used to display multi-turn dialogue between the user and the agent.
You can explore our three-step interpreter agent template, where the **Interact** component is used to display the final translation, or our customer service agent template, where the **Interact** component is the immediate downstream of **Begin** and is used to display multi-turn dialogue between the user and the agent.
75 changes: 75 additions & 0 deletions docs/references/agent_component_reference/retrieval.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
sidebar_position: 3
slug: /retrieval_component
---

# Retrieval component

A component that retrieves information from specified datasets.

## Scenarios

A **Retrieval** component is essential in most RAG scenarios, where information is extracted from designated knowledge bases before being sent to the LLM for content generation.

## Configurations

Click on a **Retrieval** component to open its configuration window.

### Input

The **Retrieval** component relies on input variables to specify its data inputs (queries). Click **+ Add variable** in the **Input** section to add the desired input variables. There are two types of input variables: **Reference** and **Text**.

- **Reference**: Uses a component's output or a user input as the data source. You are required to select from the dropdown menu:
- A component ID under **Component Output**, or
- A global variable under **Begin input**, which is defined in the **Begin** component.
- **Text**: Uses fixed text as the query. You are required to enter static text.

### Similarity threshold

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.

### Keywords similarity weight

This parameter sets the weight of keyword similarity in the combined similarity score. The total of the two weights must equal 1.0. Its default value is 0.7, which means the weight of vector similarity in the combined search is 1 - 0.7 = 0.3.

### Top N

This parameter selects the "Top N" chunks from retrieved ones and feed them to the LLM.

Defaults to 8.


### Rerank model

*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.
:::


### Knowledge bases

*Required*

You are required to select the knowledge base(s) to retrieve data from.

:::danger IMPORTANT
If you select multiple knowledge bases must ensure that the knowledge bases (datasets) you select use the same embedding model; otherwise, an error message would occur.
:::



## Examples

Explore our customer service agent template, where the **Retrieval** component (component ID: **Search product info**) is used to search the dataset and send the Top N results to the LLM:

1. Click the **Agent** tab at the top center of the page to access the **Agent** page.
2. Click **+ Create agent** on the top right of the page to open the **agent template** page.
3. On the **agent template** page, hover over the **Interperter** card and click **Use this template**.
4. Name your new agent and click **OK** to enter the workflow editor.
5. Click on the **Retrieval** component to display its **Configuration** window.
6 changes: 3 additions & 3 deletions web/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default {
cancel: 'Cancel',
rerankModel: 'Rerank model',
rerankPlaceholder: 'Please select',
rerankTip: `If left empty, RAGFlow will use a combination of weighted keyword similarity and weighted vector cosine similarity; if a rerank model is selected, a weighted reranking score will replace the weighted vector cosine similarity.`,
rerankTip: `If left empty, RAGFlow will use a combination of weighted keyword similarity and weighted vector cosine similarity; if a rerank model is selected, a weighted reranking score will replace the weighted vector cosine similarity. Please be aware that using a rerank model will significantly increase the system's response time.`,
topK: 'Top-K',
topKTip: `K chunks will be fed into rerank models.`,
delimiter: `Delimiter`,
Expand Down Expand Up @@ -410,7 +410,7 @@ This procedure will improve precision of retrieval by adding more information to
improvise: 'Improvise',
precise: 'Precise',
balance: 'Balance',
freedomTip: `Set the freedom level to 'Precise' to strictly confine the LLM's response to your selected knowledge base(s). Choose 'Improvise' to grant the LLM greater freedom in its responses, which may lead to hallucinations. 'Balance' is an intermediate level; choose 'Balance' for more balanced responses.`,
freedomTip: `A shortcut to 'Temperature', 'Top P', 'Presence penalty', and 'Frequency penalty' settings, indicating the freedom level of the model. This parameter has three options: Select 'Improvise' to produce more creative responses; select 'Precise' (default) to produce more conservative responses; 'Balance' is a middle ground between 'Improvise' and 'Precise'.`,
temperature: 'Temperature',
temperatureMessage: 'Temperature is required',
temperatureTip: `This parameter controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses.`,
Expand Down Expand Up @@ -723,7 +723,7 @@ This procedure will improve precision of retrieval by adding more information to
title: 'ID:',
beginDescription: 'This is where the flow begins.',
answerDescription: `A component that serves as the interface between human and bot, receiving user inputs and displaying the agent's responses.`,
retrievalDescription: `A component that retrieves information from a specified knowledge base and returns 'Empty response' if no information is found. Ensure the correct knowledge base is selected.`,
retrievalDescription: `A component that retrieves information from specified knowledge bases (datasets). Ensure that the knowledge bases you select use the same embedding model.`,
generateDescription: `A component that prompts the LLM to generate responses. Ensure the prompt is set correctly.`,
categorizeDescription: `A component that uses the LLM to classify user inputs into predefined categories. Ensure you specify the name, description, and examples for each category, along with the corresponding next component.`,
relevantDescription: `A component that uses the LLM to assess whether the upstream output is relevant to the user's latest query. Ensure you specify the next component for each judge result.`,
Expand Down

0 comments on commit 7bebf4b

Please sign in to comment.