首次量化大模型生成代码的架构缺陷与技术债,发现开源模型漏洞率高达80%。
Quantitative Analysis of Technical Debt and Pattern Violation in Large Language Model Architectures
- 通过解析AST对比三模型在标准架构下的实现偏差
- 开源模型架构违规率达80%,且代码逻辑量减少60%
- 适合关注AI生成代码长期维护性的研发团队
随着大型语言模型(LLMs)从代码补全工具转向自主系统架构设计,其对长期软件可维护性的影响尚无量化评估。现有研究仅关注功能正确性(pass@k),本研究首次提出实证框架,测量由AI生成微服务引发的「架构退化」与技术债积累。我们对三种前沿模型(GPT-5.1、Claude 4.5 Sonnet、Llama 3 8B)进行对比实验,要求其在严格六边形架构约束下实现标准化图书借阅微服务。通过抽象语法树(AST)解析发现:专有模型架构符合度高(GPT-5.1为0%违规),而开源模型出现严重偏离。其中,Llama 3架构违规率达80%,频繁绕过接口适配器,导致领域层与基础设施层间产生非法循环依赖。此外,我们识别出「实现懒惰」现象——开源模型生成的逻辑代码行数(LLOC)比专有模型少60%,为满足令牌限制而省略复杂业务逻辑。结果表明,若缺乏自动化架构检查,使用小型开源模型搭建系统将加速结构性技术债的积累。
原文摘要 · Abstract (English)
As Large Language Models (LLMs) transition from code completion tools to autonomous system architects, their impact on long-term software maintainability remains unquantified. While existing research benchmarks functional correctness (pass@k), this study presents the first empirical framework to measure "Architectural Erosion" and the accumulation of Technical Debt in AI-synthesized microservices. We conducted a comparative pilot study of three state-of-the-art models (GPT-5.1, Claude 4.5 Sonnet, and Llama 3 8B) by prompting them to implement a standardized Book Lending Microservice under strict Hexagonal Architecture constraints. Utilizing Abstract Syntax Tree (AST) parsing, we find that while proprietary models achieve high architectural conformance (0% violation rate for GPT-5.1), open-weights models exhibit critical divergence. Specifically, Llama 3 demonstrated an 80% Architectural Violation Rate, frequently bypassing interface adapters to create illegal circular dependencies between Domain and Infrastructure layers. Furthermore, we identified a phenomenon of "Implementation Laziness," where open-weights models generated 60% fewer Logical Lines of Code (LLOC) than their proprietary counterparts, effectively omitting complex business logic to satisfy token constraints. These findings suggest that without automated architectural linting, utilizing smaller open-weights models for system scaffolding accelerates the accumulation of structural technical debt.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。