Metaphor-Induced Algorithmic Steering: Cross-Domain Procedural Transfer in LLM Code Generation

πŸ“… 2026-07-29
πŸ“ˆ Citations: 0
✨ Influential: 0
πŸ“„ PDF
πŸ€– AI Summary
This study addresses how metaphorical instructions can inadvertently induce large language models to transfer inefficient algorithmic patterns from the source domain during code generation, leading to degraded cross-task performance. The work presents the first systematic investigation into this metaphor-induced algorithmic bias, introducing the MASC framework to deliberately elicit and analyze the phenomenon through metaphor restructuring, behavioral evaluation, hidden state analysis, and prototype detection. Findings reveal that the detrimental influence of metaphors stems from deep programmatic patterns rather than superficial linguistic features and can be precisely identified: MASC achieves high accuracy in detecting metaphor-derived coding skills and their associated inefficient implementations, demonstrating that model hidden states shift toward prototypical representations of suboptimal behaviors.
πŸ“ Abstract
Large language models benefit from elements in natural language, such as metaphors and analogies in training data and inference input to achieve generalisability across different domains. However, these language elements may also lead to unwanted behaviors when metaphorical expressions implicitly transfer inappropriate procedural patterns into new tasks. In this paper, we show that metaphorical instructions can induce analogical transfer of procedural mechanisms, thus steering code-generation models towards less efficient algorithms. We refer to this metaphor-induced effect as metaphorical algorithmic steering: a skill that is benign and plausible within its source domain transfers an abstract procedural schema into a programming task, causing the model to favor exhaustive search, full scans, or repeated reconstruction without explicitly mentioning the target algorithm. More broadly, this suggests that code-generation models can carry procedures that are appropriate in a task's background domain into the task's programming problem, where they can lead to unwanted outcomes. To study this phenomenon, we develop MASC (Metaphorical Algorithmic Steering for Code Generation), a framework that iteratively metaphorizes and refines benign skills to elicit low-efficiency code while remaining benign and task-relevant. Beyond behavioral evaluation, we study whether this phenomenon is detectable and mechanistically reflected in model representations. Our method achieves high detection rates for metaphorical skills and less-efficient implementations. We also find that metaphorical skills induce a hidden-state shift towards lower-efficiency procedural behavior prototypes. These results suggest that metaphorical algorithmic steering operates through the transfer of procedural patterns associated with metaphorical source scenarios rather than surface level metaphorical language alone.
Problem

Research questions and friction points this paper is trying to address.

metaphor
algorithmic steering
procedural transfer
code generation
large language models
Innovation

Methods, ideas, or system contributions that make the work stand out.

metaphorical algorithmic steering
procedural transfer
code generation
large language models
MASC
πŸ”Ž Similar Papers