B4: 타당한 테스트를 통한 타당한 코드 솔루션의 최적 평가 방향
B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Tests
September 13, 2024
저자: Mouxiang Chen, Zhongxin Liu, He Tao, Yusu Hong, David Lo, Xin Xia, Jianling Sun
cs.AI
초록
다수의 생성된 코드 솔루션 중 최상의 솔루션을 선택하는 것은 코드 생성에서 중요한 작업이며, 신뢰할 수 있는 유효성 검사기(예: 개발자가 작성한 테스트 케이스)를 사용하여 이를 달성할 수 있습니다. 신뢰할 만한 테스트 케이스가 항상 제공되지는 않고 실제로 구축하기 비용이 들기 때문에, 연구자들은 코드 솔루션을 평가하기 위해 자동으로 테스트 케이스를 생성하는 것을 제안합니다. 그러나 코드 솔루션과 테스트 케이스가 모두 타당하고 신뢰할 수 없는 경우, 최상의 솔루션을 선택하는 것은 어려워집니다. 이 문제를 해결하기 위해 일부 휴리스틱 전략이 제안되었지만, 강력한 이론적 보장이 부족하며 최적 선택 전략이 존재하는지 여전히 미해결된 문제입니다.
우리의 연구는 두 가지 측면에서 기여합니다. 첫째, 베이지안 프레임워크 내에서 관찰된 통과 상태의 사후 확률을 기반으로 최적 선택 전략을 정의할 수 있다는 것을 보여줍니다. 그런 다음, 최상의 솔루션을 식별하는 문제는 정수 프로그래밍 문제로 구성됩니다. 둘째, 이 최적(그러나 계산할 수 없는) 전략을 근사하는 효율적인 방법을 제안하며, 이 근사화 오차는 사전 지식의 정확성에 의해 제한됩니다. 그런 다음 효과적인 사전 지식을 통합하여 코드 생성 작업을 맞춤화합니다. 이론적 및 경험적 연구 모두, 기존의 휴리스틱이 타당한 테스트 케이스로 최상의 솔루션을 선택하는 데 제한이 있음을 확인합니다. 우리가 제안하는 근사 최적 전략 B4는 LLM(대형 언어 모델)이 생성한 코드 솔루션을 LLM이 생성한 테스트로 선택하는 데 가장 강력한 휴리스틱보다 최대 50%의 상대적 성능 향상 및 가장 어려운 시나리오에서 가장 강력한 휴리스틱 대비 246%의 상대적 성능 향상을 달성하며, 이 코드는 https://github.com/ZJU-CTAG/B4에서 공개적으로 이용 가능합니다.
English
Selecting the best code solution from multiple generated ones is an essential
task in code generation, which can be achieved by using some reliable
validators (e.g., developer-written test cases) for assistance. Since reliable
test cases are not always available and can be expensive to build in practice,
researchers propose to automatically generate test cases to assess code
solutions. However, when both code solutions and test cases are plausible and
not reliable, selecting the best solution becomes challenging. Although some
heuristic strategies have been proposed to tackle this problem, they lack a
strong theoretical guarantee and it is still an open question whether an
optimal selection strategy exists. Our work contributes in two ways. First, we
show that within a Bayesian framework, the optimal selection strategy can be
defined based on the posterior probability of the observed passing states
between solutions and tests. The problem of identifying the best solution is
then framed as an integer programming problem. Second, we propose an efficient
approach for approximating this optimal (yet uncomputable) strategy, where the
approximation error is bounded by the correctness of prior knowledge. We then
incorporate effective prior knowledge to tailor code generation tasks. Both
theoretical and empirical studies confirm that existing heuristics are limited
in selecting the best solutions with plausible test cases. Our proposed
approximated optimal strategy B4 significantly surpasses existing heuristics in
selecting code solutions generated by large language models (LLMs) with
LLM-generated tests, achieving a relative performance improvement by up to 50%
over the strongest heuristic and 246% over the random selection in the most
challenging scenarios. Our code is publicly available at
https://github.com/ZJU-CTAG/B4.Summary
AI-Generated Summary