Opennmt-py: how to integrate wordpiece?

Created on 26 Jun 2019  路  3Comments  路  Source: OpenNMT/OpenNMT-py

I'm thinking of integrating the BERT model hidden states from (https://github.com/huggingface/pytorch-pretrained-BERT) but BERT takes in wordpiece while current OpenNMT-py takes in words. Any ideas or simple hacks to get around it?

Thanks!

Most helpful comment

OpenNMT-py doesn't specify a tokenization schema - If you want to use a word-level tokenization algorithm (such as the Moses/NLTK/SpaCy/BERT BasicTokenizer in the Pytorch-pretrained-BERT repo) or a subword tokenization algorithm (such as WordPiece or BPE), you should do that and then format the output to have one example per line with whitespaces separating words/subwords/whatever your tokens are. Refer to http://opennmt.net/OpenNMT-py/extended.html where the Moses Tokenizer is used.

All 3 comments

OpenNMT-py doesn't specify a tokenization schema - If you want to use a word-level tokenization algorithm (such as the Moses/NLTK/SpaCy/BERT BasicTokenizer in the Pytorch-pretrained-BERT repo) or a subword tokenization algorithm (such as WordPiece or BPE), you should do that and then format the output to have one example per line with whitespaces separating words/subwords/whatever your tokens are. Refer to http://opennmt.net/OpenNMT-py/extended.html where the Moses Tokenizer is used.

Same question. Thank you!

"whitespaces separating words/subwords/whatever your tokens are"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

howardyclo picture howardyclo  路  6Comments

achaitanyasai picture achaitanyasai  路  5Comments

kakkartushar1 picture kakkartushar1  路  5Comments

paulkp picture paulkp  路  6Comments

AyaNsar picture AyaNsar  路  4Comments