Transformers can generate two text streams at once by mixing inputs
Your Transformer Can Hold Two Thoughts at Once: Evidence of Linear Superposition in LLMs
Computation and LanguageArtificial Intelligence
Summary
Large Language Models like transformers use complex math, but this paper shows they have a simple kind of ‘linearity’ when combining two different text inputs. The researchers found that mixing inputs causes the model to mix its outputs in a predictable way, like holding two thoughts at once. This behavior is built into the model’s design and can even be improved with some fine-tuning. They also created a method to separate these mixed outputs so the model can produce two coherent text continuations at the same time.
What this means in practice
- •For natural language processing engineers: Generate two different text continuations in a single forward pass by decoding mixed model outputs from combined inputs.
- •For machine learning system builders: Restore and exploit linearity in pretrained transformer models to reduce divergence in mixed input processing with lightweight fine-tuning.
Authors
Pavel Tikhonov, Anton Korznikov, Matvey Mikhalchuk, Nikita Dragunov, Temurbek Rahmatullaev, Polina Druzhinina, Anton Razzhigaev, Ivan Oseledets, Elena Tutubalina
Abstract
While Large Language Models (LLMs) rely on highly non-linear components, in this work we demonstrate that they exhibit fundamental linearity: when inputs from distinct text streams are linearly combined, the model outputs a superposition of the individual next-token distributions. We term this the \textit{Superposition Linearity Hypothesis}. We provide evidence that superposition is an intrinsic property of the Transformer architecture rather than an emergent consequence of training; in fact, we observe that it tends to diminish as pretraining progresses. However, we demonstrate that linearity can be substantially restored through lightweight fine-tuning, significantly reducing the divergence between the predicted next-token distribution and the average of the individual next-token distributions. Finally, we introduce a guided decoding procedure that disentangles superposed outputs, enabling the simultaneous generation of two coherent continuations from a single forward pass.