AI
New system predicts code quality before LLMs generate it, saving developers time and effort
Researchers propose PreMaQ, a method that forecasts maintainability issues in AI-generated code using internal model signals before the code is even created.
As language models grow more skilled at writing code, determining which generated solutions are worth keeping has become a real challenge for developers. Beyond just checking if code works, teams must also evaluate whether it's maintainable and follows best practices—a time-consuming process when reviewing many generated candidates.
A new research effort tackles this problem head-on by attempting to predict code quality before generation happens, potentially saving developers from wasting time on subpar outputs.
The Research Approach#
The team behind PreMaQ (Pre-Generation Maintainability-Related Quality Prediction) developed a technique that examines the internal representations within large language models to forecast two key quality metrics: the Code Smell Score (CSS)—which identifies problematic code patterns—and the Maintainability Index (MI), which measures how easy code is to update and maintain.
The researchers evaluated their method on four different open-weight LLMs and four Python benchmarks, analyzing roughly 2,700 tasks in total. The scope of the evaluation provides a solid foundation for understanding how well the approach generalizes across different models and coding scenarios.
Key Results#
Predictions generated by PreMaQ showed consistent correlation with actual observed quality scores. The method achieved mean Spearman rank correlations of 0.57 for CSS and 0.65 for MI across all tested model-benchmark pairs—meaningful associations that suggest the predictions capture real quality patterns.
When used to select which model should generate code on a given task, PreMaQ achieved 59.5% of the maximum improvement in maintainability that an oracle selector could achieve. Combining PreMaQ's predictions with information from prompt embeddings increased that figure to 60.7%, pointing toward complementary signals that could work together.
Why This Matters#
The ability to estimate code quality before generation opens practical possibilities for development workflows. Rather than generating and then reviewing dozens of code samples, developers could use PreMaQ to identify which models are likely to produce maintainable solutions and prioritize those, cutting down on wasted effort and review cycles. The research suggests that LLM internals contain exploitable signals about code quality—knowledge that wasn't previously clear and could drive future tool improvements.
More information: The full paper is available on .

