codelion/adaptive-classifier
A flexible, adaptive classification system for dynamic text classification
What it solves
Adaptive Classifier is a PyTorch-based library designed to overcome the rigidity of traditional text classification. It solves the problem of "catastrophic forgetting" and the need for constant retraining when new classes or examples are added to a production system. It also addresses the vulnerability of classifiers to adversarial manipulation and the challenge of ensuring model confidence scores are actually reliable probabilities.
How it works
The library uses a hybrid architecture that combines two distinct signals for prediction:
- Prototype Memory: Uses FAISS-powered similarity search to find how close a text's embedding is to the mean embedding (prototype) of a class.
- Adaptive Neural Layer: A small, trainable classification head that uses Elastic Weight Consolidation (EWC) to prevent forgetting old knowledge while learning new patterns.
It integrates with HuggingFace transformers for embeddings and supports ONNX Runtime for accelerated CPU inference. To handle new classes, it employs a ramping mechanism that relies on prototypes until enough examples are gathered to train the neural head effectively.
Who it’s for
It is intended for developers and ML engineers building enterprise-grade text classification systems that require zero-downtime updates, the ability to add/remove categories at runtime, and robustness against adversarial "gaming" of the model.
Highlights
- Continuous Learning: Add new examples or entire classes at runtime without retraining the whole model.
- Strategic Defense: Implements game-theoretic defenses to maintain accuracy against adversarial inputs.
- Zero-Downtime Adaptation: Update models in production without service interruption.
- Reliable Confidence: Includes calibration tools to ensure prediction scores match actual accuracy and supports out-of-distribution (OOD) detection.
- ONNX Optimization: Built-in support for 2-4x faster CPU inference via quantized ONNX models.
- Active Learning: Tools to suggest which unlabeled texts should be labeled next to improve the model most efficiently.
Related
- Project
- Project
- Dispatch
- Dispatch
- Dispatch