chapter five
5 Resampler: Reliability through repeated sampling
This chapter covers
- Understanding how randomness in generative models causes failures at code–AI interfaces
- Using the Resampler pattern to constrain stochasticity for reliability and exploit it for creative exploration
- Practical uses of resampling for reliable reasoning, style enforcement, and discovering chemical reaction chains
What do you do when you ask an AI chatbot to solve a problem and it does not give you the answer you expect? Sure, you can clarify the task or give the chatbot additional instructions, but there is an easier way: just ask the same question again! Most AI models, especially generative ones, rely heavily on probabilistic sampling. As a result, they rarely give exactly the same output when asked the same question twice, unless the question is very simple or you are explicitly trying to eliminate all randomness from their operation.