AdaptShot Documentation¶

Human-Aligned Few-Shot Vision Learning for Resource-Constrained Environments
AdaptShot is a production-hardened, CPU-first few-shot vision library that learns from every human correction, guarantees calibrated uncertainty, and runs deterministically on edge hardware. Built in Tanzania by Johnson Christopher Hassan.
v0.2.0 Production Hardened
92 regression tests, strict mypy type-checking, 0 ruff lint errors, 68% CIFAR-10 benchmark accuracy at 20ms latency. Full changelog โ
Feature Overview¶
| Category | Capability | Detail |
|---|---|---|
| ๐ง Few-Shot Learning | Prototypical, nearest-neighbor, and contrastive inference | 5-way 10-shot classification at 68%+ accuracy |
| ๐ Conformal Prediction | True leave-one-out calibration | Distribution-free 95% coverage guarantee |
| ๐ Uncertainty Quantification | Epistemic ยท Aleatoric ยท Distributional (Mahalanobis) | Three complementary signals with shrinkage covariance |
| ๐ Explainability | Feature attribution ยท Confidence decomposition ยท Counterfactuals | Historical penalty tracking, no magic numbers |
| ๐ Continual Learning | Head-only CA-EWC fine-tuning ยท UP-UGF pruning with LSH acceleration | O(N log N) buffer management for >100 examples |
| โก CPU-First | Numpy-based ยท <250MB RAM ยท 20ms P95 latency | No GPU required; PyTorch optional |
| ๐ค Human-in-the-Loop | ACT adaptive thresholds ยท Feedback routing ยท Bootstrap calibration | Symmetric threshold updates with mean-reversion |
| ๐ Production Ready | ONNX export ยท Memory profiling ยท Deterministic seeding ยท SHA-256 checkpoints | Torch-free inference via bundled backbones |
How AdaptShot Works¶
graph TB
A[User Image] --> B[FewShotLearner.predict]
B --> C[Extractor<br/>Frozen ResNet/MobileNet]
C --> D[Embedding Vector]
D --> E{Inference Mode}
E -->|nearest_neighbor| F[Cosine/Euclidean<br/>Similarity Search]
E -->|prototypical| G[Class Prototype<br/>Distance]
F --> H[CalibrationEngine<br/>Temperature Scaling + Bootstrap]
G --> H
E -->|contrastive| G2[Gradient-Trained<br/>Contrastive Prototypes]
G2 --> H
H --> I[ACTEngine<br/>Adaptive Threshold + Mean-Reversion]
I -->|Accept| J[PredictionResult]
I -->|Request Feedback| K[Human Review]
K --> L[FewShotLearner.correct]
L --> M[FeedbackRouter]
M --> N[CA-EWC Head Fine-Tune]
M --> O[UP-UGF Buffer Prune]
N --> B
O --> B
J --> P{Uncertainty?}
P -->|Yes| K
P -->|No| Q[Return Result<br/>+ Conformal Set<br/>+ Uncertainty Report<br/>+ Explanation]
The pipeline is a closed loop: every human correction feeds back into the learner, improving calibration, adjusting confidence thresholds, and fine-tuning the classification head while preserving prior knowledge.
Quick Links¶
๐ Start Here¶
- Installation โ Install in under 60 seconds
- Quick Start โ First prediction in 5 minutes
- Beginner 101 โ No AI experience required
- Benchmarks โ Run the smoke test on your machine
๐ Tutorial-Style Guides¶
- Tutorial Index โ 18 hands-on tutorials from basic to advanced
- Conformal Prediction โ Guaranteed coverage sets
- Advanced Uncertainty โ Multi-signal confidence
- Explainability & XAI โ Understand every prediction
- Contrastive Learning โ Gradient-trained prototypes
- End-to-End Workflow โ Full production pipeline
- Memory Profiling โ Monitor RAM and latency
- ONNX Deployment โ Torch-free inference
๐ API Reference¶
- Full API Reference (v0.2.0) โ Every class, method, and data structure
- Core Engine โ FewShotLearner, calibration, ACT, conformal
- Training & Continual Learning โ CA-EWC, UP-UGF, FeedbackRouter
- Configuration & Utilities โ AdaptShotConfig (27 fields), determinism, I/O
๐งญ Advanced Guides¶
- Architecture Deep-Dive โ Module map and data flow
- Algorithm Theory โ Mathematical foundations
- Real-World Use Cases โ Agriculture, healthcare, conservation
- Human-in-the-Loop Deep Dive โ Feedback loop mechanics
- Error Handling & Troubleshooting โ Common problems solved
- Migration Guide (v0.1 โ v0.2) โ Upgrade safely
๐ง Reference¶
- Config Reference (All 27 Fields) โ Every parameter explained
- Changelog โ Full release history
- Contributing โ How to contribute
- Code of Conduct
๐ Community & Support¶
Use The Source As Truth
If documentation and behavior differ, verify against src/adaptshot/ and open an issue with the mismatch.
Verification Checklist¶
- [ ] You can install
adaptshot. - [ ] You can run the quickstart script.
- [ ] You can run
python -m benchmarks.run_benchmark --smoke-test --seed 42from a source checkout. - [ ] You can trace each documented API to
src/adaptshot/.
Created by Johnson Christopher Hassan
Connect on LinkedIn
Project: github.com/johnson2006christopher/adaptshot