Skip to content

Backtrack handler not supporting ChainOfThought (Or Predict) #7957

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

Open
jnakhle-sabis opened this issue Mar 13, 2025 · 0 comments
Open

Backtrack handler not supporting ChainOfThought (Or Predict) #7957

jnakhle-sabis opened this issue Mar 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jnakhle-sabis
Copy link

What happened?

When I try executing the provided code, I keep getting this error:

ERROR dspy.utils.parallelizer: Error for Example({'question': "Question here", 'output': '1'}) (input_keys={'question'}): 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/dspy/utils/parallelizer.py", line 52, in safe_func
return user_function(item)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/dspy/evaluate/evaluate.py", line 154, in process_item
score = metric(example, prediction)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

Steps to reproduce

dff=pd.DataFrame(df).sample(10)

dspy.settings.configure(lm=lm,trace=[])

import random
import ast
import dspy

trainset=dff[:7]
testset=dff[7:]

trainset = [dspy.Example(question=trainset.loc[index, 'Student_answer'], output=trainset.loc[index, 'Grade']).with_inputs("question") for index in trainset.index]
testset = [dspy.Example(question=testset.loc[index, 'Student_answer'], output=testset.loc[index, 'Grade']).with_inputs("question") for index in testset.index]

class ReferenceAnswer(dspy.Signature):

question=dspy.InputField()
output=dspy.OutputField()

class PredictModel(dspy.Module):
def init(self):
self.predict=dspy.ChainOfThought(ReferenceAnswer)
def forward(self,question):
return self.predict( question=question)

suzan=PredictModel()

from dspy.evaluate import Evaluate
from dspy.evaluate.metrics import answer_exact_match

evaluate_program=Evaluate(devset=testset, metrics=answer_exact_match, provide_traceback=True)

evaluate_program(suzan)

DSPy version

dspy-2.6.11

@jnakhle-sabis jnakhle-sabis added the bug Something isn't working label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant