input.nlu.intentMapperResults.scores[x].description object for each mapped intent, where x represents the priority of the intent.
The stored descriptions are sent to an external LLM via a prompt, which you can create in the LLM Prompt node.
The external LLM analyzes the data and generates a result based on the retrieved descriptions. This result is recorded in the input.promptResult object by default.
Once you have the correct intent, you can continue the flow based on this intent. For example, if a user requested information about a product, you can provide product descriptions, answers to frequently asked questions, and options for placing an order.
Prerequisites
- Add an external LLM that supports the LLM Prompt node and LLM-powered answer extraction features.
- Create a flow and intents in it.
Set up intent reranking
To rerank intents via an external LLM, follow these steps:Add descriptions to intents
Add descriptions to intents
To add descriptions to intents, follow these steps:
- In the navigation menu, go to Advanced > NLU.
- From the Flow list, select the flow you want to change.
- On the Intents tab, locate the intent to which you want to add a description.
- On the intent page, click
, then select Edit. - In the Edit Intent pane, go to the Description field. Enter a clear and concise description that reflects the content of the example sentences listed in the intent. Note that the Description field can contain no more than 200 characters.
- Click Save.
- Repeat steps 3–6 for other intents within the flow.
- In the upper-right corner, click Build Model.
Add an LLM prompt node
Add an LLM prompt node
To add an LLM Prompt node with the relevant prompt, follow these steps:
- In the flow editor, add an LLM Prompt node.
- In the LLM Prompt node, go to the Instructions (System Message/Prompt) field and enter the following prompt for reranking:
- Go to the Advanced section and configure the recommended parameters as follows:
- From the Sampling Method list, select Temperature and set the temperature to
0. - From the Response Format list, select JSON Object.
- From the Sampling Method list, select Temperature and set the temperature to
- (Optional) If you want the model to return a similar result for subsequent requests, specify a number in the Seed field. For example,
123. - Click Save Node.
Retrieve and reuse results
Retrieve and reuse results
By default, the correct intent will be stored in the
input.promptResult.intent object.
To retrieve this intent for further use, follow these steps:- Below the LLM Prompt node, add a Code node.
- In the Code field of the Code node, specify
input.intent = input.promptResult.intent. - Click Save Node.
- Below the Code node, add a Lookup node.
- In the Lookup node editor, configure the following fields:
- From the Type list, select Intent.
- Set the Intent Level field to Default, matching intents at the most detailed hierarchy level.
- From the Type list, select Intent.
- Click Save Node.
- Add child Case nodes of the Lookup node, specifying the intent name in the Value field for each node.
Example
In this example, a user wants to order pizza and shares their preferences. The agent recognizes if the user has ingredient restrictions and determines the correct intent.Data
Assume that we have the following intent data:Intent data
Intent data
User input
User input
Consider the example of intent reranking based on the following user input:
Result
Cognigy NLU
Cognigy NLU
After applying Cognigy NLU intent mapping, Alternatively, to view up to five probable results, you can output them via a Say node by including the prompt in the Text field.
Fallback Reject Intent
is assigned priority 1 with a score of 0.588120879379653, instead of the correct intent Veggie Pizza,
which has priority 3 with a score of 0.026957729768803257.Cognigy NLU + external LLM
Cognigy NLU + external LLM
After applying the Cognigy NLU intent mapping and external LLM reranking, the correct intent Once the agent identifies the correct intent, you can continue the flow.
For example, the agent can offer pizza options from the identified category
Veggie Pizza is identified.Veggie Pizza.