Nearest Neighbor Speculative Decoding for LLM Generation and Attribution

Large language models (LLMs) often hallucinate and lack the ability to provide attribution for their generations. Semi-parametric LMs, such as kNN-LM, approach these limitations by refining the output of an LM for a given prompt using its nearest neighbor matches in a non-parametric data store. However, these models often exhibit slow inference speeds and produce non-fluent texts. In this paper, we introduce Nearest Neighbor Speculative Decoding (NEST), a novel semi-parametric language modeling approach that is capable of incorporating real-world text spans of arbitrary length into the LM generations and providing attribution to their sources. NEST performs token-level retrieval at each inference step to compute a semi-parametric mixture distribution and identify promising span continuations in a corpus. It then uses an approximate speculative decoding procedure that accepts a prefix of the retrieved span or generates a new token. NEST significantly enhances the generation quality and attribution rate of the base LM across a variety of knowledge-intensive tasks, surpassing the conventional kNN-LM method and performing competitively with in-context retrieval augmentation. In addition, NEST substantially improves the generation speed, achieving a 1.8x speedup in inference time when applied to Llama-2-Chat 70B. Code will be released at https://github.com/facebookresearch/NEST/tree/main.

Paper

References (61)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer kPHS7/10 · confidence 3/52024-07-09

Summary

The paper presents a new semi-parametric language modeling approach that can incorporate text spans from a datastore into LLM-based generation improving both quality and attribution of generated texts. They propose a two-step approach that requires constructing an on-the-fly token-level datastore based on a small number of retrieved passages from a passage-level datastore. The current token is generated from the mixture distribution between the base LLM and the retrieved token-level distribution interpolated using a relative retrieval confidence score capturing the uncertainty of the token retriever. Furthermore, the approach enables extending the generation from token to an n-gram span based on a speculative decoding that rejects or accepts the tokens in the continuations, thus enabling span-level generation, improving efficiency.

Strengths

1. Extensive experiments across tasks and datasets shows the efficacy of the proposed approach over standard LLM decoding, KNN and Retrieval augmented incontext learning variants. 2. Ablations show how the relaxation factor used for speculative decoding can enable flexible-length n-gram continuations to be incorporated based on the domain and can provide a good tradeoff between accuracy and attribution.

Weaknesses

