Back to directory

context-engine

A pure-Python library that decides what an LLM actually sees from retrieved documents: retrieval, re-ranking, memory decay and token-budget enforcement in one pipeline.

context-engine

context-engine handles what comes after a basic RAG retrieve-and-stuff step: a Retriever offering keyword, TF-IDF or hybrid embedding-plus-TF-IDF search, a Re-ranker that blends tag-weighted scores to promote domain-relevant documents, a Memory component with exponential decay, auto-importance scoring and deduplication, a Compressor with truncate, sentence or extractive query-aware modes, and a TokenBudget that enforces a slot-based budget across system, history and document text.

All five components are chained through a single build() call. The core runs on the Python standard library plus numpy with no other required dependencies; installing the optional sentence-transformers package enables hybrid embedding retrieval, and without it hybrid mode falls back to random embeddings with a warning, useful for development and testing. Seven runnable demos cover each component individually and the full pipeline under tight token pressure.

More in Agent memory

See all 450
  • A long technical guide to AI agent memory: why stateless LLMs need it, the different memory architectures from vector stores to knowledge graphs, and how Cognee implements one as an open-source memory layer.

  • A local, file-based long-term memory layer for a personal AI that never summarizes conversations, keeping every line with a timestamp and searching by time first and words second, rather than retrieving only similar-seeming chunks.

  • NEOTH

    deepwiki.com

    A local-first personal AI daemon in Rust with five memory tiers, consent-gated tools, a WASM plugin sandbox, multi-provider model routing and signed audit logs, aimed at people who want both a daily assistant and a serious coding helper.