Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI & ML · Const

Zero-shot Learning

Zero-shot classification with embeddings assigns new text to the most similar candidate class without labeled training data. Embed each class name or short description, compare it with the input embedding, and choose the highest-similarity class.

How it works

Zero-shot classification uses an embedding model without labeled training examples. Represent each candidate class by its name or a short description, embed the new text and every class representation, then compare similarities and select the class with the highest score.

Syntax

client.embeddings.create(model="text-embedding-3-small", input=[...])

Key points

  • Embeddings support classification when no labeled examples are available.
  • Create one embedding for each candidate class name or concise class description.
  • Embed the incoming text and compare it against every candidate-class embedding.
  • Assign the class whose embedding has the greatest similarity to the input embedding.

Common mistakes

  • Zero-shot classification does not require labeled training data, but its quality depends on the class representations and similarity method.

Example: Embedding-based zero-shot classification

from openai import OpenAI

client = OpenAI()

response = client.embeddings.create(
    model="text-embedding-3-small",
    input=["cat", "dog", "vehicle"]
)

# Compare each input embedding with embeddings for class descriptions,
# then choose the class with the highest similarity.

This example obtains embeddings that can be compared with embeddings for candidate class descriptions; classification selects the most similar class.

When to use it

Unsupervised category assignment

Classify text into predefined categories when labeled examples are unavailable.

Intent routing

Match incoming text to candidate intents represented by short descriptions.

Semantic classification

Select the closest semantic label from a fixed list of classes.

  • Vector embeddings
  • embeddings API
  • text-embedding-3-small
  • zero-shot classification

Source: Vector embeddings | OpenAI API. Checked 2026-10-15.