Skip to main content

Build multi-task classifiers and augment classification datasets with ease

Project description

RapidFit

Turn a handful of labeled examples into a production-ready multi-task classifier.

RapidFit handles the two biggest pain points in text classification: not enough data and too many separate models. Give it a few examples per class, and it will generate more training data using LLMs, then train a single model that handles all your classification tasks at once.

Installation

pip install rapidfit

Augment Your Data

Start with just a few examples. RapidFit uses LLMs to expand your dataset while preserving label quality.

from rapidfit import LLMAugmenter

seed_data = {
    "sentiment": [
        {"text": "I love this product!", "label": "positive"},
        {"text": "Terrible experience.", "label": "negative"},
    ],
    "emotion": [
        {"text": "This makes me so happy!", "label": "joy"},
        {"text": "I can't believe they did this.", "label": "anger"},
    ],
}

augmenter = LLMAugmenter(api_key="your-api-key")
augmented = augmenter.augment(seed_data)

Configure generation with optional parameters:

Parameter Default Description
model_id gpt-4.1-mini LLM to use for generation
max_samples_per_task 128 Target samples per task
batch_size 8 Samples per generation call
save_path ./saved Output directory
save_format json Format: json, jsonl, or csv
write_mode overwrite overwrite or append to existing data

When using append mode, RapidFit loads existing data from the save path and skips duplicate texts during generation.

Train a Classifier

One model, multiple tasks. The multihead architecture shares a single encoder across all your classification tasks, making it efficient and consistent.

from rapidfit import MultiheadClassifier

classifier = MultiheadClassifier()
classifier.train(augmented)
classifier.save("./model")

Or train directly from a saved data directory:

classifier = MultiheadClassifier()
classifier.train(data_save_dir="./saved")
classifier.save("./model")

Customize training:

from rapidfit import MultiheadConfig, TrainingConfig, LossConfig

config = MultiheadConfig(
    training=TrainingConfig(epochs=10, learning_rate=2e-5),
    loss=LossConfig(use_class_weights=True),
)
classifier = MultiheadClassifier(config)

For a complete guide on configuration options and use cases, see How the Multihead Classifier Works.

Predict

classifier = MultiheadClassifier()
classifier.load("./model")

# Single task
classifier.predict(["Great product!"], task="sentiment")
# [{"label": "positive", "confidence": 0.95}]

# All tasks
classifier.predict_all_tasks(["Great product!"])

Extend It

Build custom augmenters or classifiers by extending the base classes:

from rapidfit import BaseAugmenter, BaseClassifier

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapidfit-0.1.3.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rapidfit-0.1.3-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file rapidfit-0.1.3.tar.gz.

File metadata

  • Download URL: rapidfit-0.1.3.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for rapidfit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 79674508eacc3806d35392e11f8dab177936117a78653a23a8c8212b552b9665
MD5 043e85dd700ac69ae0c1d0aee10ddae4
BLAKE2b-256 aa9ee399e377a05d60fb892d658b5604cea93f3e16d3f1f176f1187768772990

See more details on using hashes here.

File details

Details for the file rapidfit-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rapidfit-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for rapidfit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5995e79b133c1778c143d09461658a64b54b28c351a0c7a9aa8c9bc053f28c9c
MD5 48c1dcd46e76c56dd2332bda2b2e3e5d
BLAKE2b-256 7854f948f3ead3c256d61b33f5b315ff870b99b666e4e4102edce71b7975d166

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page