Go to file
thomwolf 12e013dbac added wordpiece - updated readme 2018-10-30 23:09:09 +01:00
.gitignore getting ready 2018-10-30 20:18:49 +01:00
README.md added wordpiece - updated readme 2018-10-30 23:09:09 +01:00
bert_model.py added wordpiece - updated readme 2018-10-30 23:09:09 +01:00
data_processor.py added wordpiece - updated readme 2018-10-30 23:09:09 +01:00
download_weights.sh getting ready 2018-10-30 20:18:49 +01:00

README.md

pytorch-pretrained-BERT

A PyTorch version of Google's pretrained BERT model as described in

No bells and whitles, just:

  • one class with a clean commented version of Google's BERT model that can load the weights pre-trained by Google's authors,
  • another class with all you need to pre- and post-process text data for the model (tokenize and encode),
  • and a script to download Google's pre-trained weights.

Here is how to use these:

from .bert_model import BERT
from .data_processor import DataProcessor

bert_model = BERT(bert_model_path='.')
data_processor = DataProcessor(bert_vocab_path='.')

input_sentence = "We are playing with the BERT model."

tensor_input = data_processor.encode(input_sentence)
tensor_output = bert_model(prepared_input)
output_sentence = data_processor.decode(tensor_output)