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.
