Skip to content

Instantly share code, notes, and snippets.

@andrewkkchan
Created April 28, 2025 14:11
Show Gist options
  • Save andrewkkchan/0e7ef7aadef39471e53a3d4db830b213 to your computer and use it in GitHub Desktop.
Save andrewkkchan/0e7ef7aadef39471e53a3d4db830b213 to your computer and use it in GitHub Desktop.
dspy eval flow
from dspy.evaluate import SemanticF1
# Instantiate the metric.
metric = SemanticF1(decompositional=True)
# Produce a prediction from our `cot` module, using the `example` above as input.
pred = cot(**example.inputs())
# Compute the metric score for the prediction.
score = metric(example, pred)
print(f"Question: \t {example.question}\n")
print(f"Gold Response: \t {example.response}\n")
print(f"Predicted Response: \t {pred.response}\n")
print(f"Semantic F1 Score: {score:.2f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment