A trainable continual-learning architecture (manas/buddhi/ahaṃkāra/citta) you train on your own data — no forgetting (DER++ · O-LoRA · forgetting-curve replay), energy + feature-space + one-class novelty, calibrated abstention, scale-stable mātrā-LAMB optimization, adaptive plasticity, and a swappable risk-tier control ring. Stable 1.x API.
Project description
antahkarana — train a continual-learning mind on your data
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.
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 1.1.0 — four ways to not forget · scale-stable training · closed-loop plasticity
A backward-compatible release — every new behaviour is opt-in; the defaults reproduce 1.0. Validated on the NSL-KDD high-interference stream (3 seeds), cross-checked on UNSW-NB15 + vision; core gates green.
- Four complementary no-forgetting mechanisms — saṃskāra (EWC) · DER++ (now on the text adapter too) ·
OrthoLoRAstructural isolation (forgetting +0.288 → +0.215 where a penalty gives ~0) · forgetting-curve replay (nidrā) that rehearses the about-to-be-forgotten items first (rare-tail recall 0.276 → 0.314). MatraLAMBscale-stable optimization (Antahkarana(optimizer="lamb")) — a trust-ratio step (mātrā) so a full backbone and a tiny adapter move in proportion to their own magnitude, and one lr is stable across any scale. At the lr that used to collapse O-LoRA, forgetting +0.167 → +0.003 (≈ zero), accuracy up, robust on every seed; plusmax_grad_normgradient clipping (saṃyama).- Adaptive guṇa (
Antahkarana(adaptive_guna=True)) — plasticity closes the loop on measured forgetting: strictly Pareto-better where there's headroom (−11% forgetting and +accuracy), a safe no-op when there isn't. OneClassNovelty— complementary zero-day detector for threats sitting inside the known-data manifold (UNSW Backdoor AUROC 0.47 → 0.93).
Full details + the honest negatives we kept (and didn't ship): CHANGELOG · API.md.
The 1.0 foundation — stable API, with the control ring + calibrated novelty built in
The public API is now frozen under SemVer — 13 symbols (Antahkarana, the adapters, FeatureOOD,
NoveltyCalibrator, the eval metrics, and the Policy / RiskRouter / Tier / Intervention control ring).
A breaking change to any of them — or to the frozen BackboneAdapter contract — bumps the major version, so your
adapters and training code keep working while organ implementations stay free to improve. Full surface +
guarantees: API.md. The two capabilities that landed on the road to 1.0 are part of that stable surface:
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, and every decision is logged (transparency by construction).
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.
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
See examples/control_ring.py.
Calibrated novelty — NoveltyCalibrator (manas → ring)
Raw novelty scores live on arbitrary scales, so a fixed ring threshold over- or under-blocks. NoveltyCalibrator
maps one or more signals (energy, FeatureOOD, …) to a calibrated [0,1] against a normal reference
(empirical CDF) — so a ring threshold of 0.95 is a 5% false-alarm rate, and manas output is directly ring-ready.
from antahkarana import NoveltyCalibrator
cal = NoveltyCalibrator(mode="mean") # "mean" steadier · "max" more sensitive
cal.fit(energy=normal_energy, feature=normal_feat) # calibrate against NORMAL data
p = cal.score(energy=new_energy, feature=new_feat) # 0..1 ; 0.95 ≈ 5% false alarms
Honest note: no unsupervised fusion of energy+feature beat the best single signal on held-out UNSW-NB15 families — calibration's value is the FPR-tunable scale, not an AUROC boost.
Core (since 0.3.0) — DER++ replay + feature-space novelty
DER++ 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 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.)
60-second tour
python examples/try_it.py # no-forgetting · zero-day · abstention · control ring
(API stability + the frozen BackboneAdapter contract are covered under The 1.0 foundation above; full surface in
API.md.)
Author — Deepak Soni · Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file antahkarana-1.1.1.tar.gz.
File metadata
- Download URL: antahkarana-1.1.1.tar.gz
- Upload date:
- Size: 38.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbc503c03fb2789b792d67bd064f26f55b58ec1fd1c738eaac611baed77529b3
|
|
| MD5 |
93dd2467dc80defb8fa459ea5220046e
|
|
| BLAKE2b-256 |
7e9a0ad2c4a97231c1becdf6866f8ef1b1a2083956b27dd41e73045133be8857
|
File details
Details for the file antahkarana-1.1.1-py3-none-any.whl.
File metadata
- Download URL: antahkarana-1.1.1-py3-none-any.whl
- Upload date:
- Size: 42.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60529f39b16f0ffd9058e9882b6ab76511359a79c44b6a789b21544057b2ccf8
|
|
| MD5 |
b5703863421bd06510fff1a93b3144be
|
|
| BLAKE2b-256 |
50282e1fe8be1bc13324c811538c292a6beff1704572b4f09279c43fa00a4034
|