A Study of LLMs' Preferences for Libraries and Programming Languages
This paper presents the first empirical study revealing that large language models exhibit strong biases toward popular libraries like NumPy and the Python language, often prioritizing familiarity over task-specific optimality and necessitating targeted improvements in training and evaluation.
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 have a team of incredibly talented, super-fast apprentices. They can write code (the instructions that tell computers what to do) faster than any human. But there's a catch: these apprentices don't just write code; they also make design choices. They decide which tools to use and which language to speak.
This paper is like a detective story where researchers went behind the scenes to ask: "Do these AI apprentices actually know the best tools for the job, or do they just pick the ones they've seen the most?"
Here is the breakdown of their findings, using some everyday analogies.
1. The "Familiarity Trap" (Libraries)
Think of libraries in programming like kitchen appliances.
- The Situation: You ask an apprentice to bake a cake.
- The Ideal Choice: You need a mixing bowl and a whisk. Simple, effective.
- The AI's Choice: The apprentice grabs a massive, industrial-grade food processor (a library called NumPy) to mix the batter.
What the study found:
The AI models have a massive habit of grabbing the "famous" tools, even when they aren't needed.
- They love NumPy and Pandas (the food processors of the coding world).
- In nearly 45% of cases, the AI used these heavy-duty tools even when the task didn't require them.
- The Analogy: It's like using a sledgehammer to crack a nut. It works, but it's overkill, slower, and makes the kitchen (your code) messy and harder for others to clean up. They ignore newer, lighter, faster tools (like Polars or FastAPI) because they haven't seen them as much in their training data.
2. The "One-Size-Fits-All" Language (Programming Languages)
Think of programming languages like vehicles.
- Python is a minivan: Great for families, easy to drive, comfortable, and good for most daily errands.
- Rust, C++, or Go are Formula 1 race cars or heavy-duty trucks: Built for speed, safety, and heavy lifting.
What the study found:
The AI models are obsessed with the minivan.
- Even when the job requires a race car (like building a high-speed trading platform or a system that needs to be crash-proof), the AI almost always hands you a minivan (Python).
- In 58% of cases where a high-performance language was the obvious choice, the AI still picked Python.
- The Analogy: It's like asking a mechanic to build a rocket ship, and they hand you a Toyota Camry because, "Well, everyone drives a Camry, and it has four wheels, so it must work for space travel."
- The AI ignores the race cars (Rust) entirely in many high-stakes scenarios, even though those tools are safer and faster for the specific job.
3. The "Talk vs. Action" Gap
This is the most surprising part. The researchers asked the AI two things:
- What would you recommend? (The "Consultant" mode)
- Now, actually write the code. (The "Worker" mode)
What the study found:
The AI is a hypocrite.
- When asked for advice, the AI might say, "For this high-speed task, you should definitely use Rust."
- But when it actually writes the code, it immediately switches back to Python.
- The Analogy: It's like a nutritionist who tells you, "You should eat a salad for dinner," but then goes home and eats a giant pizza. The AI knows the "right" answer in theory, but its habits (training data) pull it back to the "easy" answer in practice.
Why Does This Matter?
You might think, "So what? If the code works, isn't that good?"
The Problem:
- The Feedback Loop: If everyone uses the AI, and the AI always picks the "popular" tools, then the internet gets flooded with code using those same tools. This makes the AI even more likely to pick them next time.
- Stifling Innovation: New, better tools (like the newer libraries or languages) never get a chance to grow because the AI never recommends them.
- Performance Issues: Using a minivan for a race can lead to crashes or slow performance. In software, this means slower apps, higher costs, and security risks.
The Bottom Line
The study concludes that these AI models are conservative. They prioritize popularity and familiarity over suitability and optimization.
They are like a student who always answers questions with the first thing they memorized in class, rather than thinking about what the specific question actually needs. To fix this, the researchers suggest we need to teach these AIs to be more flexible, diversify what they learn, and stop letting them just "go with the flow" of what's popular.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.