LIVE · Thursday 3 December

Best Models for Text Classification: ModernBERT, SetFit, DeBERTa Zero-Shot, GPT-6 Luna or TF-IDF by Situation

The right text classifier depends on how many labeled examples you have, which languages you serve and how long your documents are. Here is how each candidate works and how to test it.

By Surya11 min read

For text classification with plenty of labeled data, fine-tune ModernBERT-base, and compare it with DeBERTa-v3 when inputs are short English text. With only a few labeled examples per class, train SetFit. With no labels, start with the zero-shot model MoritzLaurer/deberta-v3-large-zeroshot-v2.0 locally, or GPT-6 Luna when labels depend on detailed instructions. Use XLM-RoBERTa for many languages, and always run a TF-IDF linear baseline first, because the cheapest model that passes a held-out test is the one to ship.

No single model wins every workload. No published study has compared all of these candidates on one dataset with shared splits, hardware and cost accounting. The choice below therefore rests on each model's own published evidence and on a test that you run on your own data.

The amount of labeled data decides which family of model fits

Text classifiers fall into three groups, and the group that fits depends mostly on how many labeled examples you have.

  • A supervised encoder such as ModernBERT, DeBERTa-v3 or XLM-RoBERTa is fine-tuned on thousands of labeled examples. It then runs cheaply and quickly on every new document.
  • A few-shot method such as SetFit trains on a handful of examples per class. It trades some accuracy headroom for much less labeling work.
  • A zero-shot model scores text against label names that you supply. The MoritzLaurer DeBERTa models and instruction-following LLMs such as GPT-6 Luna work this way, and they need no training at all.

A fourth option works as a baseline for all three. TF-IDF features with a linear classifier, or hand-written rules, can be enough when categories follow keywords. These options also set the bar that any neural model has to beat.

The following table matches common situations to a first candidate.

Your situation Try first Also test
Many labels, high volume ModernBERT-base, fine-tuned DeBERTa-v3 for short English text
A few labels per class SetFit Few-shot MoritzLaurer model
No labels, local serving MoritzLaurer zero-shot DeBERTa-v3 Its commercial "-c" variant
Labels need long instructions GPT-6 Luna TOD as an option scorer
Many languages XLM-RoBERTa, fine-tuned bge-m3 zero-shot model
CPU only, keyword-like classes TF-IDF with a linear model Hand-written rules

The ModernBERT classification benchmark shows a fast encoder that must be fine-tuned first

ModernBERT is an encoder that Answer.AI and LightOn released on December 19, 2024. It comes in a base size of 149 million parameters and a large size of 395 million. It reads up to 8,192 tokens, which its authors describe as "over 16x larger than most existing encoders."

The base checkpoint cannot classify anything out of the box. According to the release post, ModernBERT "can only do masked word prediction" until it is fine-tuned, so you need labeled data and a standard BERT fine-tuning recipe.

ModernBERT's accuracy is close to DeBERTa-v3's rather than clearly better. The model card gives ModernBERT-base a GLUE score of 88.4 against 88.1 for DeBERTaV3-base. At the large size the order reverses, with 90.4 for ModernBERT against 91.4 for DeBERTaV3-large. The authors concede that ModernBERT "slightly lags DeBERTaV3" in natural language understanding.

Speed is the stronger reason to choose ModernBERT. The authors report that ModernBERT runs twice as fast as DeBERTa, and up to four times as fast when inputs vary in length. They also report that it uses less than a fifth of DeBERTa's memory. Their efficiency table uses an NVIDIA RTX 4090, and the post does not name the hardware behind the DeBERTa comparison.

ModernBERT was trained on English text and code, and its model card warns that other languages may perform worse. It is released under Apache 2.0.

Supervised DeBERTa-v3 remains the accuracy comparison for short English text

DeBERTa-v3-base from Microsoft has 86 million backbone parameters plus 98 million embedding parameters from a 128,000-token vocabulary. Its model card lists 90.6 accuracy on MNLI against 87.6 for RoBERTa-base. It is released under the MIT licence.

DeBERTa-v3 belongs in any fully supervised test for English, especially where documents are short. The ModernBERT authors' own numbers show that the large DeBERTa model still scores higher on GLUE. A fine-tuned DeBERTa-v3 will cost more to serve than ModernBERT, according to the ModernBERT authors' speed and memory figures. It is worth choosing only if your held-out test shows a quality gain that matters.

