Context-Aware Assistant Selection for Improved Inference Acceleration with Large Language Models

Jerry Huang, Prasanna Parthasarathi, Mehdi Rezagholizadeh, Sarath Chandar

Introduction

Large Language Models (LLMs) have transformed natural language processing but remain constrained by their auto-regressive nature, generating text one token at a time. Speculative decoding has emerged as a promising acceleration technique, utilizing a smaller "draft model" to predict sequences that the larger "target model" then verifies in parallel. However, the effectiveness of this approach is highly dependent on the "alignment" between the draft and target models. If a draft model lacks expertise in a specific domain (e.g., a summarization model drafting code), frequent rejections by the target model can lead to "negative speedup," where inference becomes slower than standard auto-regressive generation.

Methodology: Context-Aware Assistant Selection

To address the alignment challenge, we propose a framework that dynamically selects the most suitable draft model for each specific query. This selection process is modeled as a contextual bandit problem:

  1. Context: The input query, represented via sentence embeddings.
  2. Actions: The available pool of draft models, including an option to bypass drafting entirely.
  3. Reward: A composite score reflecting the alignment (e.g., ROUGE-L) between the draft and target outputs, potentially adjusted for model latency.

Workflow

The system operates in two phases:

  • Offline Training: Candidate draft models and the target expert model process a training set. The resulting performance data (state-action-reward triplets) is stored in an offline dataset. A lightweight Multi-Layer Perceptron (MLP) is then trained using the REINFORCE algorithm to map query embeddings to the optimal assistant.
  • Inference: For a new query, the policy selects the best assistant in a single forward pass. This assistant then performs speculative decoding alongside the target model.
Workflow of the Context-Aware Assistant Selection framework.

Experimental Setup

The framework was evaluated across diverse benchmarks to test its robustness and domain-specific expertise:

  • IWSLT2017 EN-DE: Machine translation.
  • XSUM: Extreme text summarization.
  • GSM8K: Grade school math word problems.
  • SpecBench: A multi-task benchmark covering QA, Math, RAG, and Summarization.

Key Results

The dynamic selection policy consistently outperforms static assistant assignments. On tasks involving a mix of translation and summarization, the policy achieved a 1.13x average speedup. In contrast, using a mismatched static draft model (e.g., a summarization-specialized model for translation) resulted in a performance penalty, dropping speed to 0.83x of the baseline.

Comparative performance results on translation and summarization tasks.

Furthermore, on the SpecBench benchmark with a Vicuna-33B target model, the policy-based approach reached up to a 1.60x average speedup, demonstrating its scalability to larger model architectures.

Discussion and Insights

  • Alignment as a Proxy for Speed: A critical finding is that maximizing output similarity (alignment) between the drafter and the target is a sufficient proxy for maximizing wall-clock speedup, simplifying the reward function.
  • The "None" Option: In complex domains like mathematics (GSM8K), where small draft models often fail, the policy learns to revert to standard auto-regressive generation, preventing the overhead of failed speculative attempts.
  • Sample Efficiency: The policy is highly efficient, reaching peak performance with only 10,000 training examples. Its lightweight MLP architecture ensures that the decision-making overhead is negligible.

Limitations and Future Work

While effective, the approach requires hosting multiple draft models, which may increase VRAM requirements. Future research could explore "Adaptive Speculative Decoding," where the policy switches assistants mid-generation, or transition to online learning setups to continuously adapt to evolving user query distributions.

Summary updated

BibTeX
@inproceedings{huang2024context,
  author = {Jerry Huang and Prasanna Parthasarathi and Mehdi Rezagholizadeh and Sarath Chandar},
  title = {{Context-Aware Assistant Selection for Improved Inference Acceleration with Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.332},
}
Figure