[논문 리뷰] An Empirical Study of the Non-determinism of ChatGPT in Code Generation
이 논문은 CodeContests, APPS, HumanEval 전반에서 ChatGPT의 코드 생성에 있어 높은 비결정성(non-determinism)을 실증적으로 보여주고, 제로 온도가 결정성을 보장하지 않으며, 작업 특성과의 상관관계를 분석한다.
There has been a recent explosion of research on Large Language Models (LLMs) for software engineering tasks, in particular code generation. However, results from LLMs can be highly unstable; nondeterministically returning very different codes for the same prompt. Non-determinism is a potential menace to scientific conclusion validity. When non-determinism is high, scientific conclusions simply cannot be relied upon unless researchers change their behaviour to control for it in their empirical analyses. This paper conducts an empirical study to demonstrate that non-determinism is, indeed, high, thereby underlining the need for this behavioural change. We choose to study ChatGPT because it is already highly prevalent in the code generation research literature. We report results from a study of 829 code generation problems from three code generation benchmarks (i.e., CodeContests, APPS, and HumanEval). Our results reveal high degrees of non-determinism: the ratio of coding tasks with zero equal test output across different requests is 75.76%, 51.00%, and 47.56% for CodeContests, APPS, and HumanEval, respectively. In addition, we find that setting the temperature to 0 does not guarantee determinism in code generation, although it indeed brings less non-determinism than the default configuration (temperature=1). These results confirm that there is, currently, a significant threat to scientific conclusion validity. In order to put LLM-based research on firmer scientific foundations, researchers need to take into account non-determinism in drawing their conclusions.
연구 동기 및 목표
- 여러 벤치마크에서 ChatGPT의 코드 생성에 대한 비결정성의 정도를 정량화한다.
- 코드 생성에서 온도가 비결정성에 미치는 영향을 평가한다.
- 서로 다른 프롬프트 구성(다중 요청 대 단일 요청) 간의 비결정성을 비교한다.
- 코딩 작업 특성(예: 지시문 길이)과 비결정성 간의 상관관계를 탐색한다.
- 실험적 소프트웨어 공학 연구에서 비결정성을 고려하기 위한 연구자들을 위한 지침을 제공한다.
제안 방법
- 세 벤치마크(CodeContests, APPS, HumanEval)에 걸쳐 각 코딩 작업당 다섯 개의 코드 후보를 생성하기 위해 ChatGPT(gpt-3.5-turbo 및 gpt-4)를 사용한다.
- API 응답에서 코드를 추출하기 위해 Markdown 형식으로 Python3 코드를 프롬프트한다.
- 테스트 통과율, 출력 동등성 비율(OER) 및 예외를 제외한 OER을 통해 의미를 평가한다.
- 코드 후보 간 LCS와 Levenshtein 편집 거리로 구문 유사성을 측정한다.
- AST 기반 방법(pycode_similar with Unified_Diff and Tree_Diff)을 사용하여 구조적 유사성을 측정한다.
- 온도(0, 1, 2)의 영향을 조사하고 GPT-3.5와 GPT-4의 차이를 비교한다.

실험 결과
연구 질문
- RQ1RQ1: 의미적, 구문적, 구조적 관점에서 ChatGPT의 코드 생성은 얼마나 비결정적인가?
- RQ2RQ2: 온도가 코드 생성의 비결정성 정도에 어떻게 영향을 미치는가?
- RQ3RQ3: 서로 다른 요청으로 얻은 다섯 개 후보와 한 요청에서 얻은 다섯 개 상위 1위 후보 간의 비결정성은 어떻게 비교되는가?
- RQ4RQ4: 코딩 작업 특징(예: 지시문 길이, 난이도)과 비결정성 지표 간의 상관관계는 무엇인가?
- RQ5RQ5: 코드 생성을 위한 GPT-4의 비결정성은 GPT-3.5와 어떻게 비교되는가?
주요 결과
- 높은 비결정성 위협이 관찰되었다: CodeContests, APPS, HumanEval의 작업 중 각각 72.73%, 60.40%, 65.85%에서 상위 다섯 후보 가운데 동일한 테스트 출력이 하나도 없었다.
- 여러 후보 간 테스트 통과율의 최대 차이는 모든 데이터셋에서 1.00에 도달하며, HumanEval 문제의 48.17%에서 이 최대 차이가 관찰된다.
- 제로 온도가 결정성을 보장하지 않는다; 다만 온도 0은 온도 1보다 더 나은 결정성을 제공하고, 온도 2는 대체로 코드가 균일하게 더 나쁘게 만들어진다.
- 더 긴 코딩 지시문은 구문적 및 구조적 유사성과 평균 정확도와 음의 상관관계를 보인다.
- 조사된 문헌에서 LLM 기반 코드 생성 연구의 21.1%–22.4%만이 실험에서 비결정성을 고려한다.
- 구조적 유사성은 후보 간 비교에서 비교적 높게 유지된다(United_Diff: CodeContests 0.46, APPS 0.52, HumanEval 0.69; Tree_Diff: CodeContests 0.60, APPS 0.68, HumanEval 0.72).

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