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

Fixing camembert tokenization #2065

Merged
merged 2 commits into from
Dec 5, 2019
Merged

Fixing camembert tokenization #2065

merged 2 commits into from
Dec 5, 2019

Conversation

thomwolf
Copy link
Member

@thomwolf thomwolf commented Dec 5, 2019

The original fairseq implmentation of Camembert has a bunch of duplicate tokens in the dictionary, in particular there are two <unk> tokens but only the index of the first <unk> should be used:

import torch
camembert = torch.hub.load('pytorch/fairseq', 'camembert.v0')
list(camembert.task.source_dictionary[i] for i in range(10))
>>> ['<s>', '<pad>', '</s>', '<unk>', '<unk>', '<s>', '</s>', ',', '▁de', '.']

This PR updates Camembert tokenizer to fix this behavior and as a consequence fixes #2019 and #2020

@thomwolf
Copy link
Member Author

thomwolf commented Dec 5, 2019

Merging now to fix the xlnet test issue on master at the same time.

@thomwolf thomwolf merged commit af077b1 into master Dec 5, 2019
@julien-c julien-c deleted the fixing-camembert branch December 5, 2019 16:19
@julien-c
Copy link
Member

julien-c commented Dec 5, 2019

Also cc'ing @louismartin on this.

@louismartin
Copy link
Contributor

Thanks for fixing that.
This comes from a problem in fairseq where special tokens are added twice when using SentencePiece.
Cross-referencing the fairseq issue: facebookresearch/fairseq#1309

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.

[CamemBert] Tokenizer function add_tokens doesn't work
3 participants