# Zero-shot classification: how a model understands rules written in plain words

> How can a model enforce “No spoilers” if it was never trained on that rule? Natural language inference, entailment and custom moderation rules, explained.

Source: https://www.vigimod.com/en/learn/zero-shot-classification-nli · VigiMod (https://www.vigimod.com) · updated 2026-11-11 · 7 min

## In short

- A zero-shot classifier can check categories it was never trained on, written as sentences.
- Many work with natural language inference (NLI): does this text imply that hypothesis?
- Custom moderation rules (“No selling accounts”) become hypotheses scored like any category.
- Short, concrete rules work best; vague rules give vague scores.

## The problem

A classic classifier knows only the categories it was trained on. But every community has its own rules: no spoilers, no selling accounts, only football talk, no links to other servers. Training a new model for every rule of every community is impossible.

**Zero-shot classification** solves it: the model receives the category *as a sentence* at the moment of the request, and judges whether the text matches it.

## Natural language inference (NLI)

Many zero-shot classifiers are built on a task called **natural language inference**. The model gets two texts:

- a **premise** (here: the chat message),
- a **hypothesis** (here: a rule or a category description),

and decides whether the premise **entails** the hypothesis, contradicts it or is neutral.

| Premise (message) | Hypothesis | Answer |
|---|---|---|
| “lol the dog dies at the end” | “This message reveals the plot of a film or series.” | entails |
| “anyone watched the finale?” | “This message reveals the plot of a film or series.” | does not entail |
| “selling my lvl 80 account, DM me” | “This message offers to buy or sell game accounts.” | entails |

The probability of “entails” becomes the **score** of the rule. The same mechanism handles fixed categories too: “insult” is just the hypothesis “This message insults a person”.

## Why it generalises

During training the model sees hundreds of thousands of premise–hypothesis pairs about every kind of topic. It does not learn the rules themselves: it learns **the skill of checking** whether a text matches a description. That skill transfers to rules it has never seen, in any language the model knows.

## Writing good rules

- **Concrete beats abstract.** “No buying, selling or trading accounts or items” works better than “Respect the economy”.
- **One idea per rule.** Split “No spam and no politics” into two rules.
- **Describe the behaviour, not the word list.** “Do not reveal the end of films or series” catches spoilers written in any way.
- **Test on real examples** and adjust the threshold, as for any category.

## Context helps rules too

“He dies at the end” is a spoiler only if the conversation is about a series. Zero-shot models that also read the previous messages can judge rules that depend on the chat, see [context in moderation](https://www.vigimod.com/en/learn/context-in-moderation).

## In VigiMod

Rules are sent with each request, up to 10, in any language:

`"rules": {"no-spoilers": "No spoilers about films or series"}`

Each rule returns its own score and flag (`rule:no-spoilers`), next to the built-in categories. Details in the [documentation](https://www.vigimod.com/en/docs).

## Quiz

1. What does “zero-shot” mean here?
   Answer: The model needs zero examples of a rule to check it. The rule is given as a sentence at request time, no training needed.
2. In NLI, the chat message plays the role of…
   Answer: the premise. The message is the premise; the rule is the hypothesis.
3. Which rule is likely to work best?
   Answer: “No buying, selling or trading game accounts”. Concrete rules about a behaviour give clearer scores.
4. Why can the model check a rule it never saw?
   Answer: It learned the general skill of checking whether a text matches a description. NLI training teaches matching, not specific rules.
