@@ -198,13 +198,18 @@ func runBaseline(ctx context.Context, task Task, client providers.Client) Benchm
198198
199199// RLMOptions holds configuration for RLM runs.
200200type RLMOptions struct {
201- LogDir string
202- Verbose bool
203- Streaming bool
204- Pool * repl.REPLPool
205- Compression bool
206- VerbatimIters int
207- Backend string
201+ LogDir string
202+ Verbose bool
203+ Streaming bool
204+ Pool * repl.REPLPool
205+ Compression bool
206+ VerbatimIters int
207+ Backend string
208+ Adaptive bool
209+ BaseIters int
210+ MaxIters int
211+ EarlyTerminate bool
212+ RecursionDepth int
208213}
209214
210215// ModelClient is an interface for clients that expose their model name.
@@ -240,7 +245,7 @@ func runRLM(ctx context.Context, task Task, client providers.Client, opts RLMOpt
240245
241246 // Build RLM options
242247 rlmOpts := []rlm.Option {
243- rlm .WithMaxIterations (30 ),
248+ rlm .WithMaxIterations (opts . MaxIters ),
244249 rlm .WithVerbose (opts .Verbose ),
245250 rlm .WithLogger (log ),
246251 }
@@ -257,6 +262,21 @@ func runRLM(ctx context.Context, task Task, client providers.Client, opts RLMOpt
257262 rlmOpts = append (rlmOpts , rlm .WithHistoryCompression (opts .VerbatimIters , 500 ))
258263 }
259264
265+ if opts .Adaptive {
266+ rlmOpts = append (rlmOpts , rlm .WithAdaptiveIterationConfig (rlm.AdaptiveIterationConfig {
267+ Enabled : true ,
268+ BaseIterations : opts .BaseIters ,
269+ MaxIterations : opts .MaxIters ,
270+ ContextScaleFactor : 100000 , // 100KB per additional iteration
271+ EnableEarlyTermination : opts .EarlyTerminate ,
272+ ConfidenceThreshold : 1 ,
273+ }))
274+ }
275+
276+ if opts .RecursionDepth > 0 {
277+ rlmOpts = append (rlmOpts , rlm .WithMaxRecursionDepth (opts .RecursionDepth ))
278+ }
279+
260280 r := rlm .New (client , client , rlmOpts ... )
261281
262282 start := time .Now ()
@@ -370,6 +390,11 @@ func main() {
370390 verbatimIters = flag .Int ("verbatim-iters" , 3 , "Keep last N iterations verbatim (requires -compression)" )
371391 enablePrefixCaching = flag .Bool ("prefix-caching" , true , "Enable Anthropic prefix caching" )
372392 enableAsync = flag .Bool ("async" , false , "Use async sub-LLM queries where possible" )
393+ enableAdaptive = flag .Bool ("adaptive" , false , "Enable adaptive iteration strategy" )
394+ baseIters = flag .Int ("base-iters" , 10 , "Base iterations for adaptive mode" )
395+ maxIters = flag .Int ("max-iters" , 30 , "Maximum iterations (used in both adaptive and fixed modes)" )
396+ enableEarlyTerm = flag .Bool ("early-termination" , true , "Enable early termination on confidence (requires -adaptive)" )
397+ recursionDepth = flag .Int ("recursion-depth" , 1 , "Max recursion depth for multi-depth RLM (0=disabled, 1=paper default)" )
373398 )
374399 flag .Parse ()
375400
@@ -410,6 +435,7 @@ func main() {
410435 fmt .Printf ("Provider: %s\n " , provider )
411436 fmt .Printf ("Model: %s\n " , * model )
412437 fmt .Printf ("Tasks: %d\n " , len (tasks ))
438+ fmt .Printf ("Max Iterations: %d\n " , * maxIters )
413439 if * enableStreaming {
414440 fmt .Println ("Streaming: enabled" )
415441 }
@@ -419,6 +445,12 @@ func main() {
419445 if * enableCompression {
420446 fmt .Printf ("History Compression: enabled (verbatim=%d)\n " , * verbatimIters )
421447 }
448+ if * enableAdaptive {
449+ fmt .Printf ("Adaptive Iteration: enabled (base=%d, max=%d, early-term=%v)\n " , * baseIters , * maxIters , * enableEarlyTerm )
450+ }
451+ if * recursionDepth > 0 {
452+ fmt .Printf ("Multi-Depth Recursion: enabled (max-depth=%d)\n " , * recursionDepth )
453+ }
422454 if * enablePrefixCaching && provider == providers .Anthropic {
423455 fmt .Println ("Prefix Caching: enabled (Anthropic)" )
424456 } else if provider == providers .Anthropic {
@@ -454,13 +486,18 @@ func main() {
454486
455487 // Build RLM options
456488 rlmOpts := RLMOptions {
457- LogDir : * logDir ,
458- Verbose : * verbose ,
459- Streaming : * enableStreaming ,
460- Pool : pool ,
461- Compression : * enableCompression ,
462- VerbatimIters : * verbatimIters ,
463- Backend : string (provider ),
489+ LogDir : * logDir ,
490+ Verbose : * verbose ,
491+ Streaming : * enableStreaming ,
492+ Pool : pool ,
493+ Compression : * enableCompression ,
494+ VerbatimIters : * verbatimIters ,
495+ Backend : string (provider ),
496+ Adaptive : * enableAdaptive ,
497+ BaseIters : * baseIters ,
498+ MaxIters : * maxIters ,
499+ EarlyTerminate : * enableEarlyTerm ,
500+ RecursionDepth : * recursionDepth ,
464501 }
465502
466503 var baselineResults []BenchmarkResult
@@ -554,6 +591,16 @@ func main() {
554591 output := map [string ]any {
555592 "model" : * model ,
556593 "prefix_caching" : * enablePrefixCaching ,
594+ "streaming" : * enableStreaming ,
595+ "pooling" : * enablePooling ,
596+ "pool_size" : * poolSize ,
597+ "compression" : * enableCompression ,
598+ "verbatim_iters" : * verbatimIters ,
599+ "adaptive" : * enableAdaptive ,
600+ "base_iters" : * baseIters ,
601+ "max_iters" : * maxIters ,
602+ "early_termination" : * enableEarlyTerm ,
603+ "recursion_depth" : * recursionDepth ,
557604 "baseline_results" : baselineResults ,
558605 "rlm_results" : rlmResults ,
559606 "baseline_summary" : baselineSummary ,
0 commit comments