@@ -127,6 +127,15 @@ def compile(
127127 if self .max_errors is not None
128128 else dspy .settings .max_errors
129129 )
130+
131+ # Update max demos if specified
132+ initial_max_bootstrapped_demos = self .max_bootstrapped_demos
133+ if max_bootstrapped_demos is not None :
134+ self .max_bootstrapped_demos = max_bootstrapped_demos
135+ initial_max_labeled_demos = self .max_labeled_demos
136+ if max_labeled_demos is not None :
137+ self .max_labeled_demos = max_labeled_demos
138+
130139 zeroshot_opt = (self .max_bootstrapped_demos == 0 ) and (self .max_labeled_demos == 0 )
131140
132141 # If auto is None, and num_trials is not provided (but num_candidates is), raise an error that suggests a good num_trials value
@@ -149,11 +158,6 @@ def compile(
149158 seed = seed or self .seed
150159 self ._set_random_seeds (seed )
151160
152- # Update max demos if specified
153- if max_bootstrapped_demos is not None :
154- self .max_bootstrapped_demos = max_bootstrapped_demos
155- if max_labeled_demos is not None :
156- self .max_labeled_demos = max_labeled_demos
157161
158162 # Set training & validation sets
159163 trainset , valset = self ._set_and_validate_datasets (trainset , valset )
@@ -199,7 +203,10 @@ def compile(
199203
200204 # If zero-shot, discard demos
201205 if zeroshot_opt :
206+ logger .info ("ZEROSHOT IS TRUE" )
202207 demo_candidates = None
208+ else :
209+ logger .info ("ZEROSHOT IS FALSE" )
203210
204211 with dspy .context (lm = self .task_model ):
205212 # Step 3: Find optimal prompt parameters
@@ -216,6 +223,10 @@ def compile(
216223 seed ,
217224 )
218225
226+ # Reset max demos
227+ self .max_bootstrapped_demos = initial_max_bootstrapped_demos
228+ self .max_labeled_demos = initial_max_labeled_demos
229+
219230 return best_program
220231
221232 def _set_random_seeds (self , seed ):
@@ -447,6 +458,7 @@ def _optimize_prompt_parameters(
447458 logger .info (
448459 "We will evaluate the program over a series of trials with different combinations of instructions and few-shot examples to find the optimal combination using Bayesian Optimization.\n "
449460 )
461+ logger .info (f"INSIDE OPTIMIZE PROMPT PARAMS: { demo_candidates } " )
450462
451463 # Compute the adjusted total trials that we will run (including full evals)
452464 run_additional_full_eval_at_end = 1 if num_trials % minibatch_full_eval_steps != 0 else 0
0 commit comments