LocAgent: 코드 위치 탐색을 위한 그래프 기반 LLM 에이전트
LocAgent: Graph-Guided LLM Agents for Code Localization
March 12, 2025
저자: Zhaoling Chen, Xiangru Tang, Gangda Deng, Fang Wu, Jialong Wu, Zhiwei Jiang, Viktor Prasanna, Arman Cohan, Xingyao Wang
cs.AI
초록
코드 로컬라이제이션(Code Localization)—코드베이스 내에서 정확히 어디를 변경해야 하는지 식별하는 작업—은 소프트웨어 유지보수에서 기본적이면서도 어려운 과제입니다. 기존의 접근 방식은 관련 코드 섹션을 식별할 때 복잡한 코드베이스를 효율적으로 탐색하는 데 어려움을 겪습니다. 이 문제는 자연어로 된 문제 설명과 적절한 코드 요소를 연결하는 데 있으며, 종종 계층적 구조와 다중 의존성을 넘나드는 추론이 필요합니다. 우리는 그래프 기반 표현을 통해 코드 로컬라이제이션을 해결하는 LocAgent 프레임워크를 소개합니다. LocAgent는 코드베이스를 방향성 이종 그래프로 파싱하여 파일, 클래스, 함수와 같은 코드 구조와 그들의 의존성(임포트, 호출, 상속)을 포착하는 경량 표현을 생성합니다. 이를 통해 LLM 에이전트가 강력한 다중 홉 추론을 통해 관련 엔티티를 효과적으로 검색하고 위치를 파악할 수 있습니다. 실제 벤치마크에서의 실험 결과는 우리의 접근 방식이 코드 로컬라이제이션의 정확도를 크게 향상시킴을 보여줍니다. 특히, 미세 조정된 Qwen-2.5-Coder-Instruct-32B 모델을 사용한 우리의 방법은 SOTA 독점 모델과 비슷한 결과를 훨씬 낮은 비용(약 86% 절감)으로 달성하며, 파일 수준 로컬라이제이션에서 최대 92.7%의 정확도를 보입니다. 또한 다중 시도(Pass@10)에서 GitHub 이슈 해결 성공률을 12% 향상시켰습니다. 우리의 코드는 https://github.com/gersteinlab/LocAgent에서 확인할 수 있습니다.
English
Code localization--identifying precisely where in a codebase changes need to
be made--is a fundamental yet challenging task in software maintenance.
Existing approaches struggle to efficiently navigate complex codebases when
identifying relevant code sections. The challenge lies in bridging natural
language problem descriptions with the appropriate code elements, often
requiring reasoning across hierarchical structures and multiple dependencies.
We introduce LocAgent, a framework that addresses code localization through
graph-based representation. By parsing codebases into directed heterogeneous
graphs, LocAgent creates a lightweight representation that captures code
structures (files, classes, functions) and their dependencies (imports,
invocations, inheritance), enabling LLM agents to effectively search and locate
relevant entities through powerful multi-hop reasoning. Experimental results on
real-world benchmarks demonstrate that our approach significantly enhances
accuracy in code localization. Notably, our method with the fine-tuned
Qwen-2.5-Coder-Instruct-32B model achieves comparable results to SOTA
proprietary models at greatly reduced cost (approximately 86% reduction),
reaching up to 92.7% accuracy on file-level localization while improving
downstream GitHub issue resolution success rates by 12% for multiple attempts
(Pass@10). Our code is available at https://github.com/gersteinlab/LocAgent.Summary
AI-Generated Summary