getting ready
This commit is contained in:
18
example.py
Normal file
18
example.py
Normal 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))
|
||||
Reference in New Issue
Block a user