Skip to content

WaitThatShouldntWork/vegeta

Repository files navigation

VEGETA: Graph Learns, LLM Executes

Uncertainty-first question answering using Amortized Active Inference.

Core Concept

  • Graph stores learned policies (MetaPatterns with Hebbian-updated strengths)
  • Graph stores episodic memory (PastDecisions for in-context learning)
  • LLM interprets patterns (frozen reader, doesn't learn)

Quick Start

# 1. Setup
pip install -r requirements.txt

# 2. Start Neo4j and Ollama

# 3. Initialize graph
python scripts/setup_mvp_graph.py

# 4. Run demo
python scripts/run_movie_session.py

# 5. Quick test
python scripts/quick_test.py -c recommendation

Architecture

User Query
    │
    ▼
┌─────────────┐     ┌──────────────┐     ┌─────────────────┐
│ Extraction  │────▶│  Retrieval   │────▶│ Action Selection│
│ (entities)  │     │ (k-NN + edges)│     │ (EIG + Hebbian) │
└─────────────┘     └──────────────┘     └────────┬────────┘
                                                  │
                    ┌──────────────┐              │
                    │   Learning   │◀─────────────┤
                    │ (Hebbian LTP)│              ▼
                    └──────────────┘     ┌─────────────────┐
                           ▲             │    Executor     │
                           └─────────────│ (ASK/SEARCH/ANS)│
                                         └─────────────────┘
Active Inference VEGETA Component
States S Knowledge Graph + BeliefState
Observations O User queries, Search results
Policy π MetaPatterns (condition → action)
Expected Free Energy G EIG computation + Hebbian weights

Modular Architecture

vegeta_mvp/
├── core/
│   ├── extraction.py      # Query → Entities (heuristic + intent markers)
│   ├── retrieval.py       # Per-entity k-NN → TaskPatterns → MetaPatterns
│   ├── action_selection.py # EIG + Hebbian + Hyperprior blending
│   ├── executor.py        # ASK/SEARCH/ANSWER dispatch
│   ├── learning.py        # Hebbian LTP/LTD + episodic memory
│   ├── loop.py            # Thin orchestrator (POMDP cycle)
│   ├── types.py           # BeliefState, Action, MetaPattern, etc.
│   ├── belief.py          # Bayesian belief + EIG computation
│   └── priors.py          # Hyperprior system
├── utils/
│   ├── database.py        # Neo4j connection
│   └── llm_client.py      # Ollama client
├── tests/                 # 78 unit tests
scripts/
├── setup_mvp_graph.py     # Schema + seed MetaPatterns
├── run_movie_session.py   # Interactive demo
└── quick_test.py          # Fast iteration testing

Learning Loop

1. EXTRACT: Query → entities + intent markers
2. RETRIEVE: Per-entity k-NN → TaskPatterns → MetaPatterns (via ASSOCIATED_WITH edges)
3. SELECT: EIG scores + Hebbian weights + Hyperpriors → Action
4. EXECUTE: ASK user / SEARCH external / ANSWER from facts
5. LEARN: Hebbian update on edges + store PastDecision

Graph Schema

  • TaskPattern: Intent types (factual_lookup, recommendation, etc.)
  • MetaPattern: Policies (search_when_unknown, ask_preferences, etc.)
  • ASSOCIATED_WITH: Learned edge weights (Hebbian substrate)
  • PastDecision: Episodic memory with USED_PATTERN edges

Tests

python -m pytest vegeta_mvp/tests/ -v

About

A knowledge graph based bayesian active inference system with predictive coding.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published