Repolode
codelion

codelion/adaptive-classifier

Python library for text classification that learns new examples and new classes at runtime, with calibrated confidence and out-of-distribution detection.

Stars
577
Forks
43
Open issues
2
Last commit
5 days ago

What is it?

Adaptive Classifier is a PyTorch-based Python library for text classification built on HuggingFace transformer encoders. Each class is represented by prototype embeddings stored with FAISS, and a small trainable neural head is combined with prototype similarity to produce predictions. New examples and new classes can be added at runtime without retraining the whole model, and examples or classes can be removed later.

The library also covers the operational side of a classifier: calibrating confidence scores on held-out data, returning prediction sets with a coverage target, abstaining on low-confidence or out-of-distribution inputs, suggesting unlabeled texts for annotation, and detecting drift in incoming traffic. Models can be saved locally or pushed to the HuggingFace Hub, and ONNX export is included for faster CPU inference.

It offers a multi-label classifier, a scikit-learn compatible estimator, and an HTTP serving module. The project also includes an experimental strategic-classification mode that blends predictions with a cost-based model of adversarial manipulation.

Key features

  • 01Adds new classes and examples at runtime without retraining the full model
  • 02Removes wrong examples or whole classes after training
  • 03Calibrates confidence and returns prediction sets with a target coverage
  • 04Detects out-of-distribution inputs and can abstain on them
  • 05Suggests unlabeled texts for labeling and reports data drift
  • 06Exports ONNX models for faster CPU inference and provides an HTTP server

Use cases

  • Routing support tickets or emails into categories that change over time
  • Classifying content where new labels appear frequently and retraining is costly
  • Building a text classifier with a scikit-learn Pipeline and cross-validation
  • Routing LLM queries to different model tiers based on predicted complexity

Quick start

  1. 1

    Install the library from PyPI

    pip install adaptive-classifier
  2. 2

    Import the classifier and initialize it with a HuggingFace model

  3. 3

    Add training examples with their labels

  4. 4

    Call predict on new text to get class confidences

Things to know

  • Predictions depend on the chosen HuggingFace encoder, and the README's examples download large transformer models.

In collections

Topics

#text-classification#continuous-learning#transformers#pytorch#faiss#onnx#online-learning#nlp#adaptive-learning#adaptive-neural-network

FAQ

What is adaptive-classifier?
Python library for text classification that learns new examples and new classes at runtime, with calibrated confidence and out-of-distribution detection. Adaptive Classifier is a PyTorch-based Python library for text classification built on HuggingFace transformer encoders. Each class is represented by prototype embeddings stored with FAISS, and a small trainable neural head is combined with prototype similarity to produce predictions. New examples and new classes can be added at runtime without retraining the whole model, and examples or classes can be removed later.
Is adaptive-classifier free to use? What license does it have?
adaptive-classifier is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is adaptive-classifier still maintained?
Actively maintained. The last commit to adaptive-classifier was on Nov 2, 2026.
What can I use adaptive-classifier for?
Routing support tickets or emails into categories that change over time Classifying content where new labels appear frequently and retraining is costly Building a text classifier with a scikit-learn Pipeline and cross-validation Routing LLM queries to different model tiers based on predicted complexity
How do I install adaptive-classifier?
Install the library from PyPI: pip install adaptive-classifier Import the classifier and initialize it with a HuggingFace model Add training examples with their labels Call predict on new text to get class confidences
Where can I get adaptive-classifier?
The source code and installation instructions are on GitHub: https://github.com/codelion/adaptive-classifier

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects