Instructions to use Falln87/clerk-memory with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Falln87/clerk-memory with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
CLERK project README: method summary, novelty statement, repro instructions
Browse files
README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: peft
|
| 4 |
+
base_model: Qwen/Qwen2.5-0.5B-Instruct
|
| 5 |
+
tags:
|
| 6 |
+
- memory
|
| 7 |
+
- long-context
|
| 8 |
+
- multi-session
|
| 9 |
+
- consolidation
|
| 10 |
+
- lora
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# CLERK — Consolidated Ledger with Eviction and Rewrite Keys
|
| 14 |
+
|
| 15 |
+
**Fixed-budget, write-time memory consolidation for LLMs, trained (not
|
| 16 |
+
prompted).** CLERK maintains memory as a JSON ledger of atomic fact slots.
|
| 17 |
+
At every session boundary a trained policy reads (ledger, session
|
| 18 |
+
transcript) and emits a structured edit program — `ADD`, `UPDATE`
|
| 19 |
+
(supersede), `TOMBSTONE`, `EVICT` — which a deterministic reducer applies.
|
| 20 |
+
Reading then costs O(budget) tokens forever, regardless of history length,
|
| 21 |
+
and supersession is explicit rather than buried in stale text.
|
| 22 |
+
|
| 23 |
+
## Why this is new
|
| 24 |
+
|
| 25 |
+
- All published write-time consolidation is **prompt-heuristic** (Mem0,
|
| 26 |
+
Zep, CUPMem); prior work shows LLM-consolidated memories corrupt over
|
| 27 |
+
repeated updates. CLERK **trains** the write policy on exact supervision
|
| 28 |
+
from programmatically generated gold ledger transitions.
|
| 29 |
+
- Learned memory policies (Memory-T1, MemAgent) act at **read time**;
|
| 30 |
+
CLERK acts at write time with a **fixed budget** and learned eviction.
|
| 31 |
+
- Prior fixed-budget parametric memories (RMT, Infini-attention) are
|
| 32 |
+
opaque token memories trained from scratch; CLERK is **interpretable,
|
| 33 |
+
reducer-checked, and LoRA-scale**.
|
| 34 |
+
|
| 35 |
+
## Repository layout
|
| 36 |
+
|
| 37 |
+
```
|
| 38 |
+
clerk/
|
| 39 |
+
common.py slot schema, edit-op reducer, serializers, salience oracle
|
| 40 |
+
prompts.py CONSOLIDATE / ANSWER instruction formats (single source of truth)
|
| 41 |
+
generator.py seeded synthetic evolving-session generator (gold ledger states)
|
| 42 |
+
build_sft.py timelines -> SFT messages dataset (CONSOLIDATE + ANSWER mixture)
|
| 43 |
+
train_sft.py LoRA SFT via TRL (verified against trl/examples/sft_qlora)
|
| 44 |
+
eval_synthetic.py held-out benchmark: clerk vs prompted-ledger/full/window/RAG
|
| 45 |
+
eval_locomo.py LoCoMo-MC10 zero-shot (Percena/locomo-mc10)
|
| 46 |
+
tests_smoke.py data-invariant checks (run before any GPU job)
|
| 47 |
+
run_all.sh end-to-end pipeline
|
| 48 |
+
requirements.txt pinned dependencies
|
| 49 |
+
paper/ the paper
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Reproduce
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
pip install -r requirements.txt
|
| 56 |
+
huggingface-cli login
|
| 57 |
+
bash run_all.sh # ~2-3 GPU-hours on one 16GB GPU (L4/A10G class)
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Everything is seeded (generator seed 137/991/4242; training seed 137).
|
| 61 |
+
Smoke tests verify: gold op programs are executable by the reducer,
|
| 62 |
+
budgets are never exceeded, serializers round-trip, and QA supervision
|
| 63 |
+
matches the memory state it was answered against.
|
| 64 |
+
|
| 65 |
+
## Results
|
| 66 |
+
|
| 67 |
+
See `paper/paper.md` and `results/` (populated by `run_all.sh`).
|
| 68 |
+
|
| 69 |
+
## License
|
| 70 |
+
|
| 71 |
+
Apache-2.0. Author: Justin Wolcott, fallnai-research.org.
|