Skip to content

AdaptShot Documentation

AdaptShot logo

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.


๐Ÿš€ Start Here

๐Ÿ“š Tutorial-Style Guides

๐Ÿ“– API Reference

๐Ÿงญ Advanced Guides

๐Ÿ”ง Reference


๐ŸŒ Community & Support

- :fontawesome-brands-github:{ .lg .middle } **Star & Fork on GitHub** --- [:star: Star the project](https://github.com/johnson2006christopher/adaptshot) to show your support and stay updated with new releases. Every star helps AdaptShot reach more people who need CPU-first AI. - :fontawesome-brands-whatsapp:{ .lg .middle } **Join the WhatsApp Community** --- [Join our WhatsApp group](https://chat.whatsapp.com/J6AbrvbjmBc5XXX2fnN6RK) for real-time discussion, help, and collaboration with fellow AdaptShot users and contributors worldwide. - :fontawesome-brands-github:{ .lg .middle } **Discussions & Ideas** --- [Start a GitHub Discussion](https://github.com/johnson2006christopher/adaptshot/discussions) to ask questions, propose features, or share how you're using AdaptShot in your community. - :material-hand-heart:{ .lg .middle } **Contribute** --- [Open a Pull Request](https://github.com/johnson2006christopher/adaptshot/pulls) or look for [good first issues](https://github.com/johnson2006christopher/adaptshot/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). Whether you write code, improve docs, or share your experience โ€” every contribution matters.

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 42 from 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