Search papers, labs, and topics across Lattice.
This paper introduces Prompt Codebooks (PCO), a compositional prompt optimization framework that learns a discrete vocabulary of reusable instruction units ("instincts") for LLMs. PCO uses an LLM-based encoder to route inputs to relevant instincts, which are then composed into a prompt by a generator, and trained via language-valued gradients from a critic. Experiments on Qwen3-8B and LLaMA-3.1-8B show that PCO outperforms existing prompt optimization methods, achieving up to +30.36 points improvement over zero-shot and reducing prompt length significantly.
Forget monolithic prompts – Prompt Codebooks unlock reusable "instincts" that can be composed on the fly, boosting LLM performance while slashing prompt length by up to 14x.
Automatic prompt optimization (APO) has driven significant gains in LLM-based agentic workflows. However, existing methods treat each task's prompt as a monolithic, instance-blind string optimized through global edits, producing brittle updates and preventing the reuse of learned sub-behaviors. We propose Prompt Codebooks (PCO), a novel compositional prompt optimization framework that recasts APO as discrete learning over a finite vocabulary of natural-language instincts - atomic, reusable instruction units. PCO organizes prompt-construction knowledge in a discrete codebook and routes each input to a small subset of entries via an LLM-based encoder; a generator composes them into a prompt for the frozen target model; a critic emits a structured verdict that decomposes by attribution into per-variable textual gradients, jointly training the encoder, generator, and codebook under a language-valued min-max objective. The resulting routing is per-instance: different inputs in the same task receive different instinct compositions, a regime structurally inexpressible under instance-blind methods. Across six benchmarks on Qwen3-8B and LLaMA-3.1-8B, PCO improves over zero-shot by up to +30.36 points, surpasses the strongest prior baseline (GEPA) by +3.34 on HotpotQA and +1.11 in aggregate, and reduces deployed prompt length by up to 14.1x versus MIPROv2 and 3.0x versus GEPA using only K=16 instincts.