An Exploratory Study of Bayesian Prompt Optimization for Test-Driven Code Generation with Large Language Models

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Tomar, Shlok, Deshwal, Aryan, Villalovoz, Ethan, Fazzini, Mattia, Cai, Haipeng, Doppa, Janardhan Rao
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866909966859763712
author Tomar, Shlok
Deshwal, Aryan
Villalovoz, Ethan
Fazzini, Mattia
Cai, Haipeng
Doppa, Janardhan Rao
author_facet Tomar, Shlok
Deshwal, Aryan
Villalovoz, Ethan
Fazzini, Mattia
Cai, Haipeng
Doppa, Janardhan Rao
contents We consider the task of generating functionally correct code using large language models (LLMs). The correctness of generated code is influenced by the prompt used to query the given base LLM. We formulate the problem of finding the appropriate prompt as combinatorial search process and propose a Bayesian optimization (BO) approach referred to as {\em BO for Code GENeration (BODE-GEN)}. BODE-GEN performs an adaptive data-driven search over prompts guided by training data in the form of prompts tried and the functional accuracy of the generated code over a set of given test cases. The key insight is to perform BO in continuous embedding space by using an auxiliary LLM to bridge the gap between discrete prompt space and continuous embedding space. We leverage two synergistic ideas, namely, random projections and dimensionality scaled priors, to build effective Gaussian process based surrogate models over the high-dimensional embedding space. Our experiments on the HumanEval+ benchmark using multiple base LLMs show that BODE-GEN can improve performance in terms of code generation accuracy compared to fixed prompts and manual prompt engineering. Additionally, we demonstrate that BODE-GEN is sample-efficient, requiring relatively few iterations of BO to demonstrate improvements in code accuracy.
format Preprint
id arxiv_https___arxiv_org_abs_2512_15076
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle An Exploratory Study of Bayesian Prompt Optimization for Test-Driven Code Generation with Large Language Models
Tomar, Shlok
Deshwal, Aryan
Villalovoz, Ethan
Fazzini, Mattia
Cai, Haipeng
Doppa, Janardhan Rao
Software Engineering
We consider the task of generating functionally correct code using large language models (LLMs). The correctness of generated code is influenced by the prompt used to query the given base LLM. We formulate the problem of finding the appropriate prompt as combinatorial search process and propose a Bayesian optimization (BO) approach referred to as {\em BO for Code GENeration (BODE-GEN)}. BODE-GEN performs an adaptive data-driven search over prompts guided by training data in the form of prompts tried and the functional accuracy of the generated code over a set of given test cases. The key insight is to perform BO in continuous embedding space by using an auxiliary LLM to bridge the gap between discrete prompt space and continuous embedding space. We leverage two synergistic ideas, namely, random projections and dimensionality scaled priors, to build effective Gaussian process based surrogate models over the high-dimensional embedding space. Our experiments on the HumanEval+ benchmark using multiple base LLMs show that BODE-GEN can improve performance in terms of code generation accuracy compared to fixed prompts and manual prompt engineering. Additionally, we demonstrate that BODE-GEN is sample-efficient, requiring relatively few iterations of BO to demonstrate improvements in code accuracy.
title An Exploratory Study of Bayesian Prompt Optimization for Test-Driven Code Generation with Large Language Models
topic Software Engineering
url https://arxiv.org/abs/2512.15076