From 9ae48efbe60d3a9df6397d3f3c7d12fb595332da Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Mon, 19 Jun 2023 22:27:50 +0200 Subject: [PATCH] added dialogue docs --- docs/docs/llms/llm-dialogue.mdx | 81 ++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/docs/docs/llms/llm-dialogue.mdx b/docs/docs/llms/llm-dialogue.mdx index e52757ddf851..3e156422db5c 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,74 @@ 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 offered by 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 where +user interactions diverge from the expected or desired course. Meanwhile, +business logic or 'Flows' are used to manage 'happy paths'—scenarios 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" behavior, 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're 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. + +## Example Conversation + +[Example conversation goes here]