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: strip whitespaces safely from FARMReader's answers #3526

Merged
merged 9 commits into from
Nov 8, 2022

Conversation

ZanSara
Copy link
Contributor

@ZanSara ZanSara commented Nov 4, 2022

Related Issues

Proposed Changes:

  • Remove mindless .strip() call in _span_to_string that was messing with the token offsets for FARMReader.
  • Strip right-side whitespace safely and adjust the start char position when necessary

How did you test it?

  • CI

Notes for the reviewer

n/a

Checklist

@ZanSara ZanSara requested a review from a team as a code owner November 4, 2022 09:52
@ZanSara ZanSara requested review from julian-risch and removed request for a team November 4, 2022 09:52
@ZanSara ZanSara changed the title Strip whitespaces safely from FARMReader's answers fix: strip whitespaces safely from FARMReader's answers Nov 4, 2022
@ZanSara ZanSara added type:bug Something isn't working topic:modeling topic:reader topic:predictions format of predictions, score, probability ... labels Nov 4, 2022
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

The changes to the test case look good to me but I have a few questions about the data type of right_offset and how it is used for calculations.

haystack/modeling/model/predictions.py Outdated Show resolved Hide resolved
haystack/modeling/model/predictions.py Outdated Show resolved Hide resolved
@ZanSara ZanSara marked this pull request as draft November 4, 2022 11:08
@ZanSara ZanSara marked this pull request as ready for review November 4, 2022 12:12
@ZanSara ZanSara requested a review from julian-risch November 4, 2022 14:23
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

I agree with the change from rstrip to lstrip. 👍 Regarding the int() call and the right_offest I still need to be convinced of the change. 🙂 I think we can leave out the int() call and I would rename right_offset to left_offset.

@@ -753,12 +753,6 @@ def no_answer_reader(request):
)


@pytest.fixture
Copy link
Member

Choose a reason for hiding this comment

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

I can confirm that prediction isn't used in any other tests except for the reader.py. However, it might be useful to have this fixture available to other nodes as well no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. I think fixtures should stay close to the tests that use them, and this is such a small one I hardly see the point of having it at all. Let's keep it near the tests.

test/nodes/test_reader.py Show resolved Hide resolved
haystack/modeling/model/predictions.py Outdated Show resolved Hide resolved
haystack/modeling/model/predictions.py Outdated Show resolved Hide resolved
@ZanSara ZanSara requested a review from julian-risch November 4, 2022 15:00
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks good to me! 👍 Thank you for patiently addressing the change requests and for the quick responses in our discussions. 🙂

@ZanSara
Copy link
Contributor Author

ZanSara commented Nov 4, 2022

Thank you for catching them! 🙌

@ZanSara ZanSara merged commit 43b24fd into main Nov 8, 2022
@ZanSara ZanSara deleted the farm-duplicate-end-chars branch November 8, 2022 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:modeling topic:predictions format of predictions, score, probability ... topic:reader type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

End of search context not pointing to the end of a phrase
2 participants