Skip to content

Commit

Permalink
Llm dialogue docs (#12530)
Browse files Browse the repository at this point in the history
* added dialogue docs

* Apply suggestions from code review

Co-authored-by: Maxime Vdb <m.verger@rasa.com>

* review comments

---------

Co-authored-by: Maxime Vdb <m.verger@rasa.com>
  • Loading branch information
tmbo and m-vdb committed Jun 20, 2023
1 parent af2d35e commit cb46a13
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 21 deletions.
7 changes: 3 additions & 4 deletions docs/docs/llms/large-language-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 62 in docs/docs/llms/large-language-models.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

llm-dialogue

"llm-dialogue" is a typo. Did you mean "ll-dialogue"?
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
Expand Down
84 changes: 67 additions & 17 deletions docs/docs/llms/llm-dialogue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,

Check warning on line 26 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

chatbot's

"chatbot's" is a typo. Did you mean "catboat's"?
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

Check warning on line 28 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

chatbot's

"chatbot's" is a typo. Did you mean "catboat'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

Check warning on line 46 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

chatbot's

"chatbot's" is a typo. Did you mean "catboat's"?

Check warning on line 46 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

llm-nlg

"llm-nlg" is a typo. Did you mean "ll-nlg"?
language models generate the chatbot's responses, ensuring they feel natural and

Check warning on line 47 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

chatbot's

"chatbot's" is a typo. Did you mean "catboat's"?
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

Check warning on line 77 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

LLMResponseRephraser

"LLMResponseRephraser" is a typo. Did you mean "LLMResponseRephrase"?
```
Additional configuration parameters are explained in detail in the documentation
pages for each of these components:
- [LLMFlowClassifier](./llm-flow-classifier.mdx)

Check warning on line 82 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

llm-flow-classifier

"llm-flow-classifier" is a typo. Did you mean "ll-flow-classifier"?
- [FlowPolicy](./flow-policy.mdx)
- [LLMResponseRephraser](./llm-nlg.mdx)

Check warning on line 84 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

LLMResponseRephraser

"LLMResponseRephraser" is a typo. Did you mean "LLMResponseRephrase"?

Check warning on line 84 in docs/docs/llms/llm-dialogue.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

llm-nlg

"llm-nlg" is a typo. Did you mean "ll-nlg"?
## Example Conversation
[Example conversation goes here]

0 comments on commit cb46a13

Please sign in to comment.