Skip to content
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

Colab demo: finder.get_answers throws error #68

Closed
patil-suraj opened this issue Apr 20, 2020 · 10 comments
Closed

Colab demo: finder.get_answers throws error #68

patil-suraj opened this issue Apr 20, 2020 · 10 comments
Assignees
Labels
type:bug Something isn't working

Comments

@patil-suraj
Copy link

patil-suraj commented Apr 20, 2020

I was trying out the Bsic QA colab tutorial and the call to finder.get_answers throws following error

----> 1 prediction = finder.get_answers(question="Who is the father of Arya Stark?", top_k_retriever=10, top_k_reader=5)

1 frames
/usr/local/lib/python3.6/dist-packages/haystack/finder.py in get_answers(self, question, top_k_reader, top_k_retriever, filters)
     53 
     54         # 3) Apply reader to get granular answer(s)
---> 55         len_chars = sum([len(d.text) for d in documents])
     56         logger.info(f"Reader is looking for detailed answer in {len_chars} chars ...")
     57         results = self.reader.predict(question=question,

/usr/local/lib/python3.6/dist-packages/haystack/finder.py in <listcomp>(.0)
     53 
     54         # 3) Apply reader to get granular answer(s)
---> 55         len_chars = sum([len(d.text) for d in documents])
     56         logger.info(f"Reader is looking for detailed answer in {len_chars} chars ...")
     57         results = self.reader.predict(question=question,

AttributeError: 'list' object has no attribute 'text'

I looked through the codebase and it seems that finder.getanswers expects a list of Document objects form retriever.retrieve but retriever.retrieve returns a tuple with 2 lists, list of paragraph text and list of meta-data dicts.

@tholor
Copy link
Member

tholor commented Apr 20, 2020

Thanks for reporting this @patil-suraj!

@tanaysoni Can you please have a look? I think it's related to our change from last Friday introducing the Document class. We haven't changed it for the SQL-based Retriever yet.

@patil-suraj
Copy link
Author

I managed to fix this issue by converting the list of Paragraph tuples to Document objects in retrieve method. Also changed the getanswers method to accept both document list and meta-data dicts. This fixed the issue.

@mansilla
Copy link

Hey @patil-suraj, so there's is a pull request or something with the fix? Thanks

@tholor
Copy link
Member

tholor commented Apr 26, 2020

Hey @mansilla ,
We will update the tutorials tomorrow with a fix. Sorry for the inconvenience.

@mansilla
Copy link

Great! Thanks for the hard work.

@patil-suraj
Copy link
Author

Hey @mansilla
You can install haystack from my fork to try the demo till the fix comes live. https://github.com/patil-suraj/haystack/

@tanaysoni
Copy link
Contributor

We are working on revamping the tutorials in #79 and incorporating the many new features released since the tutorials were written.

This issue will be fixed in the updated tutorials.

@patil-suraj
Copy link
Author

@tanaysoni Great! And thank you for resolving this issue.

@mansilla
Copy link

@tanaysoni Thanks!

@tholor
Copy link
Member

tholor commented May 6, 2020

Fixed

@tholor tholor closed this as completed May 6, 2020
@tholor tholor added the type:bug Something isn't working label May 6, 2020
masci pushed a commit that referenced this issue Nov 27, 2023
Add component `from_dict` and `to_dict` methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants