Skip to content

Instantly share code, notes, and snippets.

@GeorgeDittmar
Created December 24, 2020 09:27
Show Gist options
  • Save GeorgeDittmar/1415b38df3bef2900940fd44993dc3b9 to your computer and use it in GitHub Desktop.
Save GeorgeDittmar/1415b38df3bef2900940fd44993dc3b9 to your computer and use it in GitHub Desktop.
huggingface text generation call
generated_text_samples = model.generate(
input_ids,
max_length=150,
num_return_sequences=5,
no_repeat_ngram_size=2,
repetition_penalty=1.5,
top_p=0.92,
temperature=.85,
do_sample=True,
top_k=125,
early_stopping=True
)
#Print output for each sequence generated above
for i, beam in enumerate(beam_output):
print("{}: {}".format(i,tokenizer.decode(beam, skip_special_tokens=True)))
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment