Learning to Decode Collaboratively with Multiple Language Models

Zejiang Shen, Hunter Lang, Bailin Wang, Yoon Kim, David A. SontagACL 2024

Abstract

Large Language Models (LLMs) present a persistent trade-off between computational efficiency and task performance. While small models offer speed, they often lack the specialized knowledge of their larger counterparts. We present Co-LLM, a novel framework that enables a small "base" model to collaborate with a larger "assistant" model by interleaving their generations at the token level. By treating the decision to switch models as a latent variable, Co-LLM learns to defer to the assistant only when necessary. Our evaluations across mathematical reasoning and biomedical QA show that Co-LLM frequently outperforms standalone models while maintaining high efficiency.

Introduction

The deployment of LLMs is often constrained by the "size vs. capability" dilemma. Small models are cost-effective but prone to hallucinations, whereas large models are powerful but expensive. Previous attempts to combine models often relied on manual heuristics or explicit tool-calling triggers. Co-LLM addresses this by asking: can a model learn to recognize its own limitations and organically call for assistance?

Methodology: Latent-Variable Collaborative Decoding

The core of Co-LLM is a latent-variable framework where, for every token $t$, a hidden decision $Z_t$ determines whether the base model or the assistant should generate the output.

The Co-LLM framework illustrating token-level deferral from a base model to an assistant model based on predicted probability.

The system is trained using unsupervised learning to maximize the marginal likelihood of a training set. A lightweight linear classification head is added to the base model's final layer to predict the deferral probability. During inference, a tunable threshold $\eta$ allows users to balance speed and accuracy.

Key Insights and Results

A significant finding is the "template-filling" strategy: the base model naturally handles structural "scaffolding" (e.g., "The answer is...") while deferring to the assistant for complex computations or factual "slots."

Examples of collaborative decoding where the base model provides structure and the assistant provides specialized knowledge.

Performance Benchmarks

  • Mathematical Reasoning: On the MATH dataset, a Llama-7B base collaborating with a Llemma-34B assistant achieved a score of 24.5, vastly outperforming the standalone Llama-7B (7.6) and Llemma-34B (6.3).
  • Biomedical QA: In BioASQ tasks, the Llama-7B + Meditron-70B pairing matched a fully finetuned 70B model's performance while deferring only 50% of the time.

Discussion and Future Work

Co-LLM demonstrates that token-level collaboration can create a system better than the sum of its parts. However, challenges remain, such as the need for per-task threshold tuning and the risk of error propagation if the assistant provides incorrect context. Future research will explore multi-directional collaboration among a "panel" of experts and the integration of backtracking mechanisms to refine deferral decisions.

Summary updated

BibTeX
@inproceedings{shen2024learning,
  author = {Zejiang Shen and Hunter Lang and Bailin Wang and Yoon Kim and David A. Sontag},
  title = {{Learning to Decode Collaboratively with Multiple Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.701},
}
Figure