[WIP] feat: add reasoning flag in dspy.LM
#7994
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
reasoning_model
parameter indspy.LM
to indicate if the LM is a reasoning model.lm
is set withreasoning_model == True
, we use plain predictor instead of the CoT prompted predictor.Explanation
This PR addresses how reasoning models, a new category of models capable of effective self-CoT, are changing the ecosystem. Many best practice guides recommend removing CoT prompts to reduce token usage, and even recommend avoiding them in OpenAI's documentation.
Since the
ChainOfThought
module is a core component of dspy, completely refactoring all clients would cause significant breaking changes. Instead, I've implemented two separate predictors with routing based on thelm
type.This PR should be considered primarily as a proposal. Given how rapidly the ecosystem is evolving, self-CoT models may soon become the standard, potentially making the CoT module obsolete. I recognize that the current solution isn't ideal, but it offers a path forward.