arXiv:2501.16191cs.SEcs.AI2025-01中稿 · the first annual w…被引 5

用大模型自动修复Python依赖冲突,效果显著优于现有方法。

The Last Dependency Crusade: Solving Python Dependency Conflicts with LLMs

  • 基于检索增强生成的LLM迭代推理依赖组合
  • 在Gistable HG2.9K上比基线高15.97%~21.58%修复率
  • 特别适合依赖多或使用科学计算库的项目

解决Python依赖问题仍是一项繁琐且易出错的任务,开发者需手动尝试兼容的模块版本和解释器配置。现有自动化方案如基于知识图谱和数据库的方法,受限于依赖错误类型多样、模块版本组合庞大及传递依赖冲突。本文研究使用大语言模型(LLM)自动修复Python程序中的依赖问题。提出PLLm(发音为"plum"),一种检索增强生成(RAG)方法,通过迭代推断缺失或错误依赖。PLLm构建测试环境,让LLM提出模块组合,根据执行反馈观察并利用自然语言处理解析错误信息进行预测优化。在真实世界Python程序数据集Gistable HG2.9K上评估,对比六种开源LLM在有无RAG下的表现。结果表明RAG持续提升修复率,最佳效果来自Gemma-2 9B结合RAG。相比两个先进基线PyEGo和ReadPyE,PLLm修复率分别高出15.97%和21.58%。进一步分析显示,其对依赖量多或使用特定数值/机器学习库的项目尤为有效。

原文摘要 · Abstract (English)

Resolving Python dependency issues remains a tedious and error-prone process, forcing developers to manually trial compatible module versions and interpreter configurations. Existing automated solutions, such as knowledge-graph-based and database-driven methods, face limitations due to the variety of dependency error types, large sets of possible module versions, and conflicts among transitive dependencies. This paper investigates the use of Large Language Models (LLMs) to automatically repair dependency issues in Python programs. We propose PLLM (pronounced "plum"), a novel retrieval-augmented generation (RAG) approach that iteratively infers missing or incorrect dependencies. PLLM builds a test environment where the LLM proposes module combinations, observes execution feedback, and refines its predictions using natural language processing (NLP) to parse error messages. We evaluate PLLM on the Gistable HG2.9K dataset, a curated collection of real-world Python programs. Using this benchmark, we explore multiple PLLM configurations, including six open-source LLMs evaluated both with and without RAG. Our findings show that RAG consistently improves fix rates, with the best performance achieved by Gemma-2 9B when combined with RAG. Compared to two state-of-the-art baselines, PyEGo and ReadPyE, PLLM achieves significantly higher fix rates; +15.97\% more than ReadPyE and +21.58\% more than PyEGo. Further analysis shows that PLLM is especially effective for projects with numerous dependencies and those using specialized numerical or machine-learning libraries.

Python依赖修复LLMRAG

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。