mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
bertdeep-learningflaxhacktoberfestjaxlanguage-modellanguage-modelsmachine-learningmodel-hubnatural-language-processingnlpnlp-librarypretrained-modelspythonpytorchpytorch-transformersseq2seqspeech-recognitiontensorflowtransformer
.gitignore | ||
bert_model.py | ||
data_processor.py | ||
download_weights.sh | ||
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)