Skip to main content
QUICK REVIEW

[논문 리뷰] CodePlan: Repository-level Coding using LLMs and Planning

Ramakrishna Bairi, Atharv Sonwane|arXiv (Cornell University)|2023. 09. 21.
Software Engineering ResearchComputer Science인용 수 3
한 줄 요약

CodePlan은 증분적 종속성 및 영향 분석을 통해 다단계 편집을 조율함으로써 LLM을 활용해 복잡하고 레포지터리 전체에 걸친 코드 수정을 자동화하는 계획 기반 프레임워크입니다. 상호의존성 있는 파일 간에 필요한 변경 사항을 동적으로 식별하고 전파함으로써 6개 레포지터리 중 5개에서 유효성 검사를 통과하며, 기존 베이스라인들이 전부 실패한 것과 대비해 뛰어난 성능을 보입니다.

ABSTRACT

Software engineering activities such as package migration, fixing errors reports from static analysis or testing, and adding type annotations or other specifications to a codebase, involve pervasively editing the entire repository of code. We formulate these activities as repository-level coding tasks. Recent tools like GitHub Copilot, which are powered by Large Language Models (LLMs), have succeeded in offering high-quality solutions to localized coding problems. Repository-level coding tasks are more involved and cannot be solved directly using LLMs, since code within a repository is inter-dependent and the entire repository may be too large to fit into the prompt. We frame repository-level coding as a planning problem and present a task-agnostic framework, called CodePlan to solve it. CodePlan synthesizes a multi-step chain of edits (plan), where each step results in a call to an LLM on a code location with context derived from the entire repository, previous code changes and task-specific instructions. CodePlan is based on a novel combination of an incremental dependency analysis, a change may-impact analysis and an adaptive planning algorithm. We evaluate the effectiveness of CodePlan on two repository-level tasks: package migration (C#) and temporal code edits (Python). Each task is evaluated on multiple code repositories, each of which requires inter-dependent changes to many files (between 2-97 files). Coding tasks of this level of complexity have not been automated using LLMs before. Our results show that CodePlan has better match with the ground truth compared to baselines. CodePlan is able to get 5/6 repositories to pass the validity checks (e.g., to build without errors and make correct code edits) whereas the baselines (without planning but with the same type of contextual information as CodePlan) cannot get any of the repositories to pass them.

연구 동기 및 목표

  • 현재 LLM 기반 도구의 범위를 초월해 전체 레포지터리에 걸쳐 광범위하고 상호의존적인 코드 수정을 자동화하는 데 도전하는 것.
  • 맥락 창 크기 제약과 코드 상호의존성으로 인해 LLM이 레포지터리 전체 편집을 처리하는 데 한계를 갖는 문제를 극복하는 것.
  • 코드 종속성과 변경 영향의 동적 분 析에 기반한 편집 체인을 생성하는 작업에 종속되지 않는 프레임워크를 설계하는 것.
  • 계획 수립과 LLM 생성을 통합하여 자동화된 코드 마이그레이션 및 리팩터링의 정확성과 신뢰성을 향상시키는 것.

제안 방법

  • CodePlan은 레포지터리 수준의 코딩을 계획 문제로 프레임워크화하여, 편집을 맥락 인식 가능한 원자적 LLM 호출의 시퀀스로 분해합니다.
  • 레포지터리 내 파일 간의 문법적 및 의미적 관계를 추적하기 위해 증분적 종속성 분 析을 수행합니다.
  • 각 편집이 영향을 줄 수 있는 코드 영역을 예측하기 위해 변경 사항 영향 분석을 적용하고, 이후 단계를 위한 '변경 의무'를 생성합니다.
  • 종속성 순서와 영향력 전파를 기반으로 편집의 우선순위와 순서를 정하기 위해 적응형 계획 알고리즘을 사용합니다.
  • 정확성을 보장하기 위해 전체 레포지터리, 이전 편집, 그리고 작업별 지침을 포함한 커리티드 컨텍스트를 각 LLM 호출에 제공합니다.
  • 각 편집을 증분적으로 검증하여 다음 단계로 진행하기 전에 문법적 및 의미적 일관성을 확보합니다.

실험 결과

연구 질문

  • RQ1다양한 파일에 걸쳐 광범위하고 상호의존적인 변경이 필요한 레포지터리 수준의 코딩 작업을 효과적으로 자동화할 수 있는 계획 기반 프레임워크는 가능한가?
  • RQ2맥락이 단일 프ompt로 처리하기에 너무 큰 대규모 코드베이스에서 LLM이 정확하고 일관된 편집을 수행하도록 어떻게 이끌 수 있는가?
  • RQ3동적 영향 분석은 다단계 코드 변환에서 오류를 줄이고 정확성을 향상시키는 데 어떤 역할을 하는가?
  • RQ4단일 코드 컨텍스트에 대한 직접적인 LLM 프롬프팅과 비교해 적응형 계획 수립은 성공률을 어떻게 향상시키는가?
  • RQ5작업에 종속되지 않는 프레임워크는 API 마이그레이션과 시간적 편집과 같은 다양한 레포지터리 수준 작업을 얼마나 잘 처리할 수 있는가?

주요 결과

  • CodePlan은 동일한 맥락 정보를 갖는 베이스라인들이 전부 실패한 것과는 대조적으로, 6개 레포지터리 중 5개에서 유효성 검사를 통과(예: 컴파일 및 정확한 의미적 변경)했습니다.
  • 특히 파일 간 전이적 종속성을 다룰 때, 베이스라인 방법에 비해 Ground Truth 편집과 더 높은 일치도를 보였습니다.
  • 영향 분석 덕분에 LLM 개입 이전에 영향을 받는 코드 영역을 식별함으로써 잘못되거나 중복된 편집의 수를 크게 줄였습니다.
  • 증분적 종속성 추적을 통해 복잡한 콜 그래프와 데이터 종속성 간에 정확한 변경 사항 전파가 가능했습니다.
  • 적응형 계획 전략은 비계획 기반 베이스라인 대비 수렴 성능을 향상시키고 실패한 편집 시퀀스의 수를 줄였습니다.
  • C# 및 Python 레포지터리(2~97개 파일) 모두에서 조율된 편집이 필요로 하는 작업을 성공적으로 처리하여 확장성과 견고성을 입증했습니다.

더 나은 연구,지금 바로 시작하세요

논문 읽기부터 검토까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.