Context-PEFT: Efficient Multi-Modal, Multi-Task Fine-Tuning

Avelina Asada Hadji-Kyriacou, Ognjen ArandjelovicarXiv 2023 · DOI

Introduction

Parameter-Efficient Fine-Tuning (PEFT) methods, most notably LoRA, have transformed the adaptation of Large Language Models (LLMs) by allowing specific task tuning without the prohibitive cost of retraining billions of parameters. However, extending these benefits to multi-modal tasks—such as image captioning—presents unique challenges. Traditional approaches often rely on expensive full fine-tuning or complex architectural modifications like cross-attention layers.

Context-PEFT addresses this gap by introducing a framework that bridges vision and language modalities within a frozen transformer backbone. By applying different sets of adapter weights based on a token's "context," the model achieves superior performance with a fraction of the trainable parameters.

Methodology: Context-Aware Adaptation

The core innovation of Context-PEFT is the assignment of a "context identifier" to every token in a sequence. Rather than applying a single, uniform set of adapter weights across all inputs, the framework routes tokens to modality-specific parameters.

Context-PEFT architecture showing modality-specific adapter routing (T-Ada and I-Ada) within a frozen language model.

Context-Specific Adapters

In this architecture, image-projection tokens are processed by one set of weights (I-Ada), while text tokens are processed by another (T-Ada). This modality-specific routing allows the model to manage inter-modality interactions more effectively than a "one-size-fits-all" approach. To maintain computational efficiency, the authors developed a "Context-LoRA" algorithm using einsum operations, which applies these specific weights without materializing a massive, fully-expanded weight matrix. This approach is versatile and can be integrated with various PEFT techniques, including LoRA, BitFit, and $IA^3$.

Model Architecture

The experimental setup utilizes a frozen Swin Transformer V2 as the vision encoder and a 150M parameter Llama-2 style LLM as the language backbone. The vision encoder was pre-trained on ImageNet, while the language model was trained on a 5-billion-token subset of The Pile.

Key Results and Performance

Evaluated on the COCO image captioning task, Context-PEFT consistently outperformed both vanilla PEFT methods and full fine-tuning in data-constrained scenarios.

Comparison of test perplexity across various fine-tuning methods and model scales, demonstrating the consistent advantage of context-specific adaptation.

Superior Efficiency

On the COCO dataset, Context-LoRA 64 (using a Tiny Swin encoder) achieved a perplexity (PPL) of 7.48, notably better than the 7.70 achieved by full fine-tuning over the same 8-epoch training period. This performance gain is achieved with significantly fewer parameters: Context-LoRA-64 requires approximately 26 million trainable parameters, compared to the 153 million required for full backbone fine-tuning.

Scaling and Consistency

The framework scales effectively with visual feature quality; upgrading to a "Large" Swin encoder reduced perplexity further to 6.93. Across all tested PEFT methods—LoRA, BitFit, and $IA^3$—the context-specific variants consistently outperformed their context-agnostic counterparts.

Insights and Future Directions

Analysis of the results yielded several key insights:

  • Regularization Effect: The low-rank nature of Context-LoRA appears to act as a beneficial regularizer, preventing overfitting on smaller datasets where full fine-tuning might struggle.
  • Attention Sinks: The authors observed "attention sinking," where the model places disproportionately high weight on the first and last image tokens. This suggests that explicit boundary tokens (e.g., [section] tags) could further refine modality transitions.
  • Security Implications: The authors hypothesize that using distinct adapters for "system" versus "user" tokens could help mitigate prompt injection attacks by allowing the model to isolate and potentially ignore malicious contexts.

While Context-PEFT excels in data-constrained environments, future work will explore its performance on massive, web-scale datasets and expand its application to other modalities, such as Video Question Answering (VQA) and speech recognition.

Summary updated

BibTeX
@misc{hadjikyriacou2023context,
  author = {Avelina Asada Hadji-Kyriacou and Ognjen Arandjelovic},
  title = {{Context-PEFT: Efficient Multi-Modal, Multi-Task Fine-Tuning}},
  year = {2023},
  eprint = {2312.08900},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.08900},
}
Figure