feat: Implement Adaptive Sampling loop (Algorithm 2) for Online Mode #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the Adaptive Sampling logic described in Algorithm 2 and Appendix B.1 of the paper.
Previously, the$\beta \ge \tau$ ) before proceeding, ensuring the model stops generation early when a confident consensus is reached.
_deepthink_onlinemethod generated the entire trace budget in a single batch after warmup. This implementation updates the logic to generate traces iteratively, checking for consensus (Changes
deepconf/wrapper.py:_deepthink_onlineto replace bulk generation with awhileloop.consensus_threshold(default0.95) andadaptive_step_size(default1to strictly follow Appendix B.1 logic) to thedeepthinkinterface.Motivation
The paper describes "Online Thinking" as a dynamic process that halts trace generation once consensus is reached to save tokens. The previous implementation lacked this iterative check, generating the full
total_budgetregardless of consensus. This change aligns the codebase with the paper's efficiency claims (e.g., Figure 6).Test Plan
Verified using the existing
examples/example_online.py.