PEMA: Plug-in External Memory Adaptation for Language Models

HyunJin Kim, Young Jin Kim, JinYeong Bak · DOI

Introduction: The Deadlock of Proprietary Models

In the current "Model-as-a-Service" (MaaS) landscape, a fundamental conflict exists between model owners and data owners. Large-scale Pre-trained Language Models (PLMs) like GPT-4 or LLaMA are often proprietary, with their weights kept confidential by providers. Conversely, users often possess sensitive, private datasets they are unwilling to upload to external servers for fine-tuning.

This creates a deadlock: standard fine-tuning requires access to model weights (which the owner won't share), and "offsite" tuning typically requires sharing data (which the user won't share). Furthermore, full fine-tuning of billion-parameter models is computationally prohibitive for most researchers and small companies.

Overview of the PEMA framework, illustrating the interaction between the PLM Owner and Data Owner during training and inference.

Methodology: The PEMA Framework

The authors propose Plug-in External Memory Adaptation (PEMA) to break this deadlock. PEMA acts as a lightweight "plug-in" that resides locally with the data owner. It adapts the PLM without requiring full weight access or data disclosure.

The architecture consists of three primary components:

  1. External Memory: PEMA constructs a local datastore by mapping the Context Representation (CR)—the hidden state from the PLM’s final layer—to target tokens from the user's training set.
  2. Bottleneck Adapter: A small set of trainable weights ($A, B_{rct}, B_{pd}$) is used to learn task-specific predictions while maintaining the ability to reconstruct the original PLM's hidden states, preserving general knowledge and mitigating hallucinations.
  3. Gradual Unrolling (GU): This is the core inference strategy. PEMA interpolates its predictions with the base PLM's output to maintain fluency while adopting the new task.

Key Insights: The Power of Gradual Unrolling

A significant challenge for small adapters is "forgetting" global context during long generations. PEMA addresses this through Gradual Unrolling (GU).

The Gradual Unrolling (GU) mechanism: PEMA steers the initial generation while the base LM takes over for long-range coherence.

At the beginning of a sequence, PEMA exerts high control to ensure the model adopts the correct task-specific style or translation target. As generation continues, the influence of the PEMA adapter is "unrolled," gradually handing control back to the base PLM. This allows the system to leverage the adapter for steering and the massive pre-trained model for maintaining linguistic fluency and coherence.

Experimental Results

The researchers evaluated PEMA on models ranging from OPT-1.3B to OPT-30B and LLaMA-7B across Machine Translation (WMT22 EN→DE) and Style Transfer (GYAFC) tasks.

  • Efficiency: PEMA is remarkably lightweight. For an OPT-1.3B model, it requires only 478 MB of training memory, a 90% reduction compared to LoRA's 5,056 MB.
  • Performance: In translation tasks, PEMA achieved a Sacre-BLEU score of 12.87 on OPT-1.3B, outperforming LoRA (4.28) and even full fine-tuning (10.15) in specific configurations.
  • Style Transfer: PEMA excelled at formality transfer, effectively removing informal artifacts (e.g., slang, all-caps) while preserving semantic meaning better than competitive baselines like UniPELT or Offsite-Tuning.

Conclusion and Future Work

PEMA demonstrates that high-quality model adaptation is possible without compromising data privacy or requiring massive compute. By focusing on final-layer representations and employing Gradual Unrolling, it provides a practical path for "offsite" tuning.

Future work aims to remove the requirement for access to the PLM's "LM Head" (the final layer mapping hidden states to word probabilities), which is currently restricted by some commercial APIs. The authors suggest that generating a local LM head could further enhance the privacy and applicability of the PEMA framework.

Summary updated

BibTeX
@inproceedings{kim2024pema,
  author = {HyunJin Kim and Young Jin Kim and JinYeong Bak},
  title = {{PEMA: Plug-in External Memory Adaptation for Language Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.naacl-long.336},
}
Figure