

TITLE
DestilGTP2 code from pytorch-transformers does not work in transformers, I made a basic example

COMMENTS
1

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
How would i convert this to new version of transformers. Or is it possible to somehow use DestilGTP2 with pytorch-transformers.

    use_transformers = True
    if use_transformers: 
        import torch   
        from transformers import GPT2Tokenizer, GPT2Model, GPT2LMHeadModel                       
        tokenizer1 = GPT2Tokenizer.from_pretrained('distilgpt2',cache_dir="/var/software/Models/")
        model1 = GPT2LMHeadModel.from_pretrained('distilgpt2',cache_dir="/var/software/Models/") 
        model1.eval()
        model1.to('cuda')
        text = "Who was Jim Henson ?"
        indexed_tokens = tokenizer1.encode(text)
        tokens_tensor = torch.tensor([indexed_tokens])
        tokens_tensor = tokens_tensor.to('cuda')
       with torch.no_grad():
            predictions_1 = model1(tokens_tensor) 
       print(predictions_1) 
   
    else:  
        import torch  
        from pytorch_transformers import GPT2Tokenizer, GPT2Model, GPT2LMHeadModel
        tokenizer1 = GPT2Tokenizer.from_pretrained('gpt2',cache_dir="/var/software/Models/") # cache_dir=None
        model1 = GPT2LMHeadModel.from_pretrained('gpt2',cache_dir="/var/software/Models/")
        model1.eval()
        model1.to('cuda')
        text = "Who was Jim Henson ?"
        indexed_tokens = tokenizer1.encode(text)
        tokens_tensor = torch.tensor([indexed_tokens])
        tokens_tensor = tokens_tensor.to('cuda')
        with torch.no_grad():
            predictions_1 = model1(tokens_tensor) 
        print(predictions_1) 

When i try i get an error, and tried to follow the guide but do not get what the new tokeniser does differently. 

    