SetFit few-shot classification needs only a handful of labeled examples

SetFit is a training method, not a single model. Lewis Tunstall, Nils Reimers and colleagues described it in a paper submitted on September 22, 2022. It first fine-tunes a Sentence Transformer on pairs of labeled examples, so that texts with the same label move closer together. It then trains a small classification head on the resulting embeddings.

The method needs no prompts and no large generative model. According to the project's README, SetFit with only 8 labeled examples per class on the Customer Reviews sentiment dataset is competitive with fine-tuning RoBERTa Large on the full training set of 3,000 examples. The authors report that training runs an order of magnitude faster than prompt-based few-shot methods.

SetFit works with any Sentence Transformer on the Hugging Face Hub. That means you can pick a multilingual embedding model when your text is not in English. It also supports multilabel prediction through a multi_target_strategy setting with "one-vs-rest", "multi-output" and "classifier-chain" options. The library is released under Apache 2.0.

MoritzLaurer DeBERTa-v3 zero-shot classification works without training data

The model MoritzLaurer/deberta-v3-large-zeroshot-v2.0 turns classification into a yes-or-no question. It checks whether a statement such as "This text is about politics" is true for the text, and it repeats that check for each label that you supply.

According to its model card, the model averages 0.673 macro-F1 across 28 datasets with no training data from those datasets. The same table gives 0.497 for facebook/bart-large-mnli. With up to 500 training examples per class, the model's score rises to 0.846. Those figures are dated April 3, 2024.

The licensing detail matters for commercial use. Models with "-c" in the name were trained only on commercially friendly data. The variant without "-c" adds datasets under a broader mix of licences. The "-c" version of this model scores 0.676, so choosing it costs nothing in average accuracy.

The model reads up to 512 tokens, and the card warns that longer inputs are slower and can reduce performance. Results also change with the wording of the hypothesis template and the label names. The card suggests testing several phrasings, much as you would test prompts. For non-English text it recommends the bge-m3 variant or machine translation to English.

GPT classification with GPT-6 Luna suits labels that depend on detailed instructions

An instruction-following LLM becomes the right first try when the label rules are long, full of exceptions or likely to change weekly. You write the rules in a prompt instead of relabeling data.

OpenAI describes GPT-6 Luna as "our most efficient model for focused, high-volume tasks," and its model guidance lists classification among the examples. That positioning makes Luna a reasonable candidate. It does not show that Luna beats a fine-tuned encoder on your data.

Luna costs $0.10 per million input tokens, $0.01 per million cached input tokens and $0.50 per million output tokens, according to its model page. Batch requests cost half. The model supports structured outputs, which help constrain answers to a fixed label set. It does not support fine-tuning.

Versioning is a real concern for a production classifier. The model page lists only one snapshot, gpt-6-luna, rather than a dated version that you can pin. A classifier built on it should be re-tested on a held-out set whenever OpenAI updates the model.

The scikit-learn sparse-feature benchmark shows why a linear baseline comes first

The scikit-learn documentation includes an executable benchmark on four categories of the 20 newsgroups dataset. It trains eight classifiers on TF-IDF features from 2,034 training documents and tests them on 1,353.

The results show how much a simple model can do on topic-style categories. Complement naive Bayes reached 0.779 accuracy, and logistic regression reached 0.772. Logistic regression trained in 0.174 seconds, and linear SVC trained in 0.0298 seconds. The documentation explains that linear models suit text because most problems "become linearly separable" once the feature space has 10,000 or more dimensions.

These numbers come from one small dataset, so they are not a ranking of TF-IDF against transformers. They do show why a sparse baseline is cheap enough to run first on every project. If it already meets your quality bar, a neural model adds serving cost without a measured gain. Hand-written rules play the same role when categories follow fixed keywords or codes.

FacebookAI XLM-RoBERTa multilingual classification covers 100 languages

XLM-RoBERTa is the multilingual encoder in this group. Alexis Conneau and colleagues trained it on more than two terabytes of filtered CommonCrawl text in 100 languages, in a paper submitted on November 5, 2019.

The authors report gains of 14.6 points of average accuracy over multilingual BERT on the XNLI benchmark. They also report large gains for lower-resource languages, such as 15.7 points of XNLI accuracy for Swahili over earlier XLM models. The base model card lists 0.3 billion parameters and an MIT licence, and it states that the model is "mostly intended to be fine-tuned on a downstream task."

