Controlled Text Generation via Language Model Arithmetic

Jasper Dekoninck, Marc Fischer, Luca Beurer-Kellner, Martin T. Vechev
2/12/2026

No official code found. Best implementation: eth-sri/language-model-arithmetic (223 stars, MIT, last commit 2024-09-15).

Abstract

As Large Language Models (LLMs) are deployed more widely, customization with respect to vocabulary, style, and character becomes more important. In this work, we introduce model arithmetic, a novel inference framework for composing and biasing LLMs without the need for model (re)training or highly specific datasets. In addition, the framework allows for more precise control of generated text than direct prompting and prior controlled text generation (CTG) techniques. Using model arithmetic, we can express prior CTG techniques as simple formulas and naturally extend them to new and more effective formulations. Further, we show that speculative sampling, a technique for efficient LLM sampling, extends to our setting. This enables highly efficient text generation with multiple composed models with only marginal overhead over a single model. Our empirical evaluation demonstrates that model arithmetic allows fine-grained control of generated text while outperforming state-of-the-art on the task of toxicity reduction. We release an open source easy-to-use implementation of our framework at https://github.com/eth-sri/language-model-arithmetic.

View on arXivView PDF

Code Implementations(1)

MIT

Controlled Text Generation via Language Model Arithmetic

22316Shell, PythonNov 21, 20232 years agoMIT

Similar Papers

Cite this paper

@article{dekoninck2026controlled,
  title  = {Controlled Text Generation via Language Model Arithmetic},
  author = {Jasper Dekoninck and Marc Fischer and Luca Beurer-Kellner and Martin T. Vechev},
  year   = {2026},
  eprint = {2311.14479},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2311.14479},
  journal = {ICLR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2311.14479.svg)](https://codeofpaper.com/paper/2311.14479)

Discussion