ravana-chat 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. ravana_chat-0.1.1/PKG-INFO +481 -0
  2. ravana_chat-0.1.1/README.md +463 -0
  3. ravana_chat-0.1.1/pyproject.toml +23 -0
  4. ravana_chat-0.1.1/setup.cfg +4 -0
  5. ravana_chat-0.1.1/src/ravana/__init__.py +26 -0
  6. ravana_chat-0.1.1/src/ravana/bootstrap/__init__.py +6 -0
  7. ravana_chat-0.1.1/src/ravana/bootstrap/manager.py +46 -0
  8. ravana_chat-0.1.1/src/ravana/chat/__init__.py +6 -0
  9. ravana_chat-0.1.1/src/ravana/chat/__main__.py +5 -0
  10. ravana_chat-0.1.1/src/ravana/chat/interface.py +1376 -0
  11. ravana_chat-0.1.1/src/ravana/cognitive/__init__.py +142 -0
  12. ravana_chat-0.1.1/src/ravana/cognitive/framework.py +687 -0
  13. ravana_chat-0.1.1/src/ravana/core/__init__.py +23 -0
  14. ravana_chat-0.1.1/src/ravana/core/belief_store.py +242 -0
  15. ravana_chat-0.1.1/src/ravana/core/dual_process.py +106 -0
  16. ravana_chat-0.1.1/src/ravana/core/emotion.py +94 -0
  17. ravana_chat-0.1.1/src/ravana/core/global_workspace.py +86 -0
  18. ravana_chat-0.1.1/src/ravana/core/identity.py +104 -0
  19. ravana_chat-0.1.1/src/ravana/core/meaning.py +68 -0
  20. ravana_chat-0.1.1/src/ravana/core/meta_cognition.py +100 -0
  21. ravana_chat-0.1.1/src/ravana/core/sleep.py +188 -0
  22. ravana_chat-0.1.1/src/ravana/decoder/__init__.py +6 -0
  23. ravana_chat-0.1.1/src/ravana/decoder/engine.py +492 -0
  24. ravana_chat-0.1.1/src/ravana/graph/__init__.py +22 -0
  25. ravana_chat-0.1.1/src/ravana/graph/engine.py +1025 -0
  26. ravana_chat-0.1.1/src/ravana/language/__init__.py +11 -0
  27. ravana_chat-0.1.1/src/ravana/language/basal_ganglia.py +320 -0
  28. ravana_chat-0.1.1/src/ravana/language/cerebellar_ngram.py +314 -0
  29. ravana_chat-0.1.1/src/ravana/language/prefrontal_workspace.py +439 -0
  30. ravana_chat-0.1.1/src/ravana/language/surface_realizer.py +388 -0
  31. ravana_chat-0.1.1/src/ravana/language/syntactic_cell_assembly.py +499 -0
  32. ravana_chat-0.1.1/src/ravana/nn/__init__.py +5 -0
  33. ravana_chat-0.1.1/src/ravana/nn/rlm/__init__.py +15 -0
  34. ravana_chat-0.1.1/src/ravana/nn/rlm/plasticity.py +444 -0
  35. ravana_chat-0.1.1/src/ravana/nn/rlm/propagation.py +279 -0
  36. ravana_chat-0.1.1/src/ravana/nn/rlm/relation_predictor.py +587 -0
  37. ravana_chat-0.1.1/src/ravana/web/__init__.py +6 -0
  38. ravana_chat-0.1.1/src/ravana/web/learner.py +767 -0
  39. ravana_chat-0.1.1/src/ravana/world/__init__.py +3 -0
  40. ravana_chat-0.1.1/src/ravana_chat.egg-info/PKG-INFO +481 -0
  41. ravana_chat-0.1.1/src/ravana_chat.egg-info/SOURCES.txt +42 -0
  42. ravana_chat-0.1.1/src/ravana_chat.egg-info/dependency_links.txt +1 -0
  43. ravana_chat-0.1.1/src/ravana_chat.egg-info/requires.txt +13 -0
  44. ravana_chat-0.1.1/src/ravana_chat.egg-info/top_level.txt +1 -0
