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

UnboundLocalError when running eval with isolated_node and filters #2273

Closed
thimo72 opened this issue Mar 3, 2022 · 4 comments
Closed

UnboundLocalError when running eval with isolated_node and filters #2273

thimo72 opened this issue Mar 3, 2022 · 4 comments
Labels

Comments

@thimo72
Copy link
Contributor

thimo72 commented Mar 3, 2022

Describe the bug
When running pipe.eval with add_isolated_node_eval=True, an UnboundLocalError occurs.

Error message
UnboundLocalError: local variable 'predict' referenced before assignment. In haystack/nodes/reader/base.py at line 95.

Expected behavior
I assume the reader should take the input from the context given in the label for isolated evaluation.

Additional context
The error only occurs when evaluating on documents other than the ones from the eval labels (open-domain QA setting) and adding filters to the labels such that there are no documents in the document store that are matching the filter.

System:

  • OS:
  • GPU/CPU: CPU
  • Haystack version (commit or version number): 1.2.0
  • DocumentStore: Elasticsearch
  • Reader: FARMReader
  • Retriever: ElasticsearchRetriever (bm25)

Possible Solution (?)
I'm not quite sure what causes the error, but adding
predict = self.timing(self.predict, "query_time")
to haystack/nodes/reader/base.py line 94 seems to solve the error.

@tstadel
Copy link
Member

tstadel commented Mar 4, 2022

Hey @thimo72,
thanks for reaching out. Yes, the predict assignment should have happened before the if block in line 81.
In your case the retriever seems not to return any documents, thus choosing the else block (line 84) and predict remains unknown. Later on in add_isolated_node_eval the call of predict fails.

The cleanest solution would be to move the predict assignment from line 82 to line 81 (before the if block). Would you like to contribute this fix in a PR? Otherwise I'll fix it. Just let me know, so we make it work as intended quickly.

@thimo72
Copy link
Contributor Author

thimo72 commented Mar 4, 2022

Hi @tstadel,
thank you for the quick response. I can fix this an open a PR, probably this afternoon.

@tstadel
Copy link
Member

tstadel commented Mar 8, 2022

@thimo72 I merged your PR. Can we close this issue?

@thimo72
Copy link
Contributor Author

thimo72 commented Mar 8, 2022

Yeah, sure. Thank you

@thimo72 thimo72 closed this as completed Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants