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

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")

Customize training:

classifier = MultiheadClassifier({
    "model_name": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
    "epochs": 10,
    "freeze_epochs": 3,
    "learning_rate": 2e-5,
    "patience": 3,
})

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.1.tar.gz (16.4 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.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rapidfit-0.1.1.tar.gz
  • Upload date:
  • Size: 16.4 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.1.tar.gz
Algorithm Hash digest
SHA256 67f74168f7fea180ebe9d68cdb571740283f962914f8196aef60017c6a0f8560
MD5 db0afef2a7fc755c2abf2cf3d1688ab6
BLAKE2b-256 3de09f5d993760cd3a3ec4e3538bfd8c21f7204ca715058df52753997515f8b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rapidfit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a27389dccf71a914016c0c1b0c0483dd857e5140c6eab0eacbe6476afc0877d
MD5 49ccc50d94093b00669801820fc8b539
BLAKE2b-256 fef1d7798ab047fb35a6441bb18b8294ba0355cc9fcde49c6cde5e98e88e38e4

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