DEV Community

Cover image for I Built a Decentralized Vector Database on Bittensor Because AI Memory Shouldn't Be Owned by Anyone
Divine Evna Olong
Divine Evna Olong

Posted on

I Built a Decentralized Vector Database on Bittensor Because AI Memory Shouldn't Be Owned by Anyone

#ai

AI agents forget everything.
Every session restart, every redeployment, every time you switch providers — gone. The fixes we've been handed are all centralized: Pinecone, Weaviate, Chroma Cloud, AWS OpenSearch. One API deprecation, one pricing change, one banned account away from losing your entire memory layer.
I built Engram because that's a bad foundation to build AI on.

What is Engram?
Engram is a decentralized vector database running on Bittensor subnet 450. It lets you store text, images, and PDFs as permanent, content-addressed vector embeddings — retrieved by incentivized miners, verified by cryptographic storage proofs, and archived on Arweave.
No AWS. No central authority. No single point of failure.
The core insight comes from IPFS: address data by what it is, not where it lives. Every embedding in Engram gets a SHA-256 content identifier (CID). The same input always maps to the same CID, forever — regardless of which miner is storing it.
v1::a3f9d2e8c7b14f09d6e3...
Same text in → same CID out. Always. That's content addressing.
The Problem With Centralized Vector Stores
If you're building RAG pipelines or AI agents with persistent memory, you're probably using one of:

Pinecone — proprietary, expensive at scale, you're locked in
Weaviate Cloud — solid tech, still centralized
Chroma / Qdrant — great self-hosted, but self-hosting isn't permanent

The deeper issue isn't pricing. It's trust. You're trusting a company to:

Keep your data available
Not change terms
Not go under
Not get acquired and sunseted

For personal projects, fine. For infrastructure that AI agents depend on long-term? That's a real risk.
How Engram Works
store("The transformer architecture changed everything.")


┌───────────────────────────────┐
│ CID: v1::a3f2b1c4d5e6f7... │
│ Embedding: [0.02, -0.14, ...]│
│ Stored on: miners 3, 7, 11 │
└───────────────────────────────┘

query("how does attention work?")


┌───────────────────────────────┐
│ score: 0.9821 cid: v1::a3f │
│ score: 0.8744 cid: v1::b2e │
│ score: 0.8291 cid: v1::c1d │
└───────────────────────────────┘
Ingest: You send text (or a pre-computed vector). Engram hashes it into a permanent CID using SHA-256. Identical input = identical CID, every time.
Route & Replicate: Kademlia XOR routing distributes the embedding to the right miners deterministically. The same CID always routes to the same set of miners.
Query: HNSW indexing (via FAISS and Qdrant) powers sub-50ms approximate nearest-neighbor search at scale.
Prove Storage: Validators issue HMAC-SHA256 challenge-response proofs. Miners must prove they actually hold the data, or get slashed. No bluffing.
The Incentive Layer
This is where Bittensor does the heavy lifting.
Miners earn TAO emissions based on a composite score calculated every 120 seconds:
composite_score = 0.50 × recall@10
+ 0.30 × latency_score # 1.0 at ≤100ms, 0.0 at ≥500ms
+ 0.20 × proof_success_rate
Miners who can't pass 50% of storage challenges get weight 0 — no emissions. This keeps the network honest without any central operator enforcing it.
Drop-in Replacement for Pinecone
The Python SDK is designed to feel familiar if you're coming from any centralized vector store:
pythonpip install engram-subnet
pythonfrom engram.sdk import EngramClient

client = EngramClient("http://127.0.0.1:8091")

Store text — returns a permanent CID

cid = client.ingest("The transformer architecture changed everything.")
print(cid) # v1::a3f2b1...

Semantic search

results = client.query("how does attention work?", top_k=5)
for r in results:
print(f"{r['score']:.4f} {r['cid']}")
LangChain:
pythonfrom engram.sdk.langchain import EngramVectorStore

store = EngramVectorStore(
miner_url="http://127.0.0.1:8091",
embeddings=your_embeddings
)
retriever = store.as_retriever(search_kwargs={"k": 5})
LlamaIndex:
pythonfrom engram.sdk.llama_index import EngramVectorStore

store = EngramVectorStore(miner_url="http://127.0.0.1:8091")
index = VectorStoreIndex.from_documents(
documents,
storage_context=StorageContext.from_defaults(vector_store=store)
)
Swap your vector store to Engram in one line. That's the goal.
The Stack

Rust core (PyO3) — CID generation and HMAC proof verification in compiled Rust. 10–50× faster than pure Python for these operations.
FAISS / Qdrant — HNSW approximate nearest-neighbor indexing
Kademlia DHT — XOR-distance routing. Deterministic. Same CID, same miners, every time.
Bittensor (TAO) — incentive layer, on-chain weight setting, TAO emissions
Arweave — permanent archival storage for embeddings
Next.js — the web dashboard and playground

Language breakdown: 59% Python, 37% TypeScript, 4% Rust.
Where We Are
Engram is live on testnet with active miners. Here's the current roadmap:
PhaseTimelineStatusLocal PrototypeQ1 2026✅ DoneTestnet AlphaQ2 2026🟡 In progressMainnet LaunchQ3 2026PlannedEcosystem (LangChain native, OpenAI-compat endpoint)Q4 2026PlannedScale & Moat (shared agent memory, cross-subnet querying)2027Planned
What I Need From the Dev Community
Three things:

  1. Miners. If you have a machine with 4GB RAM and 100GB SSD sitting around, you can run an Engram miner on testnet right now: bashgit clone https://github.com/Dipraise1/Engram.git cd Engram python3 -m venv .venv .venv/bin/pip install -r requirements.txt .venv/bin/pip install -e .
  2. Developers building RAG. If you're using Pinecone, Weaviate, or Chroma in a project and want to try swapping it out — the SDK is designed to make that painless. Try it and tell me what breaks.
  3. Feedback on the protocol. The scoring formula, the CID spec, the proof mechanism — all of it is open and I want eyes on it. Open an issue, start a discussion, or drop into the Discord. Links

🌐 Website: theengram.space
💻 GitHub: github.com/Dipraise1/Engram
🎮 Playground: theengram.space/playground
📊 Dashboard: theengram.space/dashboard
💬 Discord: discord.gg/ehpvsyTyJ
📦 Docs: theengram.space/docs

Built in public. MIT licensed. Feedback welcome.

Top comments (0)