Skip to content

Commit

Permalink
added dialogue docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Jun 19, 2023
1 parent 87348ba commit 9ae48ef
Showing 1 changed file with 64 additions and 17 deletions.
81 changes: 64 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,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,

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're 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.
## Example Conversation
[Example conversation goes here]

0 comments on commit 9ae48ef

Please sign in to comment.