I am a beginner for bert, and I am trying to use files of bert given on the GitHub:https://github.com/google-research/bert
However I cannot import files(such as run_classifier, optimisation and so on) from bert after using pip install bert
to install bert in terminal. I tried to run following codes in jupiter notebook:
import bert
from bert import run_classifier
And the error is:
ImportError: cannot import name 'run_classifier'
Then I found the file named 'bert' in \anaconda3\lib\python3.6\site-packages
, and there were no python files named 'run_classifier', 'optimization' etc inside it. So I downloaded those files from GitHub and put them into file 'bert' by myself. After doing this I could import run_classifier.
However, another problem occurred. I couldn't use the functions inside the files although I could import them.
For example, there's a function convert_to_unicode
in tokenization.py:
Help on module bert.tokenization in bert:
NAME
bert.tokenization - Tokenization classes.
FUNCTIONS
convert_to_unicode(text)
Converts `text` to Unicode (if it's not already), assuming utf-8 input.
Then I tried this:
import tokenization from bert
convert_to_unicode('input.txt')
And the error is:
NameError: name 'convert_to_unicode' is not defined
Then I tried:
from tokenization import convert_to_unicode
And the error is:
ModuleNotFoundError: No module named 'tokenization'
I am really confused about this.
The package you're looking for is bert-tensorflow
, not bert
.
bert-tensorflow is the Python package for Google's BERT implementation.
bert is a serialization library.