How do Llamas process multilingual text? A latent exploration through activation patching

Clément Dumas, Veniamin Veselovsky, Giovanni Monea, Robert West, Chris WendlerMI @ ICML 2024

TL;DR

This paper investigates whether large language models (LLMs) like Llama-2 represent concepts in a language-agnostic way. Using a technique called "activation patching," they found that Llama-2 first determines the target language and then the concept, suggesting a disentangled representation. This implies LLMs might have a universal understanding of concepts independent of the language used.

What Problem Does This Paper Address?

A fundamental question in multilingual natural language processing is whether large language models (LLMs) develop a truly universal understanding of concepts, or if their representations are inherently tied to specific languages. In other words, when an LLM processes the word "dog," does it activate a representation that's the same regardless of whether the input was English, French, or Chinese, or is the representation different for each language? This paper aims to shed light on this by exploring how Llama-2, a prominent LLM, handles multilingual text, specifically in translation tasks.

Methods

The core technique employed is activation patching, a method from mechanistic interpretability. Here's how it works in this context:

  1. Source and Target Prompts: The researchers create pairs of translation prompts. For example, a source prompt might ask to translate a German word into Italian, and a target prompt might ask to translate a French word into Chinese. Crucially, these prompts can involve different concepts and languages.
  2. Latent Extraction and Insertion: During the forward pass of the LLM, they extract the "latent representation" (the internal state or activation) at a specific layer from the source prompt's computation. This extracted latent is then "patched" or inserted into the corresponding layer of the target prompt's computation.
  3. Observing the Output: By observing how this patching affects the LLM's final output (specifically, the probability of predicting certain words), they can infer what information is encoded in the latents at different layers and how language and concept information are processed.

They also introduce a variation where they average latents from multiple source prompts to see if this "mean" representation is more robust.

Datasets

The paper does not explicitly mention training datasets. For evaluation, they use a set of translation prompts derived from existing work (Wendler et al., 2024), featuring various language pairs (e.g., German to Italian, French to Chinese) and concepts. They report using 41 source concepts and 38 target concepts in their experiments.

Key Insights and Ideas

  • Language First, Then Concept: The most striking finding is that Llama-2 appears to determine the output language in earlier layers (around layer 12) and then the concept to be translated in later layers (around layer 16). This suggests a sequential processing order where language context is established before the specific meaning is fully resolved.
  • Disentangled Representations: The ability to change the concept without changing the language, and vice versa, through activation patching strongly supports the idea that Llama-2 maintains language-agnostic concept representations. This means the model can represent "dog" in a way that is independent of whether it's translating from English, German, or any other language.
  • Averaging Enhances Concepts: Patching with the average latent representation across different language pairs not only doesn't degrade performance but actually improves the model's ability to translate the concept. This "concept denoising" effect further strengthens the hypothesis of language-agnostic concept representations, as averaging multiple language-specific versions of a concept leads to a clearer, more robust representation.
  • Hypothesis Testing: The experiments were designed to test two hypotheses: H1 (language and concept are independent) and H2 (they are entangled). The results strongly favor H1.

Key Results

  • Layered Processing:
    • Layers 0-11: Target concept decoded in the target language.
  • Layers 12-16: Target concept decoded in the source language.
  • Layers 16-31: Source concept decoded in the source language.
  • Concept Manipulation: The researchers successfully demonstrated that they could change the predicted concept without altering the predicted language, and vice versa, by strategically patching latents.
  • Improved Performance with Averaging: Patching with the mean over latents from different language pairs improved the probability of correctly predicting the target concept.

Limitations and Future Work

  • Limited Prompt Types: The study primarily used simple, few-shot translation prompts. More complex or diverse multilingual tasks would be needed to generalize these findings.
  • Probing Specific Words: The analysis focused on the translation of specific words. Further research is needed to understand how Llama-2 handles broader multilingual contexts and more subtle concept-language entanglements.
  • Degree of Specialization: The paper calls for more fine-grained probing to determine the extent to which Llama-2 can specialize a concept for a particular language and how deeply concepts and languages are entangled in more complex scenarios.
  • Other Models: While the paper mentions testing on other models (Mistral-7B, Llama-3-8B, Qwen1.5-7B, Llama-2-70B) and finding similar behavior, a deeper dive into inter-model differences could be a future direction.

Summary updated

BibTeX
@inproceedings{dumas2024how,
  author = {Clément Dumas and Veniamin Veselovsky and Giovanni Monea and Robert West and Chris Wendler},
  title = {{How do Llamas process multilingual text? A latent exploration through activation patching}},
  booktitle = {MI @ ICML},
  year = {2024},
  url = {https://openreview.net/forum?id=0ku2hIm4BS},
}
Figure