Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rewrite.mdx 4.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---
  2. sidebar_position: 8
  3. slug: /rewrite_component
  4. ---
  5. # Rewrite component
  6. A component that rewrites a user query.
  7. ---
  8. A **Rewrite** component uses a specified LLM to rewrite a user query from the **Interact** component, based on the context of previous dialogues.
  9. ## Scenarios
  10. 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.
  11. :::tip NOTE
  12. See also the [Keyword](./keyword.mdx) component, a similar component used for multi-turn optimization.
  13. :::
  14. ## Configurations
  15. :::tip NOTE
  16. 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.
  17. :::
  18. ### Model
  19. Click the dropdown menu of **Model** to show the model configuration window.
  20. - **Model**: The chat model to use.
  21. - Ensure you set the chat model correctly on the **Model providers** page.
  22. - You can use different models for different components to increase flexibility or improve overall performance.
  23. - **Freedom**: A shortcut to **Temperature**, **Top P**, **Presence penalty**, and **Frequency penalty** settings, indicating the freedom level of the model. From **Improvise**, **Precise**, to **Balance**, each preset configuration corresponds to a unique combination of **Temperature**, **Top P**, **Presence penalty**, and **Frequency penalty**.
  24. This parameter has three options:
  25. - **Improvise**: Produces more creative responses.
  26. - **Precise**: (Default) Produces more conservative responses.
  27. - **Balance**: A middle ground between **Improvise** and **Precise**.
  28. - **Temperature**: The randomness level of the model's output.
  29. Defaults to 0.1.
  30. - Lower values lead to more deterministic and predictable outputs.
  31. - Higher values lead to more creative and varied outputs.
  32. - A temperature of zero results in the same output for the same prompt.
  33. - **Top P**: Nucleus sampling.
  34. - 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*.
  35. - Defaults to 0.3.
  36. - **Presence penalty**: Encourages the model to include a more diverse range of tokens in the response.
  37. - A higher **presence penalty** value results in the model being more likely to generate tokens not yet been included in the generated text.
  38. - Defaults to 0.4.
  39. - **Frequency penalty**: Discourages the model from repeating the same words or phrases too frequently in the generated text.
  40. - A higher **frequency penalty** value results in the model being more conservative in its use of repeated tokens.
  41. - Defaults to 0.7.
  42. :::tip NOTE
  43. - 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.
  44. - If you are uncertain about the mechanism behind **Temperature**, **Top P**, **Presence penalty**, and **Frequency penalty**, simply choose one of the three options of **Preset configurations**.
  45. :::
  46. ### Message window size
  47. 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.
  48. Defaults to 1.
  49. :::tip IMPORTANT
  50. 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.
  51. :::
  52. ## Examples
  53. 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.
  54. 1. Click the **Agent** tab at the top center of the page to access the **Agent** page.
  55. 2. Click **+ Create agent** on the top right of the page to open the **agent template** page.
  56. 3. On the **agent template** page, hover over the **Customer service** card and click **Use this template**.
  57. 4. Name your new agent and click **OK** to enter the workflow editor.
  58. 5. Click on the **Rewrite** component to display its **Configuration** window.