Skip to content

Instantly share code, notes, and snippets.

@MathewAlexander
Last active September 23, 2020 18:50
Show Gist options
  • Select an option

  • Save MathewAlexander/dc7214e95fd4abc4538b0208b06bee8c to your computer and use it in GitHub Desktop.

Select an option

Save MathewAlexander/dc7214e95fd4abc4538b0208b06bee8c to your computer and use it in GitHub Desktop.
tokenizer = T5Tokenizer.from_pretrained('t5-base')
model =T5ForConditionalGeneration.from_pretrained('path_to_trained_model',
return_dict=True)
def generate(text,model,tokenizer):
model.eval()
input_ids = tokenizer.encode("WebNLG:{} </s>".format(text),
return_tensors="pt")
outputs = model.generate(input_ids)
return tokenizer.decode(outputs[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment