[논문 리뷰] Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learning
이 논문은 대형 언어 모델(Codex)이 맥락 학습을 통해 다중 의도 코드 주석을 생성할 수 있음을 보여주며, 시연 10개와 검색 기반 시연 전략 및 재랭킹을 사용할 때 강한 이점을 얻는다.
Code comment generation aims at generating natural language descriptions for a code snippet to facilitate developers' program comprehension activities. Despite being studied for a long time, a bottleneck for existing approaches is that given a code snippet, they can only generate one comment while developers usually need to know information from diverse perspectives such as what is the functionality of this code snippet and how to use it. To tackle this limitation, this study empirically investigates the feasibility of utilizing large language models (LLMs) to generate comments that can fulfill developers' diverse intents. Our intuition is based on the facts that (1) the code and its pairwise comment are used during the pre-training process of LLMs to build the semantic connection between the natural language and programming language, and (2) comments in the real-world projects, which are collected for the pre-training, usually contain different developers' intents. We thus postulate that the LLMs can already understand the code from different perspectives after the pre-training. Indeed, experiments on two large-scale datasets demonstrate the rationale of our insights: by adopting the in-context learning paradigm and giving adequate prompts to the LLM (e.g., providing it with ten or more examples), the LLM can significantly outperform a state-of-the-art supervised learning approach on generating comments with multiple intents. Results also show that customized strategies for constructing the prompts and post-processing strategies for reranking the results can both boost the LLM's performances, which shed light on future research directions for using LLMs to achieve comment generation.
연구 동기 및 목표
- 다양한 개발자 의도를 반영하기 위해 다중 의도 코드 주석 생성을 촉진한다.
- 사전 학습된 LLM이 맥락 학습을 통해 파인튜닝 없이 여러 관점의 주석을 생성할 수 있는지 조사한다.
- 성과를 극대화하기 위해 시연 수, 검색 기반 시연 선택, 사후 재랭킹을 평가한다.
- 대규모 Java 코드-주석 데이터셋 Funcom 및 TLC에서 최신 감독 학습 방법(DOME)과 비교한다.
제안 방법
- 다중 의도 코드 주석 생성을 수행하기 위해 LLM으로 OpenAI Codex를 사용한다.
- 언어 지시, 의도 카테고리, 각 코드 시演과 대응 주석을 포함하는 프롬프트 템플릿을 제공한다.
- 목표 코드와 유사한 시演을 선택하기 위한 두 가지 검색 전략(토큰 기반 및 의미 기반)을 설계하여 프롬프트 구성에 활용한다.
- 가장 유사하게 검색된 코드의 참조 주석을 이용해 생성 주석을 재랭킹하는 전략을 적용하고 토큰 기반 및 의미 기반 유사도를 계산한다.
- BLEU, ROUGE-L, METEOR를 지표로 Funcom과 TLC Java 데이터셋에서 평가한다.
- 무작위/제로샷 설정의 무작위성을 고려하기 위해 다수 실행(100회)을 수행하고 평균을 보고한다; 재랭킹 평가도 최적 결과를 추정하기 위해 100회 수행한다.

실험 결과
연구 질문
- RQ1RQ1: 제로샷, 원샷, 라샷에서 Codex가 다중 의도 주석 생성을 수행하는 데 DOME에 비해 얼마나 효과적인가?
- RQ2RQ2: 검색 기반 시연 선택이 Codex의 성능을 향상시킬 수 있는가?
- RQ3RQ3: 생성 주석의 재랭킹이 Codex의 결과를 더 향상시킬 수 있는가?
주요 결과
- Codex는 시연이 많아질수록 향상되며, 10-shot 프롬프트가 BLEU, ROUGE-L, METEOR에서 평균적으로 DOME을 능가한다.
- 목표 코드와의 유사성에 따른 시연 선택이 성능을 크게 향상시키며 Funcom에서 BLEU가 97%, TLC에서 131%의 개선을 보이고 무작위 선택 대비 상승한다.
- 유사한 코드의 참조 주석을 이용한 재랭킹은 추가 이점을 제공하며 Funcom에서 최대 약 9.9%, TLC에서 약 9.6%의 BLEU 향상을 가져온다.
- 제로샷 및 원샷 Codex는 DOME에 비해 뒤처지지만, 5-shot Codex는 ROUGE-L과 METEOR에서 경쟁력이 있을 수 있으며 10-shot Codex는 두 데이터셋에서 모든 지표에서 지속적으로 DOME을 상회한다.
- 의도 전반에서, 10-shot 프롬프트를 사용한 Codex의 최상의 결과는 제로/소수-shot 기반선 대비 상당한 이득을 보여주며 다중 의도 코드 주석 생성에 대한 LLM의 잠재력을 시사한다.
- 연구 결과는 LLM 기반 코드 주석 생성에서 프롬프트 설계, 시연 검색 및 후처리의 유망한 방향을 제시한다.

이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.