Projects / oss-model-memory
oss-model-memory
Notes on giving a 1B–14B open chat model the same kind of product memory the big chat apps have. Files, summaries, and facts. They stay in the prompt.
Why
Most of what feels like memory in those apps is not in the weights. It is a small store packed into the prompt. A small model is worse at picking a chunk, worse at ignoring a wrong-but-similar chunk, and it has a smaller window. The notes start there, and they skip a vector database and weight updates.
Diagrams
A solid outline is the path in the repo. A dashed outline is the alternative that shape is refusing.
Facts and the index are always in the prompt. Session summaries roll, oldest first. A topic costs zero tokens until a keyword or memory_read_topic hits it. The always-on block is capped around 1.5K tokens.
flowchart TD
facts["facts.jsonl, always"]
memory["MEMORY.md, always"]
sessions["sessions.jsonl, rolling"]
topics["topics, on a hit"]
prompt["Prompt pack"]
facts --> prompt
memory --> prompt
sessions --> prompt
topics -->|"keyword or memory_read_topic"| prompt
class facts,memory,sessions,topics,prompt chosen
The notes are product memory: markdown and JSONL you can cat. They are not a vector index and not a weight update. A fact is written when the user says remember, or when the user says yes to a proposal. A forget is a tombstone.
flowchart TD
q{What gets called memory}
q -->|"files a person can cat"| files["Markdown and JSONL in git"]
q -->|"embed a chunk and retrieve it"| vec["Vector database"]
q -->|"train the fact into the weights"| weights["Parametric memory"]
write{A new fact}
write -->|"remember, or yes to a proposal"| gate["Commit after a yes"]
write -->|"the model writes on its own"| free["Ungated extractor"]
class files,gate chosen
class vec,weights,free rejected
Why this shape
The store is a git repo of markdown and JSONL. Anything you can cat is allowed. The layout in the notes is MEMORY.md as the always-loaded index, facts.jsonl for durable facts, sessions.jsonl for rolling chat summaries, and topics/ for notes loaded only when something asks for them. Retrieval for the first version is that index plus the facts, then grep or a keyword hit for a topic. No embeddings.
Writes are two paths, copied from how the big apps do it. The user says remember or forget, or the model proposes a fact and it is committed only after a yes. A forget is a tombstone (status: forgotten), not a silent rewrite. Session summaries are written at chat close, or after idle time, and they summarize the user side, not the model’s replies. The current transcript is what gets trimmed first.
The notes treat memory as a harness. A base 8B is not assumed to know when to save. The prompt has to name memory_write, memory_forget, and memory_read_topic. Vector search, a knowledge graph, and weight edits are listed as later, on purpose.
Where it breaks
This repo is the design and a schema, not a running chat app. If the packer is wrong, a question like “what is my name” fails with the store on. If an extractor writes too freely, facts get polluted, and the notes say to tighten the gate rather than add retrieval. A fact the user marked forgotten has to stay a tombstone. Rewriting the line would hide that they asked to forget it.