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

fix: ONNX FARMReader model conversion is broken #3211

Merged
merged 10 commits into from
Sep 26, 2022
Merged

fix: ONNX FARMReader model conversion is broken #3211

merged 10 commits into from
Sep 26, 2022

Conversation

vblagoje
Copy link
Member

@vblagoje vblagoje commented Sep 13, 2022

Related Issues

Proposed Changes:

During a recent language and tokenization refactoring, we broke FarmReader ONNX conversion support. A simple ONNX conversion of a QA model fails; we don't have a test case for it.

How did you test it?

Added a unit test for FarmReader ONNX conversion

Notes for the reviewer

Is there a more straightforward way to figure out the model type (aside from loading it using get_language_model)? See PR changes.

Checklist

@vblagoje vblagoje requested a review from a team as a code owner September 13, 2022 09:57
@vblagoje vblagoje requested review from bogdankostic and removed request for a team September 13, 2022 09:57
@vblagoje vblagoje added this to the https://github.com/deepset-ai/haystack/milestone/8 milestone Sep 19, 2022
@@ -626,8 +626,8 @@ def convert_to_onnx(
https://huggingface.co/transformers/main_classes/model.html#transformers.PreTrainedModel.from_pretrained
:return: None.
"""
language_model_class = LanguageModel.get_language_model_class(model_name)
if language_model_class not in ["Bert", "Roberta", "XLMRoberta"]:
language_model = get_language_model(model_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might use here this function:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try, thanks Bogdan

@vblagoje
Copy link
Member Author

@bogdankostic when I move the onnx test to be executed after test_retrieval (mdr+memory) then both tests pass.

@vblagoje
Copy link
Member Author

@bogdankostic with your suggested change this PR started to pass 🚀

@vblagoje
Copy link
Member Author

I added dedicated onnx test file so we can start testing this part of the code base even better in the future

Copy link
Contributor

@bogdankostic bogdankostic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just added some minor comments about imports that don't seem to be used.

@@ -1,4 +1,5 @@
import logging
import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this import is not used either.

@@ -11,6 +12,7 @@
from elasticsearch import Elasticsearch

from haystack.document_stores import WeaviateDocumentStore
from haystack.nodes import FARMReader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@@ -1,4 +1,7 @@
import math
import os
import tempfile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this import is not used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, that's because we don't check imports for tests, will fix - thanks @bogdankostic

@vblagoje vblagoje merged commit 9582a42 into deepset-ai:main Sep 26, 2022
@vblagoje vblagoje deleted the fix_onnx branch October 24, 2022 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ONNX FARMReader model conversion is broken
2 participants