Skip to main content

Lifelong, contradiction-aware, curiosity-driven memory infrastructure for large language models. Local-first, LLM-agnostic, symbolic.

Project description

Ouroboros Memory

"The LLM is the voice. Ouroboros is the mind."

Symbolic, contradiction-aware, lifelong memory infrastructure for large language models.

Ouroboros Memory is a production-ready local-first system that brings persistent, coherent, auditable memory to any LLM. Unlike embeddings-based approaches, it uses transparent symbolic knowledge graphs that detect contradictions, infer missing facts, and organize autonomouslyโ€”without cloud lock-in or GPU requirements.

PyPI Python 3.10+ License Apache 2.0 Tests Passing Coverage


The Problem

Current LLMs suffer from three critical memory failures:

Problem Impact
No persistent memory Each conversation starts blank. Context windows can't hold real history.
No contradiction detection Conflicting information silently overwrites; coherence degrades over time.
Cloud lock-in Embeddings/vectors require expensive APIs; local alternatives are unauditable.

Ouroboros solves all three: persistent symbolic memory, contradiction detection, full auditability, runs on consumer hardware.


Key Features

โœจ Symbolic Knowledge Graph

  • Transparent (subject, relation, object) triples with confidence weights
  • No opaque embeddingsโ€”every fact is human-readable and auditable
  • Contradictions detected and flagged, never silently blended

๐Ÿง  Curiosity-Driven Autonomous Learning

  • Automatic tension detection: contradictions, prediction errors, novelty, information gaps
  • System autonomously formulates clarifying questions
  • Self-organizing fact consolidation and reorganization

๐Ÿ”Œ LLM-Agnostic

  • Drop-in support for 6 providers: Ollama, llama.cpp, vLLM, OpenAI, Anthropic, Google Gemini
  • Switch providers without losing a single memory
  • Identical API across all backends

๐Ÿ’ป Local-First

  • Runs on laptops and consumer hardware
  • No GPU required for the memory layer
  • Optional local LLM support (Ollama, llama.cpp) for fully offline operation

๐Ÿ” Privacy-Respecting

  • Optional 5-level privacy bridge (PII tokenization, synthetic noise injection, cloud-disable mode)
  • Powered by DigiKabaz
  • All privacy layers are transparent and configurable

๐Ÿ“Š Production Ready

  • 88.79% test coverage (85+ passing tests across core, llm, api, cli, storage, privacy)
  • Strict code quality: ruff linting + mypy --strict type checking
  • Proven scalability: 1M-fact benchmarks with constant throughput (29,469 facts/sec)
  • Paper-conformant: 28 architecture claims validated against empirical data

30-Second Example

from ouroboros import OuroborosMind

# Create a mind (first-run wizard writes ~/.ouroboros/config.yaml)
mind = OuroborosMind()

# Add a fact
mind.chat("My name is Tony. I like dark mode.")
# โ†’ "Noted, Tony. I have crystallized your preference for dark mode."

# Switch LLM provider (memory transfers instantly)
mind.switch_llm("openai", "gpt-4o")

# Query the memory
mind.chat("What do I like?")
# โ†’ "Based on my memory, you enjoy dark mode, Tony."

# Inspect what was stored
print(mind.crystal.facts)
# โ†’ [Fact(subject='Tony', relation='has_name', object='Tony', confidence=1.0),
#     Fact(subject='Tony', relation='prefers', object='dark mode', confidence=0.95)]

Installation

PyPI (Recommended)

pip install ouroboros-memory

From Source

git clone https://github.com/Open-ouroboros/ouroboros-memory
cd ouroboros-memory
pip install -e .[dev,all]

LLM Setup

By default, Ouroboros uses Ollama with gemma3:4b-cloud. No setup needed; the app will guide you.

To use OpenAI, Anthropic, or other providers:

# Configure via interactive setup
ouroboros config

# Or edit directly
nano ~/.ouroboros/config.yaml

Architecture at a Glance

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  LLM Agent (OpenAI ยท Anthropic ยท Ollama ยท etc.)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚ System Prompt + Injected Facts
                 โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚             8-Step Chat Pipeline                    โ”‚
โ”‚  Query Analysis โ†’ Crystal Ranker โ†’ Context Inject   โ”‚
โ”‚       โ†’ LLM Response โ†’ Fact Extract โ†’ Tension       โ”‚
โ”‚           Detection โ†’ Infer โ†’ Consolidate           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ        โ–ผ        โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚        Ouroboros Memory Core                  โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
    โ”‚  โ”‚  Crystal (Dual-layer Knowledge Graph)   โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข 28 semantic relation types            โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Contradiction detection               โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Fact confidence tracking              โ”‚  โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
    โ”‚  โ”‚  Resonance (Dynamic Attention Field)    โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข 24โ†’120 dimensional embedding space   โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Concept ranking and relevance        โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข O(1) query performance                โ”‚  โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
    โ”‚  โ”‚  Tension Engine (Curiosity System)      โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข 7 tension types (contradictions,     โ”‚  โ”‚
    โ”‚  โ”‚    prediction errors, novelty, gaps)    โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Autonomous question formulation      โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Self-directed learning               โ”‚  โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
    โ”‚  โ”‚  Storage Backend (PostgreSQL, SQLite)   โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Persistent fact storage              โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข Scalable to millions of facts        โ”‚  โ”‚
    โ”‚  โ”‚  โ€ข ACID transactions                    โ”‚  โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Full architectural detail: docs/architecture.md


Privacy & Security

Ouroboros integrates DigiKabaz, a privacy bridge with five graduated levels:

