Skip to main content

A trainable continual-learning architecture (manas/buddhi/ahaṃkāra/citta) you train on your own data — no forgetting (DER++), energy + feature-space novelty, calibrated abstention, and a swappable risk-tier control ring. Stable 1.0 API.

Project description

antahkarana — train a continual-learning mind on your data

PyPI License Python Model card

antahkarana is a trainable architecture, not a frozen model. You bring your data (and optionally your backbone); it trains a model that learns continually without forgetting, detects novelty / zero-days, abstains when unsure, and consolidates in sleep. Four organs — manas · buddhi · ahaṃkāra · citta — the mind is the same for every domain; only a thin adapter changes.

architecture

Built on the validated Antaḥkaraṇa-base core (gated G0–G5, proven across language · vision · security · with seeded, adaptive evaluation — see the model card for plots, results, and honest limits).

Install

pip install antahkarana            # core + tabular
pip install antahkarana[text]      # + HuggingFace LLM adapter

Train on your data in ~10 lines (tabular)

from antahkarana import Antahkarana, TabularAdapter

# YOUR data: a list of tasks, each (X_train, y_train, X_test, y_test)
stream = TabularAdapter.make_stream(your_tasks)

bb   = TabularAdapter(input_dim=122, n_tasks=4, n_classes=2)   # built-in MLP — bring only data
mind = Antahkarana(bb, replay_strategy="der", avidya_strategy="energy")
res  = mind.train(stream)

print(res["forgetting"], res["final_row"], res["risk_coverage"])

New in 0.4.0 — the control ring (Layer-2 policy)

A swappable risk-tier router over any trained backbone. One consolidated brain (the weights = Layer-1 disposition), many deployment policies (config = Layer-2) — change safety posture without retraining. Each request's novelty/risk maps to a tier and every decision is logged (transparency by construction).

two-layer architecture

A request flows through the consolidated organs (Layer 1); manas emits a risk score; the RiskRouter applies the deployment Policy (Layer 2) to pick a tier — ALLOW / NOTIFY / SOFT_BLOCK / HARD_BLOCK — and logs every decision.

control ring performance

Validated on UNSW-NB15: calibrated to ~5% false-block on normal traffic, the ring gates known attacks and catches ~95% of a held-out zero-day family it never trained on — built on the Layer-1 DER++ no-forgetting win.

from antahkarana import Policy, RiskRouter
ring = RiskRouter(Policy.load("policy.yaml"))     # hard/soft blocks, thresholds, operator overrides
iv   = ring.gate(score=novelty, category="intrusion")
# iv.tier ∈ {allow, notify, soft_block, hard_block};  iv.allowed / iv.notify / iv.reason drive the response

Validated end-to-end on UNSW-NB15 (KAVACA detector → ring, calibrated to 5% FPR): normal ~85% pass, known attacks gated, a held-out zero-day family ~95% caught. See examples/control_ring.py.

New in 0.3.0 — DER++ replay + feature-space novelty

DER++ now works for tabular (replay_strategy="der"): on a 6-family UNSW-NB15 stream it cut forgetting from +0.048 (naive) to +0.009 — the no-forgetting guarantee now holds on modern data, not just text/vision.

FeatureOOD adds a penultimate-feature novelty detector (Mahalanobis / kNN) complementary to the default energy score — measured to rescue families where energy fails (Backdoor AUROC 0.37→0.79) while energy remains better where it already works. Pick per deployment or ensemble; energy stays the default.

from antahkarana import FeatureOOD
det   = FeatureOOD("mahalanobis").fit(known_features, known_labels)   # bb.features(inputs) -> embeddings
score = det.score(new_features)        # higher = more novel / likely zero-day

Text (any HuggingFace causal-LM + LoRA)

from antahkarana import Antahkarana, TextAdapter
bb     = TextAdapter("mistralai/Mistral-7B-v0.1")             # frozen base, small LoRA trains
stream = TextAdapter.make_stream(your_text_tasks)             # [(train_pairs, eval_pairs), …]
Antahkarana(bb).train(stream)

Any other modality

Copy antahkarana/adapters/template.py (CustomAdapter) and implement 5 methods over your encoder (audio, graph, multi-modal, robotics, …). The continual-learning mind is unchanged.

Runnable examples

python examples/train_tabular.py     # concept-drift stream: naive forgets, the core doesn't
python examples/train_security.py    # continual threat detection (attack families) + calibrated triage

What you get back

train() returns: the task×task accuracy matrix, final_row, final_avg, forgetting, risk_coverage (calibrated abstention), recovery (sleep), and the trajectory (per-task guṇa/novelty).

Knobs

Antahkarana(bb, samskara=, replay_strategy="naive"|"der", avidya_strategy="msp"|"energy", sleep=, base_lr=, epochs=) — turn each organ on/off and swap in the SOTA implementation (DER++ dark-knowledge replay, energy-OOD novelty).

Ship it closed-source

python build_wheel.py compiles the engine to binary .so (Nuitka) and drops the source, leaving only the public interface readable — others can pip install and train on their data without seeing your code. (For maximum IP protection, serve it behind an API instead.)

Stable API (1.0)

From 1.0.0 the public symbols (from antahkarana import …) are stable under SemVer — a breaking change bumps the major version. The BackboneAdapter contract (5 required methods + the optional logits / features / capture+der_loss hooks) is frozen, so your adapters and training code keep working. Organ implementations stay free to improve. Full surface + guarantees: API.md.

python examples/try_it.py        # 60-sec tour: no-forgetting · zero-day · abstention · control ring

Author — Deepak Soni · Apache-2.0

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

antahkarana-1.0.0.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

antahkarana-1.0.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file antahkarana-1.0.0.tar.gz.

File metadata

  • Download URL: antahkarana-1.0.0.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for antahkarana-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eeef825346f6f61c2494d583b316e992c84b9a61fb95d36d8e8f8d7d0d58b2c4
MD5 43e6de770195cce3af1cc2d2513e16c7
BLAKE2b-256 8767b6739290e41a80a231284df408337d47787bbd70e8b09480d3f12736f5d7

See more details on using hashes here.

File details

Details for the file antahkarana-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: antahkarana-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for antahkarana-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e13e94a1561c4a3a65ff901c0a0778f2ed385f1a78f18189aacad3906b6889e
MD5 5956eee07ae67d503cc856c04f6fff9b
BLAKE2b-256 0f2c169646aa7c11e81594115d14b81aecfde088df884866e3e5a977844690ac

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