From cb46a13727d6d306474d0741350ba19db8e92433 Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Tue, 20 Jun 2023 13:54:18 +0200 Subject: [PATCH] Llm dialogue docs (#12530) * added dialogue docs * Apply suggestions from code review Co-authored-by: Maxime Vdb * review comments --------- Co-authored-by: Maxime Vdb --- docs/docs/llms/large-language-models.mdx | 7 +- docs/docs/llms/llm-dialogue.mdx | 84 +++++++++++++++++++----- 2 files changed, 70 insertions(+), 21 deletions(-) diff --git a/docs/docs/llms/large-language-models.mdx b/docs/docs/llms/large-language-models.mdx index bcd8fee9e175..67749f84d4f0 100644 --- a/docs/docs/llms/large-language-models.mdx +++ b/docs/docs/llms/large-language-models.mdx @@ -59,10 +59,9 @@ This section of the documentation guides you through the diverse ways you can integrate LLMs into Rasa. We will delve into the following topics: 1. [Setting up LLMs](./llm-setup.mdx) -2. [Intent Classification with LLMs](./llm-intent.mdx) -3. [Dialogue Handling using LLMs](./llm-intentless.mdx) -4. [NLG using LLMs](./llm-nlg.mdx) -5. [Custom usage of LLMs](./llm-custom.mdx) +2. [IntentDialogues with LLMs & Flows](./llm-dialogue.mdx) +4. [Business Logic with Flows](../flows.mdx) +5. [Handling Unhappy Paths](./unhappy-paths.mdx) Each link will direct you to a detailed guide on the respective topic, offering further depth and information about using LLMs with Rasa. By the end of this diff --git a/docs/docs/llms/llm-dialogue.mdx b/docs/docs/llms/llm-dialogue.mdx index e52757ddf851..b3fc6dd78b58 100644 --- a/docs/docs/llms/llm-dialogue.mdx +++ b/docs/docs/llms/llm-dialogue.mdx @@ -3,7 +3,7 @@ id: llm-dialogue sidebar_label: Dialogues with LLMs & Flows title: Dialogues with LLMs & Flows abstract: | - Dialogue Management combining LLMs and business logic (Flows). + This documentation explores dialogue management by combining Large Language Models (LLMs) and business logic through Flows. --- import RasaDiscoveryBanner from "@theme/RasaDiscoveryBanner"; @@ -12,27 +12,77 @@ import RasaDiscoveryBanner from "@theme/RasaDiscoveryBanner"; ## Motivation -The approach combine the best of both worlds: +Our approach aims to harness the strengths of both Large Language Models (LLMs) +and the control needed for business logic. This innovative blend enables you to +manage both the flexible and predictable aspects of dialogues within your +chatbot. -- the flexibility of LLMs and -- the control of business logic. +By utilizing LLMs, we can effectively handle ["unhappy paths"—instances](../glossary.mdx#happy--unhappy-paths) where +user interactions diverge from the expected or desired course. Meanwhile, +business logic or 'Flows' are used to manage ["happy paths"—scenarios](../glossary.mdx#happy--unhappy-paths) where +interactions proceed as anticipated. -The idea is to use LLMs to handle unhappy paths and to use business logic to -handle happy paths. - -The combination of LLMs and Flows avoids "black box" behavior. This approach -allows to limit the specification of business logic to a minimum and provides -ample opportunity to customize dialogue behavior. +Combining LLMs and Flows helps prevent "black box" behaviors, whereby the +chatbot's responses can seem inexplicable or out of control. With this method, +you only need to specify a minimal amount of business logic. At the same time, +it opens up a wide range of possibilities for customizing your chatbot's +dialogue behavior. ## Approach -- specify happy paths with business logic -- specify patterns of unhappy paths using separate flows -- use flows to keep track of state -- use LLMs to update flow states +Here's a breakdown of our approach: + +- We specify 'happy paths' using business logic. This means setting out clear, + pre-defined paths that the conversation should follow under ideal + circumstances using [Flows](../flows.mdx). +- We identify patterns of 'unhappy paths' and specify these using separate + Flows. These [conversational patterns](./unhappy-paths.mdx) define how the + chatbot should respond when the user's input doesn't match the expected course + of a flow. +- We use Flows to keep track of the conversation's state, ensuring we always + know where we are in the dialogue and what's been covered. +- We employ LLMs to update the state of these Flows. These language models + process user input, adjusting the conversation's course as needed. +- We use LLMs to [improve the chatbot's responses](./llm-nlg.mdx). These + language models generate the chatbot's responses, ensuring they feel natural and + fluent. ## Configuration and Setup -- get the dm2 branches -- configure the config.yml -## Example conversation +In order to set up and configure this approach: + +- You'll first need to get the `dm2` branches of `rasa` and `rasa-plus`. + All components are implemented on these branches. +- Next, you'll need to configure the `config.yml` file to ensure your bot + recognizes and applies this combination of LLMs and Flows. + +An example configuration file is shown below: + +```yaml title="config.yml" +recipe: default.v1 +language: en +pipeline: + - name: LLMFlowClassifier + +policies: + - name: rasa.core.policies.flow_policy.FlowPolicy + - name: RulePolicy +``` + +To use the rephrasing capability, you'll also need to add the following to your +endpoint configuration: + +```yaml title="endpoints.yml" +nlg: + type: rasa_plus.ml.LLMResponseRephraser +``` + +Additional configuration parameters are explained in detail in the documentation +pages for each of these components: +- [LLMFlowClassifier](./llm-flow-classifier.mdx) +- [FlowPolicy](./flow-policy.mdx) +- [LLMResponseRephraser](./llm-nlg.mdx) + +## Example Conversation + +[Example conversation goes here]