Ensembling Language Models with Sequential Monte Carlo
Organizations: ETH Zürich · CHI-FRO · McGill University · Mila ·
Abstract
Practitioners have access to an abundance of language models and prompting strategies for solving many language modeling tasks; yet prior work shows that modeling performance is highly sensitive to both choices. Classical machine learning ensembling techniques offer a principled approach: aggregate predictions from multiple sources to achieve better performance than any single one. However, applying ensembling to language models during decoding is challenging: naively aggregating next-token probabilities yields samples from a locally normalized, biased approximation of the generally intractable ensemble distribution over strings. In this work, we introduce a unified framework for composing language models into -ensemble distributions for a wide range of functions . To sample from these distributions, we propose a byte-level sequential Monte Carlo (SMC) algorithm that operates in a shared character space, enabling ensembles of models with mismatching vocabularies and consistent sampling in the limit. We evaluate a family of -ensembles across prompt and model combinations for various structured text generation tasks, highlighting the benefits of alternative aggregation strategies over traditional probability averaging, and showing that better posterior approximations can yield better ensemble performance.
Figures & tables
| Name | {\color[rgb]{0,0,0}f} -Ensemble | Minimized | ||
| Minimum | \frac{1}{Z}\min_{k=1}^{K}{\color[rgb]{0,0,0}p}_{k}({{\color[rgb]{0,0,0}\bm{x}}}) | D_{\infty}({\color[rgb]{0,0,0}\Phi{}}\mid\mid{\color[rgb]{0,0,0}p}_{k}) | ||
| consensus | Harmonic | \frac{1}{Z}\left(\sum_{k=1}^{K}\frac{w_{k}}{{\color[rgb]{0,0,0}p}_{k}({{\color[rgb]{0,0,0}\bm{x}}})}\right)^{-1} | D_{\chi^{2}}({\color[rgb]{0,0,0}\Phi{}}\mid\mid{\color[rgb]{0,0,0}p}_{k}) | |
| Product | \frac{1}{Z}\prod_{k=1}^{K}{\color[rgb]{0,0,0}p}_{k}({{\color[rgb]{0,0,0}\bm{x}}})^{w_{k}} | D_{\mathrm{KL}}({\color[rgb]{0,0,0}\Phi{}}\mid\mid{\color[rgb]{0,0,0}p}_{k}) | ||
| [1pt/2pt] | Sum | \frac{1}{Z}\sum_{k=1}^{K}w_{k}{\color[rgb]{0,0,0}p}_{k}({{\color[rgb]{0,0,0}\bm{x}}}) | D_{\mathrm{KL}}({\color[rgb]{0,0,0}p}_{k}\mid\mid{\color[rgb]{0,0,0}\Phi{}}) | |
| coverage | Quadratic | \frac{1}{Z}\sqrt{\sum_{k=1}^{K}w_{k}{\color[rgb]{0,0,0}p}_{k}({{\color[rgb]{0,0,0}\bm{x}}})^{2}} | D_{\chi^{2}}({\color[rgb]{0,0,0}p}_{k}\mid\mid{\color[rgb]{0,0,0}\Phi{}}) | |
| Maximum | \frac{1}{Z}\max_{k=1}^{K}{\color[rgb]{0,0,0}p}_{k}({{\color[rgb]{0,0,0}\bm{x}}}) | D_{\infty}({\color[rgb]{0,0,0}p}_{k}\mid\mid{\color[rgb]{0,0,0}\Phi{}}) |
| JSON Schema | BBH (Word Sorting) | SPIDER (Text-to-SQL) | |||||||
| Method | Q wen | P hi | L lama | Q wen | P hi | L lama | Q wen | P hi | L lama |
| Prompt 1 | |||||||||
| Prompt 2 | † | ||||||||
| Local Prob. Avg. | |||||||||
| Best Local {\color[rgb]{0,0,0}f} -Ens. | † | † | † | † | |||||
| [1pt/2pt] Best Global {\color[rgb]{0,0,0}f} -Ens. (Token SMC, ) | |||||||||
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Token SMC | Byte SMC | |||||
| Model | Base Model | Local Ensemble | ||||
| Llama-3.1-8B | 0.76 | 2.34 | 15.24 | 32.88 | 104.30 | 63.45 |
| Phi-4 | 1.42 | 3.84 | 23.27 | 59.90 | 167.59 | 166.76 |
| Qwen2.5-7B | 0.79 | 2.96 | 18.89 | 45.64 | 124.50 | 47.52 |
| JSON Schema | BBH (Word Sorting) | SPIDER (Text-to-SQL) | |||||||
| Method | Qwen | Phi | Llama | Qwen | Phi | Llama | Qwen | Phi | Llama |
| Prompt 1 | |||||||||
| Prompt 2 | |||||||||
| † | † | † | |||||||
| Product | † | † | |||||||
| Mixture | |||||||||
| BBH (Word Sorting) | SPIDER (Text-to-SQL) | JSON Schema | |||||||
| Method | Qwen | Phi | Llama | Qwen | Phi | Llama | Qwen | Phi | Llama |
| ∗∗∗ | ∗∗∗ | ∗∗ | ∗ | ∗∗∗ | ∗∗∗ | ||||
| Product | ∗∗∗ | ∗∗∗ | ∗∗∗ | ∗∗∗ | ∗∗∗ | ∗∗∗ | |||
| Sum | ∗ | ||||||||
| ∗∗∗ | ∗∗ | ∗ | |||||||
Language Model Ensembles
Language model ensembles combine predictions or reasoning from multiple models to improve accuracy, reliability, coverage, or efficiency.
See all 134 papers