Engram README

The project's README from github.com/deepseek-ai/Engram. As one markdown file: README.md.

DeepSeek-V3

Homepage Chat Hugging Face
Discord Wechat Twitter Follow
License

1. Introduction

This repository contains the official implementation for the paper: Conditional Memory via Scalable Lookup: A New Axis of Sparsity for Large Language Models.

Abstract: While Mixture-of-Experts (MoE) scales capacity via conditional computation, Transformers lack a native primitive for knowledge lookup. To address this, we explore conditional memory as a complementary sparsity axis, instantiated via Engram, a module that modernizes classic $N$-gram embeddings for $\mathcal{O}(1)$ lookup.

Key Contributions:

2. Architecture

The Engram module augments the backbone by retrieving static $N$-gram memory and fusing it with dynamic hidden states. The architecture is shown below (drawio provided):

Engram Architecture

3. Evaluation

Scaling Law

Scaling Law


Large Scale Pre-training

Pre-training Results


Long-context Training

Long Context Results

4. Case Study of Engram

Long Context Results

5. Quick Start

We recommend using Python 3.8+ and PyTorch.

pip install torch numpy transformers sympy

We provide a standalone implementation to demonstrate the core logic of the Engram module:

python engram_demo_v1.py

⚠️ Note: The provided code is a demonstration version intended to illustrate the data flow. It mocks standard components (like Attention/MoE/mHC) to focus on the Engram module.

6. License

The use of Engram models is subject to the Model License.

7. Contact

If you have any questions, please raise an issue or contact us at [email protected].

Engram (deepseek-ai/Engram)

Searching Database…

4.8K ·GitHub
What is this?This is the official code release for the DeepSeek paper 'Conditional Memory via Scalable Lookup', introducing Engram, a module that gives Transformers a native knowledge-lookup primitive by modernizing classic N-gram embeddings for O(1) retrieval, as a complement to Mixture-of-Experts sparsity.
Is this a full trainable model or just demo code?It is a standalone demonstration implementation meant to show the data flow of the Engram module; it mocks surrounding components like Attention, MoE, and mHC rather than providing a complete trainable model.
How do I try the code?Install Python 3.8+ and PyTorch, then run the standalone script in the repo that demonstrates the Engram module's core logic and data flow.
What do I need installed to run it?Just Python 3.8 or newer and PyTorch; no other setup is described for the demo code.
Does this include the full Engram-27B model or training pipeline?No, only a simplified standalone demo of the Engram module is released; the paper's Engram-27B pre-training setup, MoE baselines, and real Attention/mHC components are not provided here.
What exactly is the Engram module doing?It retrieves static N-gram-based memory via deterministic lookup and fuses it with the model's dynamic hidden states, giving the Transformer a conditional-memory mechanism alongside conditional-computation methods like MoE.
How does Engram compare to Mixture-of-Experts?Under matched parameter and FLOPs budgets, the Engram-27B model consistently outperforms MoE baselines on knowledge, reasoning, code, and math tasks, and the paper derives a U-shaped scaling law for splitting capacity between MoE compute and Engram memory.
Why is Engram efficient at inference?Because its addressing is deterministic, the large embedding tables it relies on can be offloaded to host memory with minimal inference overhead, and it frees early layers from memorizing static patterns, preserving effective depth for reasoning.
Size
2.2 MB
Stars
4.8K
Updated
CommitJan 14
Age
9mo
Commits · 90 Days