1. Multiple-token nearest neighbor generation has been proposed in prior work but was not discussed or compared, see: [1] Chunk-based Nearest Neighbor Machine Translation (https://aclanthology.org/2022.emnlp-main.284/).

Questions

See weaknesses.

Rating

7

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

Yes

Reviewer vMVQ5/10 · confidence 4/52024-07-11

Summary

This paper: * Introduces NEST, a semi-parametric language modeling approach that integrates real-world text spans into language model generations. * Enhances generation quality and reduces latency by using token-level retrieval and speculative decoding. * Outperforms conventional kNN-LM and competes well with in-context retrieval methods. * Demonstrates significant improvements with various models.

Strengths

* Introduces a novel semi-parametric language modeling technique for improved attribution and generation quality. * Demonstrates a significant increase in speed and efficiency in language model generation. * Outperforms conventional kNN-LM and shows competitive results against in-context retrieval methods across various knowledge-intensive tasks. * Effective across a range of tasks including text completion, question answering, and factuality-aware generation, showcasing the method's adaptability to different content requirements.

Weaknesses

* Performance heavily relies on the accuracy of the first-stage passage retrieval and second-stage token retrieval. * The retrieval process may still be complex and resource-intensive for practical deployment. * The gains in performance and efficiency are less pronounced in larger models.

Questions

* How scalable is the NEST approach in real-world scenarios? * What measures are taken to mitigate the impact of noise and errors introduced during the data retrieval stages? * How does NEST address potential biases that may arise from the retrieved data? * How well does NEST adapt to the evolving nature of language?

Rating

5

Confidence

4

Soundness

3

Presentation

3

Contribution

2

Limitations

* The overall effectiveness of NEST is contingent upon the precision of both stages of text retrieval. * The approach may struggle with ensuring that the retrieved content is contextually relevant and free from biases.

Reviewer L2uT7/10 · confidence 2/52024-07-12

Summary

This work presents Nearest Neighbor Speculative Decoding (NEST), a technique to better inject real-world text spans into the output of existing language models. NEST is a kNN-LM approach adding an initial passage retrieval step. During inference, NEST uses Relative Retrieval Confidence (RRC) for confidence-based interpolation, dynamically extends selected tokens to include text spans when confidence is high, and employs a relaxed speculative decoding process that accepts only highly probable token spans. According to the evaluation conducted by the authors with Llama 2 chat, NEST significantly outperforms both the base LM and standard kNN-LM, in terms of speed and accuracy.

Strengths

- well-written: The paper is clear and easy to understand. Figure 1 itself is enough to understand what the paper presents - well-motivated: The paper explains the problem that it tries to solve and provides the motivations for why it needs to be solved - Extensive experiments demonstrating that the proposed approach works

Weaknesses

- It’s unclear to me what are the most important contributions of this work. What is really new and has the most impact on the results? Even with the help of the related work section I cannot answer this question, hence my low confidence score.

Questions

It’s unclear to me what are the most important contributions of this work. What is really new and has the most impact on the results? Even with the help of the related work section I cannot answer this question, hence my low confidence score

Rating

7

Confidence

2

Soundness

4

Presentation

3

Contribution

2

Limitations

The limitations are pointed out and sufficiently discussed.

Authorsrebuttal2024-08-13

Respectfully Asking to Reconsider Your Rating

Thank you again for your feedback. We would like to follow up on our rebuttal to ensure that we have thoroughly addressed your initial concerns, and to respectfully ask for a reconsideration of the overall rating. Specifically, we would like to provide additional clarification on the two areas of concerns raised. (1) **Novelty:** Our proposed approach, NEST, primarily consists of two novel techniques: (1) a confidence-adjusted, token-level retrieval score to extract text spans from real-world corpora as draft inputs, and (2) a relaxed-speculative decoding procedure to seamlessly integrate these drafts into the LLM generation process, rejecting the uncertain suffixes. We demonstrated empirically that this approach allows attribution of the generated text directly to the source, and yields significant improvements in both generation speed and quality compared to the base LLMs and kNN-LM with two-stage retrieval. kNN-LM with two-stage retrieval is a stronger baseline compared to the standard kNN-LM. Reviewers nNiG, vMVQ, and kPHS have also recognized the novelty and strengths of our approach. (2) **Which technique had the most impact on performance:** We included an ablation study in the appendix of our submission (**Appendix C.2, Table 3**). The results show that both adjusting the interpolation score based on token-level retrieval confidence (+4.6 ROUGE-1 for WikiText-103 and +6.8 FactScore on Biography) and performing token rejection using relaxed speculative decoding (+2.3 ROUGE-1 for WikiText-103 and +5.2 FactScore on Biography) significantly contribute to the performance improvements. We plan to move the ablation study to the main text to provide clearer insights for future readers with additional main content space. | Models (7B) | Wiki./ROUGE-1 | NQ/ALR | Bio./FS | |---------------------------------|---------------|--------|---------| | kNN-LM (two-stage) | 20.1 | 40.8 | 34.8 | | + Relative Retrieval Confidence | 24.7 | 44.4 | 41.6 | | + Dynamic Span selection | 24.5 | 44.6 | 41.6 | | + Relaxed speculative decoding | 26.8 | 45.4 | 46.8 |

Reviewer nNiG5/10 · confidence 4/52024-07-13

Summary

The paper introduces NEST, a novel semi-parametric language modeling approach that enhances the generation quality and attribution of Large Language Models (LLMs) by incorporating real-world text spans. NEST employs a two-stage k-NN search and speculative decoding, achieving improved performance and reduced inference time.

Strengths

The two-stage k-NN search is a smart optimization that balances search accuracy and efficiency. The paper demonstrates significant improvements in generation quality and speed, offering a competitive edge over traditional methods. The approach of providing direct attribution to sources is valuable for enhancing the reliability of LLMs.

Weaknesses

The paper could benefit from a more detailed comparison with state-of-the-art methods. The generalizability of NEST across different domains and languages needs further exploration. The potential impact of NEST on the in-context learning ability of LLMs is not thoroughly discussed. The paper lacks a comprehensive analysis of error rates and statistical significance.

Questions

How does NEST compare with other advanced language models in terms of handling long-tail knowledge? What are the implications of using NEST for models pre-trained with different objectives or datasets? Could the authors elaborate on the impact of NEST on the diversity and creativity of LLM generations? On page 2, the authors mention a 1.8× speedup; could they specify if this is consistent across different model sizes? How does NEST handle potential biases in the retrieved text spans from the corpus? Can the authors provide more insight into the decision process behind the choice of hyperparameters? Is there a risk of overfitting the corpus used for training the key-value datastore?

Rating

5

Confidence

4

Soundness

2

Presentation

2

Contribution

2

Limitations

N/A

Reviewer nNiG2024-08-13

I have read the author's response and other reviews, and I will keep my rating unchanged.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC