█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

Memorilla

फ़्रीज़्ड LLM के लिए पूरे document collection को 16 tokens में समेटने वाली latent memory

Agent Memoryओपन सोर्स
भाषा
Python
लाइसेंस
Apache-2.0
संक्षेप में

Memorilla क्या है?

Memorilla फ़्रीज़्ड LLM के लिए पूरे document collection को 16 tokens में समेटने वाली latent memory. यह Agents & Automation टूल्स की Agent Memory श्रेणी में आता है; ओपन सोर्स है, Python में लिखा गया है और Apache-2.0 लाइसेंस के तहत है। शुरू करने के लिए: clone करें और इंस्टॉल करें.

सारांश

Memorilla, Stanford के SNAP group की एक open-source memory system है, जो एक फ़्रीज़्ड LLM को उसकी context window में समा सकने वाली सामग्री से कहीं ज़्यादा material इस्तेमाल करने देती है। यह पूरा document collection पढ़ती है, जैसे किसी user की पिछली chats या कोई लंबी किताब, और हर सवाल के लिए LLM को 16 memory tokens का एक तय सेट देती है, जिसमें उस सवाल को चाहिए वही जानकारी होती है। इसके लिए documents या कुछ retrieved chunks को prompt में चिपकाना नहीं पड़ता। यह रिपॉज़िटरी पेपर Memorilla: Latent Semantic Memory for LLMs (arXiv 2610.21375) का code रखती है, जो Apache 2.0 के तहत जारी है, और trained चेकपॉइंट्स Hugging Face पर उपलब्ध हैं।

Memorilla architecture: a frozen query encoder embeds the question and a frozen document encoder embeds the user's chats; the trained Memorilla module cross-attends from K learned latents over both to produce K memory latents, which are stacked with the question's LLM embeddings and fed to a frozen LLM that answers 'Given your iron deficiency, eat more meat'.
How Memorilla turns a question and a document collection into memory latents for a frozen LLM.Memorilla README ↗

अंदर की बात यह है कि एक फ़्रीज़्ड query encoder और एक फ़्रीज़्ड document encoder (डिफ़ॉल्ट रूप से Qwen3-Embedding-4B) सवाल और हर document को embeddings में बदलते हैं। एक trained memory module, जिसमें सीखे हुए latents हैं, उन embeddings पर cross-attention करता है और memory latents निकालता है। इन latents को सवाल के सामान्य token embeddings के साथ जोड़कर फ़्रीज़्ड decoder (डिफ़ॉल्ट रूप से Qwen3-8B) को भेजा जाता है। चूँकि decoder हमेशा एक ही 16 tokens पढ़ता है, उसकी लागत collection के साथ नहीं बढ़ती; बढ़ती है सिर्फ़ memory module की लागत। एक वैकल्पिक memory cache cross-attention के keys और values को documents लिखते समय एक बार गणना कर लेता है। README के अनुसार इससे एक मिलियन से ज़्यादा documents वाले collection पर सवाल का जवाब B200 पर 8.1 ms में, या torch.compile के साथ 5.0 ms में मिल जाता है।

README के मुताबिक़ इस बजट में Memorilla Mem0 और MemoRAG जैसे तरीकों के मुकाबले सबसे अच्छा औसत स्कोर हासिल करता है। FactKG पर यह LLM को हर document देने वाले तरीके को पीछे छोड़ता है (84.33% बनाम 80.43%), और 108× कम tokens इस्तेमाल करता है। किसी agent की memory के रूप में GRPO से trained होने पर यह TextWorld games में औसत success rate को 18.6% से बढ़ाकर 24.2% कर देता है। यह कोई hosted service नहीं, बल्कि GPU research codebase है: इसे Linux, CUDA GPUs और Python 3.11 चाहिए, और quick-start example में एक 80 GB GPU इस्तेमाल होता है।

यह क्या करता है

  • फ़िक्स्ड 16-token memory: फ़्रीज़्ड LLM को चाहे कितने भी documents स्टोर हों, memory tokens की संख्या हमेशा एक जितनी रहती है
  • Query-dependent compression — memory module हर सवाल के लिए पूरे collection को दोबारा पढ़ता है, इसलिए अलग-अलग सवालों को अलग memory tokens मिलते हैं
  • vLLM पर Python inference API: MemoryVLLM.from_pretrained, फिर collection लिखें और उस पर सवाल पूछें
  • एक GPU पर चार मिलियन तक documents वाले collections पर तेज़ सवालों के लिए वैकल्पिक memory cache और torch.compile
  • Hugging Face पर trained checkpoints (Stage 1–3 के साथ PersonalizationV4 और PersonaMem-v2 fine-tunes), Qwen3-8B और Qwen3-Embedding-4B के साथ
  • अपने documents और सवालों पर parquet files से train और evaluate करें, बिना कोड बदले
  • Closed-book, top-5 RAG और full-context baselines, साथ ही TextWorld पर agent memory के लिए GRPO recipe

शुरू करें

Memorilla Linux और CUDA GPUs तथा Python 3.11 पर चलता है, और uv से source से इंस्टॉल होता है। Quick-start example को एक 80 GB GPU चाहिए, और पहली बार चलाने पर लगभग 25 GB models डाउनलोड होते हैं।

