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 can be made via 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 intent.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 & LLM-powered Answer Extraction features.
- Create a Flow and Intents in it.
How to Set up
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 left-side menu of the Project, go to Build > Flows.
- On the Flows page, select the Flow you want to change.
- In the upper-right corner, select NLU.
- On the Intents tab, locate the Intent to which you want to add a description.
- On the Intent page, in the upper-right corner, click
> Edit.
- In the Edit Intent window, 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 6–9 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 Instruction (System Message/Prompt) field and enter the following prompt for reranking:
- Navigate 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 the similar result for the subsequent requests, specify a number in the Seed parameter. 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 AI 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
Consider the example of Intent reranking based on the following user input:
User Input
User Input
Result
Cognigy NLU
Cognigy NLU
After applying Cognigy NLU Intent mapping, Alternatively, to view up to 5 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 AI Agent identifies the correct Intent, you can continue the Flow.
For example, the AI Agent can offer pizza options from the identified category
Veggie Pizza is identified.Veggie Pizza.