Skip to main content
Glama

HuggingFace — Zero-shot Text Classification

hf_inference.nlp.zero_shot
Read-onlyIdempotent

Classify text into any custom set of categories without requiring model fine-tuning or training data. Provide a list of 2–20 candidate labels; the model determines which best describes the input text. Returns labels ranked by confidence score. Supports multi-label mode (text can match multiple categories). Default model: facebook/bart-large-mnli. Ideal for routing, content moderation, intent detection, and ad-hoc categorization tasks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesInput text to process. Maximum ~10,000 characters depending on model context window.
modelNoHuggingFace model ID to use for zero-shot classification. Default: "facebook/bart-large-mnli" (MNLI-trained, accurate but slower). Alternatives: "cross-encoder/nli-deberta-v3-small" (lighter and faster).
multi_labelNoIf true, scores are independent for each label (text can match multiple categories simultaneously). If false (default), scores are mutually exclusive and sum to 1 (single best category).
candidate_labelsYesList of candidate category labels to classify the text into (2–20 labels). Example: ["politics", "sports", "technology", "entertainment"]. Labels can be any descriptive phrases — the model performs inference without prior training on these labels.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorNoPresent only when the call failed. Includes error code, message, request_id, and any provider-specific extras.
resultNoTool response payload. Shape varies per tool — consult the tool description and inputSchema. May be an object, array, string, or number depending on the upstream provider response.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, openWorldHint=true, and destructiveHint=false, so the safety profile is covered. The description adds meaningful behavioral context beyond this: returns labels ranked by confidence, supports multi-label mode where text can match multiple categories, and names the default model (facebook/bart-large-mnli). No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four sentences with zero filler. Purpose, key constraints, output behavior, default model, and ideal use cases each get one focused sentence, with the most important differentiating information front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a moderate-complexity classification tool with an output schema and thorough annotations, the description is complete: it states the core operation, label constraints, output ranking, multi-label option, default model, and representative use cases. The 10,000-character text limit is covered in the schema, and the output schema covers return structure, so nothing critical is missing for an agent to select and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds a few high-level hints (2–20 labels, multi-label behavior, default model), but these largely duplicate what the schema already states in detail, such as candidate_labels 'can be any descriptive phrases' and multi_label semantics. The description does not significantly compensate beyond the schema, so 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Classify text into any custom set of categories without requiring model fine-tuning or training data.' It clearly distinguishes zero-shot classification from the sibling NLP tools (sentiment, NER, summarize, translate) by emphasizing arbitrary/custom labels and no training data, leaving no ambiguity about what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit use cases ('Ideal for routing, content moderation, intent detection, and ad-hoc categorization tasks'), which conveys when to reach for this tool. It does not explicitly name sibling tools as alternatives or state when NOT to use it, but the custom-label / no-training framing implicitly distinguishes it from sentiment or NER. This is clear context without formal exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.