Controlled Text Generation via Language Model Arithmetic
cs.CL
Submitted: 2023-11-24
Updated: 2026-10-12
Code: https://github.com/eth-sri/language-model-arithmetic
License: http://creativecommons.org/licenses/by/4.0/
The gist: As Large Language Models (LLMs) are deployed more widely, customization with respect to vocabulary, style, and character becomes more important.
Terminology
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.
Sources
- Accelerating Large Language Model Decoding with Speculative Sampling
- Controllable Text Generation with Language Constraints
- PaLM: Scaling Language Modeling with Pathways
- RoBERTa: A Robustly Optimized BERT Pretraining Approach
- SpecInfer: Accelerating Generative Large Language Model Serving with Tree-based Speculative Inference and Verification
- GPT-4 Technical Report
- Code Llama: Open Foundation Models for Code
- Stay on topic with Classifier-Free Guidance
- GEDI: GEnerative and DIscriminative Training for Self-Supervised Learning
- Classifiers are Better Experts for Controllable Text Generation
- Release Strategies and the Social Impacts of Language Models
- Accelerating LLM Inference with Staged Speculative Decoding
- Llama 2: Open Foundation and Fine-Tuned Chat Models
Related papers
- Exploring Solution Divergence and Its Effect on Large Language Model Problem Solving
- Ishigaki-IDS-Bench: A Benchmark for Generating Information Delivery Specification from BIM Information Requirements
- Subliminal Steering: Stronger Encoding of Hidden Signals
- MedStruct-S: A Benchmark for Key Discovery, Key-Conditioned QA and Semi-Structured Extraction from OCR Clinical Reports
- The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures
- Untangling the Mechanisms of Misleading Context in Medical Question Answering