Clone करें और इंस्टॉल करें

uv के साथ Python 3.11 environment बनाएँ और package इंस्टॉल करें। FlashAttention-2 सिर्फ़ training के लिए चाहिए; evaluation और inference इसके बिना भी चलते हैं।

bashbash
git clone https://github.com/snap-stanford/memorilla.git && cd memorilla
uv venv --python 3.11 && source .venv/bin/activate
uv pip install -e .
uv pip install --no-build-isolation flash-attn==2.7.4.post1

किसी document collection से सवाल का जवाब लें

Memory module के साथ Qwen3-8B checkpoint लोड करें और सवाल के साथ सभी documents पास करें। यह उदाहरण PersonaMem-v2 test set से एक user की 107 पुरानी बातचीत लेता है और उन्हें 16 memory tokens में समेट देता है।

pythonpython
from memorilla.benchmarks import PERSONA_PROMPT
from memorilla.data import ensure_data, load_split
from memorilla.vllm import MemoryVLLM

row = load_split("pmv2", "test", ensure_data("pmv2", ["test"]))[73]

model = MemoryVLLM.from_pretrained("memorilla/Memorilla-Qwen3-8B", "pmv2")
answer = model.answer(row["question"], row["documents"], system_prompt=PERSONA_PROMPT)
print(answer)

Collection एक बार लिखें, फिर उससे query करें

Memory cache चालू करें ताकि documents एक बार encode हों और आगे के हर सवाल में सिर्फ़ cached keys और values पर attention हो।

pythonpython
model = MemoryVLLM.from_pretrained("memorilla/Memorilla-Qwen3-8B", "pmv2", memory_cache=True, compile_memory=True)
collection = model.write(row["documents"])
answer = model.answer(row["question"], collection, system_prompt=PERSONA_PROMPT)
Two log-scale charts on an NVIDIA B200: latency per question rising with collection size for the default forward pass (283 ms at four million documents), the memory cache (32.8 ms) and the cache with torch.compile (5.04 ms at one million, 14.6× faster than default), and GPU memory for document embeddings (20 GiB) and the memory cache (80 GiB) at four million documents.
Memory-module latency and GPU memory from 1 to 4 million documents, with and without the memory cache.Memorilla README ↗

अपने डेटा पर train करें

हर split के लिए एक parquet file लिखें, जिसमें columns collection_id, question, answer और documents हों, और उसे my_data/data/my_task/ के अंतर्गत रखें; फिर train और evaluate करें। single_task recipe Stage 2 checkpoint से warm-start करता है।

bashbash
python train.py --config configs/single_task.yaml --data_repo my_data --datasets my_task --output_dir runs/my_task
python evaluate.py --data_repo my_data --config my_task --split test --scoring generation --checkpoint runs/my_task/epoch-04

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • किसी user की पूरी chat history के आधार पर assistant को personalise करना हो, और हर पुरानी बातचीत को prompt में ठूँसे बिना, तो इसका इस्तेमाल करें।
  • किताबों और स्क्रिप्ट्स जैसी बहुत लंबी सामग्री पर सवालों के जवाब देने के लिए इसका इस्तेमाल करें; README के अनुसार NarrativeQA पर 4,000× से ज़्यादा compression मिलता है।
  • जब जवाब कई documents में बिखरे सुरागों को जोड़ने पर निर्भर हो, तब top-k RAG के सीखे हुए विकल्प के रूप में इसका इस्तेमाल करें।
  • TextWorld games पर अपनी GRPO recipe से trainable agent memory पर शोध करने के लिए इसका इस्तेमाल करें।

How Memorilla compares

Memorilla alongside other open-source agent memory tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Claude-Mem★ 121kcoding agents के लिए सेशनों के बीच बना रहने वाला context
Mem0★ 69.9kएक मेमोरी लेयर, जो LLM agents को अलग-अलग सेशनों में यूज़र्स को याद रखने देती है
Hindsight★ 64.5kएक एजेंट मेमोरी सर्वर, जो एजेंट्स को सिर्फ़ चैट इतिहास दोहराने के बजाय सीखने में सक्षम बनाने के लिए बनाया गया है
MemPalace★ 60.8kलोकल-फ़र्स्ट एजेंट मेमोरी, जो बातचीत को हू-ब-हू सहेजती है और कभी उसका सार नहीं बनाती
OpenViking★ 43.1kएक context database, जिसे agent किसी black-box vector store की तरह नहीं, बल्कि filesystem की तरह ब्राउज़ करता है
Cognee★ 33.8kओपन सोर्स AI मेमोरी, जो आपके डेटा को एजेंट्स के लिए क्वेरी करने योग्य नॉलेज ग्राफ़ में बदल देती है
Graphiti★ 33.3kAI एजेंट के facts समय के साथ कैसे बदलते हैं, यह ट्रैक करने वाले temporal knowledge graph बनाएँ
Memorilla★ 1.7kफ़्रीज़्ड LLM के लिए पूरे document collection को 16 tokens में समेटने वाली latent memory