Cohere Fine-Tuned Large Language Models & Intent Recognition

This article considers how a custom fine-tuned Large Language Model (LLM) can be used for intent detection. And how a process of continued improvement can be followed for intelligent intent driven NLU design and development.

Cobus Greyling
4 min readDec 19, 2022

--

Recently I wrote an article on how to create a fine-tuned custom LLM making use of Cohere and HumanFirst Studio.

HumanFirst Studio is an accelerated latent space for converting unstructured data into NLU Design data.

In this article I demonstrate how the fine-tuned LLM model is used for intent detection from user utterances. I also consider how the results compare with the HumanFirst NLU.

Read more about the direct integration between HumanFirst Studio & Cohere Large Language Models here.

A fairly new addition to the Cohere interface is the Dashboard, which can be seen as a staging area. And also serves as a next step, moving from the Playground to a more production orientated environment.

In the image below you see the dashboard, where models are selected. A list of both default Cohere and custom models are displayed.

In the image below, the custom fine-tuned model is selected under “Your models” and accessed via the Cohere Playground.

Within the playground, at the top right, a list of models are shown.

You will see the addition of a new multilingual model.

Under Fine Tuned models you will see the custom banking model; the creation of this model is described here.

The user interface shows the labels (intents) in the left-hand pane. After an input utterance is entered, a user can click on classify to generate a result.

The output lists the relevant labels, with the percentage or relevance.

Performing the same test against the HumanFirst NLU, yields a more distributed result, which is in keeping with previous findings.

Read more about Analysis of the HumanFirst and Cohere integration & considering complex utterances.

Below is a code snipped illustrating how to make use of the custom fine-tuned Cohere model in python code.

# pip install cohere
# In a notebook, you will first have to intall cohere

import cohere
from cohere.classify import Example
co = cohere.Client('API Key')
response = co.classify(
model='d13388ea-7017-4a62-bcf5-7add7bb024fa-ft',
inputs=["My card is damaged and I cannot cancel a transfer"])
print('The confidence levels of the labels are: {}'.format(response.classifications))

After running the code, you will see the results below:

The confidence levels of the labels are: 

[Classification<prediction: "cancel_transfer", confidence: 0.895705>]

Finally, the cycle of continuous improvement and augmentation of the NLU Design data fed into the custom LLM is detailed below.

The ideal is to have this data pipeline automated as much as possible. And adhering to a human-in-the-loop process during the Evaluation and NLU Design phases.

For considerations on using a data pipeline approach for NLU Data engineering from a HumanFirst perspective, click here.

⭐️ Please follow me on LinkedIn for updates on Conversational AI ⭐️

I’m currently the Chief Evangelist @ HumanFirst. I explore and write about all things at the intersection of AI and language; ranging from LLMs, Chatbots, Voicebots, Development Frameworks, Data-Centric latent spaces and more.

https://www.linkedin.com/in/cobusgreyling
https://www.linkedin.com/in/cobusgreyling

--

--

Cobus Greyling
Cobus Greyling

Written by Cobus Greyling

I’m passionate about exploring the intersection of AI & language. www.cobusgreyling.com

Responses (1)