# SetFit

> Efficient few-shot learning with Sentence Transformers

Source: https://talira.ai/catalog/setfit-5sbs98se
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [ai / nlp / text classification](https://talira.ai/categories/ai/nlp/text-classification), [languages / python](https://talira.ai/categories/languages/python)
- Licence: Apache-2.0[^1][^2]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Self-hostable: yes[^3]
- Backed by: [Hugging Face](https://talira.ai/orgs/hugging-face.md)

SetFit is a Hugging Face Python library for training text classifiers from very few labelled examples. It fine-tunes a Sentence Transformer contrastively on pairs built from your examples, then fits a classification head (scikit-learn logistic regression, or a differentiable PyTorch head) on the resulting embeddings, with no prompts or verbalizers. Its README reports that with 8 labelled examples per class on the Customer Reviews sentiment dataset it is competitive with RoBERTa Large fine-tuned on the full 3,000 examples, and it trains and predicts an order of magnitude or more faster than prompting large models. It also does multi-label and zero-shot classification (from label names), aspect-based sentiment analysis, knowledge distillation and ONNX export, and works with any Sentence Transformer on the Hub, including multilingual ones.

## Links

- Website: https://huggingface.co/docs/setfit/index
- GitHub: https://github.com/huggingface/setfit
- Docs: https://huggingface.co/docs/setfit/index

## Problems it solves

- I only have 8 to 20 labelled examples per class and need a text classifier that's actually accurate
- fine-tune a classifier without writing prompts or paying for an LLM call on every request
- label a few dozen user queries by intent and train a model that beats my keyword rules
- build a first text classifier from nothing but the label names, before I have any training data
- multi-label classification of tickets when I've only labelled a small sample
- aspect-based sentiment on reviews: which product features people praise or complain about
- classify text in German, Spanish or other languages by fine-tuning a multilingual embedding model
- distill a slow, accurate text classifier into a smaller, faster student model
- export a small fine-tuned text classifier to ONNX for faster CPU inference
- run a hyperparameter search for a few-shot text classifier with Optuna

## Features

- few-shot fine-tuning of any Sentence Transformer on the Hugging Face Hub
- no prompts or verbalizers
- scikit-learn logistic regression head or a differentiable PyTorch head
- multi-label classification
- zero-shot classification from label names via synthetic examples
- aspect-based sentiment analysis (ABSA)
- knowledge distillation into smaller models
- hyperparameter optimization with Optuna
- ONNX and OpenVINO export
- push trained models to the Hugging Face Hub with generated model cards

## Trust

Overall: 0.27 out of 1.
Signals: backing 0.30, extensibility 0.00.

- backed by Hugging Face

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [GLiNER2.5-Decide](https://talira.ai/catalog/gliner2-5-decide-44fhqwfc.md): The 340M English classification model in the GLiNER2.5 family: any label set at call time, no generated tokens
- [Jev](https://talira.ai/catalog/jev-xe4k64zz.md): TypeSafe's System One model: typed decisions with calibrated probabilities instead of generated text
- [Model2Vec](https://talira.ai/catalog/model2vec-8r1qxjkw.md): Fast state-of-the-art static embeddings, and lightweight classifiers trained on top of them

## Sources

[^1]: https://github.com/huggingface/setfit/blob/main/LICENSE (checked 20 Nov 2026)
[^2]: https://pypi.org/project/setfit/ (checked 20 Nov 2026)
[^3]: https://github.com/huggingface/setfit/blob/main/README.md (checked 20 Nov 2026)
