Closed wodecki closed 6 months ago
Problem solved. The reason was an incorrect script. Correct one is below:
class is_forecast(dspy.Signature):
"""Określ, czy dany tekst jest prognozą czy nie? Zwróć Y - gdy tekst jest prognozą lub N - gdy tekst nie jest prognozą."""
text = dspy.InputField()
answer = dspy.OutputField(desc="Y lub N")
class check_if_forecast(dspy.Module):
def __init__(self):
super().__init__()
self.prog = dspy.ChainOfThought(is_forecast)
def forward(self, text):
return self.prog(text=text)
program = check_if_forecast()
# Evaluation
from dspy.evaluate.evaluate import Evaluate
evaluate = Evaluate(devset=devset, num_threads=1, display_progress=True, display_table=5)
# Evaluate the program with the `answer_exact_match` metric.
metric = dspy.evaluate.answer_exact_match
# Optimization
from dspy.teleprompt import BootstrapFewShotWithRandomSearch
fewshot_optimizer = BootstrapFewShotWithRandomSearch(metric=metric, max_bootstrapped_demos=2, num_candidate_programs=8, num_threads=6)
your_dspy_program_compiled = fewshot_optimizer.compile(student = program, trainset=trainset, valset=devset)
Error:
Code to reproduce: