[논문 리뷰] Improving Code Generation via Small Language Model-as-a-judge
본 논문은 소형 언어 모델(SLM)을 미세조정하여 코드의 정합성을 판단하게 하고, 이를 심판으로 활용해 SLM이 생성한 여러 해답 중에서 최적의 해답을 선택하는 방법을 제시하며, 대형 LLM의 비용에 비해 상당히 낮은 비용으로 경쟁력 있는 코드 생성 성능을 달성한다.
Large language models (LLMs) have shown remarkable capabilities in automated code generation. While effective for mainstream languages, they may underperform on less common or domain-specific languages, prompting companies to develop in-house code generators. While open-source models can be trained for this, only LLMs with tens of billions of parameters match the performance of commercial tools, demanding costly training and deployment. Recent work proposed supporting code generation with smaller models (SLMs) by generating multiple candidate solutions and using another SLM to select the most likely correct one. The most recent work in this area is the one by Sun et al. [29] presenting RankEF, a T5 model trained to rank code solutions using both execution-based and non-execution-based information. However, Sun et al. do not assess the T5 ranker's classification accuracy, that is, how often it misjudges correct implementations as incorrect or vice versa, leaving open questions about the reliability of LMs as code correctness judges for other tasks (e.g., automated code review). Moreover, their experiments involve relatively old models, making it unclear the extent to which such a methodology would still help companies in cheaply training their own code generators with performance comparable to those of massive LLMs. We present a study addressing these limitations. We train several state-of-the-art SLMs as code correctness judges and assess their ability to discriminate between correct and wrong implementations. We show that modern SLMs outperform RankEF, even without exploiting execution-based information. When used as code rankers, they achieve higher performance gains than RankEF and perform competitively with LLMs 5-25x larger, at a fraction of the cost.
연구 동기 및 목표
- 도메인 특화 언어(DSL)와 덜 흔한 언어를 위한 비용 효율적인 내부 코드 생성 도구의 필요성을 제고한다.
- 생성 작업과 무관하게 미세조정된 SLM이 신뢰할 수 있게 코드 정합성을 판단할 수 있는지 평가한다.
- SLMs-심판으로서 여러 후보 해답 중에서 선택해 코드 생성 성능을 향상시킬 수 있는지 평가한다.
- 성능 및 배포 비용 측면에서 SLM 기반 접근법을 RankEF 및 대형 LLM 베이스라인과 비교한다.
제안 방법
- 네 가지 최첨단 SLM(Qwen2.5 Coder 0.5B/3B, Gemma-3 4B, Llama-3.2 3B)을 코드 정합성 판단기로 미세조정하고 GPT-4.1-mini 및 RankEF과 비교한다.
- 테스트 실행을 통해 올바른지/잘못된지 라벨이 부여된 후보 구현을 포함하는 Java HumanEval/MBPP(Java)와 CoderEval 벤치마크의 722개 코드 생성 작업에서 학습 데이터를 구성한다.
- 다섯 개의 코드 생성기로부터 작업당 10개의 후보 해답을 생성해 판단을 위한 작업당 50개의 후보를 만든다.
- 무지도, 소수샘플, 미세조정(실행 피드백 여부 포함) 등 네 가지 설정으로 심판을 학습하고, 테스트 결과에 대해 F1 및 Cohen’s Kappa로 평가한다.
- 최상위 성능의 SLM을 심판으로 사용해 SLM이 생성한 후보 풀에서 최적 해답을 선택하고 RankEF, 무작위 및 로그 가능도 baselines와 비교한다.
- 소형 모델과 대형 LLM 간 추론 하드웨어 요구사항을 비교하여 비용/지연 시간을 분석한다.
실험 결과
연구 질문
- RQ1RQ1: 소형 언어 모델을 효과적으로 코드 정합성 판단으로 미세조정할 수 있으며, GPT-4.1-mini 및 RankEF와 비교해 성능이 어떠한가?
- RQ2RQ2: SLM을 심판으로 사용해 SLM 생성기가 생성한 여러 후보 중에서 선택할 때 코드 생성 성능이 향상되며, 정확도와 비용 측면에서 대형 LLM과 비교해 어떠한가?
주요 결과
- SLMs는 코드 정합성에 대한 제로샷 심판으로 작동할 수 없지만, 미세조정이 판단 정확도를 크게 향상시킨다.
- 미세조정된 SLM은 실제 정답과의 중간 정도의 일치를 달성(Cohen’s Kappa 0.45~0.57)하고, 여러 설정에서 RankEF를 능가한다.
- SLMs-as-judges can yield higher code generation performance than RankEF in four of five benchmarks when selecting among multiple candidates.
- 여러 SLM 심판을 사용해 후보를 순위화하면 배치 비용의 일부로 5~25배 큰 LLM과 비슷한 성능을 달성한다.
- 소형 모델로 구성된 생성기와 심판을 실행하는 하드웨어/추론 비용은 대략 1k 수준으로, 약 30B LLM의 ~17k에 비해 현저히 저렴하다.
- 본 연구는 재현을 위한 공개 코드와 데이터를 제공한다.
이 논문 읽기
누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.
누빈트에서 이 논문 읽기이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.