Downloads · 30 days
33
34% of all-time downloads
kurcontko/mnemotree-leaf-v1
mnemotree-leaf-v1 is a text generation model from kurcontko. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Structured memory extractor for mnemotree — a local-first memory system for LLM agents.
Downloads · 30 days
33
34% of all-time downloads
All-time downloads
97
Public
Parameters
1.7B
3.4 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.4 GB · 100%
From the Hugging Face model README
Structured memory extractor for mnemotree — a local-first memory system for LLM agents.
Extracts structured JSON from conversation turns based on memory type (episodic, semantic, procedural). Runs in ~1s on GPU.
| Base model | SmolLM2-1.7B-Instruct (1.7B params) |
| Task | Structured JSON extraction |
| Training | Full fine-tune with SFTTrainer (TRL) |
| Precision | bfloat16 |
| Max seq length | 512 tokens |
| Size | 3.2 GB |
| Metric | Score |
|---|---|
| Schema validity | 93.5% |
| JSON parse rate | 93.5% |
| Type | Samples | Schema Valid | Mean ROUGE-L |
|---|---|---|---|
| Semantic | 141 | 90.8% | 0.382 |
| Episodic | 55 | 100% | 0.517 |
| Procedural | 4 | 100% | 0.347 |
Given a memory type, the model outputs structured JSON:
Semantic (facts, knowledge):
{"fact": "Python uses GIL for thread safety", "subject": "Python", "confidence": 0.92}
Episodic (events, experiences):
{"event": "Alice went hiking in Yosemite", "who": "Alice", "confidence": 0.88}
Procedural (instructions, workflows):
{"procedure": "Deploy with docker compose up -d", "subject": "deployment", "confidence": 0.85}
from transformers import AutoTokenizer, AutoModelForCausalLM
import json
model = AutoModelForCausalLM.from_pretrained(
"kurcontko/mnemotree-leaf-v1", torch_dtype="bfloat16", device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("kurcontko/mnemotree-leaf-v1")
system = (
"You are a memory extraction assistant. Given a conversation turn with a "
"type prefix (<|semantic|>, <|episodic|>, or <|procedural|>), extract "
"structured information as a JSON object. Output ONLY valid JSON, no explanation."
)
user = "<|semantic|> Python uses the GIL for thread safety in CPython."
messages = [
{"role": "system", "content": system},
{"role": "user", "content": user},
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(inputs, max_new_tokens=256, temperature=0.1, top_p=0.95)
result = tokenizer.decode(output[0][inputs.shape[1]:], skip_special_tokens=True)
parsed = json.loads(result)
# {"fact": "Python uses GIL for thread safety in CPython", "subject": "Python", "confidence": 0.92}
from mnemotree import MemoryCoreBuilder
memory = (
MemoryCoreBuilder(store)
.with_local_models(device="cuda") # auto-downloads root + leaf
.build()
)
item = await memory.remember("Python uses the GIL for thread safety")
print(item.metadata["extraction"])
# {"fact": "...", "subject": "Python", "confidence": 0.92}
Pair with mnemotree-root-v1 (ModernBERT classifier, 149M) for the full pipeline:
root (5ms) → classify type → leaf (1s) → extract structured JSON
@misc{mnemotree2025,
title={mnemotree: Local-first memory for LLM agents},
author={kurcontko},
year={2025},
url={https://github.com/kurcontko/mnemotree}
}