LLM 코드 생성과 검증을 연결하기 위해 속성 기반 테스팅 활용
Use Property-Based Testing to Bridge LLM Code Generation and Validation
June 23, 2025
저자: Lehan He, Zeren Chen, Zhe Zhang, Jing Shao, Xiang Gao, Lu Sheng
cs.AI
초록
대형 언어 모델(LLMs)은 코드 생성에 탁월한 능력을 보이지만, 특히 복잡한 프로그래밍 작업에서 출력물의 기능적 정확성을 보장하는 것은 지속적인 과제로 남아 있습니다. 전통적인 테스트 주도 개발(TDD)은 코드 개선을 위한 방법을 제공하지만, LLMs와의 효율성은 고품질 테스트 케이스의 부족 또는 자동화된 테스트 생성의 함정, 예를 들어 편향된 테스트나 부정확한 출력 예측으로 인해 수정 과정을 잘못 이끌 수 있는 문제로 인해 종종 제한됩니다. 본 논문은 특정 입력-출력 예제에 의존하는 대신, 속성 기반 테스트(PBT)를 활용하여 고수준 프로그램 속성이나 불변식을 검증하는 새로운 프레임워크인 Property-Generated Solver를 소개합니다. 이러한 속성은 종종 철저한 테스트 오라클을 직접 예측하는 것보다 정의하고 검증하기가 더 간단하며, 테스트가 검증하려는 코드와 동일한 결함을 공유할 수 있는 "자기기만의 순환"을 깨뜨립니다. Property-Generated Solver는 두 개의 협력적인 LLM 기반 에이전트를 사용합니다: 코드 생성과 반복적 개선에 전념하는 Generator와 PBT 생명주기를 관리하고 속성 위반으로부터 의미적으로 풍부한 피드백을 형성하는 Tester입니다. 그 결과로 생성된 포괄적이고 실행 가능한 피드백은 Generator의 개선 작업을 안내합니다. 이 반복적이고 폐쇄형 패러다임 내에서 PBT를 핵심 검증 엔진으로 설정함으로써, Property-Generated Solver는 LLMs가 더 정확하고 일반화 가능한 코드를 생성하도록 이끄는 강력한 메커니즘을 제공합니다. 여러 코드 생성 벤치마크에서의 광범위한 실험 결과는 Property-Generated Solver가 기존 TDD 방법 대비 23.1%에서 37.3%에 이르는 상대적 개선을 달성함을 보여줍니다.
English
Large Language Models (LLMs) excel at code generation, but ensuring their
outputs to be functionally correct, especially in complex programming tasks, is
a persistent challenge. While traditional Test-Driven Development (TDD) offers
a path for code refinement, its efficacy with LLMs is often undermined by the
scarcity of high-quality test cases or the pitfalls of automated test
generation, including biased tests or inaccurate output predictions that can
misdirect the correction process. This paper introduces Property-Generated
Solver, a novel framework that leverages Property-Based Testing (PBT) to
validate high-level program properties or invariants, instead of relying on
specific input-output examples. These properties are often simpler to define
and verify than directly predicting exhaustive test oracles, breaking the
"cycle of self-deception" where tests might share flaws with the code they are
meant to validate. Property-Generated Solver employs two collaborative
LLM-based agents: a Generator dedicated to code generation and iterative
refinement, and a Tester that manages the PBT life-cycle and formulate
semantically rich feedback from property violations. The resulting
comprehensive and actionable feedback then guides the Generator in its
refinement efforts. By establishing PBT as the core validation engine within
this iterative, closed-loop paradigm, Property-Generated Solver provides a
robust mechanism for steering LLMs towards more correct and generalizable code.
Extensive experimental results on multiple code generation benchmarks
demonstrate that Property-Generated Solver achieves substantial pass@1
improvements, ranging from 23.1% to 37.3% relative gains over established TDD
methods.