COMPAS: Difficulty-Aware Joint Search for Optimizing Code Generation
COMPAS is a difficulty-aware framework that optimizes code generation by jointly searching for the best model, prompt, and decoding settings for specific task difficulty groups, achieving significant improvements in both pass rates and cost efficiency on benchmarks like LiveCodeBench and SWE-bench.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to bake the perfect cake, but you have a magical oven that can talk to you. In the world of computer science, this "oven" is a Large Language Model (LLM), a super-smart AI that can write computer code just like a human programmer. To get the best cake, you need to choose three things: which oven to use (the model), what recipe to give it (the prompt), and how to set the temperature and timer (decoding settings). For a long time, scientists tried to find the one perfect recipe and oven setting that would work for every single cake, from a simple cupcake to a complex wedding tier. But they kept running into a problem: a setting that makes a cupcake fluffy might burn a wedding cake, and a setting that saves money on flour might ruin the taste. The big question was: how do we find the perfect combination for each specific task without spending a fortune or years of time trying every possibility?
Enter COMPAS, a new method that acts like a brilliant, budget-conscious head chef. Instead of guessing one rule for everyone, COMPAS realizes that different tasks have different "difficulty levels." It suggests that we should group our tasks—like sorting problems into "Easy," "Medium," and "Hard"—and then find a unique, perfect recipe for each group. The researchers found that prompts (the instructions) and decoding settings (the oven dials) work best when tweaked together, not separately, and that what works for one AI model might fail for another. By using a smart two-step process—first picking the right oven for the job, then fine-tuning the recipe and dials together—they built a "menu" of options for each difficulty level. When a new task arrives, COMPAS instantly checks its difficulty, picks the perfect pre-made menu for that group, and gets to work.
In their experiments, this approach was a huge success. On a test set of coding problems called LiveCodeBench, COMPAS managed to get the right answer 52.8% of the time, beating the previous best method which only reached 45.9%. Even better, it did this while spending significantly less money: the cost dropped from $36.57 down to just $4.92. They also tested it on a more complex challenge involving fixing bugs in entire software projects (SWE-bench), where it solved 76.0% of the tasks, again outperforming the best existing methods.
The secret sauce of COMPAS is its "difficulty-aware" strategy. The researchers discovered three key things through their experiments. First, the instructions and the oven settings interact; changing both together yields better results than changing them one by one. Second, a tweak that helps one AI model might actually hurt another, so you have to pick your model carefully before you start tweaking. Third, and most importantly, the "best" setting for an easy problem is totally different from the "best" setting for a hard one. A global, one-size-fits-all approach just doesn't work.
To solve this, COMPAS uses a two-phase plan. In the offline phase (the preparation stage), it splits all the training tasks into groups based on how hard they are. It then runs a fast, cheap test to pick the best AI model for each group. Once the model is chosen, it goes into a "joint search" mode, where it uses a smart feedback loop to simultaneously adjust the prompt and the decoding settings. It doesn't just try random combinations; it learns from its mistakes and successes, building a "quality-cost front"—essentially a list of the best possible trade-offs between getting a good result and saving money—for each difficulty group.
In the online phase (the real-time cooking), when a new task comes in, COMPAS doesn't waste time searching. It simply looks at the task's difficulty label, finds the matching group, and picks the best configuration from that group's pre-built menu. It's like having a library of perfectly tuned recipes ready to go, so you never have to start from scratch.
The paper shows that this method is robust. Even when they changed the random seeds (like shuffling the deck of cards differently) or tested it on different types of AI models, COMPAS consistently outperformed other methods. It also proved that breaking tasks down by difficulty is crucial; if you ignore the difficulty levels and try to use one setting for everything, your results drop significantly. While the method currently works best when the AI models are from the same "family," the researchers suggest that this approach could be expanded in the future. For now, COMPAS stands as a powerful demonstration that being smart about how you search for the right settings is just as important as the settings themselves.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.