--- id: setfit version: "1.1.3" license: Apache 2.0 license_treatment: permissive maintenance: active --- # setfit — Efficient few-shot learning with Sentence Transformers License: permissive · Maintenance: active · Downloads: 261.2K/mo ## 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 above — 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 pip install setfit uv add setfit 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: unspecified - Install friction: low - Maintenance: active - Downloads: 261.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags few-shot text classification, efficient fine-tuning sentence transformers, low-data text labeling, prompt-free few-shot learning, multilingual text classification, small-sample model training, few-shot-learning, text-classification, sentence-embeddings [View on SkillFed](https://skillfed.io/packages/setfit) · [View on PyPI](https://pypi.org/project/setfit/)