Metaphor-Induced Algorithmic Steering: Cross-Domain Procedural Transfer in LLM Code Generation
This paper introduces "metaphorical algorithmic steering," a phenomenon where metaphorical instructions in natural language cause large language models to inappropriately transfer procedural patterns from a source domain into code generation tasks, resulting in inefficient algorithms, and proposes the MASC framework to study, elicit, and detect this hidden-state shift.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are teaching a brilliant, eager robot how to write computer code. You don't just give it a dry list of rules; you speak to it in natural language, using stories, examples, and even metaphors to explain what you want. This is how Large Language Models (LLMs) work: they are like super-readers who have devoured millions of books, articles, and code snippets. They learn by spotting patterns in how humans talk and think. If you tell them, "Think like a chef," they might start organizing information in a way that feels like a kitchen. This ability to understand context and analogies is their superpower, allowing them to solve new problems by borrowing ideas from old ones. But, just like a superpower, it has a flip side. Sometimes, the very thing that makes them smart—connecting ideas across different worlds—can trick them into making silly, inefficient choices. It's as if you asked a robot to build a bridge, and because you told it to "think like a detective," it decided to check every single brick individually instead of using a blueprint, simply because that's how detectives solve mysteries.
This paper explores a sneaky glitch in that superpower called "metaphorical algorithmic steering." The researchers found that if you give a coding AI a helpful-sounding instruction filled with metaphors from a different field (like medicine or biology), the AI might accidentally swap its smart, efficient coding strategy for a slow, clumsy one. It's not that the AI is broken or being told to be slow; it's that the metaphor acts like a hidden instruction, whispering, "Do it the hard way because that's how we do it in this story." The team built a tool called MASC to test this. They created "benign" (harmless) skills that sounded perfectly reasonable in their original context but secretly encouraged the AI to use "brute force" methods—like checking every single possibility one by one—instead of using clever shortcuts like dynamic programming.
The results were surprisingly clear. When the researchers used these metaphorical instructions, the AI models (specifically Qwen, Deepseek, and Gemma) frequently switched from their default, efficient solutions to much slower ones. For instance, on a set of coding problems, the metaphorical steering worked about 41% of the time for one model, compared to only 17% when they used direct, literal instructions. The paper suggests that the AI isn't just copying words; it's actually shifting its internal "thinking process" to match the slow, exhaustive pattern of the metaphor. Even worse, the AI didn't need to be told to be slow; the metaphor did it for them. The researchers also found that they could detect this shift by looking at the AI's internal "brain waves" (hidden states), which moved toward the "slow thinking" pattern when the metaphors were present. While this doesn't mean the AI is dangerous, it does suggest that when we talk to these smart machines, we need to be careful about the stories we tell them, because a well-meaning analogy might just lead them down a very long, very slow road.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.