<p align="center">
<img src="https://raw.githubusercontent.com/heraclitus0/cognize/main/assets/logo.png" width="160"/>
</p>
<h1 align="center">Cognize</h1>
<p align="center"><em>Programmable cognition for Python systems</em></p>
<p align="center">
<a href="https://pypi.org/project/cognize"><img src="https://img.shields.io/pypi/v/cognize?color=blue&label=version" alt="PyPI version"></a>
<img src="https://img.shields.io/badge/python-3.10%2B-blue" alt="Python 3.10+">
<img src="https://img.shields.io/badge/status-beta-orange" alt="Status: beta">
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License">
<a href="https://pepy.tech/project/cognize"><img src="https://static.pepy.tech/badge/cognize" alt="Downloads"></a>
<a href="https://doi.org/10.5281/zenodo.17042859"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.17042859.svg" alt="DOI"></a>
</p>
---
## Overview
**Cognize** is a lightweight cognition engine for Python.
It tracks a system’s **belief** (`V`) against **reality** (`R`), accumulates **misalignment memory** (`E`), and triggers **rupture** when drift exceeds a threshold (`Θ`).
It’s programmable at runtime — inject your own threshold, realignment, and collapse logic, or use the included safe presets.
---
## Features
- **Epistemic kernel** — `EpistemicState` (scalar & vector), tracking `V, R, Δ, Θ, E`, with rupture and step-capped updates.
- **Programmable policies** — inject custom `threshold`, `realign`, `collapse` functions or use safe presets (`cognize.policies`).
- **Perception adapter** — `Perception` fuses text/image/sensor inputs into a normalized vector; bring your own encoders.
- **Meta-policy selection** — `PolicyManager` with shadow evaluation, ε-greedy exploration, and safe promotion (`SAFE_SPECS`).
- **Epistemic graphs** — `EpistemicGraph` / `EpistemicProgrammableGraph` orchestrate states via directed, decay/cooldown-aware links with programmable edges (gate → influence → magnitude → target(slice) → nudge → damp).
- **Meta-learning bounds** — `ParamRange`, `ParamSpace`, `enable_evolution()` and `enable_dynamic_evolution()` for bounded/static or provider-driven evolution.
- **Safety & telemetry by design** — step caps, oscillation damping, cooldowns; per-edge influence logs, cascade traces, `explain_last()`, CSV/JSON export.
- **Ergonomic helpers** — `make_simple_state`, `make_graph`, `demo_text_encoder` for fast setup.
- **Lightweight core** — NumPy-only dependency; optional viz/dev extras.
---
## Use Cases
- **Drift & anomaly detection (streaming)** — compute `Δ, E, Θ`; trigger ruptures; emit CSV/JSON telemetry for dashboards.
- **Continual-learning guardrails** — under non-stationarity, apply reversible cooling (`Θ↑`, `k↓` / LR↓) to reduce catastrophic forgetting.
- **Modulation for NNs (no retrain)** — runtime, slice-level nudges (attention logits, LayerNorm γ, MoE gates, temperatures) with caps & logs.
- **Multimodal arbitration (explainable fusion)** — gate/bias text–vision contributions when disagreement spikes; audit who influenced whom and why.
- **Cognitive & adaptive agents** — systems that self-correct against misalignment with interpretable state and policy switches.
- **Metacognitive mechanics** — self-monitoring, policy evaluation/evolution, and reflective control over when/how modules adapt.
- **Networked control** — orchestrate layers/heads/modules/sensors as nodes; propagate influence with decay/cooldowns for stable coordination.
- **Simulation & research** — explore rupture dynamics, policy A/B, and bounded evolution with reproducible logs.
---
## Install
```bash
pip install cognize
```
---
## Core primitives
| Symbol | Meaning |
|:------:|-----------------------|
| `V` | Belief / Projection |
| `R` | Reality signal |
| `∆` | Distortion (`R−V`) |
| `Θ` | Rupture threshold |
| `E` | Misalignment memory |
| `⊙` | Realignment operator |
---
## Examples
### 1) Quick start (scalar)
```python
from cognize import EpistemicState
from cognize.policies import threshold_adaptive, realign_tanh, collapse_soft_decay
state = EpistemicState(V0=0.5, threshold=0.35, realign_strength=0.3)
state.inject_policy(threshold=threshold_adaptive, realign=realign_tanh, collapse=collapse_soft_decay)
for r in [0.1, 0.3, 0.7, 0.9]:
state.receive(r)
print(state.explain_last()) # human-readable step summary
print(state.summary()) # compact state snapshot
```
### 2) Multimodal in one pass (vector)
```python
import numpy as np
from cognize import EpistemicState, Perception
def toy_text_encoder(s: str) -> np.ndarray:
return np.array([len(s), s.count(" "), s.count("a"), 1.0], dtype=float)
P = Perception(text_encoder=toy_text_encoder)
state = EpistemicState(V0=np.zeros(4), perception=P)
state.receive({"text": "hello world"})
print(state.last()) # includes Δ, Θ, ruptured, etc.
```
### 3) Meta‑policy selection
```python
from cognize import EpistemicState, PolicyManager, PolicyMemory, ShadowRunner, SAFE_SPECS
from cognize.policies import threshold_adaptive, realign_tanh, collapse_soft_decay
s = EpistemicState(V0=0.0, threshold=0.35, realign_strength=0.3)
s.inject_policy(threshold=threshold_adaptive, realign=realign_tanh, collapse=collapse_soft_decay)
s.policy_manager = PolicyManager(
base_specs=SAFE_SPECS, memory=PolicyMemory(), shadow=ShadowRunner(),
epsilon=0.15, promote_margin=1.03, cooldown_steps=30
)
for r in [0.2, 0.4, 0.5, 0.7, 0.6, 0.8]:
s.receive(r)
print(s.summary())
```
### 4) CSV / JSON export & small stats
```python
from pathlib import Path
from statistics import mean
from cognize import EpistemicState
from cognize.policies import threshold_adaptive, realign_tanh, collapse_soft_decay
s = EpistemicState(V0=0.0, threshold=0.35, realign_strength=0.3)
s.inject_policy(threshold=threshold_adaptive, realign=realign_tanh, collapse=collapse_soft_decay)
for r in [0.1, 0.3, 0.9, 0.2, 0.8, 0.7]: s.receive(r)
out = Path("trace.csv"); s.export_csv(str(out))
print("ruptures:", s.summary()["ruptures"])
print("mean |Δ| (last 10):", mean(abs(h["∆"]) for h in s.history[-10:]))
```
### 5) Plain EpistemicGraph (coupling multiple states)
```python
from cognize import make_simple_state, EpistemicGraph
G = EpistemicGraph(damping=0.5, max_depth=2, max_step=1.0, rupture_only_propagation=True)
G.add("A", make_simple_state(0.0)); G.add("B", make_simple_state(0.0)); G.add("C", make_simple_state(0.0))
# A → B (pressure), B → C (delta)
G.link("A", "B", weight=0.8, mode="pressure", decay=0.9, cooldown=3)
G.link("B", "C", weight=0.5, mode="delta", decay=0.9, cooldown=2)
# Step node A with evidence; influence cascades per edge modes
G.step("A", 1.2)
print(G.stats())
print("hot edges:", G.top_edges(by="applied_ema", k=5))
print("last cascade:", G.last_cascade(5))
```
### 6) Programmable graph: register a strategy and link by reference
```python
from typing import Dict, Any, Optional
import numpy as np
from cognize import EpistemicProgrammableGraph, register_strategy
# Minimal programmable pieces (use defaults for the rest)
def gate_fn(src_st, dst_st, ctx: Dict[str, Any]) -> bool:
# fire only on rupture for 'pressure'/'policy'; always for 'delta'
mode = ctx["edge"]["mode"]; rupt = bool(ctx["post_src"].get("ruptured", False))
return (mode != "pressure" and mode != "policy") or rupt
def influence_fn(src_st, post_src: Dict[str, Any], ctx: Dict[str, Any]) -> float:
delta, theta = float(post_src.get("∆", 0.0)), float(post_src.get("Θ", 0.0))
return max(0.0, delta - theta) # pressure
def target_fn(dst_st, edge_meta: Dict[str, Any], ctx: Dict[str, Any]) -> Optional[slice]:
# take middle half of a vector V if available
if not isinstance(dst_st.V, np.ndarray): return None
n = dst_st.V.shape[0]; i, j = n//4, 3*n//4
return slice(i, j)
register_strategy("cooling@1.0.0", gate_fn=gate_fn, influence_fn=influence_fn, target_fn=target_fn)
G = EpistemicProgrammableGraph(damping=0.6, max_depth=2)
G.add("X"); G.add("Y")
# attach by reference; params are JSON-safe and persisted
G.link("X", "Y", mode="policy", weight=0.7, decay=0.9, cooldown=4,
strategy_id="cooling@1.0.0", params={"bias_decay": 0.9})
# Drive X; programmable edge applies reversible Θ↑/k↓ bias on Y when X ruptures
G.step("X", 1.4)
print(G.last_cascade(3))
# Persist topology + strategy references (no code serialization)
G.save_graph("graph.json", include_strategies=True)
# Load later (rebinds strategies by ID from registry)
H = EpistemicProgrammableGraph()
H.add("X"); H.add("Y")
H.load_graph("graph.json", strict_strategies=False)
```
### 7) Influence preview (what would be applied?)
```python
from cognize import EpistemicGraph, make_simple_state
G = EpistemicGraph()
G.add("A", make_simple_state(0.0)); G.add("B", make_simple_state(0.0))
G.link("A", "B", weight=0.8, mode="pressure", decay=0.9, cooldown=1)
# Pretend A just ruptured with Δ=1.0, Θ=0.3 (no state mutation)
postA = {"∆": 1.0, "Θ": 0.3, "ruptured": True}
print("predicted magnitude:", G.predict_influence("A", "B", post=postA))
```
### 8) Suspend propagation (isolate learning vs. coupling)
```python
from cognize import EpistemicGraph, make_simple_state
G = EpistemicGraph()
for n in ("A","B"): G.add(n, make_simple_state(0.0))
G.link("A","B", weight=1.0, mode="pressure")
with G.suspend_propagation():
# A will update itself, but won't influence B during this block
G.step("A", 2.0)
# Propagation resumes here
G.step("A", 2.2)
```
### 9) Tiny NN control‑plane sketch (PyTorch, optional)
```python
# Pseudo-code: shows the observer → graph → nudge loop
import torch
from cognize import EpistemicProgrammableGraph
peg = EpistemicProgrammableGraph(max_depth=1, damping=0.5)
peg.add("L23"); peg.add("HEAD7")
peg.link("L23","HEAD7", mode="policy", weight=0.6, decay=0.9, cooldown=3)
def entropy(x): # simple example metric
p = torch.softmax(x.flatten(), dim=0); return -(p * (p+1e-9).log()).sum().item()
attn_logits_ref = {} # cache last logits tensor per step (just illustrative)
def hook_L23(module, inp, out):
peg.step("L23", {"norm": out.norm().item(), "ruptured": False}) # you decide the R fields
def hook_HEAD7(module, inp, out):
attn_logits_ref["HEAD7"] = out # capture a handle to nudge later
# Attach forward hooks on your model (where it makes sense)
# layer23.register_forward_hook(hook_L23)
# head7.register_forward_hook(hook_HEAD7)
# After forward:
# peg.step("HEAD7", {"entropy": entropy(attn_logits_ref["HEAD7"])})
# (peg runs propagation internally during step)
# Apply your bounded nudges here according to your edge strategies/logs.
```
---
## Citation
If you use **Cognize**, please cite the concept DOI (always resolves to the latest version):
```bibtex
@software{pulikanti_cognize,
author = {Pulikanti, Sashi Bharadwaj},
title = {Cognize: Programmable cognition for Python systems},
publisher = {Zenodo},
doi = {10.5281/zenodo.17042859},
url = {https://doi.org/10.5281/zenodo.17042859}
}
```
---
## License
Licensed under the **Apache License 2.0**.
© 2025 Pulikanti Sashi Bharadwaj
Raw data
{
"_id": null,
"home_page": "https://github.com/heraclitus0/cognize",
"name": "cognize",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "cognition, epistemic, rupture, projection, AI, symbolic, drift",
"author": "Pulikanti Sashi Bharadwaj",
"author_email": "Pulikanti Sashi Bharadwaj <bharadwajpulikanti11@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b5/bd/45c03fff9298966cd772615de86aa78f90b18aa2c704ad248beb119ed774/cognize-0.1.8.tar.gz",
"platform": null,
"description": "<p align=\"center\">\r\n <img src=\"https://raw.githubusercontent.com/heraclitus0/cognize/main/assets/logo.png\" width=\"160\"/>\r\n</p>\r\n\r\n<h1 align=\"center\">Cognize</h1>\r\n<p align=\"center\"><em>Programmable cognition for Python systems</em></p>\r\n\r\n<p align=\"center\">\r\n <a href=\"https://pypi.org/project/cognize\"><img src=\"https://img.shields.io/pypi/v/cognize?color=blue&label=version\" alt=\"PyPI version\"></a>\r\n <img src=\"https://img.shields.io/badge/python-3.10%2B-blue\" alt=\"Python 3.10+\">\r\n <img src=\"https://img.shields.io/badge/status-beta-orange\" alt=\"Status: beta\">\r\n <img src=\"https://img.shields.io/badge/license-Apache%202.0-blue\" alt=\"License\">\r\n <a href=\"https://pepy.tech/project/cognize\"><img src=\"https://static.pepy.tech/badge/cognize\" alt=\"Downloads\"></a>\r\n <a href=\"https://doi.org/10.5281/zenodo.17042859\"><img src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.17042859.svg\" alt=\"DOI\"></a>\r\n</p>\r\n\r\n---\r\n\r\n## Overview\r\n\r\n**Cognize** is a lightweight cognition engine for Python. \r\nIt tracks a system\u2019s **belief** (`V`) against **reality** (`R`), accumulates **misalignment memory** (`E`), and triggers **rupture** when drift exceeds a threshold (`\u0398`).\r\n\r\nIt\u2019s programmable at runtime \u2014 inject your own threshold, realignment, and collapse logic, or use the included safe presets.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- **Epistemic kernel** \u2014 `EpistemicState` (scalar & vector), tracking `V, R, \u0394, \u0398, E`, with rupture and step-capped updates.\r\n- **Programmable policies** \u2014 inject custom `threshold`, `realign`, `collapse` functions or use safe presets (`cognize.policies`).\r\n- **Perception adapter** \u2014 `Perception` fuses text/image/sensor inputs into a normalized vector; bring your own encoders.\r\n- **Meta-policy selection** \u2014 `PolicyManager` with shadow evaluation, \u03b5-greedy exploration, and safe promotion (`SAFE_SPECS`).\r\n- **Epistemic graphs** \u2014 `EpistemicGraph` / `EpistemicProgrammableGraph` orchestrate states via directed, decay/cooldown-aware links with programmable edges (gate \u2192 influence \u2192 magnitude \u2192 target(slice) \u2192 nudge \u2192 damp).\r\n- **Meta-learning bounds** \u2014 `ParamRange`, `ParamSpace`, `enable_evolution()` and `enable_dynamic_evolution()` for bounded/static or provider-driven evolution.\r\n- **Safety & telemetry by design** \u2014 step caps, oscillation damping, cooldowns; per-edge influence logs, cascade traces, `explain_last()`, CSV/JSON export.\r\n- **Ergonomic helpers** \u2014 `make_simple_state`, `make_graph`, `demo_text_encoder` for fast setup.\r\n- **Lightweight core** \u2014 NumPy-only dependency; optional viz/dev extras.\r\n\r\n---\r\n\r\n## Use Cases\r\n\r\n- **Drift & anomaly detection (streaming)** \u2014 compute `\u0394, E, \u0398`; trigger ruptures; emit CSV/JSON telemetry for dashboards.\r\n- **Continual-learning guardrails** \u2014 under non-stationarity, apply reversible cooling (`\u0398\u2191`, `k\u2193` / LR\u2193) to reduce catastrophic forgetting.\r\n- **Modulation for NNs (no retrain)** \u2014 runtime, slice-level nudges (attention logits, LayerNorm \u03b3, MoE gates, temperatures) with caps & logs.\r\n- **Multimodal arbitration (explainable fusion)** \u2014 gate/bias text\u2013vision contributions when disagreement spikes; audit who influenced whom and why.\r\n- **Cognitive & adaptive agents** \u2014 systems that self-correct against misalignment with interpretable state and policy switches.\r\n- **Metacognitive mechanics** \u2014 self-monitoring, policy evaluation/evolution, and reflective control over when/how modules adapt.\r\n- **Networked control** \u2014 orchestrate layers/heads/modules/sensors as nodes; propagate influence with decay/cooldowns for stable coordination.\r\n- **Simulation & research** \u2014 explore rupture dynamics, policy A/B, and bounded evolution with reproducible logs.\r\n\r\n---\r\n\r\n\r\n## Install\r\n\r\n```bash\r\npip install cognize\r\n```\r\n\r\n---\r\n\r\n## Core primitives\r\n\r\n| Symbol | Meaning |\r\n|:------:|-----------------------|\r\n| `V` | Belief / Projection |\r\n| `R` | Reality signal |\r\n| `\u2206` | Distortion (`R\u2212V`) |\r\n| `\u0398` | Rupture threshold |\r\n| `E` | Misalignment memory |\r\n| `\u2299` | Realignment operator |\r\n\r\n---\r\n\r\n## Examples\r\n\r\n### 1) Quick start (scalar)\r\n```python\r\nfrom cognize import EpistemicState\r\nfrom cognize.policies import threshold_adaptive, realign_tanh, collapse_soft_decay\r\n\r\nstate = EpistemicState(V0=0.5, threshold=0.35, realign_strength=0.3)\r\nstate.inject_policy(threshold=threshold_adaptive, realign=realign_tanh, collapse=collapse_soft_decay)\r\n\r\nfor r in [0.1, 0.3, 0.7, 0.9]:\r\n state.receive(r)\r\n\r\nprint(state.explain_last()) # human-readable step summary\r\nprint(state.summary()) # compact state snapshot\r\n```\r\n\r\n### 2) Multimodal in one pass (vector)\r\n```python\r\nimport numpy as np\r\nfrom cognize import EpistemicState, Perception\r\n\r\ndef toy_text_encoder(s: str) -> np.ndarray:\r\n return np.array([len(s), s.count(\" \"), s.count(\"a\"), 1.0], dtype=float)\r\n\r\nP = Perception(text_encoder=toy_text_encoder)\r\nstate = EpistemicState(V0=np.zeros(4), perception=P)\r\n\r\nstate.receive({\"text\": \"hello world\"})\r\nprint(state.last()) # includes \u0394, \u0398, ruptured, etc.\r\n```\r\n\r\n### 3) Meta\u2011policy selection\r\n```python\r\nfrom cognize import EpistemicState, PolicyManager, PolicyMemory, ShadowRunner, SAFE_SPECS\r\nfrom cognize.policies import threshold_adaptive, realign_tanh, collapse_soft_decay\r\n\r\ns = EpistemicState(V0=0.0, threshold=0.35, realign_strength=0.3)\r\ns.inject_policy(threshold=threshold_adaptive, realign=realign_tanh, collapse=collapse_soft_decay)\r\ns.policy_manager = PolicyManager(\r\n base_specs=SAFE_SPECS, memory=PolicyMemory(), shadow=ShadowRunner(),\r\n epsilon=0.15, promote_margin=1.03, cooldown_steps=30\r\n)\r\n\r\nfor r in [0.2, 0.4, 0.5, 0.7, 0.6, 0.8]:\r\n s.receive(r)\r\n\r\nprint(s.summary())\r\n```\r\n\r\n### 4) CSV / JSON export & small stats\r\n```python\r\nfrom pathlib import Path\r\nfrom statistics import mean\r\nfrom cognize import EpistemicState\r\nfrom cognize.policies import threshold_adaptive, realign_tanh, collapse_soft_decay\r\n\r\ns = EpistemicState(V0=0.0, threshold=0.35, realign_strength=0.3)\r\ns.inject_policy(threshold=threshold_adaptive, realign=realign_tanh, collapse=collapse_soft_decay)\r\n\r\nfor r in [0.1, 0.3, 0.9, 0.2, 0.8, 0.7]: s.receive(r)\r\n\r\nout = Path(\"trace.csv\"); s.export_csv(str(out))\r\nprint(\"ruptures:\", s.summary()[\"ruptures\"])\r\nprint(\"mean |\u0394| (last 10):\", mean(abs(h[\"\u2206\"]) for h in s.history[-10:]))\r\n```\r\n\r\n### 5) Plain EpistemicGraph (coupling multiple states)\r\n```python\r\nfrom cognize import make_simple_state, EpistemicGraph\r\n\r\nG = EpistemicGraph(damping=0.5, max_depth=2, max_step=1.0, rupture_only_propagation=True)\r\nG.add(\"A\", make_simple_state(0.0)); G.add(\"B\", make_simple_state(0.0)); G.add(\"C\", make_simple_state(0.0))\r\n\r\n# A \u2192 B (pressure), B \u2192 C (delta)\r\nG.link(\"A\", \"B\", weight=0.8, mode=\"pressure\", decay=0.9, cooldown=3)\r\nG.link(\"B\", \"C\", weight=0.5, mode=\"delta\", decay=0.9, cooldown=2)\r\n\r\n# Step node A with evidence; influence cascades per edge modes\r\nG.step(\"A\", 1.2)\r\nprint(G.stats())\r\nprint(\"hot edges:\", G.top_edges(by=\"applied_ema\", k=5))\r\nprint(\"last cascade:\", G.last_cascade(5))\r\n```\r\n\r\n### 6) Programmable graph: register a strategy and link by reference\r\n```python\r\nfrom typing import Dict, Any, Optional\r\nimport numpy as np\r\nfrom cognize import EpistemicProgrammableGraph, register_strategy\r\n\r\n# Minimal programmable pieces (use defaults for the rest)\r\ndef gate_fn(src_st, dst_st, ctx: Dict[str, Any]) -> bool:\r\n # fire only on rupture for 'pressure'/'policy'; always for 'delta'\r\n mode = ctx[\"edge\"][\"mode\"]; rupt = bool(ctx[\"post_src\"].get(\"ruptured\", False))\r\n return (mode != \"pressure\" and mode != \"policy\") or rupt\r\n\r\ndef influence_fn(src_st, post_src: Dict[str, Any], ctx: Dict[str, Any]) -> float:\r\n delta, theta = float(post_src.get(\"\u2206\", 0.0)), float(post_src.get(\"\u0398\", 0.0))\r\n return max(0.0, delta - theta) # pressure\r\n\r\ndef target_fn(dst_st, edge_meta: Dict[str, Any], ctx: Dict[str, Any]) -> Optional[slice]:\r\n # take middle half of a vector V if available\r\n if not isinstance(dst_st.V, np.ndarray): return None\r\n n = dst_st.V.shape[0]; i, j = n//4, 3*n//4\r\n return slice(i, j)\r\n\r\nregister_strategy(\"cooling@1.0.0\", gate_fn=gate_fn, influence_fn=influence_fn, target_fn=target_fn)\r\n\r\nG = EpistemicProgrammableGraph(damping=0.6, max_depth=2)\r\nG.add(\"X\"); G.add(\"Y\")\r\n# attach by reference; params are JSON-safe and persisted\r\nG.link(\"X\", \"Y\", mode=\"policy\", weight=0.7, decay=0.9, cooldown=4,\r\n strategy_id=\"cooling@1.0.0\", params={\"bias_decay\": 0.9})\r\n\r\n# Drive X; programmable edge applies reversible \u0398\u2191/k\u2193 bias on Y when X ruptures\r\nG.step(\"X\", 1.4)\r\nprint(G.last_cascade(3))\r\n\r\n# Persist topology + strategy references (no code serialization)\r\nG.save_graph(\"graph.json\", include_strategies=True)\r\n\r\n# Load later (rebinds strategies by ID from registry)\r\nH = EpistemicProgrammableGraph()\r\nH.add(\"X\"); H.add(\"Y\")\r\nH.load_graph(\"graph.json\", strict_strategies=False)\r\n```\r\n\r\n### 7) Influence preview (what would be applied?)\r\n```python\r\nfrom cognize import EpistemicGraph, make_simple_state\r\n\r\nG = EpistemicGraph()\r\nG.add(\"A\", make_simple_state(0.0)); G.add(\"B\", make_simple_state(0.0))\r\nG.link(\"A\", \"B\", weight=0.8, mode=\"pressure\", decay=0.9, cooldown=1)\r\n\r\n# Pretend A just ruptured with \u0394=1.0, \u0398=0.3 (no state mutation)\r\npostA = {\"\u2206\": 1.0, \"\u0398\": 0.3, \"ruptured\": True}\r\nprint(\"predicted magnitude:\", G.predict_influence(\"A\", \"B\", post=postA))\r\n```\r\n\r\n### 8) Suspend propagation (isolate learning vs. coupling)\r\n```python\r\nfrom cognize import EpistemicGraph, make_simple_state\r\n\r\nG = EpistemicGraph()\r\nfor n in (\"A\",\"B\"): G.add(n, make_simple_state(0.0))\r\nG.link(\"A\",\"B\", weight=1.0, mode=\"pressure\")\r\n\r\nwith G.suspend_propagation():\r\n # A will update itself, but won't influence B during this block\r\n G.step(\"A\", 2.0)\r\n\r\n# Propagation resumes here\r\nG.step(\"A\", 2.2)\r\n```\r\n\r\n### 9) Tiny NN control\u2011plane sketch (PyTorch, optional)\r\n```python\r\n# Pseudo-code: shows the observer \u2192 graph \u2192 nudge loop\r\nimport torch\r\nfrom cognize import EpistemicProgrammableGraph\r\n\r\npeg = EpistemicProgrammableGraph(max_depth=1, damping=0.5)\r\npeg.add(\"L23\"); peg.add(\"HEAD7\")\r\npeg.link(\"L23\",\"HEAD7\", mode=\"policy\", weight=0.6, decay=0.9, cooldown=3)\r\n\r\ndef entropy(x): # simple example metric\r\n p = torch.softmax(x.flatten(), dim=0); return -(p * (p+1e-9).log()).sum().item()\r\n\r\nattn_logits_ref = {} # cache last logits tensor per step (just illustrative)\r\n\r\ndef hook_L23(module, inp, out):\r\n peg.step(\"L23\", {\"norm\": out.norm().item(), \"ruptured\": False}) # you decide the R fields\r\n\r\ndef hook_HEAD7(module, inp, out):\r\n attn_logits_ref[\"HEAD7\"] = out # capture a handle to nudge later\r\n\r\n# Attach forward hooks on your model (where it makes sense)\r\n# layer23.register_forward_hook(hook_L23)\r\n# head7.register_forward_hook(hook_HEAD7)\r\n\r\n# After forward:\r\n# peg.step(\"HEAD7\", {\"entropy\": entropy(attn_logits_ref[\"HEAD7\"])})\r\n# (peg runs propagation internally during step)\r\n# Apply your bounded nudges here according to your edge strategies/logs.\r\n```\r\n---\r\n\r\n## Citation\r\n\r\nIf you use **Cognize**, please cite the concept DOI (always resolves to the latest version):\r\n\r\n```bibtex\r\n@software{pulikanti_cognize,\r\n author = {Pulikanti, Sashi Bharadwaj},\r\n title = {Cognize: Programmable cognition for Python systems},\r\n publisher = {Zenodo},\r\n doi = {10.5281/zenodo.17042859},\r\n url = {https://doi.org/10.5281/zenodo.17042859}\r\n}\r\n```\r\n\r\n---\r\n\r\n## License\r\n\r\nLicensed under the **Apache License 2.0**. \r\n\u00a9 2025 Pulikanti Sashi Bharadwaj\r\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Programmable cognition for Python systems.",
"version": "0.1.8",
"project_urls": {
"Homepage": "https://github.com/heraclitus0/cognize",
"Issues": "https://github.com/heraclitus0/cognize/issues",
"Source": "https://github.com/heraclitus0/cognize",
"UserGuide": "https://github.com/heraclitus0/cognize/blob/main/docs/USER_GUIDE.md"
},
"split_keywords": [
"cognition",
" epistemic",
" rupture",
" projection",
" ai",
" symbolic",
" drift"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d2871515231ac11be6d2fd2f7553c096fa74f9a1be8792198368495ef247ed48",
"md5": "6dcc32355218d74c96a11b50c5184c20",
"sha256": "91cde7b99fa2b4442acf6f3cd9f44dc58547244bb82d5eaf7164b87986e1532f"
},
"downloads": -1,
"filename": "cognize-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6dcc32355218d74c96a11b50c5184c20",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 50824,
"upload_time": "2025-09-05T21:15:13",
"upload_time_iso_8601": "2025-09-05T21:15:13.627359Z",
"url": "https://files.pythonhosted.org/packages/d2/87/1515231ac11be6d2fd2f7553c096fa74f9a1be8792198368495ef247ed48/cognize-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b5bd45c03fff9298966cd772615de86aa78f90b18aa2c704ad248beb119ed774",
"md5": "2fb62a441bc2dc1ded71e98031bb32ff",
"sha256": "9af9404652ca0e8f4be605d73ff403386ce6b98dd051acf7f9f2ae72b1d16e04"
},
"downloads": -1,
"filename": "cognize-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "2fb62a441bc2dc1ded71e98031bb32ff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 54671,
"upload_time": "2025-09-05T21:15:15",
"upload_time_iso_8601": "2025-09-05T21:15:15.348361Z",
"url": "https://files.pythonhosted.org/packages/b5/bd/45c03fff9298966cd772615de86aa78f90b18aa2c704ad248beb119ed774/cognize-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-05 21:15:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "heraclitus0",
"github_project": "cognize",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.26"
]
]
}
],
"lcname": "cognize"
}