Large Language Models for Code Generation from Multilingual Prompts: A Curated Benchmark and a Study on Code Quality

· Source: Artificial Intelligence · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Expert, quick

Summary

A recent study investigates language bias in Large Language Models (LLMs) for code generation, specifically how prompt language affects code quality. Researchers evaluated GPT-4o mini, DeepSeek, and Claude on 460 Python and Java coding tasks. Original English prompts were translated into Chinese, Hindi, Spanish, and Italian. Evaluation covered functional correctness via test pass rates, structural quality metrics, static analysis issues, and lexical characteristics like identifier language. Key findings indicate English prompts do not consistently produce superior functional correctness or code quality. The impact of prompt language varies significantly across both the programming language and the specific LLM used. Additionally, generated code frequently blends English with the prompt language in comments and string literals.

Key takeaway

For Machine Learning Engineers optimizing code generation LLMs in multilingual environments, do not assume English prompts will yield the best code quality or functional correctness. You should rigorously evaluate models like GPT-4o mini, DeepSeek, or Claude using prompts in the specific natural languages your users or developers will employ. This ensures generated code meets quality standards and aligns with local programming conventions.

Key insights

LLM code generation quality is biased by prompt language, with English not always superior.

Principles

Method

A study translated 460 Python/Java coding tasks into five languages, then evaluated GPT-4o mini, DeepSeek, and Claude's generated code across functional, structural, static analysis, and lexical dimensions.

In practice

Topics

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

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Artificial Intelligence.