[논문 리뷰] CATCODER: Repository-Level Code Generation with Relevant Code and Type Context
CatCoder는 정적 타입 언어를 위한 검색 증강 코드 생성 프레임워크로, 정적 분석에서 유도된 타입 컨텍스트와 관련 코드를 통합하여 레포지터리 수준의 코드 생성을 향상시킵니다. 모델 미세조정이나 외부 데이터베이스 없이도 다양한 LLM에서 일관된 성능 향상을 보이며, RepoCoder 대비 최대 17.35% 향상된 pass@k 점수를 기록합니다.
Large language models (LLMs) have demonstrated remarkable capabilities in code generation tasks. However, repository-level code generation presents unique challenges, particularly due to the need to utilize information spread across multiple files within a repository. Specifically, successful generation depends on a solid grasp of both general, context-agnostic knowledge and specific, context-dependent knowledge. While LLMs are widely used for the context-agnostic aspect, existing retrieval-based approaches sometimes fall short as they are limited in obtaining a broader and deeper repository context. In this paper, we present CatCoder, a novel code generation framework designed for statically typed programming languages. CatCoder enhances repository-level code generation by integrating relevant code and type context. Specifically, it leverages static analyzers to extract type dependencies and merges this information with retrieved code to create comprehensive prompts for LLMs. To evaluate the effectiveness of CatCoder, we adapt and construct benchmarks that include 199 Java tasks and 90 Rust tasks. The results show that CatCoder outperforms the RepoCoder baseline by up to 14.44% and 17.35%, in terms of compile@k and pass@k scores. In addition, the generalizability of CatCoder is assessed using various LLMs, including both code-specialized models and general-purpose models. Our findings indicate consistent performance improvements across all models, which underlines the practicality of CatCoder. Furthermore, we evaluate the time consumption of CatCoder in a large open source repository, and the results demonstrate the scalability of CatCoder.
연구 동기 및 목표
- 기존 검색 기반 접근 방식이 교차 파일 종속성과 부족한 컨텍스트로 인해 허구적 생성(Hallucinations)을 겪는 등의 한계를 해결하기 위해.
- 정적 분석을 통해 클래스 필드와 메서드 서명에서 유도된 타입 컨텍스트가 정적 타입 언어의 코드 생성을 향상시키는 데 보완적인 정보 소스로 기능할 수 있는지 탐색하기 위해.
- 모델 미세조정이나 외부 데이터베이스 없이도 LLM 기반 코드 생성을 향상시킬 수 있는 실용적이고 일반화 가능한 프레임워크를 설계하기 위해.
- Rust와 같은 덜 연구된 언어에서 레포지터리 수준의 코드 생성을 위한 새로운 벤치마크를 구축하고 평가하기 위해.
제안 방법
- CatCoder는 이전 연구와 유사하게, RepoCoder와 같은 검색 기반 기법을 사용해 레포지터리에서 관련 코드 스니펫을 검색합니다.
- 기존 정적 분석기들을 활용해 메서드 서명에서 유도된 종속성 분석을 통해 대상 클래스의 필드와 메서드 서명 등의 타입 컨텍스트를 추출합니다.
- 추출된 타입 컨텍스트의 텍스트 표현을 생성하여 LLM 프롬프트에 통합합니다.
- 검색된 코드와 타입 컨텍스트를 하나의 포괄적인 프롬프트로 통합하여 LLM의 컨텍스트 인식 능력을 향상시킵니다.
- 모델 미세조정이나 학습이 필요 없이 동결된 LLM 위에서 작동합니다.
- 프레임워크는 실제 오픈소스 레포지터리에서 유래한 199개의 Java 및 90개의 Rust 작업으로 구성된 새로운 벤치마크를 사용해 평가되었습니다.
실험 결과
연구 질문
- RQ1검색된 코드와 타입 컨텍스트를 통합하면 정적 타입 언어에서 레포지터리 수준의 코드 생성 정확도가 향상될 수 있는가?
- RQ2RepoCoder와 같은 최신 검색 기반 베이스라인 대비 CatCoder의 pass@k 점수는 어떻게 성과를 내는가?
- RQ3CatCoder는 코드 전용 모델과 일반 목적 모델을 포함한 다양한 LLM에 대해 얼마나 일반화 가능한가?
- RQ4CatCoder는 Rust와 같이 덜 일반적인 정적 타입 언어에서도 효과적으로 코드 생성을 지원할 수 있는가?
주요 결과
- CatCoder는 평가된 벤치마크에서 RepoCoder 대비 최대 17.35% 향상된 pass@k 점수를 기록하여 뚜렷한 성능 향상을 입증합니다.
- 모델의 종류에 관계없이 코드 전용 모델과 일반 목적 모델 모두에서 CatCoder가 pass@k 점수를 향상시켜 일반화 능력을 확인합니다.
- 타입 컨텍스트의 통합은 코드 검색과 보완되는 의미 있는 보조 정보를 제공하여 허구적 생성을 줄이고 코드 정확도를 향상시킵니다.
- 본 연구는 Rust에서 레포지터리 수준의 코드 생성을 위한 최초의 벤치마크를 제시하여 이 언어에서 코드 생성 프레임워크의 평가를 가능하게 합니다.
- CatCoder는 모델 미세조정이나 외부 데이터베이스 없이도 이러한 성과를 달성하여 실세계 구현에 실용적입니다.
이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.