Table of Contents
Fetching ...

That's Deprecated! Understanding, Detecting, and Steering Knowledge Conflicts in Language Models for Code Generation

Jaesung Bae, Cameron Churchwell, Mitchell Hermon, Tsun-An Hsieh, Jocelyn Xu, Yekaterina Yegorova, Mark Hasegawa-Johnson, Heng Ji

TL;DR

This work examines how LLMs resolve conflicts between their learned parameters and conflicting prompt information, extending prior QA analyses to code generation. It introduces a domain-agnostic framework for constructing knowledge conflicts, a code-focused evaluation dataset, and methods to detect and steer knowledge reliance, including activation-based steering that can improve alignment to PK or CK. Key findings show that larger models tend to rely more on parametric knowledge and that conflicts can be detected via residual-stream probes with accuracies up to 80.65% in cross-domain tests, while steering achieves up to 12.6% improvements in steering success. The results highlight the nuanced interaction between model size, task domain, and steering direction, with implications for deploying reliable memory-aware LLMs in code-generation and beyond.

Abstract

This paper investigates how large language models (LLMs) behave when faced with discrepancies between their parametric knowledge and conflicting information contained in a prompt. Building on prior question-answering (QA) research, we extend the investigation of knowledge conflicts to the realm of code generation. We propose a domain-agnostic framework for constructing and interpreting such conflicts, along with a novel evaluation method and dataset tailored to code conflict scenarios. Our experiments indicate that sufficiently large LLMs encode the notion of a knowledge conflict in their parameters, enabling us to detect knowledge conflicts with up to \textbf{80.65\%} accuracy. Building on these insights, we show that activation-level steering can achieve up to a \textbf{12.6\%} improvement in steering success over a random baseline. However, effectiveness depends critically on balancing model size, task domain, and steering direction. The experiment code and data will be made publicly available after acceptance.

That's Deprecated! Understanding, Detecting, and Steering Knowledge Conflicts in Language Models for Code Generation

TL;DR

This work examines how LLMs resolve conflicts between their learned parameters and conflicting prompt information, extending prior QA analyses to code generation. It introduces a domain-agnostic framework for constructing knowledge conflicts, a code-focused evaluation dataset, and methods to detect and steer knowledge reliance, including activation-based steering that can improve alignment to PK or CK. Key findings show that larger models tend to rely more on parametric knowledge and that conflicts can be detected via residual-stream probes with accuracies up to 80.65% in cross-domain tests, while steering achieves up to 12.6% improvements in steering success. The results highlight the nuanced interaction between model size, task domain, and steering direction, with implications for deploying reliable memory-aware LLMs in code-generation and beyond.

Abstract

This paper investigates how large language models (LLMs) behave when faced with discrepancies between their parametric knowledge and conflicting information contained in a prompt. Building on prior question-answering (QA) research, we extend the investigation of knowledge conflicts to the realm of code generation. We propose a domain-agnostic framework for constructing and interpreting such conflicts, along with a novel evaluation method and dataset tailored to code conflict scenarios. Our experiments indicate that sufficiently large LLMs encode the notion of a knowledge conflict in their parameters, enabling us to detect knowledge conflicts with up to \textbf{80.65\%} accuracy. Building on these insights, we show that activation-level steering can achieve up to a \textbf{12.6\%} improvement in steering success over a random baseline. However, effectiveness depends critically on balancing model size, task domain, and steering direction. The experiment code and data will be made publicly available after acceptance.
Paper Structure (43 sections, 9 equations, 21 figures, 7 tables)

This paper contains 43 sections, 9 equations, 21 figures, 7 tables.

Figures (21)

  • Figure 1: Framework for analyzing context-memory conflicts. Query for Parametric Knowledge elicits the models $y_{PK}$ for a given query $q$. Construct Conflicts applies a task-specific template function to create the conflicts from $q$ and $y_{PK}$. Response Categorization categorizes the model's response $y'$ to the combined prompt $(c', q)$ either PK, CK, or Other.
  • Figure 2: Proportion of CK-based response of Llama3 model with different model sizes on (a) World Capitals and (b) Olympics Winners dataset. For the detailed results please refer to Appendix \ref{['sec:appendix:response_proportion_results']}.
  • Figure 3: Proportion of code generation responses from the 1B, 3B, and 8B Llama models which are detected as being parametric, conflicting, both, or neither. The responses are separated by perturbation type. Table \ref{['table:code']} contains a detailed breakdown
  • Figure 4: QA Probing Accuracy Across Layers
  • Figure 5: Code Dataset Probing Accuracy Across Layers. Graph created following the structure of Figure \ref{['fig:1B_Q/A_linear_probing']}.
  • ...and 16 more figures