Skip to content

How the bot answers: stories, FAQs and RAG

A Tock bot combines two ways of answering:

  • deterministic answers: stories and FAQs, written by your teams, triggered by the intent that the NLU model detects in the user sentence;
  • generated answers: the RAG, where an LLM writes the answer from your documents.

The NLU model decides, for each sentence, which of the two applies. This lets you keep control over the sensitive or transactional journeys (a booking, a claim, a handover to a human agent), and let the LLM handle the long tail of questions covered by your documents.

Processing of a user sentence

flowchart TD
    S[User sentence] --> NLU[NLU model: intent detection]
    NLU -->|intent with a story or FAQ| ST[Story / FAQ answer]
    NLU -->|tock:ragexcluded| EX[RAG excluded story<br/>'topic not covered' answer]
    NLU -->|unknown intent, or intent without a story| R{RAG activated?}
    R -->|no| UK[Unknown story]
    R -->|yes| RAG[RAG: condensing, retrieval, answer]
    RAG --> A[Generated answer with its sources]
    RAG -.->|redirection intent| ST

For each user sentence:

  1. The NLU model detects the intent of the sentence (see Language understanding).
  2. If a story (or an FAQ) starts with this intent, it answers: the LLM is not called.
  3. If the sentence is qualified with the tock:ragexcluded intent, the bot answers with its RAG excluded story (by default: "Sorry, I can't answer your question (Topic not covered)"). See RAG exclusions.
  4. Otherwise, the sentence is unknown or its intent has no story: if the RAG is activated, the bot calls the Gen AI orchestrator, which condenses the question, retrieves the documents and generates the answer (see how the RAG works). Without RAG, the bot answers with its unknown story.

Keeping control over the generated answers

Several levers, from the lightest to the strongest, restrict what the LLM answers:

Lever Where Effect
Covered and excluded topics, business lexicon Gen AI > Rag prompt context Injected into the answering prompt: the LLM is asked to stay within the covered topics
Answering prompt Gen AI > Rag settings Rules of the LLM: answer only from the documents, refuse out-of-scope questions, resist prompt injection
Search settings and compressor Gen AI > Rag settings, Compressor settings Choose how documents are retrieved, and drop the least relevant ones before they reach the LLM
RAG exclusions Language Understanding > Inbox sentences The NLU model recognizes the excluded topics before the LLM is called
Stories and FAQs Stories & Answers A written answer, or a full journey, replaces the generated one for a given intent

Excluding topics from the RAG

A RAG exclusion qualifies a sentence with the tock:ragexcluded intent. Once the NLU model is trained with enough such sentences, similar sentences are recognized as excluded and never reach the LLM. This is safer than an instruction in the prompt, because the decision is made before the LLM is called.

Answering with a story instead of the LLM

When a question calls for a precise, validated answer, create an FAQ or a story for it: the NLU model detects its intent and the story answers instead of the RAG. To train the NLU model on a new FAQ quickly, the training sentences can be generated by an LLM.

Redirecting from the RAG to a story

The answering LLM can also hand over to a story. When its JSON answer contains a redirection_intent (see the prompt output schema), the bot sends the generated answer, then switches to the story started by this intent, for example a handover to a human agent. The intent must have a story, and cannot be unknown.

Restricting the next intents

Inside a journey, a story can restrict the intents that can be detected for the next user sentence (see Restricting the scope of intents): the sentences expected by the journey are then not sent to the RAG.

See also

  • Improving the answers: testing, diagnosing and measuring the quality of the generated answers.
  • Concepts: intents, stories, and the Gen AI vocabulary.
Chat with Tock
×