Introducing Command R+: Our new, most powerful model in the Command R family.

Learn More

classify

Discover insights and patterns in your text

Classify organizes information for more effective content moderation, analysis, and chatbot experiences.

Code sample that runs the Cohere API classify endpoint with only a few lines
Using Cohere in a customer success dashboard to categorize customer questions

What's possible with Classify

Featured image for article

Customer support tagging

Save time by tasking Classify to tag inbound customer support requests so they can reach their respective teams faster.
Featured image for article

Sentiment analysis

Get to know your customers better by identifying positive and negative social media posts and reviews.
Featured image for article

Content moderation

Use Classify to identify hate speech, abusive language, spam, profanity, or anything that meets user-provided filters.

Classify text with just a few examples

No matter your level of experience with ML/AI, the Cohere Platform makes it easy to classify text in your applications.

1import cohere
2from cohere.responses.classify import Example
3co = cohere.Client('{apiKey}')
4response = co.classify(
5  model='embed-english-v2.0',
6  inputs=["This item was broken when it arrived", "This item broke after 3 weeks"],
7  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")])
8print('The confidence levels of the labels are: {}'.format(response.classifications))
1{
2   "classifications":[
3      {
4         "input":"This item was broken when it arrived",
5         "prediction":"negative",
6         "confidence":0.9956072,
7         "confidences":[
8            {
9               "option":"positive",
10               "confidence":0.0043928297
11            },
12            {
13               "option":"negative",
14               "confidence":0.9956072
15            }
16         ],
17         "labels":{
18            "negative":{
19               "confidence":0.9956072
20            },
21            "positive":{
22               "confidence":0.0043928297
23            }
24         }
25      },
26      {
27         "input":"This item broke after 3 weeks",
28         "prediction":"negative",
29         "confidence":0.9345512,
30         "confidences":[
31            {
32               "option":"positive",
33               "confidence":0.06544881
34            },
35            {
36               "option":"negative",
37               "confidence":0.9345512
38            }
39         ],
40         "labels":{
41            "negative":{
42               "confidence":0.9345512
43            },
44            "positive":{
45               "confidence":0.06544881
46            }
47         }
48      }
49   ]
50}

Why Classify

1

Integrate large language models into your builds

Our API can be used in different libraries that fit every stack. We make it easy to build machine learning into your apps with our SDKs. Our API allows you to leverage classifiers on top of large language models without the need for additional training or hosting.


2

Multiple platform support

Cohere works with all common languages through native SDK support or encapsulated REST calls.

3

World-class models

Our large language models have been trained on billions of words, allowing them to understand nuance and context.

Classify resources

Featured image for article
Featured image for article
Featured image for article

No need to know ML or AI — try Cohere now!

Background image for aesthetic purposes

Get started with Cohere today!

Reach out to us and let’s discuss your text classification needs.