Best Small Model for CPU Text Classification in 2026: SetFit, MiniLM, DistilBERT or ModernBERT?
For few labels, SetFit on all-MiniLM-L6-v2. For high volume, a fine-tuned six-layer encoder exported to ONNX int8. ModernBERT is the accuracy pick, but its CPU speed has not been measured.
The best small model for CPU text classification in 2026 depends on how many labelled examples you have. With roughly 8 to 64 examples per class, use SetFit on all-MiniLM-L6-v2, a 22.7-million-parameter sentence-transformers model that trains on a CPU in minutes. With thousands of examples and a tight latency budget, fine-tune a six-layer encoder such as MiniLM-L6 or DistilBERT and export it to ONNX int8. ModernBERT-base and DeBERTa-v3-base are the choices when accuracy matters more than speed, although nobody has published a controlled CPU latency comparison of them against DistilBERT.
The cheapest working answer starts with a TF-IDF baseline
A TF-IDF vectorizer feeding a logistic regression should be the first model that you train, because it sets the bar that every neural model must clear. It counts weighted word occurrences and fits a linear classifier on them, so it needs no GPU, no tokenizer download and almost no memory.
The scikit-learn documentation shows what this baseline can do on a small topic task. On four newsgroup categories, with 2,034 training documents and the headers removed, TF-IDF plus logistic regression reached 0.772 accuracy. It trained in 0.174 seconds and scored the 1,353 test documents in under a millisecond in total. Complement naive Bayes reached 0.779 on the same data.
That speed matters for two reasons. If your labels follow keywords, such as topic routing or spam filtering, the baseline may be good enough on its own. If your labels depend on meaning, such as intent or tone, the baseline is still useful as the first stage of a cascade that sends only uncertain cases to a stronger model.
SetFit wins when you have only a handful of labelled examples per class
SetFit is a two-step method from Hugging Face, Intel Labs and the UKP Lab. It first fine-tunes a sentence-embedding model on pairs of your labelled examples, so that texts with the same label end up close together. It then trains a small classification head on those embeddings. No prompts are involved, and Hugging Face's announcement says that training on a CPU takes "just a few minutes."
The SetFit paper measured how far ahead this puts you when labels are scarce. It compared SetFit on paraphrase-mpnet-base-v2, a 110-million-parameter model, against standard fine-tuning across six test datasets. With 8 labelled examples per class, SetFit averaged 62.3 against 43.0 for standard fine-tuning. With 64 examples per class, it averaged 75.3 against 69.7.
The gap shrinks quickly. At 8 examples per class, SetFit led by 19.3 points on average, and at 64 examples the lead fell to 5.6 points. Full fine-tuning on all available data scored 84.8. The paper did not test 500 or 5,000 examples per class, so the exact point at which full fine-tuning overtakes SetFit has not been measured. On the paper's numbers, it lies somewhere above 64 examples per class.
These results used an MPNet base model rather than MiniLM-L6. The paper's smallest variant, a 15-million-parameter MiniLM-L3 trained by distillation, scored 60.3 against 62.3 for the MPNet version. A smaller base model, in other words, gives up a few points in exchange for speed.
If you start a SetFit project today, use the current API. The v1.0.0 migration guide says to "replace all uses of SetFitTrainer with Trainer" and to move settings such as num_epochs and batch_size into a TrainingArguments object. Many older tutorials still use SetFitTrainer. SetFit v1.2.0, released on September 4, 2026, supports transformers v5 and Sentence Transformers v6, and its release notes say that ONNX and OpenVINO exports work again with recent dependencies.
A fine-tuned six-layer encoder is the speed pick once you have thousands of labels
Encoders are cheaper than generative models for classification because they read the input once and produce a label in a single pass. On a CPU, the cost of that pass grows with the number of layers, the width of each layer and the length of the input. That is why the layer count in each model's configuration is a useful first guide to CPU speed.
| Model | Parameters | Layers | Longest input |
|---|---|---|---|
all-MiniLM-L6-v2 |
22.7M | 6 | 256 word pieces by default |
distilbert-base-uncased |
67M | 6 | 512 tokens |
deberta-v3-base |
86M plus 98M in embeddings | 12 | 512 tokens |
ModernBERT-base |
149M | 22 | 8,192 tokens |
Qwen3-0.6B |
0.6B | 28 | 32,768 tokens |
MiniLM-L6 and DistilBERT both have six layers, but MiniLM-L6 uses a hidden size of 384 against DistilBERT's 768. DistilBERT's own paper describes it as 40% smaller and 60% faster than BERT while keeping 97% of BERT's language understanding. For high-volume work under a strict latency target, either model fine-tuned on your full labelled set is the sensible starting point.
One limit decides between them for long inputs. The all-MiniLM-L6-v2 model card says that input longer than 256 word pieces is truncated by default. If your documents are longer than that and the label depends on the later text, DistilBERT's 512-token limit or ModernBERT's 8,192-token limit becomes the deciding factor.
ONNX int8 export typically cuts CPU latency by about two and a half to three and a half times
Exporting a model to ONNX Runtime or OpenVINO and storing its weights as 8-bit integers makes it run faster on a CPU with a small loss of accuracy. The published measurements are narrow, but they agree on direction.
The clearest result comes from a Hugging Face and Intel post from April 3, 2024. A SetFit model on bge-small-en-v1.5, fine-tuned on SST-2 sentiment data, ran at 15.69 milliseconds per request in PyTorch fp32 on an Intel Xeon. After static int8 quantization it ran at 4.55 milliseconds, about 3.45 times faster. Accuracy moved from 88.4% to 88.1%, and the model shrank from 127 MB to 45 MB. The post does not name the exact Xeon model.
The Sentence Transformers v3.2.0 release notes, from October 10, 2024, give a broader average across four models and three datasets. For CPU they say "you can expect ~2.5x speedup at a cost of 0.4% accuracy" with the recommended setup. The library's current efficiency guide adds that OpenVINO int8 was fastest on an Intel i7-13700K, while a different backend led on a cloud instance. Its advice is plain: "It's worth testing backends on your deployment hardware."
Two cautions apply. The ONNX Runtime documentation says that "quantization is not a loss-less transformation" and that older CPUs without the right instructions can run int8 models more slowly than fp32. It recommends dynamic quantization for transformer models, which needs no calibration data. The all-MiniLM-L6-v2 repository already ships int8 ONNX files for AVX2, AVX-512 with VNNI and Arm64, and the ModernBERT-base repository ships an int8 ONNX file. The fp32-to-int8 speedup and accuracy loss for ModernBERT and DeBERTa-v3 on CPU have not been measured.
ModernBERT is the accuracy pick, but its speed claims come from a GPU
ModernBERT-base, released by Answer.AI and LightOn on December 19, 2024, is the newest serious candidate. It has 149 million parameters, was trained on 2 trillion tokens and accepts inputs of up to 8,192 tokens. Its announcement calls it "the first base-size model to beat DeBERTaV3 on GLUE" and says that it runs twice as fast as DeBERTa.
Those speed figures were measured on an NVIDIA RTX 4090, not on a CPU. Part of ModernBERT's speed comes from skipping padding tokens, and the Transformers documentation says that padding-free inference "requires flash_attention_2." On a CPU, the model still runs 22 layers against DistilBERT's six. The CPU latency of ModernBERT against DistilBERT at the same input length has not been measured, so test it on your own hardware before you commit.
ModernBERT also needs fine-tuning before it can classify anything, because the base model only predicts masked words. An industrial study from the University of Luxembourg, published in May 2025, is a reminder that a newer encoder is not automatically better on every domain. Fine-tuned ModernBERT-base scored 0.810 on a long-document dataset but 0.333 on a three-label legal dataset and 0.514 on mixed-language insurance emails. The authors linked the weak scores to the model's limited exposure to those domains and languages.
DeBERTa-v3-base remains a strong accuracy option with 12 layers. Its model card reports 90.6 on MNLI against 87.6 for RoBERTa-base. Its 128,000-token vocabulary adds 98 million embedding parameters, which raises memory use more than compute.
A small generative model is only worth it after you fine-tune it
A model such as Qwen3-0.6B can classify text by writing the label as output, but that approach costs more per prediction. It has 28 layers, generates tokens one at a time and ships with a thinking mode switched on by default, which produces extra output before the answer.
The Luxembourg study measured what happens without fine-tuning. Prompting Llama-3.2-1B scored 0.330 on the three-label legal dataset, which the authors describe as "roughly at the level of random guessing." After prefix tuning, the same 1-billion-parameter model reached 0.999 on that dataset and 0.892 on the long-document set. The study ran on GPUs, and the CPU latency of a sub-1B generative classifier has not been measured against the encoders above. Unless you need to add new labels without retraining, a fine-tuned encoder is the cheaper choice.
Five common situations each point to a different starting model
Each of the following situations points to a different starting model.
- If you have fewer than about 64 labelled examples per class, train SetFit on
all-MiniLM-L6-v2with the v1.xTrainerAPI, then export it to ONNX int8. - If you need high volume at low latency and have thousands of labels, fine-tune MiniLM-L6 or DistilBERT and serve it through ONNX Runtime or OpenVINO int8.
- If accuracy comes first and you can accept slower CPU inference, fine-tune ModernBERT-base or DeBERTa-v3-base and measure both on your own hardware.
- If your documents run past 256 word pieces, avoid the default MiniLM truncation and use DistilBERT, or ModernBERT for very long inputs.
- If you have many classes, changing labels or images, use a hosted decision model behind a calibrated local model, rather than retraining every week.
Calibrated confidence lets the cheap model handle the easy cases
A classifier is calibrated when its confidence matches its accuracy, so that predictions made at 90% confidence are right about 90% of the time. Calibration is what makes a cascade safe. If the cheap model's confidence can be trusted, you can let it answer confident cases and send uncertain ones to a stronger model or a person.
Neural classifiers often fail this test out of the box. Guo and colleagues reported in 2017 that modern neural networks are "poorly calibrated," measured with expected calibration error, or ECE. ECE sorts predictions into confidence bins and averages the gap between confidence and accuracy. On the 20 Newsgroups text task their model's ECE was 8.02%, and temperature scaling cut it to 4.11%. On binary SST sentiment, ECE fell from 6.63% to 1.84%.
Logistic regression is usually better calibrated. The scikit-learn documentation says that it "is more likely to return well calibrated predictions by itself." For any other model, scikit-learn's CalibratedClassifierCV can fit a sigmoid or isotonic correction, and its documentation says that isotonic calibration does as well or better once you have more than about 1,000 samples. Fit the calibrator on data that the classifier never trained on.
The ECE of SetFit, DistilBERT and ModernBERT classifiers on standard CPU benchmarks has not been published. The share of traffic that a calibrated cheap model can handle depends on your data and your threshold. You find it by sweeping the confidence threshold on a held-out set and recording, at each value, the accuracy of accepted cases and the share that is deferred.
A hosted decision model is the fallback when your own model is unsure
The FrugalGPT paper, published in May 2023, formalised the idea of a cascade for language models. It sends each input to cheaper models first and escalates only when needed, and it reported matching GPT-4 with up to 98% lower cost. For CPU classification, the natural cascade is TF-IDF first, then a small encoder, then a hosted model for the remainder.
OpenAI's Decisions API is one option for that last stage. It returns a probability, a choice from a fixed set or a score, charges $0.10 per million uncached input tokens and does not charge for output. Its guide advises that you "choose thresholds based on the cost of false positives and false negatives."
Parsec's TOD is another hosted option for teams whose choices come from a fixed list of allowed actions. According to Parsec's TOD page, it ranks the options, generates no free text and costs $0.30 per 1,000 decisions regardless of context length. Its published latency figures are for data-centre GPUs, and Parsec does not describe a CPU version. A hosted model makes sense when the labels change often, when inputs include images, or when you do not have labelled data to fine-tune your own model.
A worked example prices 10 million predictions a month
Take a workload of 10 million classifications a month. Assume that each item has about 150 tokens of text and that a hosted API also needs about 150 tokens of label instructions, for 300 input tokens per call. A 30-day month has 2,592,000 seconds, so the average load is about 3.9 predictions per second.
| Option | Assumption | Monthly cost |
|---|---|---|
| Two CPU servers running an int8 encoder | Hetzner CCX23, 4 dedicated vCPU, US East, two for redundancy | €175.98 excluding VAT |
| OpenAI Decisions API for every item | 3 billion input tokens at $0.10 per million | $300, before cache discounts |
| CPU servers plus 10% deferred to the Decisions API | 300 million deferred input tokens | €175.98 plus $30 |
Hetzner lists the CCX23 at €87.99 a month in its US East location, and the servers cost the same at any volume that they can carry. Whether one four-core server keeps up with your peak load has not been measured. If the 4.55 milliseconds per request from the Intel post carried over, one core would handle about 220 requests per second. That figure came from a different Xeon and a different model, so treat it as an estimate until you test. The 10% deferred share is an assumption, and the real share depends on the threshold that you set on held-out data.
Testing two candidates on your own CPU takes about a day
Before you commit, run your top two candidates on the CPU that you will deploy on. Fix the thread count, record the library versions, and measure median and 95th-percentile latency at 64, 256 and 512 tokens, in fp32 and int8. Then record accuracy, macro F1 and ECE on a held-out set. No public harness that covers all of these models on one CPU has been published, so this one-day test is the only reliable comparison available.
Sources
- Hugging Face, SetFit: Efficient Few-Shot Learning Without Prompts: https://huggingface.co/blog/setfit
- Tunstall et al., Efficient Few-Shot Learning Without Prompts: https://arxiv.org/pdf/2209.11055
- SetFit documentation: https://huggingface.co/docs/setfit/main/en/index
- SetFit v1.0.0 migration guide: https://huggingface.co/docs/setfit/main/en/how_to/v1.0.0_migration_guide
- SetFit v1.2.0 release notes: https://github.com/huggingface/setfit/releases/tag/v1.2.0
- Hugging Face, Blazing Fast SetFit Inference with Optimum Intel on Xeon: https://huggingface.co/blog/setfit-optimum-intel
- Sentence Transformers v3.2.0 release notes: https://github.com/huggingface/sentence-transformers/releases/tag/v3.2.0
- Sentence Transformers, Speeding up inference: https://sbert.net/docs/sentence_transformer/usage/efficiency.html
- ONNX Runtime, Quantize ONNX models: https://onnxruntime.ai/docs/performance/model-optimizations/quantization.html
- Hugging Face, sentence-transformers/all-MiniLM-L6-v2: https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
- Sanh et al., DistilBERT: https://arxiv.org/abs/1910.01108
- Hugging Face, distilbert/distilbert-base-uncased: https://huggingface.co/distilbert/distilbert-base-uncased
- Hugging Face, ModernBERT announcement: https://huggingface.co/blog/modernbert
- Hugging Face, answerdotai/ModernBERT-base: https://huggingface.co/answerdotai/ModernBERT-base
- Transformers documentation, ModernBERT: https://huggingface.co/docs/transformers/main/en/model_doc/modernbert
- Hugging Face, microsoft/deberta-v3-base: https://huggingface.co/microsoft/deberta-v3-base
- Hugging Face, Qwen/Qwen3-0.6B: https://huggingface.co/Qwen/Qwen3-0.6B
- Li et al., Small Language Models in the Real World: https://arxiv.org/html/2505.16078v2
- scikit-learn, Classification of text documents using sparse features: https://scikit-learn.org/stable/auto_examples/text/plot_document_classification_20newsgroups.html
- scikit-learn, Probability calibration: https://scikit-learn.org/stable/modules/calibration.html
- Guo et al., On Calibration of Modern Neural Networks: https://arxiv.org/pdf/1706.04599
- Chen et al., FrugalGPT: https://arxiv.org/abs/2305.05176
- OpenAI, Decisions API guide: https://developers.openai.com/api/docs/guides/decisions
- Parsec, TOD: https://parseclab.ai/tod/
- Hetzner, Cloud General Purpose servers: https://www.hetzner.com/cloud/general-purpose/