gpt-2-simple
gpt-2-simple copied to clipboard
gpt
Thank you
Heres a start
!pip install transformers
import transformers
config = transformers.GPT2Config.from_pretrained('/content/checkpoint/run3/hparams.json')
tokenizer = transformers.GPT2Tokenizer("checkpoint/run3/encoder.json", "checkpoint/run3/vocab.bpe")
model = transformers.GPT2Model.from_pretrained('/content/checkpoint/run3/model-1500.index',from_tf=True,config=config)
model.save_pretrained('gpt2_')
tokenizer.save_pretrained('gpt2_')
from transformers import pipeline
fill_masker = pipeline(task ='text-generation', model="/content/gpt2_")
Heres how you implement greedy
fill_masker("hello my name is inigo montoya you",max_length=20)
maybe you can ask the huggingface community for alternative searching methods
Also here how you do beam search with huggingface
fill_masker("hello my name is inigo montoya you",num_return_sequences=20, num_beams=60,batch_size=20)
refer to this link to explore different searches https://huggingface.co/docs/transformers/main_classes/text_generation