PURE PYTHON CONTEXT MEMORY FOR LOCAL LLMs

Save the context window your small local model cannot afford to waste.

$ pip install qontext-memory

from qontext_memory import MemoryStore

store.save(context_window)

Qontext-memory is a dependency-free Python library for replacing or augmenting regular context memory on local small LLM workflows. Try the Hugging Face Space to see the retrieval pack built in your browser.

PRODUCT TRAILER

A visual introduction to Qontext-memory.

This promotional video captures the idea and spirit of Qontext-memory. It is not a technical demonstration of how the library works. Try the live demo to explore the actual retrieval experience.

THE LOCAL CONTEXT PROBLEM

Context is useful. Re-sending it is expensive.

Qontext was inspired by the Quipu, the ancient Inca recording device where information lived in knots across woven cords. Local models run inside real limits: smaller windows, tighter memory, and no appetite for bloated infrastructure. Qontext-memory gives those workflows a dedicated way to keep useful context available.

Context Window

Holds the active prompt mass your local model is currently carrying.

Memory Store

Keeps reusable interaction context available outside the active prompt window.

Local Model

Recalls only the useful working context before the next response.

BUILT FOR SMALL LOCAL MODELS

Implementation proof, not platform theater.

  • Pure Python.
  • No dependency chain.
  • Designed to replace or augment regular context memory.
  • Live Hugging Face demo runs client-side with no model and no network call.
  • SAME RETRIEVAL SHAPE AS THE LIVE DEMO

    TECHNICAL MANUAL

    Quipu-inspired memory for language models.

    Qontext keeps a conversation as short, self-contained facts called knots and returns only the ones a question needs. The core is pure Python, one file, no dependencies, and supports Python 3.8+.

    Why it exists

    Long conversations do not fit in small context windows. Qontext keeps token cost flat with a fixed-size summary that does not grow with the conversation.

    Measured result: ~118x token reduction on 800-turn conversations.

    Metric

    Full transcript

    Qontext pack

    Accuracy

    10.0 / 10

    9.7 / 10

    Prompt tokens per call

    13,853

    117

    Prompt processing

    5.8 s

    0.7 s

    Core API: QontextMemory

    Most usage only needs max_entries and speakers. The default speakers="all" stores each speaker’s facts; speakers="user" restricts extraction to the user.

    Writing

  • observe(speaker, text) extracts and stores facts.
  • add(knot) stores a fact directly.
  • forget(pattern) removes matching knots.
  • clear() wipes memory and counters.
  • Reading

  • pack(query, budget=300) returns relevant knots within budget.
  • entries() returns stored knots oldest first.
  • candidates(limit) orders by importance and recency.
  • explain(query, budget) shows scores and pack choices.
  • stats() reports density and stored character data.
  • Persistence

  • serialize() and deserialize(data) round-trip JSON-compatible memory.
  • save(path) and load(path) read or write a single .qx file.
  • Missing, corrupt, or truncated files load as empty memory.
  • Design rules

    A knot must name its subject.

    The payload is the point.

    Fewer, better knots.

    Roleplay build

    RPMemory treats state as payload for scenes and characters, reserving budget for standing facts like place, possession, condition, kinship, and commitment.

    Advanced modules

    qontext_cords.py records how knots hang together and walks those links at retrieval time.

    qontext_weave.py and seed_weave.py add optional word association; measured neutral to slightly harmful, so off by default.

    llm_judge_bridge.py can use a local LLM judge through an OpenAI-compatible endpoint for harder retrieval categories.

    Honest limitations

    — Benchmark questions are hand-written by the project.

    — Measurements come from a small number of machines and quantised local models.

    — Answers are scored by keyword match, not judgement.

    — Roleplay recall uses a proxy metric without model-in-the-loop validation.

    LICENSING

    Pay for memory infrastructure that stays on the user’s computer.

    Qontext-memory uses the PolyForm Noncommercial License 1.0.0. Research, teaching, personal projects, non-profit, educational, and government use are free; commercial use requires a separate license.

    Indie Commercial

    $99 one-time

    One developer, one commercial product, under $100k/year revenue.

    Paid commercial use requires an actual signed commercial-license grant alongside the PolyForm Noncommercial public repo. Checkout is not connected yet; request the grant below.

    Startup Team

    $499/year

    Up to 5 developers, unlimited internal or commercial products, under $1M/year revenue.

    Paid commercial use requires an actual signed commercial-license grant alongside the PolyForm Noncommercial public repo. Checkout is not connected yet; request the grant below.

    Business

    $1,500/year

    Up to 20 developers, commercial distribution allowed, with priority licensing support.

    Paid commercial use requires an actual signed commercial-license grant alongside the PolyForm Noncommercial public repo. Checkout is not connected yet; request the grant below.

    Enterprise

    Custom

    OEM embedding, redistribution, procurement, legal review, or larger teams.

    Paid commercial use requires an actual signed commercial-license grant alongside the PolyForm Noncommercial public repo. Checkout is not connected yet; request the grant below.

    LICENSE DOCUMENTS

    Commercial grants that sit alongside PolyForm Noncommercial.

    Each fixed tier includes its own license grant. Enterprise is a negotiation framework, not a signable grant by itself.

    Give your local model a cheaper way to remember.

    Qontext-memory keeps the implementation small, local, and dependency-free.

    LOCAL MODEL MEMORY · PURE PYTHON · NO DEPENDENCIES