Skip to content

tinyhumansai/tinycortex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

210 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TinyCortex 🧠 β€” Human-like AI Memory in Rust

Forgets the noise β—¦ 10M+ token context β—¦ ~4000 tokens/sec β—¦ Conscious Recall

Crates.io docs.rs License: MIT

Discord β€’ Reddit β€’ X β€’ Docs

The human brain is a master at compression. It doesn't try to remember every passing detail; instead it aggressively prunes noise to keep a sharp, focused, easily accessible recall of what truly matters. Traditional AI memory systems do the opposite β€” they try to remember everything and retrieve whatever is similar. But similar doesn't mean important. The result? Your AI drowns in stale, irrelevant context that degrades every response.

TinyCortex takes the brain's approach: it intelligently forgets noise. Low-value memories naturally decay while the knowledge you recall, interact with, and build upon is reinforced. The result is a memory engine that stays lean and focused, chops through 10M+ tokens accurately at up to ~4000 tokens/second, and gets sharper with every interaction.

TinyCortex scores extremely highly on RAGAS, BABILong, Vending-Bench, LoCoMo, and HotPotQA.

What this repository is: the open-source Rust core of TinyCortex β€” the local-first memory engine β€” published on crates.io as tinycortex. It is a library: you embed it in your own agent, service, or app. The hosted TinyCortex platform is currently in closed alpha β€” reach out for access.

🎯 Core Features

Intelligent Noise Filtering

Memories that aren't accessed naturally decay over time; frequently recalled knowledge becomes more durable. The store stays lean on its own β€” no manual cleanup.

Interaction graph highlighting important knowledge

Interaction-Aware Scoring

Not all memories are equal. Views, replies, reactions, mentions, and authored content all signal what matters. Knowledge people engage with rises to the top; ignored information fades away.

Memory decay over time

Local-First & Inspectable

Markdown files are the source of truth. SQLite chunk rows, summary trees, vectors, and a git-backed change ledger are derived indexes that accelerate reads and can be rebuilt from canonical content. Every item carries source provenance and a security taint (internal vs. external-sync).

Conscious Recall

Conscious recall proactively surfaces the most relevant memories for the current moment instead of waiting for an explicit query. It tracks recent activity, combines it with time-based decay, and pulls forward the memories that are both recent and repeatedly interacted with β€” a focused slice of long-term history rather than a noisy dump.

⚑ Getting Started

TinyCortex is a Rust library. Add it to your project:

cargo add tinycortex

Store and recall a memory with the built-in in-memory backend:

use tinycortex::memory::{InMemoryMemoryStore, MemoryInput, MemoryQuery, MemoryStore};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let store = InMemoryMemoryStore::new();

    // Store a memory in the "preferences" namespace.
    store
        .insert(MemoryInput::new("preferences", "User prefers dark mode"))
        .await?;

    // Recall it with a keyword query.
    let hits = store.search(MemoryQuery::text("theme preference")).await?;
    for hit in hits {
        println!("{:.3}  {}", hit.score, hit.record.content);
    }
    Ok(())
}

The InMemoryMemoryStore is the simple reference backend. The full engine β€” content store, chunking, scoring, summary trees, vector/keyword/graph/hybrid retrieval, the diff ledger, and the async job queue β€” lives under the memory module. See the documentation for the architecture, concepts, and end-to-end ingest walkthroughs.

🧩 How It Works

TinyCortex is a layered, local-first engine. Content flows through a single ingest pipeline and is served by deterministic retrieval primitives:

source payload
  β†’ canonicalize        normalize chat / email / document into markdown
  β†’ write raw markdown   immutable body files are the source of truth
  β†’ chunk                atomic, deterministically-id'd units
  β†’ score / extract / embed   decide what's worth remembering
  β†’ enqueue tree jobs    append β†’ seal β†’ summarise (async queue)
  β†’ retrieval indexes    vector Β· keyword Β· graph Β· summary tree
Layer What it does
Storage primitives Markdown content store, SQLite chunks, summary trees, vector DB, KV, entity index
Ingest Canonicalize β†’ chunk β†’ score β†’ embed β†’ tree
Retrieval Vector, keyword, graph, tree drill-down, and hybrid search with explainable score breakdowns
Diff Git-backed source snapshots, checkpoints, and read-markers for change awareness
Entities & Graph Entity markdown files + a co-occurrence graph derived from the entity index
Goals / Tool Memory Compact long-term goal list and durable tool-scoped rules
Conversations / Archivist Transcript storage and conversion of turns into summary-tree leaves
Queue Async jobs: extract, append, seal, flush-stale, re-embed, seal-document

Full details live in the documentation.

πŸ“ˆ Benchmarks

RAGAS β€” Retrieval Quality (Sherlock Holmes Corpus)

Standard RAG quality metrics via RAGAS. TinyCortex leads in Answer Relevancy (0.97) and Context Precision (0.75), outperforming FastGraphRAG, Gemini VDB, Mem0, and SuperMemory.

ragas

TemporalBench β€” Temporal Reasoning

Accuracy across ordering, state-at-time, recency, interval, and sequence questions. TinyCortex hits 100% on recency β€” surfacing the most recent events thanks to its time-decay model.

chart_temporalbench

Vending-Bench β€” Agentic Decision-Making

An agent runs a simulated vending-machine business over 30 days. TinyCortex achieves the highest cumulative P&L (~$295 by day 30) β€” better memory leads to better long-horizon decisions.

chart_vendingbench

See benchmarks/ to reproduce these on your own corpus.

πŸ“š Documentation

🀝 Contributing

TinyCortex is built in Rust (2021 edition). Clone the repo and:

cargo test     # run unit + integration tests
cargo doc      # build the API docs
cargo fmt      # format

Issues and PRs are welcome β€” see CONTRIBUTING.md.


⭐ Star us on GitHub

Like contributing towards AGI 🧠? Give this repo a star and spread the love ❀️

Star History Chart

Contributors Hall of Fame

Show some love and end up in the hall of fame.

TinyCortex contributors

About

The Fastest AI Memory Model - Your Second Brain

Resources

License

Contributing

Stars

Watchers

Forks

Contributors

Languages