Merging large language models layers controls output diversity and quality

Controlling the Diversity-Quality Trade-Off of LLMs by Merging Models Before and After Alignment

Computation and LanguageMachine Learning

Summary

Large language models (LLMs) can produce either more varied or higher-quality answers depending on how they are adjusted, called alignment. The authors found a way to mix the parts of an aligned LLM with its original base model to balance variety and quality in the responses without extra training. By swapping specific layers between the two versions, they showed it changes how diverse and accurate the outputs are. This new method often works better than common tricks like tweaking the randomness in the answers.

What this means in practice

  • For ai product developers: Create LLM-powered tools that adjust output variety and quality without retraining models by merging model layers dynamically.
  • For natural language processing engineers: Control the trade-off between semantic accuracy and lexical diversity in generation tasks by merging model layers from aligned and base LLMs.

Authors

Yasuaki Sumita, Tomoharu Iwata, Toshiyuki Tanaka

Abstract

Alignment is known to change the output characteristics of large language models (LLMs). Base models tend to generate more diverse outputs, whereas aligned models tend to produce higher-quality outputs. The appropriate balance between the two depends on the task. Existing methods either require costly fine-tuning or, like temperature sampling, mainly improve lexical diversity rather than semantic diversity. We introduce a depth-aware FrankenMerging approach for controlling the diversity--quality trade-off between an aligned model and its base model without additional training. This approach combines the lower layers of an aligned model with the higher layers of its base model based on the hypothesis that lexical diversity is more closely associated with lower layers and semantic diversity with higher layers. Experiments showed that varying the number of layers taken from each model adjusts both diversity and quality. In most cases, the merged models exhibited higher semantic diversity than the aligned model, and at some split positions, they showed higher lexical diversity than both original models. They also demonstrated a better diversity--quality trade-off than temperature sampling in most settings. A supporting ablation, in which we reversed the merging order, yielded results largely consistent with the hypothesis.