arXiv cs.AI· Zhaorui Yang, Haichao Zhu, Qian Zhang, Rajiv Gupta, Ashish Kundu·· 13 小时前AI 评分39
SemLoc:将 LLM 自由形式推理结构化锚定用于故障定位
SemLoc: Structured Grounding of Free-Form LLM Reasoning for Fault Localization
AI 导读
SemLoc 把 LLM 的自由形式推理转成可执行、可验证的语义约束,每条约束带固定类别并锚定到代码图中的变量定义、分支、循环或返回点。
正文 · 原文
Abstract:Large language models (LLMs) can describe what a piece of code should compute, but they do so in free-form text. Such text cannot be checked against program executions, and it does not reveal whether a statement is correct. We present SemLoc, which turns LLM reasoning into executable, verifiable semantic constraints. With structured semantic grounding, the LLM writes each property as a constraint with a fixed category, attached to an anchor in the code graph, such as a variable definition, branch, loop, or return. SemLoc inserts each constraint as a runtime check and runs the tests, which yields a semantic violation spectrum over passing and failing tests. Counterfactual verification then patches the code at an anchor and reruns the tests; a patch that a constraint suggests counts as verified only if all tests then pass.
We study SemLoc on fault localization, where the tests serve as the oracle for verification, with four LLMs on QuixBugs and on SemBugs, a new dataset of 809 real bugs from 750 GitHub projects. The constraints are executable: 99.4% become runtime checks, and on programs where coverage ties the faulty line with at least half of the covered lines, their violations alone rank it first in 40.9% of the cases, compared with 2.2% for spectrum-based fault localization and 7.0% for Daikon invariants. They make the LLM's answers verifiable: 68.4% of SemLoc's top-ranked answers carry a patch that the tests confirm, and 93.6% of these are correct, which the LLM's own confidence cannot match. SemLoc's first-rank accuracy does not differ significantly, for any of the four LLMs, from that of an LLM given the same inputs (81.4% vs. 82.0%), and it far exceeds that of an LLM that sees only the function (50.0%).
| Subjects: | Software Engineering (cs.SE); Artificial Intelligence (cs.AI) |
| ACM classes: | K.6.3; D.2.5 |
| Cite as: | arXiv:2603.29109 [cs.SE] |
| (or arXiv:2603.29109v2 [cs.SE] for this version) | |
| https://doi.org/10.48550/arXiv.2603.29109 arXiv-issued DOI via DataCite |
Submission history
From: Zhaorui Yang [view email]
[v1]
Tue, 31 Mar 2026 00:56:43 UTC (1,087 KB)
[v2]
Tue, 27 Oct 2026 03:31:22 UTC (345 KB)
来源:arXiv cs.AI · arxiv.org