Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import bert.tokenization

I am using Google Colab and the following import doesn't work somehow:

from bert.tokenization import FullTokenizer

I am getting this error:

ModuleNotFoundError: No module named 'bert.tokenization'

I tried to install bert by running the following command:

!pip install  --upgrade bert

Any idea how to resolve this error?

like image 937
kee Avatar asked Jun 12 '19 05:06

kee


3 Answers

I found it:

!pip install bert-tensorflow
like image 121
kee Avatar answered Oct 23 '22 22:10

kee


For anyone experiencing this problem with TensorFlow 2.0 and the bert-for-tf2 library, I found out that I was missing some files after using pip3 install. I've posted my solution here:

https://github.com/google-research/bert/issues/638#issuecomment-592488730

like image 29
GittinJiggyWithIt Avatar answered Oct 23 '22 22:10

GittinJiggyWithIt


install : pip install bert-for-tf2

then import,

from bert import bert_tokenization BertTokenizer = bert_tokenization.FullTokenizer

like image 33
Kaustuv Avatar answered Oct 23 '22 21:10

Kaustuv