Abstract
Instruction tuning is the primary method for transforming base Large Language Models (LLMs) into versatile assistants capable of following diverse prompts. However, the internal mechanisms by which these models manage multiple tasks across their deep architectures have remained poorly understood. This study investigates the "functional geography" of Llama 2 7B, identifying a distinct three-stage pipeline: early layers handle general features, middle layers transition into task-specific logic, and final layers refine representations for output. By comparing a generalist model against task-specific specialists using Centered Kernel Alignment (CKA), we demonstrate that instruction tuning fundamentally reorganizes how a model allocates its internal capacity across its depth.
Introduction
While instruction tuning is known to be the "secret sauce" behind the success of models like Llama and GPT-4, the models themselves often remain black boxes. A critical question for model efficiency and interpretability is whether all layers contribute equally to multi-task learning or if specific layers specialize. Understanding this internal organization is essential for optimizing techniques like model pruning and Parameter-Efficient Fine-Tuning (PEFT).
Methodology: The MOSSA Framework
To map the model's internal functions, researchers employed the Model-Oriented Sub-population and Spectral Analysis (MOSSA) framework. The core of this approach involves a comparative setup:
- Specialist Models: Over 60 individual models were fine-tuned, each on a single specific task.
- Generalist Model (Llama 2-SFT): One model was fine-tuned on all tasks simultaneously.
- Representational Comparison: Using Centered Kernel Alignment (CKA), the internal states of the generalist were compared against the specialists layer by layer. High CKA similarity indicates that the generalist has successfully captured the specific task's logic at that particular depth.
Additionally, the study utilized Principal Component Analysis (PCA) to measure "representational complexity," quantifying the dimensions of internal space used to process information.
The Three-Stage Functional Pipeline
The analysis revealed that Llama 2-SFT divides its 32 layers into three distinct functional zones, creating a structured pipeline for information processing.
- Shared Layers (1–9): These initial layers produce general representations utilized across all tasks. Instruction tuning actually increases the generality of these layers compared to the base model.
- Transition Layers (10–15): This is the critical zone where the model shifts from general language understanding to specific task logic. In these layers, the instruction-tuned model exhibits a "complexity bump," utilizing significantly more principal components than the base model.
- Refinement Layers (16–32): These layers act as a "finishing school," steadily polishing representations to produce the final output. By this stage, the generalist's internal states are often nearly identical to those of the single-task specialists.
Empirical Evidence of Task Specialization
The impact of instruction tuning varies significantly depending on the nature of the task. For simpler tasks like sentiment analysis or paraphrase detection, the base model already possesses sufficient representations. However, for complex, structured tasks like translation or struct-to-text, the base model is inadequate, and instruction tuning triggers a massive representational shift in the middle and late layers.
Key Results and Performance
The functional reorganization observed through MOSSA correlates directly with improved performance. Llama 2-SFT showed significant gains over the base model, moving from 41.25 to 47.81 on MMLU and 32.82 to 37.49 on BBH. Furthermore, the study found a positive correlation between a task's linguistic difficulty and the amount of task-specific information stored in the later layers, suggesting that harder tasks demand more specialized processing depth.
Limitations and Future Work
While providing a clear map of Llama 2 7B, this study has limitations. The use of Low-Rank Adaptation (LoRA) for fine-tuning may not capture the full extent of representational changes possible with full-parameter tuning. Additionally, it remains to be seen if larger models (70B+) or different architectures, such as Mixture-of-Experts (MoE), follow this same three-stage pattern. Future research will also explore whether these findings extend to non-NLP domains like code generation and mathematical reasoning.
Summary updated