Level Description
1 (None) Memory sent to cloud as-is (default for local-only LLMs)
2 (Minimal) Regex PII (email, phone, SSN) tokenized before cloud transmission
3 (Balanced, default) Names, companies, locations, financial data, health info tokenized
4 (High) All personal facts tokenized + synthetic noise injection
5 (Maximum) Cloud LLMs disabled entirely; local models only

Transparent, configurable, auditable. No hidden encryption; you control exactly what leaves your device.


Getting Started

Basic Usage

# Start interactive mode
ouroboros chat

# Start REST API server (http://localhost:8765)
ouroboros start

# GUI dashboard
# โ†’ Open browser to http://localhost:8765 after `ouroboros start`

Python API

from ouroboros import OuroborosMind

# Initialize
mind = OuroborosMind()

# Chat and learn
response = mind.chat("Tell me about reinforcement learning.")
print(response)

# Access raw facts
for fact in mind.crystal.facts:
    print(f"{fact.subject} {fact.relation} {fact.object} [{fact.confidence}]")

# Inspect tensions (curiosity)
for tension in mind.tensions:
    print(f"Tension: {tension.type} โ€” {tension.description}")

# Run a dream pass (self-directed learning)
mind.dream()

# Save and restore
mind.backup("my_memory.backup")
mind.restore("my_memory.backup")

REST API

# Start server
ouroboros start

# In another terminal:
curl -X POST http://localhost:8765/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "My birthday is May 15th"}'
# โ†’ {"response": "Noted. I have crystallized your birthday as May 15th.", "facts_learned": 1}

Examples

Seven runnable end-to-end examples in examples/:

# Example Purpose
1 01_minimal_chat.py Two-turn conversation with crystallized concept inspection
2 02_switch_providers.py One mind, three LLM providers (seamless switching)
3 03_persistence.py Save, wipe, restoreโ€”facts survive across sessions
4 04_privacy_levels.py Walk through all 5 privacy bridge levels
5 05_http_client.py Drive REST API from Python with httpx
6 06_pipeline_inspection.py Inspect each of the 8 chat pipeline steps
7 07_dream_and_stats.py Run a dream pass and read component stats

Run an example:

python examples/01_minimal_chat.py

Documentation

  • User Guide โ€” Installation, configuration, CLI commands, Python API
  • Architecture โ€” Deep dive into Crystal, Resonance, Tension Engine, Parser, Ranker, Assembler
  • API Reference โ€” REST endpoints, WebSocket schema, async patterns
  • Privacy Model โ€” DigiKabaz integration, PII detection, noise injection
  • PLAN.md โ€” Development roadmap, design rationale, future research directions
  • Benchmark Report โ€” Scalability to 1M facts, latency profiles, storage efficiency

Testing & Development

# Install dev dependencies
pip install -e .[dev,all]

# Run full test suite (85+ tests)
pytest tests/

# Run with coverage
pytest --cov=src/ouroboros tests/

# Linting & type checking
ruff check .
mypy src/ --strict

# Benchmark scalability (up to 1M facts)
python scripts/bench_scalability_1m.py

Performance

Ingestion: 29,469 facts/second (constant across all scales)
Storage: 78.5 bytes/fact (1M facts = 74.9 MB)
Query Latency: 0.2ms p50 (O(1) behavior despite 1M facts)
Recall Accuracy: 87โ€“92% (consistent across all scales)

See docs/benchmark_report.md for detailed results.


Contributing

Ouroboros is community-driven. We welcome:

  • Bug reports โ€” Use GitHub Issues
  • Feature requests โ€” Include reference to the research paper or design docs
  • Code contributions โ€” See CONTRIBUTING.md
  • Research & papers โ€” New relation types, tension algorithms, inference strategies

See DEVELOPMENT.md for contributor setup and git workflow.


License

Apache License 2.0. See LICENSE for details.

Commercial use is permitted. No warranty. Use at your own risk.


Citation

If you use Ouroboros Memory in research, please cite:

@software{ouroboros2024,
  title       = {Ouroboros Memory: Symbolic, Contradiction-Aware, Lifelong Memory for LLMs},
  author      = {Open-ouroboros Contributors},
  year        = {2024},
  url         = {https://github.com/Open-ouroboros/ouroboros-memory},
  note        = {v1.0.0, Apache 2.0 License}
}

Acknowledgments

Inspired by neuroscience, knowledge representation, and symbolic AI. Built on proven research in:

  • Contradiction detection โ€” Automated inconsistency resolution in knowledge graphs
  • Curiosity-driven learning โ€” Tension and novelty as learning drivers
  • Local-first architecture โ€” Privacy-respecting inference without cloud lock-in
  • Symbolic memory โ€” Transparent, auditable knowledge storage

Questions?

Made with โค๏ธ by the Ouroboros community.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ouroboros_memory-1.0.0.tar.gz (172.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ouroboros_memory-1.0.0-py3-none-any.whl (132.0 kB view details)

Uploaded Python 3

File details

Details for the file ouroboros_memory-1.0.0.tar.gz.

File metadata

  • Download URL: ouroboros_memory-1.0.0.tar.gz
  • Upload date:
  • Size: 172.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ouroboros_memory-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f9b7c0efb8f2f877a7bcbfa43820298339a6012572bebd8844633ab4abe4a643
MD5 fd3bd301c1a01407532f6c728e1faf4f
BLAKE2b-256 03c1e001938a64c96a2d2e9421c95aeb3dc06a471054f0e0d4f77ac86eca1dcf

See more details on using hashes here.

File details

Details for the file ouroboros_memory-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ouroboros_memory-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2055a42b05aa5a0811f391d5bdf6b603005d0cfd9f74a254bc23b445deb047af
MD5 768e082e30de62d589022f5c9aa2e680
BLAKE2b-256 212eca30741e614f01386c18b861f3cba04a76575a658151c0bb90dc394fff2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page