TAIA: Large Language Models are Out-of-Distribution Data Learners

Shuyang Jiang, Yusheng Liao, Ya Zhang, Yanfeng Wang, Yu Wang

Introduction

Fine-tuning Large Language Models (LLMs) on mismatched or "out-of-distribution" (OOD) data usually degrades their performance on downstream tasks. To address this, researchers have introduced TAIA (Training All parameters but Inferring with only Attention). This simple yet highly effective inference-time intervention trains the entire model but discards the Feed-Forward Network (FFN) updates during inference, keeping only the self-attention improvements. This allows models to learn new task formats from general data without "forgetting" the deep knowledge stored in their original parameters.

The Challenge of Out-of-Distribution Data

The standard recipe for creating specialized LLMs is Supervised Fine-Tuning (SFT) on high-quality, task-specific data. However, in specialized fields like medicine or law, such data is rare and expensive to curate. When researchers attempt to substitute this with general-purpose data or synthetic datasets that don't perfectly match the target task (OOD data), the model often suffers from catastrophic forgetting.

The authors identify a structural conflict at the heart of this issue: while fine-tuning helps a model follow instructions better, it often "overwrites" the factual knowledge encoded during pretraining. Specifically, they found that when training on mismatched data, the updates to the Feed-Forward Networks (FFNs)—which act as the model's long-term memory—introduce noise that severely degrades downstream performance.

Methodology: How TAIA Works

To solve this, the authors propose TAIA. To understand its mechanics, it is helpful to compare it against alternative fine-tuning approaches:

  1. Vanilla Fine-tuning: Trains all parameters and uses all updated parameters for inference. This is highly prone to catastrophic forgetting when data is mismatched.
  2. TOA (Train-only-Attention): Freezes the FFNs and only trains the self-attention layers. This approach generally fails because the model lacks the "optimization space" provided by FFN non-linearities during gradient descent.
  3. TAIA (The Proposed Method):
    • Training Phase: Updates all parameters (both Attention and FFN). This allows the self-attention layers to benefit from the non-linear "exploration" provided by the FFNs during the training process.
  4. Inference Phase: Discards the FFN updates, reverting them to their original pretrained state. Only the updated self-attention weights are retained.

By splitting the training and inference architectures, the model gains the improved "instruction-following" logic from the attention updates while preserving the "parametric knowledge" safely stored in the original FFNs.

Experimental Setup

The researchers evaluated TAIA across a diverse range of benchmarks and datasets:

  • Training Sets: Alpaca-GPT4 (general instruction), CoT-Collection (Chain-of-Thought reasoning), MMedBench (medical), and OpenMath.
  • Evaluation Benchmarks: Seven major tasks including MATH, BBH (Big-Bench Hard), CommonsenseQA, LogiQA, SVAMP (math word problems), MMedBench (medical knowledge), and MMLU (general knowledge).
  • Safety/Red-Teaming: The Advbench dataset was used to test the model's resistance to "jailbreaking" attempts.

Key Results and Insights

Robustness to OOD Noise

In experiments where the ratio of OOD data was steadily increased from 0% to 100%, vanilla fine-tuning performance plummeted. In stark contrast, TAIA's performance remained remarkably stable and consistently outperformed the base model, proving its high tolerance to data mismatches.

Performance of TAIA vs. Vanilla fine-tuning across different ratios of Out-of-Distribution (OOD) data.

Superior Generalization

Across almost all scenarios, TAIA outperformed both the base model and the vanilla fine-tuned model. For example, on the MATH benchmark using a Qwen1.5-7B backbone, TAIA achieved a score of 24.98, compared to 17.90 for vanilla fine-tuning and 20.30 for the base model.

The "Memory vs. Logic" Split

The paper reinforces the theory that self-attention modules primarily control instruction-following and contextual mapping, while FFNs serve as key-value memories for factual knowledge. TAIA leverages this split perfectly.

Restoring Few-Shot Ability and Defending Against Jailbreaks

Standard fine-tuning often "breaks" a model's ability to learn from examples in a prompt (few-shot learning). TAIA successfully restores this capability. Furthermore, TAIA acts as a natural defense against malicious fine-tuning. Because "harmful" knowledge or "jailbreak" instructions often get encoded into the FFN updates, discarding those updates at inference time effectively filters out the malicious behavior.

Limitations and Future Directions

While highly effective, TAIA is best suited for "eliciting" knowledge the model already possesses (e.g., using general data to improve medical reasoning). If a model must learn entirely new facts not present in its pretraining, discarding FFN updates might be counterproductive, as new facts are typically stored there. Additionally, tasks requiring specific stylistic preferences (like abstractive summarization) may see a small performance gap.

Future work will explore finding a "minimal set" of trainable parameters or developing adaptive strategies that dynamically decide which FFN layers to keep based on the specific task, rather than relying on a blanket "discard all" approach.

Summary updated

BibTeX
@inproceedings{jiang2024taia,
  author = {Shuyang Jiang and Yusheng Liao and Ya Zhang and Yanfeng Wang and Yu Wang},
  title = {{TAIA: Large Language Models are Out-of-Distribution Data Learners}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=XxSME6GE1G},
}
Figure