Code better with LLMs by picking smarter examples, not bigger models
This paper introduces methods to optimize code generation by selecting effective few-shot examples in prompts. The research demonstrates that carefully chosen examples significantly improve LLM's coding abilities without modifying the model architecture or training process.
-----
https://arxiv.org/abs/2412.02906
π€ Original Problem:
LLMs show impressive code generation capabilities, but prompt-level optimizations remain unexplored. Current techniques use predefined prompt templates with minimal modifications.
-----
π§ Solution in this Paper:
β The paper proposes two methods for selecting optimal few-shot examples: CODEEXEMPLAR-FREE and CODEEXEMPLAR-BASE.
β CODEEXEMPLAR-FREE picks examples based on perplexity metrics without requiring training data.
β CODEEXEMPLAR-BASE uses a neural network trained on bootstrapped data to select examples.
β Both methods support arbitrary token cost constraints and work without accessing model weights.
-----
π‘ Key Insights:
β Choice of few-shot examples significantly impacts coding performance across different LLMs
β Complex input examples tend to be more informative than simple edge cases
β Performance saturates after 6 examples, showing diminishing returns
-----
π Results:
β Both methods improved CODELLAMA's Pass@1 performance by ~5.7% on HumanEval+ benchmark
β CODEEXEMPLAR-BASE showed better generalization across different prompts
β Achieved significant improvements while maintaining fixed token constraints










