The Invisible Lottery: How Subtle Cues Steer Algorithm Choice in LLM Code Generation

· Source: cs.SE updates on arXiv.org · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Expert, extended

Summary

A study involving 46,535 controlled experiments across 11 tasks, 19 cue types, and 15 large language model (LLM) configurations reveals that incidental prompt cues systematically steer the algorithms LLMs select for code generation. These contextual words or metadata, even when algorithmically irrelevant, cause shifts in algorithm-family distributions by up to 100 percentage points (pp). While semantic cues like "performance critical" induce stronger steering (mean 67.2 pp), innocuous cues such as team names still cause significant shifts (mean 26.1 pp). This "invisible lottery" means functionally correct code can embed varying performance, security, and maintainability characteristics, which correctness-only benchmarks like HumanEval miss. The study found that direct algorithm naming is the most reliable mitigation, and that more sophisticated algorithm choices can sometimes reduce code reliability.

Key takeaway

For AI Engineers generating production code with LLMs, you must recognize that subtle prompt context dictates algorithm choice, impacting performance and security beyond functional correctness. Explicitly specify algorithms when implications are critical, as this is the most reliable mitigation. Standardize your system prompts and project metadata to ensure reproducible algorithm selection, and test across models, as steering effects vary significantly.

Key insights

Incidental prompt cues systematically steer LLM algorithm selection, creating an "invisible lottery" over code quality beyond functional correctness.

Principles

Method

The study used an AST-based classifier to detect algorithm families from LLM-generated code across 11 tasks and 19 cue types, measuring distribution shifts and pass rates.

In practice

Topics

Code references

Best for: NLP Engineer, AI Architect, Research Scientist, AI Scientist, Machine Learning Engineer, AI Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by cs.SE updates on arXiv.org.