Average gains across languages can hide weak spots. Evaluate each target language on its own held-out set before relying on a multilingual model for that language.

TOD scores a supplied list of labels, but no independent test against these classifiers has been published

Parsec's TOD picks from a supplied list of options instead of generating an answer. Parsec calls it a "universal decision model." It generates no free text, so only input is billed. The release consists of LoRA adapters on google/gemma-4-12B-it plus a ModernBERT-base retriever. The adapters are Apache-2.0, while the base model remains under the Gemma 4 terms that users must accept.

Classification maps onto TOD's interface directly. The document becomes the state, the question becomes "Which category fits this text?", and the label names become the options. The predict function returns one probability per option, and the probabilities sum to 1. That makes it a single-label selector, and Parsec's TOD pages do not mention multilabel use. A score is a choice among labels, not an action, so anything downstream needs its own checks.

Parsec lists TOD at $0.30 per 1,000 decisions, flat regardless of context length. Its repo says that TOD was measured with up to 300 options. These are Parsec's own figures. Parsec's published TOD results come from its own decision and option-ranking benchmarks, and no independent test of TOD against the classifiers in this guide has been published. Its own release evaluation of September 29, 2026 shows TOD scoring below its untrained base model on one public decision benchmark, a regression that Parsec says the next release will fix. The TOD release is also separate from Parsec's open-jev code, which uses a local Gemma 3 4B. Parsec says it tunes decision models on a customer's own decisions, but it publishes no price for that work. Customizing TOD, or any model, is worth it only if a held-out test shows a gain over a ready-made classifier, a prompt or rules.

A prompted model costs less per 1,000 documents than an always-on endpoint at low volume

Serving cost depends on volume, and the crossover points can be calculated from list prices. Assume 1 million documents a month, each with 400 tokens of text, a 300-token label prompt and a 10-token answer. Assume also that Luna's reasoning effort is set to none, which its model page lists as an option, and ignore cache-write charges.

  • Luna without caching costs $70 for 700 million input tokens plus $5 for output, or $75 a month. That is $0.075 per 1,000 documents.
  • Luna with the label prompt cached costs $3 plus $40 plus $5, or $48 a month. That is $0.048 per 1,000 documents.
  • TOD costs $300 a month at $0.30 per 1,000 decisions, before any cases that pass to a fallback model.
  • A fine-tuned encoder on an always-on Hugging Face Inference Endpoint costs $96 a month on a 4-vCPU CPU instance or $576 a month on one NVIDIA L4 GPU.

At these prices, one L4 instance costs the same as uncached Luna at about 7.7 million documents a month. The CPU instance breaks even at about 1.3 million. Whether one instance can carry that traffic for each encoder has not been measured. TOD's flat fee is cheaper than uncached Luna input only for documents longer than about 3,000 tokens.

A held-out test on your own data settles the choice

No public comparison covers every candidate on one workload, so the decision has to come from a test on your own data. The test is only useful if it separates zero-shot, few-shot and fully supervised results, because those use very different amounts of labeled data.

The following steps make the comparison fair and repeatable.

  1. Split your labeled data into training, validation and held-out test sets, fix the random seeds, and record the label budget for each method.
  2. Run the TF-IDF linear baseline first, then each neural candidate on the same held-out set.
  3. Report macro-F1 and per-class precision and recall, so that small classes are not hidden by an average.
  4. Measure p50 and p95 latency, throughput and cost per 1,000 documents on named hardware, precision and batch size.
  5. Check calibration separately from accuracy. scikit-learn defines a well-calibrated classifier as one where, among texts given a probability near 0.8, about 80% belong to the class. Fit any calibrator on data that was not used for training.
  6. Measure coverage at a fixed error rate. Selective classification, described by Geifman and El-Yaniv in 2017, lets a model abstain on uncertain cases so that the rest meet a target error.
  7. Test label-description wording for zero-shot models and prompts, class imbalance, short and long documents, and each language on its own.
  8. For multilabel tasks, tune a threshold for each label on the validation set, not on the test set.

Publish the prompts, training settings and evaluation code with the results, so that the comparison can be re-run when a model changes. Pick the cheapest candidate that meets your quality bar on the held-out set, and keep the baseline in the report so the gain stays visible.

Sources

More in Models

All Models →