Classification is now available

Classification is now available
Classify text into any label with just 5 examples per label

Classification is now available on the Cohere Platform through our new endpoint co.classify(). The new endpoint enables classification of information with little data for any text-to-label task. Use it to classify intent from customer queries for a chatbot, detect spam, or determine the sentiment of headlines.

Below is an overview of what's new:

Classification Playground

We designed a new Playground experience for users to test out the Classification endpoint without finetuning. Browse through some sample presets for sentiment and intent classification, or build your own by providing 5 examples for each custom label in the Examples section.

Once you've set up the model, enter some text to classify in the Inputs section and click Classify to see how our model performs.

Clicking Classify gives you predictions and confidence scores for each input

Classification endpoint

Click Export Code in the Classification Playground to get a code snippet you can hit our API with. Note that you will need to provide a minimum of 5 example texts per label unless using a finetuned model.

Clicking Export Code gives you code to classify a list of texts.

Copy the code snippet below to get the sentiment of a product review, "This item broke after 3 weeks":

    const cohere = require('cohere-ai');
    (async () => {
      const response = await cohere.classify('medium', {
        inputs: ["This item broke after 3 weeks"],
        examples: [{"text": "The order came 5 days early", "label": "positive"}, {"text": "The item exceeded my expectations", "label": "positive"}, {"text": "I ordered more for my friends", "label": "positive"}, {"text": "I would buy this again", "label": "positive"}, {"text": "I would recommend this to others", "label": "positive"}, {"text": "The package was damaged", "label": "negative"}, {"text": "The order is 5 days late", "label": "negative"}, {"text": "The order was incorrect", "label": "negative"}, {"text": "I want to return my item", "label": "negative"}, {"text": "The item\'s material feels low quality", "label": "negative"}]
      console.log(`The confidence levels of the labels are ${response.body.classifications}`);

    import cohere
    from cohere.classify import Example
    co = cohere.Client('{apiKey}')
    classifications = co.classify(
      inputs=["This item broke after 3 weeks"],
      examples=[Example("The order came 5 days early", "positive"), Example("The item exceeded my expectations", "positive"), Example("I ordered more for my friends", "positive"), Example("I would buy this again", "positive"), Example("I would recommend this to others", "positive"), Example("The package was damaged", "negative"), Example("The order is 5 days late", "negative"), Example("The order was incorrect", "negative"), Example("I want to return my item", "negative"), Example("The item\'s material feels low quality", "negative")])
    print('The confidence levels of the labels are: {}'.format(

    co model classify medium "This item broke after 3 weeks" --examples="The order came 5 days early"="positive","The item exceeded my expectations"="positive","I ordered more for my friends"="positive","I would buy this again"="positive","I would recommend this to others"="positive","The package was damaged"="negative","The order is 5 days late"="negative","The order was incorrect"="negative","I want to return my item"="negative","The item'\''s material feels low quality"="negative"

Finetune a Classifier

Our finetuned representation models now come with metrics such as Accuracy, F1, Precision, and Recall so you are able to evaluate us against your internal models and competitors. Simply go to your Cohere dashboard, click Create Finetune, select a representation finetune, and upload a dataset with a minimum of 250 labelled examples to get started. Take a look at this step-by-step guide to finetuning a representation model for more guidance.

After creating a finetune, click on the model to see accuracy metrics

Classification Pricing

Classifications will cost $5 per 1000 text classified across the platform, regardless of model size (small, medium, large, xlarge) or usage of a finetuned model.

Share what you're building on our co:mmunity forum or shoot us an email.