Behavior-driven cognitive experimentation toolkit with BCE (Behavioral Consciousness Engine) regularization, telemetry, and plug-and-play integrators for language-model training and evaluation.
- Behavioral Consciousness Engine (BCE): Regularizer that nudges models toward stable, self-consistent behavioral patterns during training.
- Telemetry-first: Self-reward and drift reflex signals are recorded during runs so you can track stability and responsiveness.
- Layered architecture: "Behavioral Consciousness", "ego", "dna", and "decay" layers compose the cognitive loop; integrators wire these into trainers.
- Eval-ready:
.tmp_multi_eval.pyruns BCE-on vs BCE-off sweeps across sample corpora (wikitext103, cc_news, tinystories) and writes metrics tollm_tests/out_hf_10ep_auto/multi100_eval_stats.json. - Python-native: Pure Python with optional PyTorch/Transformers/TensorFlow stacks; install extras only when you need them.
- Behavioral Consciousness/ — Core BCE logic, reflexes, selection, context tracking, experience transformer
- ego/ — Behavior routing, clustering, training loops and test harnesses
- dna/ — Behavior DNA, mutations, anomaly examples
- decay/ — PyTorch decay/BCE components
- backends/, sollana/backends/ — Trainer bridge, telemetry aggregation, integration utilities
- integrations/ — Reward shaping, temporal activation, feature weighting
- llm_tests/ — Evaluation scripts and outputs (e.g.,
multi100_eval_stats.json) - docs/ — Long-form guides (see
docs/guide.md)
- Python 3.9+
- Recommended: virtual environment
- For BCE training/eval: PyTorch 2.1+ (CPU or CUDA) and Hugging Face
transformers,datasets,accelerate
python -m venv .venv
. .venv/Scripts/activate # Windows
# or
source .venv/bin/activate # Linux/macOS
pip install -r requirements.txt
pip install -e .Runs BCE-on vs BCE-off and writes metrics/telemetry.
.venv/Scripts/python .tmp_multi_eval.pyOutputs: llm_tests/out_hf_10ep_auto/multi100_eval_stats.json with loss, perplexity, and telemetry (avg_dhat, avg_rs, avg_h, score).
- BCE Regularizer: Adds scheduled auxiliary loss (with warmup and boost span) to encourage behavioral stability; see decay/bce_pytorch.py and backends/trainer_bridge.py.
- Telemetry: Reflex events (
self_reward_step,drift_reflex) are recorded; trainer bridge aggregates into averages and ascore(~0.012 in sample runs). - Integrator:
Behavioral Consciousness/system_integrator.pywires reflex outputs to telemetry and scheduler controls.
- Build your model/dataloader (Hugging Face Trainer or custom loop).
- Instantiate BCE regularizer (from
decay/bce_pytorch.py) with desiredbce_weight,bce_max_weight,bce_warmup_steps,bce_boost_span. - During training, call
scheduled_bce_loss(...)and add to main loss. - Feed reflex outputs to
record_telemetry(event)to keep telemetry live. - Log eval via
.tmp_multi_eval.pyor your own harness and watchmulti100_eval_stats.json.
from decay.bce_pytorch import BCERegularizerTorch, scheduled_bce_loss
bce = BCERegularizerTorch(weight=2.0, max_weight=4.0,
warmup_steps=50, boost_span=2000)
for step, batch in enumerate(loader):
logits = model(batch["input_ids"], labels=batch["labels"]).logits
ce_loss = ce_fn(logits, batch["labels"])
bce_loss, bce_w = scheduled_bce_loss(bce, logits, step)
loss = ce_loss + bce_loss
loss.backward()
optimizer.step()from backends.trainer_bridge import record_telemetry
record_telemetry({
"event": "self_reward_step",
"payload": {"Rs": rs_val, "H": h_val, "theta_r": 0.5,
"Dhat": dhat, "Rs_bal": rs_bal, "self_thank": False}
})
record_telemetry({
"event": "drift_reflex",
"user": "user",
"C_now": c_now,
"drift_rate": drift_rate,
"rf_hat": rf_hat,
"triggered": False,
"actions": []
})Aggregated telemetry (averages + score) is surfaced in eval outputs.
- Run:
.venv/Scripts/python .tmp_multi_eval.py - Check:
llm_tests/out_hf_10ep_auto/multi100_eval_stats.json - Compare
bce_onvsbce_offperplexities; telemetryscoreshould be non-zero when wiring is active.
- Custom datasets: Swap loaders in
.tmp_multi_eval.pyor plug yourdatasetssplits. - Custom schedulers: Adjust BCE warmup/boost params in
bce_optimizer_profile(see llm_tests/train_llama_trainer.py). - Telemetry sinks: Pipe
record_telemetryto your logger/DB for long runs.
- Favor PRs: branch, commit, open PR; include eval JSON diff.
- Add new guides under
docs/and keep README concise. - Avoid committing large artifacts; keep
llm_tests/out_*small or gitignored if they grow.
- Telemetry zeros: ensure
record_telemetryis called (SystemIntegrator wiring) and eval script is rerun. - BCE weight has no effect: verify
scheduled_bce_lossis added to total loss and warmup/boost settings are non-zero. - Import errors: run
pip install -e .after venv activation.
See licence.md.