-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RAG.forward() missing 1 required positional argument: 'question' #1175
Comments
Hi! I think you need to explicitly pass question, i.e. qa = RAG()
answer = qa(question=“xxx?”).answer Does this work for your case? |
The RAG itself works: What does not work is compiling the module:
Any idea why?
I can't figure out what the issue is... |
Hey @jeremierostan ! Do pass keyword arguments, like @mlederbauer said. |
Hi, yes, I have it here and it was already working:
What is not working is the compiling:
|
Passing keyword arguments means: Do not write Instead, write Apply this in every call to a module. I hope this helps. |
Hi, I had the same issue and the solution is to specify input_keys during loading the data, e.g. |
Hi,
qa = RAG() pred = qa("xxx?") print(f"Predicted Answer: {pred.answer}")
works with the following, but compiling does not. Can anyone help?
from dspy.datasets import DataLoader dl = DataLoader() JR_qa = dl.from_csv("/content/ai_integration_qa_no_headers.csv") splits = dl.train_test_split(JR_qa, train_size=15) #
dataset` is a List of dspy.Exampletrain_dataset = splits['train']
test_dataset = splits['test']
trainset = [x.with_inputs('question') for x in train_dataset]
devset = [x.with_inputs('question') for x in test_dataset]
class GenerateAnswer(dspy.Signature):
"""Answer questions with short factoid answers."""
class RAG(dspy.Module):
def init(self, num_passages=3):
super().init()
from dspy.teleprompt import BootstrapFewShot
Validation logic: check that the predicted answer is correct.
Also check that the retrieved context does actually contain that answer.
def validate_context_and_answer(example, pred, trace=None):
answer_EM = dspy.evaluate.answer_exact_match(example, pred)
answer_PM = dspy.evaluate.answer_passage_match(example, pred)
return answer_EM and answer_PM
Set up a basic teleprompter, which will compile our RAG program.
teleprompter = BootstrapFewShot(metric=validate_context_and_answer)
Compile!
compiled_rag = teleprompter.compile(RAG(), trainset=trainset)
`
——>
TypeError Traceback (most recent call last)
in <cell line: 14>()
12
13 # Compile!
---> 14 compiled_rag = teleprompter.compile(RAG(), trainset=trainset)
4 frames
/usr/local/lib/python3.10/dist-packages/dspy/primitives/program.py in call(self, *args, **kwargs)
24
25 def call(self, *args, **kwargs):
---> 26 return self.forward(*args, **kwargs)
27
28 def named_predictors(self):
TypeError: RAG.forward() missing 1 required positional argument: 'question'
The text was updated successfully, but these errors were encountered: