DEV.co
RAG Frameworks · qhjqhj00

MemoRAG

MemoRAG is a Python-based RAG framework that uses long-context language models to build global memory over large document collections, enabling more accurate retrieval and generation. It supports contexts up to 1 million tokens and provides efficient caching to speed up repeated queries.

Source: GitHub — github.com/qhjqhj00/MemoRAG
2.3k
GitHub stars
156
Forks
Python
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryqhjqhj00/MemoRAG
Ownerqhjqhj00
Primary languagePython
LicenseApache-2.0 — OSI-approved
Stars2.3k
Forks156
Open issues23
Latest releasev0.1.5 (2024-09-24)
Last updated2025-09-11
Sourcehttps://github.com/qhjqhj00/MemoRAG

What MemoRAG is

MemoRAG implements a memory-augmented retrieval-augmented generation pipeline combining a long-context memory model (e.g., Qwen2-7B, Mistral-7B), FAISS-based retrieval, and a generation model. It employs beacon-based sparse attention and KV-cache optimization to handle extended contexts efficiently, with support for context pre-encoding and reuse.

Quickstart

Get the MemoRAG source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/qhjqhj00/MemoRAG.gitcd MemoRAG# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Large Document QA Systems

Ideal for question-answering over books, technical documentation, or research papers where global context understanding improves accuracy over traditional vector retrieval alone.

Long-Form Content Analysis

Suitable for extracting insights from lengthy sources (400K+ tokens) where memory-based clue generation helps surface non-obvious connections across the full document.

Multi-Language Knowledge Retrieval

Supports English and Chinese out-of-the-box; useful for bilingual knowledge bases where context length and semantic understanding are critical.

Implementation considerations

  • GPU memory requirement: 16–24 GiB recommended for default settings; larger beacon_ratio values scale memory usage with context length.
  • Model selection impact: Qwen2-7B handles ~400K tokens, Mistral-7B ~128K; choose based on your typical document size and available VRAM.
  • Cache management: Encoded KV caches, FAISS indices, and chunked passages must be persisted; ensure sufficient disk space and manage lifecycle for large collections.
  • Training/fine-tuning: Framework supports additional training for domain adaptation; training scripts and datasets now released as of April 2025.
  • Dependency installation: Requires PyTorch 2.3.1 and FAISS-GPU; CPU-only setup not explicitly documented, likely has reduced performance.

When to avoid it — and what to weigh

  • Sub-100K Token Datasets — Overhead of memory model encoding may not justify gains; simpler RAG or keyword search is likely more efficient for smaller, well-structured data.
  • Real-Time, Ultra-Low-Latency Requirements — Memory model inference and encoding (even with caching) incurs latency; unsuitable for sub-second response SLAs without significant optimization.
  • Proprietary/Restricted LLM Environments — Requires loading HuggingFace models (Qwen2, Mistral, Llama) or OpenAI/Azure APIs; not suitable if you cannot use external model weights or API calls.
  • Frequent Dynamic Content Updates — Cached KV states and indices require re-encoding on document changes; high-frequency updates make re-memorization costly compared to live indexing approaches.

License & commercial use

Apache License 2.0 (Apache-2.0). Permissive OSI-approved license allowing commercial use, modification, and distribution with attribution and liability disclaimers.

Apache-2.0 permits commercial deployment. However, ensure compliance with underlying model licenses: Qwen2 (MIT/Apache), Mistral (Apache 2.0), Llama 3.1 (Llama 2 Community License—requires review for production use). No commercial support or indemnification offered by MemoRAG project.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceMedium
Security considerations

No explicit security audit or vulnerability disclosure program mentioned. Uses HuggingFace model loading (potential supply-chain risk if tokens compromised). Local cache storage of KV states and indices should be protected. OpenAI/Azure API key handling not documented in detail. User responsible for input validation and content filtering.

Alternatives to consider

LangChain + FAISS

Simpler, widely adopted, lower overhead for smaller documents; lacks MemoRAG's global memory and million-token capacity but easier to integrate into existing stacks.

Anthropic Claude (200K context)

No local infrastructure required, native long-context support; higher cost per query, less customizable, no fine-tuning for domain tasks.

ColBERT or Dense Passage Retrieval (DPR)

Proven retrieval baselines with lower memory overhead; require separate generation step, no integrated memory mechanism for global understanding.

Software development agency

Build on MemoRAG with DEV.co software developers

MemoRAG powers document understanding at scale. Start with our Colab notebook, or let our team help you deploy a production RAG pipeline.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

MemoRAG FAQ

How much GPU VRAM do I need?
Minimum 16 GiB for default settings; 24 GiB recommended for larger beacon_ratio or longer contexts. CPU-only mode not documented and likely impractical.
Can I use MemoRAG with proprietary LLMs like GPT-4?
Partially. The memory model must be a HuggingFace model, but you can use OpenAI/Azure for the generation step. Full proprietary pipelines (memory + gen) are not supported.
What's the latency for a typical query after memorization?
Unknown from documentation. First-time encoding ~35 seconds for 200K tokens; loaded cache ~1.5 seconds. Query latency depends on model choice and max_new_tokens; not benchmarked in README.
Does MemoRAG support streaming or incremental indexing?
Not documented. Current design requires full context re-memorization; no documented support for streaming updates or incremental cache refresh.

Work with a software development agency

Adopting MemoRAG is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate rag frameworks software in production.

Ready to Build Long-Context RAG?

MemoRAG powers document understanding at scale. Start with our Colab notebook, or let our team help you deploy a production RAG pipeline.