https://github.com/deepleaper/opc-deepbrain
Pure local self-learning knowledge base. No cloud, no cost, your data stays on your machine.
https://github.com/deepleaper/opc-deepbrain
ai knowledge-base local-first ollama python self-learning sqlite
Last synced: 17 days ago
JSON representation
Pure local self-learning knowledge base. No cloud, no cost, your data stays on your machine.
- Host: GitHub
- URL: https://github.com/deepleaper/opc-deepbrain
- Owner: Deepleaper
- License: other
- Created: 2026-04-30T02:21:53.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2026-05-12T16:39:38.000Z (3 months ago)
- Last Synced: 2026-05-12T18:33:08.234Z (3 months ago)
- Topics: ai, knowledge-base, local-first, ollama, python, self-learning, sqlite
- Language: Python
- Homepage: https://github.com/Deepleaper
- Size: 119 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> โ ๏ธ **DEPRECATED**: OPC DeepBrain has been merged into [OPC Agent](https://github.com/Deepleaper/opc-agent) v1.0.0+.
> Install pip install opc-agent to get both the Agent and DeepBrain in a single package.
> This repository is archived for reference only.
# ๐ง OPC DeepBrain
### Self-Evolving Knowledge Engine for AI Agents โ 6-Layer Memory That Grows With You
### AI Agent ่ช่ฟๅ็ฅ่ฏๅผๆ โ 6 ๅฑ่ฎฐๅฟ๏ผ่ถ็จ่ถ่ชๆ
[](https://pypi.org/project/opc-deepbrain/)
[](https://pypi.org/project/opc-deepbrain/)
[](https://github.com/deepleaper/opc-deepbrain/stargazers)
[](LICENSE)
[](https://python.org)
[](#)
[Website](https://www.deepleaper.com) ยท [Quick Start](#-quick-start) ยท [API Reference](#-api-reference) ยท [vs Mem0](#-comparison)
---
## ๐ก Why DeepBrain?
Memory solutions like Mem0 store facts. **DeepBrain evolves knowledge.**
| Problem | Mem0 / Others | DeepBrain |
|---------|--------------|-----------|
| Memory model | Flat key-value | 6-layer evolving hierarchy |
| Quality control | None | 4-Gate validation system |
| Knowledge growth | Manual CRUD | Auto-promotion through layers |
| Dependencies | Redis, Qdrant, OpenAIโฆ | **Zero** (stdlib only) |
| Storage | Cloud vectors | SQLite (100% local) |
| Self-awareness | โ | โ
Meta-knowledge layer |
**DeepBrain** is a standalone, embeddable knowledge engine that gives any AI agent **long-term, self-evolving memory** โ in 3 lines of code, with zero dependencies.
## โจ Key Features
- ๐๏ธ **6-Layer Memory Architecture** โ From flash memory to meta-knowledge, just like the human brain
- ๐ช **4-Gate Quality Control** โ Every piece of knowledge passes Relevance โ Novelty โ Consistency โ Utility gates
- ๐ฆ **Zero Dependencies** โ Pure Python stdlib. No numpy, no torch, no API keys
- ๐พ **100% Local** โ SQLite storage. Your knowledge never leaves your machine
- ๐ **Embeddable** โ Drop into any Python agent framework in 3 lines
- ๐ **Auto-Evolution** โ Knowledge automatically promotes, consolidates, and archives
## ๐ Quick Start
```bash
pip install opc-deepbrain
```
```python
from deepbrain import DeepBrain
# Initialize
brain = DeepBrain("./my_brain.db")
# Learn
brain.learn("User prefers concise, technical answers", source="conversation")
# Recall
results = brain.search("What communication style does the user prefer?")
print(results[0]["content"]) # โ "User prefers concise, technical answers"
```
**That's it.** No API keys. No config. No cloud. 3 lines to persistent, evolving memory.
## ๐๏ธ 6-Layer Memory Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 5: ๐ฎ Meta-Knowledge โ
โ "I know that I know X well, but Y is uncertain"โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 4: ๐๏ธ Archived โ
โ Historical reference, low-access but preserved โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 3: ๐๏ธ Consolidated โ
โ Cross-session patterns, validated over time โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 2: ๐ Long-Term โ
โ Validated knowledge, frequently accessed โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 1: ๐ Short-Term โ
โ Recent interactions, hours to days โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 0: โก Flash Memory โ
โ Current session buffer, minutes โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Auto-promotion based on relevance,
frequency, and validation scores
```
### How Knowledge Evolves
1. **Ingestion** โ New knowledge enters Layer 0 (Flash)
2. **4-Gate Check** โ Relevance, Novelty, Consistency, Utility scoring
3. **Promotion** โ High-quality knowledge moves up layers over time
4. **Consolidation** โ Related facts merge into coherent understanding
5. **Meta-Learning** โ The system learns its own knowledge strengths/gaps
## ๐ช 4-Gate Quality Control
Every piece of knowledge must pass through 4 gates:
| Gate | Purpose | Question Asked |
|------|---------|---------------|
| ๐ฏ **Relevance** | Is this useful? | Does this relate to active contexts? |
| ๐ **Novelty** | Is this new? | Do we already know this? |
| โ
**Consistency** | Does this fit? | Does it contradict existing knowledge? |
| ๐ง **Utility** | Is this actionable? | Can this improve future responses? |
## ๐ API Reference
### Core API
```python
from deepbrain import DeepBrain
brain = DeepBrain(db_path="./brain.db")
# Learn โ store knowledge
brain.learn(
content="FastAPI is preferred over Flask for new projects",
source="architecture-review",
namespace="tech-decisions"
)
# Recall โ retrieve relevant knowledge
results = brain.search(
query="Which web framework should we use?",
top_k=5
)
# Search โ keyword search
results = brain.search("FastAPI", namespace="tech-decisions")
# Stats โ memory statistics
stats = brain.stats()
print(f"Total entries: {stats['total']}")
print(f"By layer: {stats['by_namespace']}")
# Evolve โ trigger manual evolution cycle
brain.evolve()
```
### Embedding in Your Agent
```python
# Works with any agent framework
class MyAgent:
def __init__(self):
self.brain = DeepBrain("./agent_brain.db")
def chat(self, user_message):
# Recall relevant context
context = self.brain.search(user_message, top_k=3)
# Generate response (your LLM call here)
response = self.llm.generate(user_message, context=context)
# Learn from the interaction
self.brain.learn(
f"User asked about: {user_message}",
source="conversation"
)
return response
```
## โ๏ธ Comparison / ๅฏนๆฏ
| Feature | **OPC DeepBrain** | Mem0 | ChromaDB | Pinecone |
|---------|:-:|:-:|:-:|:-:|
| Memory Model | 6-layer evolving | Flat store | Vector store | Vector store |
| Quality Control | 4-Gate system | โ | โ | โ |
| Auto-Evolution | โ
| โ | โ | โ |
| Meta-Knowledge | โ
| โ | โ | โ |
| Dependencies | **0** | 5+ | 3+ | 2+ |
| Storage | SQLite (local) | Redis + Qdrant | Local/Cloud | Cloud only |
| Cloud Required | โ | โ ๏ธ Optional | โ ๏ธ Optional | โ
Yes |
| Pricing | **Free** | Free/Paid | Free/Paid | Paid |
| Self-Evolving | โ
| โ | โ | โ |
| Python stdlib only | โ
| โ | โ | โ |
## ๐ Integrations
DeepBrain powers memory in:
- [OPC Agent](https://github.com/deepleaper/opc-agent) โ Local AI agent
- [Leaper Agent](https://github.com/deepleaper/leaper-agent) โ Global agent framework
- [Leaper Agent CN](https://github.com/deepleaper/leaper-agent-cn) โ China-optimized agent
- **Your project** โ `pip install opc-deepbrain` and go
## ๐ License
[BSL-1.1](LICENSE) โ see LICENSE for details.
## ๐ค Contributing
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md).
๐ง Contact: [tech@deepleaper.com](mailto:tech@deepleaper.com)
---
**Built with โค๏ธ by [Deepleaper Technology / ่ท็็งๆ](https://www.deepleaper.com)**
*Give your AI agent a brain that evolves.*