Planning In Natural Language Improves LLM Search For Code Generation
FreeLLM code generation search via natural language planning
About Planning In Natural Language Improves LLM Search For Code Generation
PlanSearch is a novel search algorithm that improves LLM-based code generation by searching over natural language plans rather than directly over code solutions. It first generates a diverse set of observations about the problem, then uses these observations to construct candidate plans in natural language. By exploring a more diverse set of high-level solution strategies, PlanSearch mitigates the lack of output diversity that hinders standard repeated sampling. The algorithm achieves state-of-the-art results on LiveCodeBench (pass@200 = 77.0% with Claude 3.5 Sonnet), outperforming both the no-search baseline (pass@1 = 41.4%) and standard repeated sampling (pass@200 = 60.6%). PlanSearch also shows strong results on HumanEval+ and MBPP+.
Key Features
Pros & Cons
- Significantly increases diversity of generated solutions compared to standard repeated sampling
- Provides consistent performance gains across different models and benchmarks
- Able to predict search gains based on diversity of generated ideas
- Open source and reproducible
- Requires multiple LLM inference passes for plan generation and evaluation
- Performance may be limited by the quality of the base LLM's planning ability
- May not be necessary for simple code generation tasks