Skip to main content
QUICK REVIEW

[논문 리뷰] GraphCodeBERT: Pre-training Code Representations with Data Flow

Daya Guo, Shuo Ren|arXiv (Cornell University)|2020. 09. 17.
Software Engineering Research참고 문헌 41인용 수 152
한 줄 요약

GraphCodeBERT는 데이터 흐름 구조를 도입하여 코드 표현을 사전 학습하고, 두 가지 구조 인식 태스크를 도입하며, 네 가지 코드 관련 다운스트림 태스크에서 최첨단을 달성한다.

ABSTRACT

Pre-trained models for programming language have achieved dramatic empirical improvements on a variety of code-related tasks such as code search, code completion, code summarization, etc. However, existing pre-trained models regard a code snippet as a sequence of tokens, while ignoring the inherent structure of code, which provides crucial code semantics and would enhance the code understanding process. We present GraphCodeBERT, a pre-trained model for programming language that considers the inherent structure of code. Instead of taking syntactic-level structure of code like abstract syntax tree (AST), we use data flow in the pre-training stage, which is a semantic-level structure of code that encodes the relation of "where-the-value-comes-from" between variables. Such a semantic-level structure is neat and does not bring an unnecessarily deep hierarchy of AST, the property of which makes the model more efficient. We develop GraphCodeBERT based on Transformer. In addition to using the task of masked language modeling, we introduce two structure-aware pre-training tasks. One is to predict code structure edges, and the other is to align representations between source code and code structure. We implement the model in an efficient way with a graph-guided masked attention function to incorporate the code structure. We evaluate our model on four tasks, including code search, clone detection, code translation, and code refinement. Results show that code structure and newly introduced pre-training tasks can improve GraphCodeBERT and achieves state-of-the-art performance on the four downstream tasks. We further show that the model prefers structure-level attentions over token-level attentions in the task of code search.

연구 동기 및 목표

  • 토큰 시퀀스를 넘어서는 코드 구조를 활용하여 코드 이해를 향상시키려는 동기를 제시한다.
  • 프로그래밍 언어에 대한 의미 구조 인지 사전 학습 프레임워크를 제안한다.
  • 코드 시맨틱을 인코딩하기 위한 확장 가능한 대안으로 데이터 흐름을 AST의 대안으로 조사한다.
  • 여러 코드 관련 태스크에서 구조 인식형 사전 학습의 이점을 보여준다.

제안 방법

  • 데이터 흐름을 그래프로 입력으로 포함하도록 보강된 Transformer 기반으로 코드를 표현한다.
  • 데이터 흐름 노드와 코드 토큰에 선택적으로 주의를 기울이도록 그래프 가이드 마스크드 어텐션을 도입한다.
  • 데이터 흐름 간선 예측과 코드와 데이터 흐름 간의 노드 정렬(정합)이라는 두 가지 구조 인식 사전 학습 태스크를 추가한다.
  • 이를 표준 마스킹 언어 모델링과 결합하여 코드와 구조의 공동 표현을 학습한다.
  • CodeSearchNet에서 GraphCodeBERT를 사전 학습하고 네 가지 다운스트림 태스크에서 평가한다.

실험 결과

연구 질문

  • RQ1데이터 흐름을 의미적 코드 구조로 도입하는 것이 토큰 시퀀스를 넘어 학습된 표현을 향상시키는가?
  • RQ2두 가지 구조 인식 사전 학습 태스크(간선 예측 및 노드 정합)가 태스크 전반에 걸쳐 코드 이해를 향상시킬 수 있는가?
  • RQ3code search, clone detection, translation, refinement에서 GraphCodeBERT가 토큰만 사전 학습된 모델과 어떻게 비교되는가?
  • RQ4실제로 모델은 원시 코드 토큰보다 데이터 흐름 노드에 더 많이 주의를 기울이는가?

주요 결과

  • GraphCodeBERT는 네 가지 다운스트림 태스크에서 최첨단 성능을 달성한다: 코드 검색, 코드 클론 탐지, 코드 번역, 코드 정제.
  • 삭제 연구에서 데이터 흐름이나 두 가지 구조 인식 태스크를 제거하면 성능이 저하되어 그 유용성이 확인된다.
  • 어텐션 분석은 코드 검색에서 모델이 순수 토큰 수준 어텐션보다 구조 수준(데이터 흐름) 어텐션을 선호함을 보인다.
  • 사례 연구는 데이터 흐름이 변수 시맨틱의 모호성을 줄이고 코드 이해를 향상시킴을 시사한다.
  • 태스크 전반에 걸쳐 코드 구조를 활용하는 것이 CodeBERT 및 RoBERTa 변종을 포함한 기준선보다 향상된다.

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

연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.

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

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