deepset-ai / haystack

:mag: AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.
https://haystack.deepset.ai
Apache License 2.0
17.17k stars 1.88k forks source link

BUG: Retriever format not matching what reader is expecting #74

Closed mansilla closed 4 years ago

mansilla commented 4 years ago

Hello, first of all. Thank you for this wonderful project. So, I'm following this tutorial here. But I'm having the following error:

Traceback (most recent call last):
  File "haystack_test.py", line 46, in <module>
    prediction = finder.get_answers(question="What is the mass of the electron?", top_k_retriever=10, top_k_reader=5)
  File "/Users/admin/miniconda3/envs/legy/lib/python3.6/site-packages/haystack/finder.py", line 55, in get_answers
    len_chars = sum([len(d.text) for d in documents])
  File "/Users/admin/miniconda3/envs/legy/lib/python3.6/site-packages/haystack/finder.py", line 55, in <listcomp>
    len_chars = sum([len(d.text) for d in documents])
AttributeError: 'list' object has no attribute 'text'

That line is actually only for printing info. But if I skip that, below in the same file haystack/finder.py, in line 61 the reader is invoked with the same documents objects and throws an error:

Traceback (most recent call last):
  File "haystack_test.py", line 46, in <module>
    prediction = finder.get_answers(question="What is the mass of the electron?", top_k_retriever=10, top_k_reader=5)
  File "/Users/admin/miniconda3/envs/legy/lib/python3.6/site-packages/haystack/finder.py", line 61, in get_answers
    top_k=top_k_reader)
  File "/Users/admin/miniconda3/envs/legy/lib/python3.6/site-packages/haystack/reader/farm.py", line 221, in predict
    "text": doc.text,
AttributeError: 'list' object has no attribute 'text'

So my conclusion is the format the reader is expecting is different from what the retriever is returning.

NOTE: I installed the library from GitHub as recommended in the Readme file.

mansilla commented 4 years ago

Closing since is the same as #68