Skip to content

Instantly share code, notes, and snippets.

@heathermiller
Created January 11, 2024 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heathermiller/bf7e7b9c5918247b0802fd8478ed9cdc to your computer and use it in GitHub Desktop.
Save heathermiller/bf7e7b9c5918247b0802fd8478ed9cdc to your computer and use it in GitHub Desktop.
DSPy
class BasicQA(dspy.Signature):
"""Answer questions with short factoid answers."""
question = dspy.InputField()
answer = dspy.OutputField(desc="often between 1 and 5 words")
# Define the predictor.
generate_answer = dspy.Predict(BasicQA)
# Call the predictor on a particular input.
pred = generate_answer(question=dev_example.question)
# Or use the Short Hand
qa = dspy.Predict("question -> answer")
qa(question="Where is Guaraní spoken?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment