skillfed

setfit

Efficient few-shot learning with Sentence Transformers

setfit v1.1.3 261.2K downloads/30d#8,386 on PyPI2,779
Permissive license Apache 2.0 Active released

What it is and what it does

SetFit is a framework for few-shot text classification that combines a pretrained Sentence Transformer body with a lightweight classification head (either scikit-learn's LogisticRegression or a differentiable PyTorch-based head). It achieves competitive accuracy on classification tasks using only a small number of labeled examples per class—the documentation cites achieving results comparable to fine-tuning RoBERTa Large on a full 3k-example training set using only 8 labeled examples per class on sentiment data.

The package integrates with Hugging Face Hub for model discovery, training, and sharing. It wraps the fine-tuning process in a Trainer class that handles dataset sampling, evaluation, and model persistence. Runtime dependencies include datasets for data loading, transformers and sentence-transformers for embeddings, evaluate for metrics, huggingface_hub for Hub integration, scikit-learn for the default classification head, and packaging for version handling. No prompts or verbalizers are required—the framework generates embeddings directly from raw text.

Use it for:

  • Train a sentiment classifier on a customer review dataset with only 8 labeled examples per sentiment class
  • Build a multilingual text classifier by fine-tuning a multilingual Sentence Transformer checkpoint on a small labeled corpus
  • Rapidly prototype a document categorization system when labeled training data is scarce or expensive to obtain
  • Evaluate few-shot learning performance on benchmark datasets and compare against other methods using the provided training scripts

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

SetFit fine-tunes Sentence Transformers for text classification using only a handful of labeled examples per class, without requiring handcrafted prompts or large language models.

Yes. SetFit is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and solves a real problem—achieving strong text classification with minimal labeled data. The low install friction, permissive license, and integration with Hugging Face Hub make it a practical choice for few-shot classification tasks. Install it if you need to classify text with limited labeled examples.

Install

setfit on PyPI

pip

pip install setfit

uv

uv add setfit

poetry

poetry add setfit

Installing setfit

Before you install

Low friction: pure Python wheel with seven runtime dependencies (datasets, sentence-transformers, transformers, evaluate, huggingface_hub, scikit-learn, packaging). Repository is active with recent commits and no archived status.

License in practice

Apache 2.0 permissive license allows commercial and private use with minimal restrictions—suitable for most production and research contexts.

Quickstart

pip install setfit

from setfit import SetFitModel, Trainer, TrainingArguments
from datasets import load_dataset

dataset = load_dataset("sst2")
model = SetFitModel.from_pretrained("sentence-transformers/paraphrase-mpnet-base-v2", labels=["negative", "positive"])
trainer = Trainer(model=model, args=TrainingArguments(batch_size=16, num_epochs=4), train_dataset=dataset["train"])
trainer.train()
preds = model.predict(["i loved the spiderman movie!"])

Verify before relying

  • Minimum Python version requirement (classifiers list 3.9–3.12 but requires_python field is unspecified)
  • Whether multilingual support requires specific Sentence Transformer checkpoints or works automatically
  • Typical memory and compute requirements for training on different dataset sizes

Package facts

License Apache 2.0 (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 7 — datasets, sentence-transformers, transformers, evaluate, huggingface_hub, scikit-learn, packaging
Maintenance actively maintained — 374 days since the last release
Last repo commit
First released
Downloads 261,172/month — #8,386 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: setfit-1.1.3-py3-none-any.whl

Keywords: nlp, machine learning, fewshot learning, transformers

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

few-shot text classificationefficient fine-tuning sentence transformerslow-data text labelingprompt-free few-shot learningmultilingual text classificationsmall-sample model training
few-shot-learningtext-classificationsentence-embeddings

More Artificial Intelligence packages

Further reading