Classify text into categories not seen during training for applications like intent detection, content moderation, and dynamic classification.

Quickstart

Classify Text into Unseen Categories

Send a text input and a set of candidate labels to receive classification results.

import Bytez from "bytez.js";

const client = new Bytez("YOUR_BYTEZ_KEY_HERE");
const model = client.model("facebook/bart-large-mnli");

const input = {
  text: "One day I will see the world",
  candidate_labels: ["travel", "cooking", "dancing"]
};

const { error, output } = await model.run(input);

if (error) {
  console.error("Error:", error);
} else {
  const { sequence, labels, scores } = output;
  const labelObjects = labels.map((v, i) => ({ sequence, label: v, score: scores[i] }));
  
  labelObjects.sort((a, b) => (a.score < b.score ? 1 : -1));
  
  for (const labelObject of labelObjects) {
    console.log(labelObject);
  }
}

Demo