microsoft / DialoGPT

Large-scale pretraining for dialogue
MIT License
2.36k stars 341 forks source link

Prop:Help How create interactive environment for simple try/test #46

Open remotejob opened 4 years ago

remotejob commented 4 years ago

After python demo.py was created dir models/output_model/GPT2.1e-05.64.0gpu.2020-07-19022953/GP2-pretrain-step-10000.pkl

Question: How create simple interactive program to use GP2-pretrain-step-10000.pk.

Something like on:

https://huggingface.co/microsoft/DialoGPT-small

`from transformers import AutoModelWithLMHead, AutoTokenizer import torch

tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-small") model = AutoModelWithLMHead.from_pretrained("microsoft/DialoGPT-small") for step in range(5): new_user_input_ids = tokenizer.encode(input(">> User:") + tokenizer.eos_token, return_tensors='pt') bot_input_ids = torch.cat([chat_history_ids, new_user_input_ids], dim=-1) if step > 0 else new_user_input_ids chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id) print("DialoGPT: {}".format(tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)))`

pranavpawar3 commented 3 years ago

@remotejob Hi, I am curious about the same thing. Did you find any help on this yet?

Thanks