Skip to content

Commit

Permalink
Update signature_opt_bayesian.py
Browse files Browse the repository at this point in the history
  • Loading branch information
okhat authored Jan 22, 2024
1 parent a02f3e3 commit 7aa6ca4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dspy/teleprompt/signature_opt_bayesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ class BasicGenerateInstruction(Signature):
proposed_prefix_for_output_field = dspy.OutputField(desc="The string at the end of the prompt, which will help the model start solving the task")

class BayesianSignatureOptimizer(Teleprompter):
def __init__(self, prompt_model=None, task_model=None, n=10, metric=None, init_temperature=1.0, verbose=False, track_stats=False):
def __init__(self, prompt_model=None, task_model=None, teacher_settings={}, n=10, metric=None, init_temperature=1.0, verbose=False, track_stats=False):
self.n = n
self.metric = metric
self.init_temperature = init_temperature
self.prompt_model = prompt_model
self.task_model = task_model
self.verbose = verbose
self.track_stats = track_stats
self.teacher_settings = teacher_settings

def _print_full_program(self, program):
for i,predictor in enumerate(program.predictors()):
Expand Down Expand Up @@ -119,7 +120,7 @@ def compile(self, student, *, devset, optuna_trials_num, max_bootstrapped_demos,
rng = random.Random(seed)
shuffled_devset = devset[:] # Create a copy of devset
rng.shuffle(shuffled_devset) # Shuffle the copy
tp = BootstrapFewShot(metric = self.metric, max_bootstrapped_demos=max_bootstrapped_demos, max_labeled_demos=max_labeled_demos)
tp = BootstrapFewShot(metric = self.metric, max_bootstrapped_demos=max_bootstrapped_demos, max_labeled_demos=max_labeled_demos, teacher_settings=self.teacher_settings)
candidate_program = tp.compile(student=module.deepcopy(), trainset=shuffled_devset)

# Store the candidate demos
Expand Down Expand Up @@ -229,4 +230,4 @@ def objective(trial):
if best_program is not None and self.track_stats:
best_program.trial_logs = trial_logs

return best_program
return best_program

0 comments on commit 7aa6ca4

Please sign in to comment.