arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2605.11772cs.SE
收藏

打破依赖混沌:一种基于约束的Python依赖解析策略与选择性LLM填补

Breaking the Dependency Chaos: A Constraint-Driven Python Dependency Resolution Strategy with Selective LLM Imputation

Kennesaw State University(肯尼索州立大学);Danovo Energy Solutions(丹诺沃能源解决方案)

Kowshik Chowdhury, Dipayan Banik, Shazibul Islam Shamim

AI总结:

本文提出SMT-LLM,通过形式化约束求解替代LLM猜测,利用AST分析和vermin工具确定Python版本,并在PyPI查询前构建约束图以解决版本一致性问题,提升解析效率。

摘要:

依赖解析是选择可共存的包版本的任务,是现代软件项目构建失败的主要原因。在Python生态系统中,此任务尤其具有挑战性,由于Python 2/3不兼容性、弃用的包和广泛缺失的元数据。最近的工作,如PLLM,通过使用大型语言模型(LLMs)从代码中推断Python和包版本,并基于构建错误迭代修复。我们提出了SMT-LLM,一种混合系统,用形式化约束求解替代LLM-only版本猜测。SMT-LLM通过抽象语法树(AST)分析进行确定性导入提取和Python版本检测,利用vermin工具推断最小Python版本,并使用五级导入到包解析器在任何LLM调用前查询PyPI。我们从PyPI元数据和LLM推断的依赖关系构建约束图,然后使用Z3 satisfiability modulo theories(SMT)求解器解决一致的版本分配。在HG2.9K基准使用Gemma2:9B(10 GB VRAM)上,SMT-LLM解析了83.6%的片段,比PLLM的54.8%高,同时将中位解析时间从151.5秒减少到23.9秒(6.3倍快),平均LLM调用次数从约24.9次减少到2.26次每片段(11倍减少)

英文摘要:

Dependency resolution is the task of selecting package versions that can be installed together without conflicts. It accounts for a significant share of build failures in modern software projects. In the Python ecosystem, this task is especially challenging due to Python 2/3 incompatibilities, deprecated packages, and widespread missing metadata. Recent work, such as PLLM, tackles this problem by using large language models (LLMs) to infer Python and package versions from code and iteratively repairing them based on build errors. We present SMT-LLM, a hybrid system that replaces LLM-only version guessing with formal constraint solving. SMT-LLM uses deterministic import extraction and Python version detection via abstract syntax tree (AST) analysis, the vermin tool to infer minimum Python versions, and a five-tier import-to-package resolver that queries PyPI before any LLM call. We construct a constraint graph from PyPI metadata and LLM-imputed dependencies for packages with missing metadata, then solve for consistent version assignments using a Z3 satisfiability modulo theories (SMT) solver. On the HG2.9K benchmark using Gemma2:9B (10 GB VRAM), SMT-LLM resolves 83.6% of snippets compared to PLLM's 54.8%, while reducing median resolution time from 151.5 s to 23.9 s (6.3x faster) and average LLM calls from ~24.9 to 2.26 per snippet (11x reduction).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