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

Use word_ids to get labels in run_ner #8962

Merged
merged 2 commits into from
Dec 7, 2020
Merged

Use word_ids to get labels in run_ner #8962

merged 2 commits into from
Dec 7, 2020

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Dec 7, 2020

What does this PR do?

As #8958 pointed out, the current way labels are computed in the run_ner script using offset mappings does not work for sentencepiece-based tokenizers. This PR fixes that using the .word_ids method which is more elegant and more reliable.

In passing it adds an early check that the tokenzier is fast (otherwise the script just doesn't work).

Fixes #8958

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for looking into it!

@sgugger sgugger merged commit 7f9ccff into master Dec 7, 2020
@sgugger sgugger deleted the fix_8958 branch December 7, 2020 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

run_ner.py with xlm-roberta-base raises an IndexError in tokenize_and_align_labels
2 participants