Files
myWiki/concepts/thompson-sampling-code-search.md
2026-06-01 10:46:01 +08:00

36 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "Thompson Sampling Code Search"
created: 2026-05-29
updated: 2026-05-29
type: concept
tags: ["search", "code-synthesis", "thompson-sampling", "optimization"]
sources: ["https://arxiv.org/abs/2603.03329"]
---
# Thompson Sampling Code Search
**Thompson Sampling Code Search** 是 [[autoharness|AutoHarness]] 中用于探索代码 harness 空间的搜索算法:维护多个代码假设的树结构,用 Thompson sampling (Tang et al., 2024) 选择下一个精炼节点。
## 算法
1. **树结构**每个节点是一个代码假设harness 的某个版本)
2. **Heuristic value**:每个节点的平均合法动作率
3. **选择**Thompson sampling 在探索(尝试不同的代码逻辑)和利用(精炼已有进展的 harness之间平衡
4. **精炼**:被选中的节点由 RefinerLLM基于环境 Critic 的 feedback 生成改进版本
## 为什么是 Thompson Sampling
- **在线学习**:每一步都需要决策下一个尝试方向
- **不确定性量化**Thompson sampling 自然处理节点价值估计的不确定性
- **平衡探索-利用**:通过后验采样自动平衡——高不确定性的节点以正概率被选中
## 在 Harness 合成中的作用
Thompson sampling 决定了在每次迭代中"精炼哪个代码版本"——这直接影响了搜索效率。平均只需 14.5 次迭代即可达到 100% 合法率。
## 相关
- [[autoharness]] — 使用此搜索的方法
- [[iterative-code-refinement]] — 每步的具体操作
- [[lou-autoharness-2026]] — 原始论文