Skip to content

Support predicted output in DSPy #8247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025

Conversation

chenmoneygithub
Copy link
Collaborator

Support the predicted output feature: https://platform.openai.com/docs/guides/predicted-outputs. The implementation is based on litellm's predicted output: https://github.com/chenmoneygithub/dspy

To avoid the edge case that user input field has prediction, I am adding a check on the format of prediction, and only when it's a valid predicted output format, I am piping it to the LM call kwargs.

@chenmoneygithub chenmoneygithub requested a review from okhat May 20, 2025 19:14
@@ -108,6 +108,17 @@ def _forward_preprocess(self, **kwargs):
if (temperature is None or temperature <= 0.15) and num_generations > 1:
config["temperature"] = 0.7

if "prediction" in kwargs:
if (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to merge for now but:

  1. Should we just check (or maybe also check?) whether prediction is a key in the signature?

  2. I suppose the cleanest way for this would have been to make it a new type and handle it in adapters 😅 But this would start to feel like too many types...

@okhat okhat merged commit 2ac7756 into stanfordnlp:main May 20, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants