Metaphor-Induced Algorithmic Steering: Cross-Domain Procedural Transfer in LLM Code Generation
- Source
- arxiv.org
- Author
- Zhibo Hu, Chen Wang, Yanfeng Shu, Hye-young Paik, Liming Dong, Liming Zhu
- Date

Context
A metaphor in a coding request can influence the algorithm a model chooses. This study reports that models sometimes transfer a procedure implied by a metaphor into generated code, favoring exhaustive searches, full scans, or repeated reconstruction even when the instruction never names those algorithms. The researchers developed a method for refining such metaphorical instructions and observed shifts in internal model representations associated with less-efficient procedures. Their finding suggests that seemingly descriptive background language can shape implementation choices. It makes algorithmic efficiency a separate question to examine when reviewing generated code, even when a prompt's language appears benign.
- The steering works by importing a procedural schema, not by naming an algorithm. A metaphor about searching a crowd carries 'check everything one by one' into the code, so the model writes an exhaustive scan without the prompt ever mentioning search strategy.
- The authors' MASC framework repeatedly rewrites benign skills into metaphors until the model emits slow code, and the prompts stay plausible and on-task throughout. A content filter looking for malicious phrasing would pass every one of them.
- The effect is not surface wordplay. Metaphorical prompts push the model's hidden states toward low-efficiency behavior prototypes, which means the bias lives in the transferred procedure and is detectable in the model's internals.
“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.”
“We also find that metaphorical skills induce a hidden-state shift towards lower-efficiency procedural behavior prototypes.”
articleImproving the Energy-Efficiency of the Code Generated by LLMs through Effective PromptingRitika Rekhi, Bing Zhang, Md Arman Islam, Jaya Krishna Pasham, Yeswanth Chitturi, Akshay Paramesha, Isha Valiveti, Asif Imran, Bekir Turkkan, Tevfik Kosar
articleHow well LLM-based test generation techniques perform with newer LLM versions?Michael Konstantinou, Renzo Degiovanni, Mike Papadakis
articleHow Reasoning Shapes Social Bias in LLM-Generated Code?Weifeng Sun, Jieke Shi, Zhou Yang, Yuchen Chen, Hongyan Li, Meng Yan, David Lo
Checking sign-in…
Loading comments…