Table of Contents
Fetching ...

Where does In-context Translation Happen in Large Language Models

Suzanna Sia, David Mueller, Kevin Duh

TL;DR

Evidence is demonstrated of a "task recognition"point where the translation task is encoded into the input representations and attention to context is no longer necessary, and the most effective layers for MT fine-tuning are the layers critical to task recognition.

Abstract

Self-supervised large language models have demonstrated the ability to perform Machine Translation (MT) via in-context learning, but little is known about where the model performs the task with respect to prompt instructions and demonstration examples. In this work, we attempt to characterize the region where large language models transition from in-context learners to translation models. Through a series of layer-wise context-masking experiments on \textsc{GPTNeo2.7B}, \textsc{Bloom3B}, \textsc{Llama7b} and \textsc{Llama7b-chat}, we demonstrate evidence of a "task recognition" point where the translation task is encoded into the input representations and attention to context is no longer necessary. We further observe correspondence between the low performance when masking out entire layers, and the task recognition layers. Taking advantage of this redundancy results in 45\% computational savings when prompting with 5 examples, and task recognition achieved at layer 14 / 32. Our layer-wise fine-tuning experiments indicate that the most effective layers for MT fine-tuning are the layers critical to task recognition.

Where does In-context Translation Happen in Large Language Models

TL;DR

Evidence is demonstrated of a "task recognition"point where the translation task is encoded into the input representations and attention to context is no longer necessary, and the most effective layers for MT fine-tuning are the layers critical to task recognition.

Abstract

Self-supervised large language models have demonstrated the ability to perform Machine Translation (MT) via in-context learning, but little is known about where the model performs the task with respect to prompt instructions and demonstration examples. In this work, we attempt to characterize the region where large language models transition from in-context learners to translation models. Through a series of layer-wise context-masking experiments on \textsc{GPTNeo2.7B}, \textsc{Bloom3B}, \textsc{Llama7b} and \textsc{Llama7b-chat}, we demonstrate evidence of a "task recognition" point where the translation task is encoded into the input representations and attention to context is no longer necessary. We further observe correspondence between the low performance when masking out entire layers, and the task recognition layers. Taking advantage of this redundancy results in 45\% computational savings when prompting with 5 examples, and task recognition achieved at layer 14 / 32. Our layer-wise fine-tuning experiments indicate that the most effective layers for MT fine-tuning are the layers critical to task recognition.
Paper Structure (41 sections, 10 figures, 6 tables)

This paper contains 41 sections, 10 figures, 6 tables.

Figures (10)

  • Figure 1: Graphical explanation of Masking the Attention over Instructions and Examples. The leftmost image has instructions and masks examples ($\texttt{Instr},\overline{\texttt{Ex}}^{Mask}$), while the right image has both instructions and examples masked ($\overline{\texttt{Instr}, \texttt{Ex}}^{Mask}$). In the interest of space we show only 2 out of 3 variants (see \ref{['fig:full_context_mask_graphics']} for all variants). In the table, the overline corresponds to the yellow highlights. $N$ and $Y$ refer to absence and presence of either Instruction of Examples. $\texttt{Instr}$: Instructions and $\texttt{Ex}$: Examples.
  • Figure 2: Layer-from context-masking experiments for GPTNeo2.7B, BLOOM3B, Llama7b, Llama7b-chat on $\texttt{en}\!\leftrightarrow\! \texttt{fr}$. The graphs show translation performance when masking contexts from the $j^{\textrm{th}}$ layer onwards. Different lines indicate different treatments of the instruction, as described in \ref{['fig:masking_context_layers_description_wfig']}. The dashed black line is the performance when shown both examples and instructions without masking.
  • Figure 3: Layer-from experiments for GPTNeo2.7B, Bloom3B, Llama and Llama7b-chat on $\texttt{en}\rightarrow \texttt{fr}$ when masking out from layer $j$ onwards. Orange and blue dashed lines refer to the baselines (without masking) of 0 and 5 prompts with instructions. In view of the smaller models failure to translate at all under the format Q: A: with no examples, we adopt "English:", "French:" as delimiters instead of QA in generating this figure.
  • Figure 4: Layer-wise masking of self-attention heads for GPTNeo2.7B, Bloom3B, Llama and Llama-chat on $\texttt{en}\leftrightarrow {fr}$. The orange and blue dotted lines refer to the baselines (without masking) of 0 and 5 prompts with instructions. We observe critical layers near the middle and redundant layers towards the end of the model.
  • Figure 5: Layer-from context-masking experiments for GPTNeo and BLOOM on $\texttt{en}\!\rightarrow\! \texttt{fr}$ investigating number of examples in the $\overline{\texttt{Ex}}^{Mask}$ mask setting (described in \ref{['fig:context_mask_graphics']}). The dashed black line refers to no instructions and no examples.
  • ...and 5 more figures