-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added descriptions of Rewrite and Switch components. To be continued (#…
…4526) ### What problem does this PR solve? ### Type of change - [x] Documentation Update
- Loading branch information
1 parent
367babd
commit e0f52ee
Showing
5 changed files
with
146 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
sidebar_position: 8 | ||
slug: /rewrite_component | ||
--- | ||
|
||
# Rewrite component | ||
|
||
A component that rewrites a user query. | ||
|
||
--- | ||
|
||
A **Rewrite** component uses a specified LLM to rewrite a user query from the **Interact** component, based on the context of previous dialogues. | ||
|
||
## Scenarios | ||
|
||
A **Rewrite** component is essential when you need to optimize a user query based on the context of previous conversations. It is usually the upstream component of a **Retrieval** component. | ||
|
||
:::tip NOTE | ||
See also the [Keyword](https://ragflow.io/docs/dev/keyword_component) component, a similar component used for multi-turn optimization. | ||
::: | ||
|
||
## Configurations | ||
|
||
:::tip NOTE | ||
The **Rewrite** component uses the user-agent interaction from the **Interact** component as its data input. Therefore, there is no need to specify its data inputs in the Configurations. | ||
::: | ||
|
||
### Model | ||
|
||
Click the dropdown menu of **Model** to show the model configuration window. | ||
|
||
- **Model**: The chat model to use. | ||
- Ensure you set the chat model correctly on the **Model providers** page. | ||
- You can use different models for different components to increase flexibility or improve overall performance. | ||
- **Freedom**: A shortcut to **Temperature**, **Top P**, **Presence penalty**, and **Frequency penalty** settings, indicating the freedom level of the model. | ||
This parameter has three options: | ||
- **Improvise**: Produces more creative responses. | ||
- **Precise**: (Default) Produces more conservative responses. | ||
- **Balance**: A middle ground between **Improvise** and **Precise**. | ||
- **Temperature**: The randomness level of the model's output. | ||
Defaults to 0.1. | ||
- Lower values lead to more deterministic and predictable outputs. | ||
- Higher values lead to more creative and varied outputs. | ||
- A temperature of zero results in the same output for the same prompt. | ||
- **Top P**: Nucleus sampling. | ||
- Reduces the likelihood of generating repetitive or unnatural text by setting a threshold *P* and restricting the sampling to tokens with a cumulative probability exceeding *P*. | ||
- Defaults to 0.3. | ||
- **Presence penalty**: Encourages the model to include a more diverse range of tokens in the response. | ||
- A higher **presence penalty** value results in the model being more likely to generate tokens not yet been included in the generated text. | ||
- Defaults to 0.4. | ||
- **Frequency penalty**: Discourages the model from repeating the same words or phrases too frequently in the generated text. | ||
- A higher **frequency penalty** value results in the model being more conservative in its use of repeated tokens. | ||
- Defaults to 0.7. | ||
- **Max tokens**: Sets the maximum length of the model's output, measured in the number of tokens. | ||
- Defaults to 512. | ||
- If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses. | ||
|
||
:::tip NOTE | ||
- It is not necessary to stick with the same model for all components. If a specific model is not performing well for a particular task, consider using a different one. | ||
- 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**. | ||
::: | ||
|
||
|
||
### Message window size | ||
|
||
An integer specifying the number of previous dialogue rounds to input into the LLM. For example, if it is set to 12, the tokens from the last 12 dialogue rounds will be fed to the LLM. This feature consumes additional tokens. | ||
|
||
Defaults to 1. | ||
|
||
:::tip IMPORTANT | ||
This feature is used for multi-turn dialogue *only*. If your **Categorize** component is not part of a multi-turn dialogue (i.e., it is not in a loop), leave this field as-is. | ||
::: | ||
|
||
## Examples | ||
|
||
Explore our customer service agent template, where the **Rewrite** component (component ID: **Refine Question**) is used to optimize a product-specific user query based on context of previous dialogues before passing it on to the **Retrieval** component. | ||
|
||
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 **Customer service** card and click **Use this template**. | ||
4. Name your new agent and click **OK** to enter the workflow editor. | ||
5. Click on the **Rewrite** component to display its **Configuration** window. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
sidebar_position: 9 | ||
slug: /switch_component | ||
--- | ||
|
||
# Switch component | ||
|
||
A component that evaluates whether specified conditions are met and directs the follow of execution accordingly. | ||
|
||
--- | ||
|
||
A **Switch** component evaluates conditions based on the output of specific components, directing the flow of execution accordingly to enable complex branching logic. | ||
|
||
## Scenarios | ||
|
||
A **Switch** component is essential for condition-based direction of execution flow. While it shares similarities with the [Categorize](https://ragflow.io/docs/dev/categorize_component) component, which is also used in multi-pronged strategies, the key distinction lies in their approach: the evaluation of the **Switch** component is rule-based, whereas the **Categorize** component involves AI and uses an LLM for decision-making. | ||
|
||
## Configurations | ||
|
||
### Case n | ||
|
||
A **Switch** component must have at least one case, each with multiple specified conditions and corresponding downstream components. When multiple conditions are specified for a case, you must set the logical relationship between them to either AND or OR. | ||
|
||
#### Next step | ||
|
||
Specifies the downstream component of this case. | ||
|
||
- *Once you specify the ID of the downstream component, a link is established between this case and the corresponding component.* | ||
- *If you manually link this case to a downstream component on the canvas, the ID of that component is auto-populated.* | ||
|
||
#### Condition | ||
|
||
Evaluates whether the output of specific components meets certain conditions, with **Component ID**, **Operator**, and **Value** together forming a conditional expression. | ||
|
||
:::danger IMPORTANT | ||
When you have added multiple conditions for a specific case, a **Logical operator** field appears, requiring you to set the logical relationship between these conditions as either AND or OR. | ||
::: | ||
|
||
- **Component ID**: The ID of the corresponding component. | ||
- **Operator**: The operator required to form a conditional expression. | ||
- Equals | ||
- Not equal | ||
- Greater than | ||
- Greater equal | ||
- Less than | ||
- Less equal | ||
- Contains | ||
- Not contains | ||
- Starts with | ||
- Ends with | ||
- Is empty | ||
- Not empty | ||
- **Value**: A single value, which can be an integer, float, or string. | ||
- Delimiters, multiple values, or expressions are *not* supported. | ||
- Strings need not be wrapped in `""` or `''`. | ||
|
||
### ELSE | ||
|
||
**Required**. Specifies the downstream component if none of the conditions defined above are met. | ||
|
||
*Once you specify the ID of the downstream component, a link is established between ELSE and the corresponding component.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters