Version: Latest

Chat With Your Text Documents

Retrieval-augmented generation is a popular approach to quickly build a chatbot using information contained in documents.

Its main purpose is to answer a "knowledge-oriented user queries" which refer to questions or requests from users that specifically seek factual information, expertise, or domain-specific knowledge.

This guide covers the process of setting up and building a RAG Assistant with Rasa using the Enterprise Search policy.

The idea behind RAG is a two step process:

  • Use what the user said to query an information retrieval system and fetch relevant documents
  • Include the retrieved documents in an LLM prompt, asking the LLM to answer the user's question based on the information provided.
example of a prompt for rag

Here are the 3 main steps to go through in order to accomplish our goal

Create a folder called docs/

  • Collect your knowledge base/corpus in a text format and dump it into the docs folder: this will represent the source of information from which the LLM will use to fetch context to generate responses.
we have five type of cards: debit card, credit card, gift card, loyalty card and smart card.
The price of debit card is between 5 euros and 10 depends on the options you want to have.
Debit cards are directly linked to the user's bank account, allowing them to make purchases with funds available in the account.
If the borrowed amount is not paid in full by the due date, credit card users may incur interest charges on the remaining balance.
Responsible use of credit cards, such as timely payments, contributes to building a positive credit history, which can impact credit scores.
Gift cards come with a predetermined monetary value, allowing recipients to make purchases up to that amount.
Recipients have the flexibility to choose the items they want within the card's value, making them a popular choice for gifts.
Loyalty cards are designed to reward customers for their repeat business. Customers typically earn points or receive discounts based on their purchases.
Loyalty cards are often part of broader membership programs that may include additional benefits, such as early access to sales, special events, or exclusive products.
Smart cards are equipped with an embedded microprocessor or chip, differentiating them from traditional magnetic stripe cards.
The embedded chip in smart cards enhances security by storing and processing data internally. This makes them less susceptible to unauthorized access or duplication

Override the pattern_search

The pattern pattern_search defines the assistant behavior for responding to knowledge-oriented user queries.

In flows.yml, add the flow pattern_search to trigger the default action action_trigger_search. The action action_trigger_search will perform the query and call the LLM to answer the user's question.

description: handle a knowledge-based question or request
name: pattern search
- action: action_trigger_search

Add the Enterprise search policy to your config

By default Enterprise Search Policy uses OpenAI embeddings to embed documents and GPT 3.5 to respond to user queries. You can configure the policy to work with other embedding models and LLMs. Read more here

Below are the default settings:

- name: EnterpriseSearchPolicy
model_name: "gpt-3.5-turbo"
model_name: "text-embedding-ada-002"
type: "faiss"
source: "./docs"


Below is a conversation example of how we can leverage Enterprise search using the steps mentioned above.

conversation example

Advanced configuration

The previously outlined setup is designed for initial exploration of the RAG approach with Rasa. The Enterprise Search Policy currently supports Milvus and Qdrant which offer multiple deployment options from self-hosted docker to cloud deployments.

Read more here.

For example, if you want to use the Milvus vector store and embeddings from huggingface, you will have to modify your config.yml and endpoints.yml files.

To configure the EnterpriseSearchPolicy to use these components, add the following lines to your config.yml depending on the version of Rasa Pro you are using:

- name: EnterpriseSearchPolicy
type: "milvus"
type: "huggingface"
model_name: "BAAI/bge-small-en-v1.5"

And add the following to your endpoints.yml:

type: milvus
host: localhost
port: 19530
collection: rasa