From 5c3b32d44d0164aaa9b91405f48e53cf53a82b35 Mon Sep 17 00:00:00 2001 From: Santosh Gupta Date: Sat, 28 Sep 2019 16:35:06 -0700 Subject: [PATCH] Update README.md Lines 183 - 200, fixed indentation. Line 198, replaced `tokenizer_class` with `BertTokenizer`, since `tokenizer_class` is not defined in the loop it belongs to. --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8dd2c2fb66..b2c5df77e9 100644 --- a/README.md +++ b/README.md @@ -180,24 +180,24 @@ for model_class in BERT_MODEL_CLASSES: # Load pretrained model/tokenizer model = model_class.from_pretrained('bert-base-uncased') -# Models can return full list of hidden-states & attentions weights at each layer -model = model_class.from_pretrained(pretrained_weights, - output_hidden_states=True, - output_attentions=True) -input_ids = torch.tensor([tokenizer.encode("Let's see all hidden-states and attentions on this text")]) -all_hidden_states, all_attentions = model(input_ids)[-2:] + # Models can return full list of hidden-states & attentions weights at each layer + model = model_class.from_pretrained(pretrained_weights, + output_hidden_states=True, + output_attentions=True) + input_ids = torch.tensor([tokenizer.encode("Let's see all hidden-states and attentions on this text")]) + all_hidden_states, all_attentions = model(input_ids)[-2:] -# Models are compatible with Torchscript -model = model_class.from_pretrained(pretrained_weights, torchscript=True) -traced_model = torch.jit.trace(model, (input_ids,)) + # Models are compatible with Torchscript + model = model_class.from_pretrained(pretrained_weights, torchscript=True) + traced_model = torch.jit.trace(model, (input_ids,)) -# Simple serialization for models and tokenizers -model.save_pretrained('./directory/to/save/') # save -model = model_class.from_pretrained('./directory/to/save/') # re-load -tokenizer.save_pretrained('./directory/to/save/') # save -tokenizer = tokenizer_class.from_pretrained('./directory/to/save/') # re-load + # Simple serialization for models and tokenizers + model.save_pretrained('./directory/to/save/') # save + model = model_class.from_pretrained('./directory/to/save/') # re-load + tokenizer.save_pretrained('./directory/to/save/') # save + tokenizer = BertTokenizer.from_pretrained('./directory/to/save/') # re-load -# SOTA examples for GLUE, SQUAD, text generation... + # SOTA examples for GLUE, SQUAD, text generation... ``` ## Quick tour TF 2.0 training and PyTorch interoperability