-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] Issue with dspy and mlflow Deployment - TypeError: ChainOfThought.forward() takes 1 positional argument but 2 were given #8134
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
Comments
Usually this error is about passing explicit named kwargs |
Hi, Thank you for the quick response. I understand that this error is usually related to passing explicit named keyword arguments. However, I would like to clarify that in my case, I haven't manually passed any named keyword arguments. The code I am running is directly copied from the official DSPy documentation tutorial here, with only minor adjustments for my specific setup (e.g., the model name and experiment name). Since I followed the official example exactly and encountered this issue, I believe this might be an issue with how the ChainOfThought module is being used with MLflow, as shown in the tutorial. Could you please help me understand if there is something specific in the code that I might have missed, or if there is any update or fix needed in the DSPy/MLflow integration? Thanks again! |
I wanted to bring your attention to the response I received from the MLflow team regarding the issue I encountered. They clarified that the error occurred because I was directly using the raw DSPy ChainOfThought without wrapping it in a custom module. According to them, MLflow expects models to handle inputs like DSPy Modules, where inputs are passed as arguments to the forward() method, not as a dictionary. You can find the details of their response here: MLflow Issue #15546. Given this, I wanted to check with you whether this approach aligns with DSPy’s intended usage with MLflow. Would it make sense to update the official DSPy tutorial on deployment (https://dspy.ai/tutorials/deployment/#deploying-with-mlflow) to reflect this? The current example might be misleading to users, as it directly uses ChainOfThought without a custom module wrapper, which could lead to confusion. Looking forward to your thoughts on this. Thanks! |
Ah, thanks @Jammillk ! We should check this. Will discuss with @chenmoneygithub |
@Jammillk What's the Mlflow version you are using? |
What happened?
Title: Issue with
dspy
andmlflow
Deployment -TypeError: ChainOfThought.forward() takes 1 positional argument but 2 were given
Description:
Hi, I am following the official DSPy documentation to deploy a DSPy application with MLflow (as outlined in the tutorial). However, I am encountering the following issue despite following the example code almost exactly.
PS:this issue also aks mlflow:mlflow/mlflow#15546
Steps to reproduce
Steps Taken:
I used the example code directly from the DSPy documentation with minor adjustments for my setup (e.g., model name and experiment name), but I received the error below.
Code (Problematic):
Error (Exception Stack):
Other Example (Working):
I found that a different example, where a
forward()
method is explicitly defined in a custom class, works correctly. Here is the working example:Result (Working Example):
Question:
Is this a bug in the DSPy library? I followed the official tutorial exactly but am getting the above error. I noticed that explicitly defining a custom
forward()
method (as in the second example) works, but the defaultChainOfThought
seems to break withmlflow.dspy.log_model
.DSPy version
dspy version 2.6.21 mlflow, version 2.22.0
The text was updated successfully, but these errors were encountered: