Skip to main content

Autodistill SetFit Module

This repository contains the code supporting the SetFit target model trainer for use with Autodistill.

SetFit is a framework for fine-tuning Sentence Transformer models with a few examples of each class on which you want to train. SetFit is developed by Hugging Face.

Installation

To use the SetFit target model, you will need to install the following dependency:

pip3 install autodistill-setfit

Quickstart

The SetFit module takes in .jsonl files and trains a text classification model.

Each record in the JSONL file should have an entry called text that contains the text to be classified. The label entry should contain the ground truth label for the text. This format is returned by Autodistill base text classification models like the GPTClassifier.

Here is an example entry of a record used to train a research paper subject classifier:

{"title": "CC-GPX: Extracting High-Quality Annotated Geospatial Data from Common Crawl", "content": "arXiv:2405.11039v1 Announce Type: new \nAbstract: The Common Crawl (CC) corpus....", "classification": "natural language processing"}
from autodistill_setfit import SetFitModel

target_model = SetFitModel()

# train a model
target_model.train("./data.jsonl", output="model", epochs=5)

target_model = SetFitModel("model")

# run inference on the new model
pred = target_model.predict("Geospatial data.")

print(pred)
# geospatial

License

This project is licensed under an MIT license.

🏆 Contributing

We love your input! Please see the core Autodistill contributing guide to get started. Thank you 🙏 to all our contributors!

Release files for autodistill-setfit 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autodistill-setfit 0.1.1
File Size Uploaded
autodistill_setfit-0.1.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autodistill-setfit 0.1.1
File Interpreter ABI Platform
autodistill_setfit-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / autodistill_setfit-0.1.1.tar.gz

Download URL autodistill_setfit-0.1.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
091d0725eae422492dec18a56040a0029618c744abea139166cd58996bda4a42
BLAKE2b-256 checksum
How to use checksums
1b07f21335d52cc7741bda813513d98fd8669cb0a1f835f7ef48d221e411e7ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / autodistill_setfit-0.1.1-py3-none-any.whl

Download URL autodistill_setfit-0.1.1-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8d9ade91788ee5392ccd01c14744a59ca766146a8b0878863e0b540eace27c2
BLAKE2b-256 checksum
How to use checksums
87a997ca687159ff67d621ace85004e4211eb44f9e5119e270264a690f21a149
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page