Continuous Language Model Interpolation for Dynamic and Controllable Text Generation

Sara Kangaslahti, David Alvarez-Melis

TL;DR

Instead of relying on prompt engineering or expensive multi-model inference to control text style, this paper shows that linearly interpolating the weights of parameter-efficient (LoRA) fine-tuned models enables continuous, on-the-fly stylistic control. By defining anchor models at attribute extremes, users can navigate the resulting weight space to smoothly dial multiple style dimensions up or down in a single forward pass with minimal attribute entanglement.

What Problem Does This Paper Address?

In user-facing applications like chatbots and writing assistants, users often have distinct, shifting preferences: one user might want an explanation that is 20% simpler, slightly more polite, and distinctly informal.

Controlling large language models (LLMs) along continuous stylistic axes remains notoriously difficult:

  1. Discrete prompting limitations: Natural language prompts cannot reliably calibrate fine-grained numerical strengths (e.g., "be 30% more formal"), often collapsing to extreme behaviors or ignoring instructions.
  2. Computational overhead: Retraining or fine-tuning models on every possible combination of intermediate styles is impossible.
  3. Inference-time bloat: Existing decoding-time guidance methods (such as DExperts or logit-level model arithmetic) require evaluating multiple models or prompts simultaneously ($2N + 1$ forward passes for $N$ attributes), multiplying latency and GPU costs.

Methods

The authors introduce a framework for continuous multi-domain weight interpolation using Low-Rank Adaptation (LoRA):

  1. Anchor Model Fine-Tuning: For each style attribute $i$, two parameter-efficient LoRA adapters are trained on opposite poles of the attribute spectrum (e.g., positive vs. negative sentiment), denoted as $\theta_{+i}$ and $\theta_{-i}$, added on top of a frozen base model $\theta_{PRE}$.
  2. Single-Attribute Interpolation ($\alpha$): For any attribute $i$, the model parameters interpolate along the line connecting the extremes using weight $\alpha_i \in [0, 1]$: $$\theta_{\alpha_i} = \theta_{PRE} + \alpha_i B_{+i} A_{+i} + (1 - \alpha_i) B_{-i} A_{-i}$$
  3. Multi-Attribute Mixing ($\lambda$): To combine $N$ different attributes simultaneously, the method takes a convex combination of the single-attribute models parameterized by normalized mixture weights $\lambda$ ($\sum_i \lambda_i = 1$): $$\theta_{\alpha, \lambda} = \sum_{i=1}^N \lambda_i \theta_{\alpha_i}$$
  4. Single-Pass Inference: Because the weights are merged directly before inference, generating text requires exactly one model forward pass, irrespective of how many attributes are controlled.

Datasets

The authors evaluated five style dimensions using Llama-2-7b as the base architecture:

  • Simplicity: TinyStories (simple) vs. BookSum novel chapters (complex).
  • Formality: Grammarly's Yahoo Answers Formality Corpus (GYAFC) (formal vs. informal).
  • Politeness: Highest vs. lowest politeness splits from Madaan et al. (2020).
  • Sentiment: Stanford Sentiment Treebank (SST-2) (positive vs. negative).
  • Humor: FlickrStyle (humorous vs. non-humorous).

Evaluation Datasets:

  • Continuations were generated using 1,000 randomly sampled prompts from WritingPrompts.
  • Per-attribute scores were evaluated via fine-tuned RoBERTa classifiers.
  • Fluency and generation quality were measured using WikiText perplexity and distinct $n$-gram diversity metrics.

Key Insights and Ideas

  • LoRA Weight Space is Surprisingly Convex and Linear: Modulating $\alpha_i$ produces smooth, monotonic changes in attribute expression that closely match "ground-truth" models retrained from scratch on proportional mixtures of data.
  • Minimal Entanglement Between Styles: Weight updates learned across distinct stylistic dimensions are largely orthogonal in LoRA parameter space (cosine similarities between different attributes typically sit between $0.004$ and $0.05$). Adjusting sentiment or simplicity has almost no unintended side effects on formality or politeness.
  • Weight Interpolation Preserves (and Often Improves) Fluency: Within the interpolation bounds ($\alpha \in [0, 1]$), WikiText perplexity for interpolated adapters is consistently equal to or slightly lower than that of the extreme anchor models.
  • Extrapolation Has Hard Boundaries: Extending $\alpha$ beyond the anchor models works within a narrow stable regime ($\alpha \in [-1, 2]$). Beyond this window, model perplexity spikes exponentially and generation diversity collapses.

Key Results

  • Performance vs. Baselines: Weight interpolation closely tracks ground-truth fine-tuning trajectories across all five attributes. In contrast, prompting-based Model Arithmetic displayed erratic, unpredictable behavior on politeness and humor.
  • Efficiency: While DExperts achieves similar continuous control curves, it requires $2N + 1$ forward passes per token. Weight interpolation achieves competitive control with a $1\times$ inference cost.
  • Multi-Attribute Steering: Across 3D simplex evaluations ($\lambda_1 + \lambda_2 + \lambda_3 = 1$) and 5D simultaneous modulations, shifting $\lambda_i$ and $\alpha_i$ reliably and independently steered the corresponding RoBERTa classifier scores (e.g., ranging continuously from $\sim 0.2$ to $\sim 0.8$).

Limitations and Future Work

  • Inherent Linguistic Correlations: Certain traits remain entangled due to real-world language distribution (e.g., politeness and formality naturally correlate, as do humor and politeness LoRA weights, which had higher cosine similarity $\sim 0.19$).
  • Bounded Attribute Ranges: Generation strength is fundamentally bounded by the anchor models. While mild extrapolation ($\alpha \in [-1, 2]$) is possible, going further destroys model coherence.
  • Lack of Human Evaluation: Validating fine-grained gradations (e.g., testing if humans perceive the difference between $\alpha=0.4$ and $\alpha=0.6$) requires hundreds of pairwise evaluations per prompt and was left out of scope.

Summary updated

BibTeX
@inproceedings{kangaslahti2024continuous,
  author = {Sara Kangaslahti and David Alvarez-Melis},
  title = {{Continuous Language Model Interpolation for Dynamic and Controllable Text Generation}},
  booktitle = {AFM @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=NOnjKBUvDk},
}
Figure