Skip to content

Transformer Memory as a Differentiable Search Index

optionalextendedfundamentalpaperrubric 8/122022 · NeurIPS 2022 · ~15 min

Yi Tay, Vinh Q. Tran, Mostafa Dehghani, … Donald Metzler

Status

TL;DR. DSI replaces the index with the model. A T5 encoder–decoder is trained to map each document’s text to its identifier (indexing) and each query to the identifier of its relevant document (retrieval). At query time it generates a docid with beam search, with no separate index. On Natural Questions subsets of up to 228K documents it beats T5 dual encoders, and it beats BM25 when trained without any labelled queries.

Retrieval becomes conditional generation of a docid string z=(z1,…,zm)z = (z_1, \dots, z_m):

p(z∣q)=∏t=1mpθ(zt∣z<t,q)p(z \mid q) = \prod_{t=1}^{m} p_\theta(z_t \mid z_{<t}, q)

The whole corpus lives in θ\theta. Two design questions dominate: how to train the model to memorise documents, and how to represent the docid.

Results (Tables 2–3, 6). On NQ320K (Hits@1 / Hits@10), BM25 scores 11.6 / 34.4 and the best T5-XXL dual encoder 24.3 / 67.3. DSI-XXL with semantic docids reaches 40.4 / 70.3. That is a large gain at rank 1 (+66% relative) but a small one at rank 10. Gains over dual encoders are largest on NQ10K. In the zero-shot setting (indexing only, no labelled queries), atomic-docid DSI-XXL gets 25.1 Hits@1 on NQ320K against BM25 11.6 and SentenceT5 16.9. Results are unstable across sizes and checkpoints: on NQ320K, atomic-docid Large (11.6) is below Base (20.7). Appendix Table 6 reports minimum- versus maximum-forgetting checkpoints that differ by up to an order of magnitude, and the main tables use the minimum-forgetting point. Each model trains for up to 1M steps on 128–256 TPUv4 chips.

  • After: Octen-WebGR scales the same idea to 201M web pages with two-token semantic ids, trie-constrained decoding and a study of forgetting. Read the two pages together.
  • Contrast with dense retrieval: DSI’s baseline is a contrastively trained T5 dual encoder. Today’s dual encoders are compared in the embedding recipes hub. Corpus updates are trivial for a dual encoder (encode the new documents) and the hard case for DSI.
  • Neither sparse nor dense: compare the representation choices in SPLADE-v3 (vocabulary terms) and ColBERT (token vectors). In DSI the “index” is the decoder’s knowledge of identifier sequences.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    DSI's semantic docids come from hierarchical k-means with k = 10, recursing while a cluster holds more than c = 100 documents; documents in a small enough cluster get an arbitrary number from 0 to c − 1. For NQ320K (about 228K unique documents), assume balanced clusters and work out how many cluster digits and leaf digits a docid needs and how many decoding steps beam search takes. Then compare the output-layer cost of atomic docids (one new softmax row per document) for T5-Base (hidden size 768) with Octen-WebGR's two sets of 65,536 identifier tokens at hidden size 2,560.

    What a strong answer covers
    • Balanced split: 228K / 10 = 22.8K, / 100 = 2,280, / 1,000 = 228 (still above 100), / 10,000 ≈ 23 ≤ 100. So 4 cluster digits, then a leaf number below 100: up to 2 more digits. Up to 6 decoding steps, each choosing among about 10 tokens.
    • The hierarchy shrinks each beam-search decision to 10 options, and similar documents share prefixes, so early mistakes land in semantically nearby subtrees.
    • Atomic: 228K × 768 ≈ 175M new output parameters, close to T5-Base's whole 220M. Every document is a single softmax class trained only from its own few examples. The paper argues structured docids scale better because the decoder vocabulary stays small, and its NQ320K atomic results are erratic across sizes (Base 20.7, Large 11.6, XL 28.1 Hits@1).
    • Octen-WebGR: 2 × 65,536 × 2,560 ≈ 336M parameters per embedding matrix, for 201M URLs. That is about 1,500 URLs per identifier token versus one row per document. Two-level codes are what makes web scale possible.
  2. Mechanism

    DSI trains two tasks together: indexing (the first L = 32 document tokens → docid) and retrieval (query → docid). Without the indexing task Hits@1 is 0%. Targets2Inputs (docid → document text) and span corruption also give 0%, while Inputs2Targets (document → docid) works. Explain these results in terms of what the decoder is trained to emit and which docids receive gradient, and why a high ratio of indexing to retrieval examples helps.

    What a strong answer covers
    • Retrieval examples only teach docids of documents that have training queries. An unseen document's docid is never a target, so the model cannot generate it, and test queries for such documents fail.
    • Inputs2Targets makes every docid a decoder target, conditioned on that document's text. The model learns both to produce every valid docid and to associate it with content, so queries that resemble the content can reach it.
    • Targets2Inputs puts the docid in the encoder input and trains the model to produce text. It never learns to emit docids, so retrieval has nothing to decode. Span corruption has the same problem: the docid is context, not a prediction target.
    • A high indexing share keeps all documents memorised while the retrieval task teaches the query → document mapping. Retrieval can be seen as generalising from document-like inputs to query-like inputs. Longer inputs (beyond 64 tokens) hurt, consistent with memorisation being the hard part.
  3. Critique

    DSI's headline is that semantic-docid DSI-XXL reaches 40.4 Hits@1 on NQ320K against 24.3 for the best T5 dual encoder. Appendix Table 6 shows the same models at their minimum-forgetting and maximum-forgetting checkpoints (for example atomic XL: 28.1 vs 2.7 Hits@1), caused by indexing and retrieval examples cycling through a shuffle buffer. Critique what this means for the headline comparison and for using DSI on a corpus that changes, and design an experiment that would settle both concerns.

    What a strong answer covers
    • The headline uses the minimum-forgetting checkpoint. If that checkpoint is chosen with test-set signal, the comparison is optimistic. A dual encoder does not oscillate like this, so the fair comparison is a checkpoint chosen on a separate validation split, or the average over late checkpoints.
    • Oscillation means memorisation is fragile: documents that have not been seen recently are forgotten. Adding new documents means more training, which can erase old ones (the conclusion lists dynamic corpora as future work).
    • Scale: 228K documents is small, and Hits@10 gains over dual encoders are modest (70.3 vs 67.3). The method also does not use constrained decoding, so it can generate invalid docids.
    • Experiment: fix checkpoint selection on held-out queries; then add 10% new documents with continued multi-task training and track Hits@1 on old and new documents over time, against a dual encoder that simply re-encodes the new documents.
    • Octen-WebGR later measures exactly this. What a pair retains depends on how much training follows its last exposure (the cumulative learning rate), which points to scheduling, not capacity, as the fix.

Done with this page?

Status