@@ -0,0 +1,481 @@
1
+ Metadata-Version: 2.4
2
+ Name: ravana-chat
3
+ Version: 0.1.1
4
+ Summary: RAVANA modular package -- decoder-first chat with continuous web learning
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy>=1.20
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest>=7.0; extra == "dev"
11
+ Provides-Extra: web
12
+ Requires-Dist: requests; extra == "web"
13
+ Requires-Dist: sentence-transformers; extra == "web"
14
+ Provides-Extra: full
15
+ Requires-Dist: requests; extra == "full"
16
+ Requires-Dist: sentence-transformers; extra == "full"
17
+ Requires-Dist: tiktoken; extra == "full"
18
+
19
+ # RAVANA — Recursive Learning Model
20
+
21
+ > **A pressure-driven cognitive ML framework where learning emerges from self-organization, not gradient descent.**
22
+
23
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](https://python.org)
24
+ [![NumPy](https://img.shields.io/badge/NumPy-1.20%2B-orange)](https://numpy.org)
25
+ [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
26
+ [![Status](https://img.shields.io/badge/Status-Research%20Prototype-yellow)]()
27
+
28
+ ---
29
+
30
+ ## What Is RAVANA?
31
+
32
+ RAVANA is a **cognitive architecture research project** proposing *pressure-driven self-organization* as an alternative to gradient descent for machine learning. Instead of minimizing loss functions via backpropagation, RAVANA learns through **cognitive dissonance minimization**: prediction errors create internal pressure (free energy), and the system self-organizes to reduce that pressure.
33
+
34
+ ```
35
+ Traditional ML: Loss(θ) = f(prediction, target) → ∇Loss → θ ← θ - η∇Loss
36
+ RAVANA: Prediction Error → Free Energy (Pressure) → Hebbian Plasticity + Sleep → Equilibrium
37
+ ```
38
+
39
+ ### Core Philosophy
40
+
41
+ | Traditional ML | RAVANA |
42
+ |----------------|--------|
43
+ | **Loss functions** → gradients | **Free energy** (pressure) → self-organization |
44
+ | **Backpropagation** | **Hebbian/anti-Hebbian plasticity** + structural plasticity |
45
+ | **Weight decay, regularization** | **Identity** + homeostatic sleep consolidation |
46
+ | **Batch/layer normalization** | **SWS + REM sleep cycles** with dream sabotage |
47
+ | **Dense weight matrices** | **ConceptGraph** (typed edges, inhibition, hierarchy) |
48
+ | **Global attention** | **Spreading activation** (local, bounded, typed) |
49
+ | **Static weights / RAG** | **Episodic → Semantic → Graph bridge** |
50
+ | **External reward functions** | **Intrinsic motivation** (Meaning = f(-Dissonance, Identity, Prediction)) |
51
+ | **No emotion/identity** | **VAD emotion engine** + momentum-based identity |
52
+
53
+ ---
54
+
55
+ ## Two Architectures, One Codebase
56
+
57
+ RAVANA now contains **two complementary cognitive architectures**:
58
+
59
+ ### 1. **RAVANA v2** — GRACE Cognitive Core (`ravana-v2/`)
60
+ The original GRACE (General Recursive Adaptive Cognitive Engine) with 27 phases (A–P) implementing:
61
+ - **Governor regulation** (Phases A–C) — Hard constraints, predictive dampening, center-seeking homeostasis
62
+ - **Strategy & Intent** (Phases D–J) — 4 strategy modes, planning, hypotheses, Occam layer
63
+ - **World Model & Epistemology** (Phases F–G.5) — Belief reasoning, active probes, VoI-driven action
64
+ - **Emotion & Sleep** (Phases K–L.5) — VAD emotion, empathy, 4-stage sleep, dual-process
65
+ - **Meaning & Consciousness** (Phases M–N) — Intrinsic motivation, global workspace
66
+ - **Human Memory & Dialogue** (Phases O–P) — Episodic/semantic persistence, conversational repair
67
+
68
+ ### 2. **RAVANA Modular** — Decoder-First Chat (`ravana/`) **NEW**
69
+ A streamlined, package-oriented architecture focused on **continuous web learning** and **decoder-first generation**:
70
+ - **CognitiveCore** (`ravana/core/`) — VAD emotion, Identity, Meaning, Dual-process, Global Workspace, Meta-cognition, Sleep, **Multi-user BeliefStore**
71
+ - **GraphEngine** (`ravana/graph/`) — Concept graph, spreading activation, hippocampal indexing, curiosity scoring
72
+ - **DecoderEngine** (`ravana/decoder/`) — Neural decoder, vocab building, seed corpus + web article training
73
+ - **WebLearner** (`ravana/web/`) — Multi-API search (circuit breaker), background learning, curiosity-driven exploration (Phase 18)
74
+ - **BootstrapManager** (`ravana/bootstrap/`) — Consolidated concept seeding (3 methods unified)
75
+ - **RLMv2 Decomposed** (`ravana/nn/rlm/`) — RelationPredictor, PropagationEngine, Plasticity
76
+ - **ChatInterface** (`ravana/chat/`) — CLI, response pipeline, reasoning loop
77
+
78
+ ---
79
+
80
+ ## Key Innovations (Shared)
81
+
82
+ ### 🧠 Pressure-Driven Learning
83
+ No loss functions, no gradients, no backpropagation. Learning driven by **5-channel free energy accumulator** tracking semantic, linguistic, episodic, contradiction, and abstraction prediction errors.
84
+
85
+ ### 🕸️ ConceptGraph with Typed Edges
86
+ Heterogeneous graph of concept nodes with **active/core/genesis vectors** connected by typed relation edges (semantic, causal, temporal, analogical, contextual, inferred, inhibitory). Each edge carries weight, confidence, relation vector, predicate token, EWC importance, and Bayesian posterior.
87
+
88
+ ### 💤 Sleep Consolidation (SWS + REM)
89
+ Two-phase sleep modeled on mammalian sleep:
90
+ - **SWS**: Structural stabilization, adaptive homeostatic downscale, hierarchical abstraction compression, inhibitory edge formation, hippocampal replay
91
+ - **REM**: Creative recombination via 20% counterfactual reversals, 10% emotional valence flipping, 1.5× failure oversampling
92
+
93
+ ### 🔄 Sleep-Time Interleaved Replay
94
+ Domain-tagged experiences buffered during training, replayed during SWS+REM. **Eliminates catastrophic forgetting entirely** (12% → 0% retention drop) in lifelong streaming benchmarks.
95
+
96
+ ### 🏛️ GRACE Governor (v2 only)
97
+ Closed-loop regulation with four layers: hard constraints (non-negotiable), predictive dampening (look-ahead), boundary pressure (air resistance), center-seeking homeostasis. **Fully observable** with clamp diagnostics.
98
+
99
+ ### 🎭 VAD Emotion Engine
100
+ 3D affective state (Valence, Arousal, Dominance) via differential equations. Modulates inference: high arousal → exploration, positive valence → trust predictions, high dominance → stronger concepts.
101
+
102
+ ### 🧩 RLMv2 — Triple Decomposition Architecture
103
+ Brain-inspired: decomposes input into **(subject, relation_type, object)** triples. Enables vector arithmetic analogy: `subject_embed + offset(verb) ≈ target_embed`. **Spreading activation is the sole inference mechanism**.
104
+
105
+ ### 📖 GloVe Semantic Embeddings
106
+ Token embeddings initialized from pre-trained GloVe (100D) projected via QR-based orthogonal projection. Replaces character n-gram embeddings for genuine semantic relationships.
107
+
108
+ ### 🎯 Verb-Stem Offset Predictor
109
+ New inference path: `offset(verb) = avg(target - subject)` over training pairs. Each verb gets its own offset. **RP-only cross-domain top-10: 3.3% → 6.7%**.
110
+
111
+ ### 🌐 Continuous Web Learning (Modular only)
112
+ `WebLearner` fetches → extracts → trains decoder online. Knowledge grows **without retraining from scratch**. Curiosity-driven (free energy + contradiction + novelty + serendipity).
113
+
114
+ ### 👥 Multi-User Belief Merging (Modular only)
115
+ `BeliefStore` tracks *who believes what*, detects contradictions, merges across users — `cross_reference_users()`, `find_agreement()`, `find_disagreement()`.
116
+
117
+ ---
118
+
119
+ ## Quick Start
120
+
121
+ ### Installation
122
+
123
+ ```bash
124
+ # Primary (Codeberg)
125
+ git clone https://codeberg.org/oxiverse/ravana.git
126
+ # Mirror (GitHub)
127
+ git clone https://github.com/oxiverse-ecosystem/ravana.git
128
+ cd ravana
129
+ pip install -e ravana/ # NumPy only (modular package)
130
+ pip install tiktoken # Optional: BPE tokenizer
131
+ ```
132
+
133
+ ### Modular Package — Decoder-First Chat (NEW)
134
+
135
+ ```bash
136
+ # Interactive chat with web learning
137
+ python -m ravana.chat
138
+
139
+ # Batch mode for testing
140
+ python -m ravana.chat --chat "hello|what is trust|explain oxiverse|bye" --strategy
141
+
142
+ # With ablation flags
143
+ python -m ravana.chat --chat "what causes rain" --no-vad --no-rlm --no-beliefs --no-curiosity
144
+ ```
145
+
146
+ **Key flags:**
147
+ - `--no-vad` — Disable VAD emotion modulation
148
+ - `--no-rlm` — Disable RLMv2 triple verification
149
+ - `--no-beliefs` — Disable belief store
150
+ - `--no-curiosity` — Disable autonomous curiosity-driven learning
151
+ - `--mode` — `stochastic` | `deterministic` | `exploratory`
152
+ - `--trace` — Print chain traces
153
+ - `--data-dir` — Custom data directory
154
+ - `--user` — Multi-user isolation
155
+
156
+ ### GRACE Cognitive Core (v2)
157
+
158
+ ```python
159
+ from ravana_v2.cognitive import CognitiveFramework
160
+
161
+ fw = CognitiveFramework()
162
+ state = fw.initialize()
163
+
164
+ for episode, (inp_vec, tgt_vec) in enumerate(training_data):
165
+ concepts = fw.perceive(state, inp_vec)
166
+ predictions = fw.predict(state, concepts)
167
+ state = fw.learn(state, predictions, tgt_vec, episode)
168
+ if episode % 100 == 0:
169
+ state = fw.sleep(state)
170
+
171
+ result = fw.infer(state, test_vec) # Inference without state change
172
+ ```
173
+
174
+ ### RLMv2 — Language Model (Shared)
175
+
176
+ ```python
177
+ from ravana.nn import RLM
178
+ from ravana_ml.tokenizer import WordTokenizer
179
+ import numpy as np
180
+
181
+ tok = WordTokenizer()
182
+ tok.encode("heat causes expansion")
183
+
184
+ model = RLM(
185
+ vocab_size=tok.vocab_size,
186
+ embed_dim=64,
187
+ concept_dim=64,
188
+ n_concepts=100,
189
+ latent_dim=64, # Set equal to embed_dim for entity adapter compatibility
190
+ )
191
+ inp = np.array(tok.encode("heat causes"), dtype=np.int64)
192
+ tgt = np.array(tok.encode("expansion"), dtype=np.int64)
193
+ model.learn(inp, tgt)
194
+ model.sleep_cycle()
195
+ logits = model.forward(inp)
196
+ ```
197
+
198
+ **Note:** The `latent_dim` parameter controls the world model latent dimension. For the entity-specific adapter (enables test-time adaptation for held-out subjects) to work without additional projection overhead, set `latent_dim=embed_dim`. If they differ, the model automatically projects embeddings to latent space before applying the adapter.
199
+
200
+ ---
201
+
202
+ ## Benchmarks (External)
203
+
204
+ All benchmarks are run via external benchmarking infrastructure. See [`docs/EXPERIMENTS.md`](docs/EXPERIMENTS.md) for reproduction instructions and expected results.
205
+
206
+ ### External Benchmark Harness (NEW)
207
+
208
+ ```bash
209
+ # Quick run (PCX + Graph, ~2 min)
210
+ python external_benchmark.py --quick
211
+
212
+ # Full suite (PCX + Lifelong + Graph, ~10 min)
213
+ python external_benchmark.py
214
+
215
+ # Individual surfaces
216
+ python external_benchmark.py --quick --skip-lifelong # PCX + Graph
217
+ python external_benchmark.py --quick --skip-pcx # Lifelong + Graph
218
+ ```
219
+
220
+ **Key external validation results:**
221
+
222
+ | Metric | Result |
223
+ |--------|--------|
224
+ | Cross-domain transfer Top-1 | **75.0%** |
225
+ | Cross-domain transfer Top-10 | **100%** |
226
+ | Held-out Science Top-1 / Top-10 | 8.3% / 25.0% (n=12) |
227
+ | Held-out Social Top-1 / Top-10 | 0.0% / 8.3% (n=36) |
228
+ | Graph Inference P95 / P99 | 2.7 ms / 2.9 ms |
229
+ | Graph Peak Memory / Throughput | 0.3 MB / 556 QPS |
230
+ | W_rel Causal / Semantic Alignment | 0.68 / 0.55 |
231
+ | Lifelong forgetting (permuted MNIST) | **0%** (with sleep) |
232
+ | Within-domain triple top-10 | 80.9% |
233
+
234
+ ---
235
+
236
+ ## Documentation
237
+
238
+ | Document | Description |
239
+ |----------|-------------|
240
+ | [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | Complete architecture reference — GRACE, RLMv2, Phases A–P, GloVe, verb-stem offset |
241
+ | [`docs/GETTING_STARTED.md`](docs/GETTING_STARTED.md) | Quickstart tutorial — install to first model in 5 minutes |
242
+ | [`docs/ML_FRAMEWORK.md`](docs/ML_FRAMEWORK.md) | ravana_ml deep dive — tensors, modules, ConceptGraph, RLM v1/v2 |
243
+ | [`docs/COGNITIVE_CORE.md`](docs/COGNITIVE_CORE.md) | ravana-v2 reference — all 27 GRACE modules, configurations |
244
+ | [`docs/UNIFIED_PACKAGE.md`](docs/UNIFIED_PACKAGE.md) | ravana/ package — PyTorch API, CognitiveFramework, serialization |
245
+ | [`docs/API_REFERENCE.md`](docs/API_REFERENCE.md) | Complete function/class reference for all three layers |
246
+ | [`docs/CONCEPTS.md`](docs/CONCEPTS.md) | Theoretical foundations — pressure, free energy, Hebbian, sleep, VAD, triples |
247
+ | [`docs/EXPERIMENTS.md`](docs/EXPERIMENTS.md) | Running experiments — cross-domain, Phase 4, RLMv2 benchmarks, cognitive phases, **modular ablations, per-triple eval** |
248
+ | [`docs/ADVANCED_TOPICS.md`](docs/ADVANCED_TOPICS.md) | Customization — tokenizers, plasticity, sleep, governor, multi-agent, lifelong |
249
+ | [`docs/TUTORIALS.md`](docs/TUTORIALS.md) | 8 step-by-step tutorials — Hello World to visualization |
250
+ | [`docs/DEVELOPER_GUIDE.md`](docs/DEVELOPER_GUIDE.md) | Contributing — code standards, testing, architecture principles, release process |
251
+
252
+ ---
253
+
254
+ ## Running Tests
255
+
256
+ ```bash
257
+ # Modular package tests (NEW)
258
+ python -m pytest tests/test_cognitive_rlm.py -v
259
+ python -m pytest tests/test_dialogue_system.py -v
260
+ python -m pytest tests/test_dialogue_engine_integration.py -v
261
+ python -m pytest tests/ -k "not slow" -v
262
+
263
+ # RLMv2 unit tests (shared)
264
+ python -m pytest tests/test_rlm_v2.py -v
265
+ python -m pytest tests/test_rp_only.py -v
266
+ python -m pytest tests/test_rp_contrastive.py -v
267
+ python -m pytest tests/test_structural_transfer.py -v
268
+
269
+ # GRACE cognitive core tests (v2)
270
+ python -m pytest ravana-v2/tests/ -v
271
+
272
+ # All tests
273
+ python -m pytest tests/ ravana-v2/tests/ -v
274
+ ```
275
+
276
+ **Current status: 169 tests passing** (15 cognitive + 49 dialogue + 15 integration + ML framework tests)
277
+
278
+ ---
279
+
280
+ ## Running Experiments
281
+
282
+ ### Modular Package Experiments (NEW)
283
+
284
+ ```bash
285
+ # Ablation study — all config combinations
286
+ python scripts/run_ablation.py --queries "hello|what is trust|explain oxiverse|bye" --runs 3
287
+ python scripts/run_ablation.py --quick --modes # Baseline + single flag removals + mode variants
288
+
289
+ # Per-triple evaluation harness
290
+ python scripts/triple_eval.py --data-dir ./data --output triple_eval_report.json
291
+ python scripts/triple_eval.py --triples-file my_triples.json --output report.json
292
+ ```
293
+
294
+ ### GRACE / ML Framework Experiments
295
+
296
+ ```bash
297
+ # Cross-domain transfer
298
+ python experiments/experiment_cross_domain.py
299
+
300
+ # Phase 4 integrated (triplet margin + wake-sleep)
301
+ python experiments/experiment_phase4_integrated.py
302
+
303
+ # RLMv2 triple benchmark
304
+ python experiments/experiment_triple_benchmark_v6.py
305
+
306
+ # Diagnostic tests
307
+ python tests/test_rp_only.py
308
+ python tests/test_rp_contrastive.py
309
+ python tests/test_structural_transfer.py
310
+
311
+ # Cognitive architecture experiments
312
+ cd ravana-v2 && python experiments/runner.py
313
+ ```
314
+
315
+ ### Custom Experiments
316
+
317
+ See [`docs/EXPERIMENTS.md`](docs/EXPERIMENTS.md#custom-experiments) for templates and configuration reference.
318
+
319
+ ---
320
+
321
+ ## Project Structure
322
+
323
+ ```
324
+ ravana/
325
+ ├── README.md # This file
326
+ ├── ravana/ # Unified pip-installable package (NEW)
327
+ │ ├── __init__.py # import ravana
328
+ │ ├── core/ # CognitiveCore
329
+ │ │ ├── emotion.py # VADEmotionEngine (VAD dynamics)
330
+ │ │ ├── identity.py # IdentityEngine (self-coherence)
331
+ │ │ ├── meaning.py # MeaningEngine (dissonance reduction)
332
+ │ │ ├── dual_process.py # DualProcessController (System 1/2)
333
+ │ │ ├── global_workspace.py # GlobalWorkspace (broadcast)
334
+ │ │ ├── meta_cognition.py # MetaCognition (bias detection)
335
+ │ │ ├── sleep.py # SleepConsolidation (hippocampal replay)
336
+ │ │ ├── belief_store.py # BeliefStore (multi-user merging)
337
+ │ │ └── __init__.py
338
+ │ ├── graph/ # GraphEngine
339
+ │ │ ├── engine.py # Concept graph, spreading activation, hippocampal indexing
340
+ │ │ └── __init__.py # + backward compat: ConceptGraph, ConceptNode, etc.
341
+ │ ├── decoder/ # DecoderEngine
342
+ │ │ ├── engine.py # Neural decoder, vocab, training, generation
343
+ │ │ └── __init__.py
344
+ │ ├── web/ # WebLearner
345
+ │ │ ├── learner.py # Multi-API search, background learning, curiosity
346
+ │ │ └── __init__.py
347
+ │ ├── bootstrap/ # BootstrapManager
348
+ │ │ ├── manager.py # Consolidated: auto_expand, seed_from_curiosity, bootstrap_domain
349
+ │ │ └── __init__.py
350
+ │ ├── nn/rlm/ # RLMv2 Decomposed
351
+ │ │ ├── relation_predictor.py # RelationPredictor (W_rel, verb-stem offset)
352
+ │ │ ├── propagation.py # PropagationEngine (multi-phase spread)
353
+ │ │ ├── plasticity.py # Plasticity (Hebbian/Anti-Hebbian/Structural)
354
+ │ │ └── __init__.py
355
+ │ ├── chat/ # ChatInterface
356
+ │ │ ├── interface.py # CLI, response pipeline, reasoning loop
357
+ │ │ └── __init__.py
358
+ │ └── pyproject.toml # numpy>=1.20
359
+ ├── ravana_ml/ # ML Framework (~5,200 lines)
360
+ │ ├── nn/rlm_v2.py # RLMv2 (triple decomposition, GloVe)
361
+ │ ├── graph.py # ConceptGraph (3,678 lines)
362
+ │ ├── tensor.py # StateTensor / RawTensor / Parameter
363
+ │ ├── plasticity.py # Hebbian, Anti-Hebbian, Structural
364
+ │ └── ... (tokenizer, embedder, free_energy, currencies, propagation)
365
+ ├── ravana-v2/ # GRACE Cognitive Core (~19,500 lines)
366
+ │ ├── core/ # 27 Phases A–P modules
367
+ │ │ ├── governor.py # Central regulation
368
+ │ │ ├── identity.py # Momentum-based self-concept
369
+ │ │ ├── sleep.py # 4-stage SWS+REM
370
+ │ │ ├── emotion.py # VAD differential equations
371
+ │ │ ├── human_memory.py # Episodic/Semantic (2,321 lines)
372
+ │ │ ├── global_workspace.py # Consciousness bottleneck
373
+ │ │ ├── meaning.py # Intrinsic motivation
374
+ │ │ ├── dual_process.py # System 1 / System 2
375
+ │ │ └── ... (20 more modules)
376
+ │ ├── experiments/phases/ # Phase runners
377
+ │ └── tests/ # Unit tests
378
+ ├── experiments/ # Cross-domain & Phase 4 experiments (18 files)
379
+ ├── scripts/ # Analysis & evaluation tools
380
+ │ ├── run_ablation.py # Ablation study runner (NEW)
381
+ │ ├── triple_eval.py # Per-triple evaluation harness (NEW)
382
+ │ └── ...
383
+ ├── tests/ # ML framework tests (17 files)
384
+ ├── docs/ # Full documentation (12 files)
385
+ ├── data/glove/ # GloVe embeddings (download required)
386
+ ├── results/ # Benchmark outputs & diagnostics
387
+ ├── ablation_results.json # Ablation study outputs
388
+ ├── triple_eval_report.json # Per-triple diagnostic reports
389
+ └── RAVANA_DEV_PLAN.md # Development roadmap
390
+ ```
391
+
392
+ ---
393
+
394
+ ## Ablation Study Framework (NEW)
395
+
396
+ The modular package includes a systematic ablation runner (`scripts/run_ablation.py`):
397
+
398
+ ```bash
399
+ # Full factorial (4 flags × 3 modes = 48 configs)
400
+ python scripts/run_ablation.py --queries "hello|what is trust|explain oxiverse|bye" --runs 3
401
+
402
+ # Quick mode (baseline + 4 single removals + 2 mode variants = 7 configs)
403
+ python scripts/run_ablation.py --quick --modes
404
+
405
+ # Output: ablation_results.json + markdown comparison table
406
+ ```
407
+
408
+ **What it tests:**
409
+ | Flag | Component |
410
+ |------|-----------|
411
+ | `--no-vad` | VAD emotion modulation |
412
+ | `--no-rlm` | RLMv2 triple verification |
413
+ | `--no-beliefs` | Multi-user belief store |
414
+ | `--no-curiosity` | Autonomous curiosity-driven learning |
415
+
416
+ **Metrics tracked:** Success rate, avg latency, total time, error modes per config.
417
+
418
+ ---
419
+
420
+ ## Per-Triple Evaluation Harness (NEW)
421
+
422
+ Detailed diagnostics instead of averaged metrics (`scripts/triple_eval.py`):
423
+
424
+ ```bash
425
+ # Default 10 triples (semantic, causal, contrastive)
426
+ python scripts/triple_eval.py --data-dir ./data --output triple_eval_report.json
427
+
428
+ # Custom triples
429
+ python scripts/triple_eval.py --triples-file my_triples.json --output report.json
430
+ ```
431
+
432
+ **Per-triple metrics:**
433
+ - **Relation type**: semantic / causal / contrastive / possessive / temporal / analogical
434
+ - **Prediction error (PE)**: how well the model predicts the object
435
+ - **Confidence**: model's confidence in the prediction
436
+ - **Top-1 / Top-5 accuracy**: exact match / in top 5
437
+ - **Rank**: position of correct object in predictions
438
+ - **Graph edge**: weight, confidence, type, `prediction_free_energy`
439
+ - **Source**: where learned — `seed` | `web` | `user` | `sleep` | `inference` | `unknown`
440
+
441
+ **Aggregated diagnostics:**
442
+ - Overall metrics + by relation type + by source
443
+ - Edge health summary (avg weight, confidence, PE, type distribution)
444
+
445
+ ---
446
+
447
+ ## License
448
+
449
+ MIT — Built for the RAVANA-AGI-Research initiative.
450
+
451
+ ---
452
+
453
+ ## About
454
+
455
+ RAVANA explores an alternative paradigm for machine learning — where cognition emerges from **internal pressure**, not gradient optimization; where knowledge **self-organizes** through Hebbian plasticity and sleep consolidation; and where **identity, emotion, and meaning** are first-class citizens of the learning dynamics.
456
+
457
+ **The core thesis**: *"Cognition as pressure-driven self-organization."*
458
+
459
+ This is the center of gravity. Everything else is implementation detail.
460
+
461
+ ---
462
+
463
+ ## Citation
464
+
465
+ If you use RAVANA in research, please cite:
466
+
467
+ ```bibtex
468
+ @misc{ravana2026,
469
+ title={RAVANA: Pressure-Driven Self-Organization for Cognitive Machine Learning},
470
+ author={RAVANA Research Team},
471
+ year={2026},
472
+ url={https://codeberg.org/oxiverse/ravana}
473
+ }
474
+ ```
475
+
476
+ ---
477
+
478
+ ## Links
479
+
480
+ - **Documentation**: [`docs/`](docs/)
481
+ - **External Audit**: [`docs/EXTERNAL_AUDIT.md`](docs/EXTERNAL_AUDIT.md)