Skip to content

Co.Classify (Cohere) v1.0.0 Help

Classifies text based on provided examples using Cohere API.

How can I use the Step?

You can use the Step to predict which label best fits the specified text inputs. This can be useful in various scenarios where text classification is required.

For more insights, explore the Text Classification guide.

How does the Step work?

You input text to classify, provide text-label pairs for reference, and set up additional parameters if necessary. The Step requests the Co.Classify endpoint using the provided inputs and returns the classification result.

Prerequisites

  • To use this Step, you need a Cohere API Key. To get one, sign up Cohere and then visit the API Keys page.

Authorization

To authorize the Step, you have two options:

  • Inherit from previous Step (default): Uses the authorization from the previous Step in your Flow.
  • Select authorization in the current Step: Lets you pick an existing authorization or create a new one.

Creating a new authorization

To create a new authorization, follow these steps:

  1. Choose Select authorization in the current Step and then select the Create a new authorization option from the list.
  2. In the Add authorization modal window, provide the required details:
    • For Authorization name, specify the name of your new authorization.
    • For API Key, enter your Cohere API key.
  3. Click Add to complete the setup and return to the main window. Now, you can find your new authorization in the authorization list.

Cohere settings

The settings in this section reflect the body parameters of the Co.Classify endpoint, which you must use as your primary reference:

  • Inputs: An array of strings, each representing a query for classification. Limit: 96 queries.
  • Examples: An array of objects that give context to the model. Each object contains a text string and its corresponding label or class. Each unique label needs at least two examples. Limit: 2500 examples, each up to 512 tokens. Format the values as {"text": "...", "label": "..."}.
  • Model: Model identifier (defaults to embed-english-v2.0). Smaller "light" models run faster, while larger models offer better performance.
  • Truncate: One of NONE|START|END to determine how the API trims inputs exceeding the maximum token length. START removes the beginning, and END removes the end of the input until it fits the model's maximum token length. Selecting NONE returns an error for inputs that exceed the limit.

Output example

The following output example illustrates the structure of the classification results returned by the Step:

json
{
  "id": "ca245541-8841-456e-b306-293370789a30",
  "classifications": [
    {
      "id": "c50ab0d9-95d8-44de-ba90-9647a1718744",
      "input": "Confirm your email address",
      "prediction": "Not spam",
      "confidence": 0.7581943,
      "labels": {
        "Not spam": {
          "confidence": 0.7581943
        },
        "Spam": {
          "confidence": 0.24180566
        }
      }
    },
    {
      "id": "8a841de2-027f-49d4-8c91-e88fa1865b89",
      "input": "hey i need u to send some $",
      "prediction": "Spam",
      "confidence": 0.9965721,
      "labels": {
        "Not spam": {
          "confidence": 0.0034279241
        },
        "Spam": {
          "confidence": 0.9965721
        }
      }
    }
  ],
  "meta": [
    {
      "api_version": [
        {
          "version": "1"
        }
      ]
    }
  ]
}
{
  "id": "ca245541-8841-456e-b306-293370789a30",
  "classifications": [
    {
      "id": "c50ab0d9-95d8-44de-ba90-9647a1718744",
      "input": "Confirm your email address",
      "prediction": "Not spam",
      "confidence": 0.7581943,
      "labels": {
        "Not spam": {
          "confidence": 0.7581943
        },
        "Spam": {
          "confidence": 0.24180566
        }
      }
    },
    {
      "id": "8a841de2-027f-49d4-8c91-e88fa1865b89",
      "input": "hey i need u to send some $",
      "prediction": "Spam",
      "confidence": 0.9965721,
      "labels": {
        "Not spam": {
          "confidence": 0.0034279241
        },
        "Spam": {
          "confidence": 0.9965721
        }
      }
    }
  ],
  "meta": [
    {
      "api_version": [
        {
          "version": "1"
        }
      ]
    }
  ]
}

Service dependencies

  • flow builder - v2.28.3
  • event-manager - v2.3.0
  • deployer - v2.6.0
  • library v2.11.3
  • studio v2.64.1

Release notes

v1.0.0

  • Initial release