From ff22b3acc097b208dfa6d470744bf47a86864e59 Mon Sep 17 00:00:00 2001 From: Stanislas Polu Date: Thu, 21 Feb 2019 09:15:27 +0000 Subject: [PATCH] Few small nits in GPT-2's code examples --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 43cf4346e7..bbe0f42aab 100644 --- a/README.md +++ b/README.md @@ -427,7 +427,7 @@ model.to('cuda') with torch.no_grad(): hidden_states_1, past = model(tokens_tensor_1) # past can be used to reuse precomputed hidden state in a subsequent predictions - # (see beam-search examples in the run_gpt2.py example + # (see beam-search examples in the run_gpt2.py example). hidden_states_2, past = model(tokens_tensor_2, past=past) ``` @@ -439,14 +439,15 @@ model = GPT2LMHeadModel.from_pretrained('gpt2') model.eval() # If you have a GPU, put everything on cuda -tokens_tensor_1 = tokens_tensor.to('cuda') +tokens_tensor_1 = tokens_tensor_1.to('cuda') +tokens_tensor_2 = tokens_tensor_2.to('cuda') model.to('cuda') # Predict all tokens with torch.no_grad(): predictions_1, past = model(tokens_tensor_1) # past can be used to reuse precomputed hidden state in a subsequent predictions - # (see beam-search examples in the run_gpt2.py example + # (see beam-search examples in the run_gpt2.py example). predictions_2, past = model(tokens_tensor_2, past=past) # get the predicted last token