bert icon indicating copy to clipboard operation
bert copied to clipboard

the vocab size of pretrained model is small

Open susht3 opened this issue 8 years ago • 2 comments

i download model of BERT-Base, Uncased(12-layer, 768-hidden, 12-heads, 110M parameters), whose file name is "uncased_L-12_H-768_A-12", and i find the vocab size is very small, only 30522. for QA tasks, the vocab size maybe not big enough, some un-frequent words can be answer, if we load this pretrained model, will it performs worse?

susht3 avatar Nov 20 '18 08:11 susht3

During tokenization step, BERT code uses a wordpiece algorithm to split words into sub-words. 30522 is a count of sub-words but not words. Other words, un-frequent words will be split into two or more sub-words.

avostryakov avatar Nov 20 '18 08:11 avostryakov

Yes, this is a standard sized vocabulary when using sub-words. You can print the output of FullTokenizer.tokenize (look at extract_features.py for a simple use case) if you're curious to see how it splits text.

jacobdevlin-google avatar Nov 23 '18 22:11 jacobdevlin-google