getting ready

This commit is contained in:
thomwolf
2018-10-30 20:18:49 +01:00
parent 43badf217d
commit ccce66be27
5 changed files with 595 additions and 104 deletions

18
example.py Normal file
View File

@@ -0,0 +1,18 @@
"""
Show how to use HuggingFace's PyTorch implementation of Google's BERT Model.
"""
from .bert_model import BERT
from .prepare_inputs import DataPreprocessor
bert_model = BERT()
bert_model.load_from('.')
data_processor = DataProcessor(encoder_file_path='.')
input_sentence = "We are playing with the BERT model."
print("BERT inputs: {}".format(input_sentence))
tensor_input = data_processor.encode(input_sentence)
tensor_output = bert_model(prepared_input)
output_sentence = data_processor.decode(tensor_output)
print("BERT predicted: {}".format(output_sentence))