Quick Start
Installation
Section titled “Installation”Python
Section titled “Python”pip install yantrikdbcargo add yantrikdbPython Quick Start
Section titled “Python Quick Start”from yantrikdb import YantrikDB
# Open or create a database (single file, like SQLite)db = YantrikDB("memory.db", embedding_dim=384)
# Set up an embedder (sentence-transformers)from sentence_transformers import SentenceTransformermodel = SentenceTransformer("all-MiniLM-L6-v2")db.set_embedder(lambda text: model.encode(text).tolist())
# Store memories with importance and emotional valencedb.record("User's name is Pranab", importance=1.0)db.record("User works at Walmart as a senior developer", importance=0.9)db.record("User is excited about their AI project", importance=0.8, valence=0.7)db.record("User prefers Rust over Python for systems work", importance=0.6)
# Recall with relevance-conditioned scoringresults = db.recall("What does the user do for work?", top_k=3)for r in results: print(f"[{r['score']:.3f}] {r['text']}")
# Build the cognitive graphdb.relate("Pranab", "Walmart", "works_at", weight=0.9)db.relate("Pranab", "Rust", "prefers", weight=0.8)db.relate("Pranab", "AI project", "excited_about", weight=0.7)
# Run autonomous cognitionresult = db.think()print(f"Triggers: {result['triggers']}")print(f"Consolidations: {result['consolidation_count']}")print(f"Conflicts found: {result['conflicts_found']}")print(f"New patterns: {result['patterns_new']}")Rust Quick Start
Section titled “Rust Quick Start”use yantrikdb::{YantrikDB, Embedder};
// Implement the Embedder trait with your preferred modelstruct MyEmbedder;
impl Embedder for MyEmbedder { fn embed(&self, text: &str) -> Result<Vec<f32>, Box<dyn std::error::Error + Send + Sync>> { // Your embedding logic here Ok(vec![0.0; 384]) } fn dim(&self) -> usize { 384 }}
fn main() -> Result<(), Box<dyn std::error::Error>> { let mut db = YantrikDB::open("memory.db", 384)?; db.set_embedder(Box::new(MyEmbedder));
// Record a memory let embedding = db.embed("User likes Rust")?; db.record_with_embedding("User likes Rust", &embedding, "semantic", 0.8, 0.5)?;
// Recall let query_emb = db.embed("What programming languages?")?; let results = db.recall(&query_emb, 5)?;
for r in &results.results { println!("[{:.3}] {}", r.score, r.text); }
Ok(())}What’s Next?
Section titled “What’s Next?”- Set up the MCP server for Claude Code / Cursor integration
- Learn about cognitive memory and how it differs from vector search
- Understand relevance scoring and why it matters