Memory Networks
- Paper: Memory Networks
- Authors: Jason Weston, Sumit Chopra, Antoine Bordes
- Lab, year: Facebook AI Research, 2014 (ICLR 2015)
- Video: YouTube Short coming on 22 Dec 2026 on Backprop Daily
Summary
A Memory Network (MemNN) is a learning model with a long-term memory that it can read and write. It has four parts: I turns the input into features, G writes it into memory, O finds the memories that support an answer, and R produces the answer (Section 2). In the paper’s version every sentence goes into its own memory slot, O retrieves one or two supporting sentences with a learned embedding score, and the model is trained with a margin ranking loss on labelled supporting facts (Section 3).
On a large question-answering set with 14M stored facts it reached an F1 of 0.82 (Table 1). On a simulated world of 4 characters, 3 objects and 5 rooms, two retrievals plus write-time features answered 99.9% of the hardest “where is the object” questions, against 29.0% for an LSTM (long short-term memory network; Section 5.2, Table 3).
What Problem Does It Solve
Recurrent networks keep everything they have read in one hidden state. The authors argue that this memory “is typically too small, and is not compartmentalized enough to accurately remember facts from the past” (Section 1). Answering a question about a story, such as where an object is now, needs specific earlier sentences, often more than one, and the most recent of them. Memory Networks store every fact separately and learn which ones to look up.
Core Idea
Score memories against the question with an embedding model s(x, y) = Φ_x(x)ᵀ Uᵀ U Φ_y(y), where Φ maps a sentence to bag-of-words features (Eq. 5). The first hop picks the memory with the highest score for the question x; the second hop picks the best memory for [x, m_o1]; the response module ranks single words given [x, m_o1, m_o2] (Eqs. 2–4).
Key Method Details
- Features: each word has three feature slots, D = 3|W|: one for the question, one for a memory that is part of the input, one for the candidate memory (Section 3.1).
- Training: a margin ranking loss over the true supporting facts and the true answer against all others (Eqs. 6–8), with SGD. The supporting facts are labelled in training but not at test time (Section 3.1).
- Write time: to prefer recent facts, the model scores pairs of memories with three extra 0/1 features saying which of the question and the two memories is older, and retrieval loops over the memories keeping the winner (Section 3.4).
- Other extensions: hashing to score only part of a large memory (Section 3.3) and a bag of neighbouring words for words never seen in training (Section 3.5).
- Simulated world settings: embedding dimension 100, learning rate 0.01, margin 0.1, 10 epochs. Difficulty 5 asks about an entity last mentioned up to 5 sentences back; there MemNN k = 2 (+time) scored 100% on actor and 99.9% on actor+object questions, k = 1 (+time) 60.8% and 44.4%, k = 1 without time 21.9% and 18.5%, and the LSTM 35.2% and 29.0% (Section 5.2, Table 3).
Simplifications in This Notebook
- Small generated world: 4 actors, 3 objects and 5 rooms as in the paper, but 1,000 training and 200 test stories of up to 24 facts, with questions asked during the story about the latest state. There are no “where was X before” questions and no difficulty limit.
- Only the simulated world: no large-scale QA, hashing or unseen-word experiments.
- Write time is simplified: the question is always newer than its memories, so only the feature “memory y is older than y′” varies.
- The LSTM baseline reads the visible facts as bags of words and is trained with Adam for 10 epochs; it is not told the supporting facts.
- The earlier notebook let questions see facts written after them, so some labels contradicted the story; questions now only see earlier facts.
What the Notebook Result Shows
| Model | Actor | Actor+object | All | Supports found (actor / actor+object) |
|---|---|---|---|---|
| MemNN k = 2 (+time) | 100.00% | 95.07% | 98.75% | 100.00% / 93.15% |
| MemNN k = 1 (+time) | 100.00% | 17.77% | 79.14% | 100.00% / 0.00% |
| MemNN k = 2, no time | 70.01% | 63.17% | 68.28% | 59.83% / 51.18% |
| LSTM | 81.80% | 40.04% | 71.21% | — |
- Both parts matter, as in Table 3: two hops and the write-time features together answer 95.07% of actor+object questions. With one hop, the model only finds the fact about the object, which names no room, and scores 17.77% (guessing gives 20%). Without time it cannot tell an actor’s latest move from an earlier one.
- The LSTM is far behind on the two-fact questions (40.04%). Its numbers are higher than the paper’s LSTM, but the stories and its training differ, so they are not comparable.
- Test set: 1,841 questions (1,374 actor, 467 actor+object), one seed.
Influence
OpenAlex lists about 1,600 citations (1,593 when checked on 3 December 2026). The same group released the bAbI tasks (Weston et al., 2015) to test this kind of reasoning, and End-To-End Memory Networks (Sukhbaatar et al., 2015) replaced the hard retrieval with soft attention so that the supporting facts no longer need labels. Key-Value Memory Networks (Miller et al., 2016) applied the idea to reading documents.
Resources
| File | Description |
|---|---|
| README.md | This overview — a 5-minute read covering the paper’s summary, core idea, key method details, influence, and a plain-English explanation of the problem it solves |
| solution.ipynb | From-scratch Memory Network with the paper’s I, G, O and R parts, margin ranking loss and write-time features, on a generated simulated world, with an LSTM baseline |
| CODE_ARCHITECTURE.md | Section-by-section breakdown of the notebook — what each cell does, data flow, tensor shapes, and key design decisions |
| TALK.md | Press coverage, Q&A (answers from the paper), and common misconceptions about the paper |