Hi @kintaro and @valhalla
Thanks @valhalla for replying right away! In this case, no_repeat_ngram_size can actually be applied both in the beam search and sampling generation. I think we just left the option out of the run_generation.py script because we didn’t want it to be too crowded, but you can just pass the argument in:

  
      github.com
  
  
    huggingface/transformers/blob/master/examples/text-generation/run_generation.py#L252 2

    )
else:
    encoded_prompt = tokenizer.encode(prompt_text, add_special_tokens=False, return_tensors="pt")
encoded_prompt = encoded_prompt.to(args.device)

if encoded_prompt.size()[-1] == 0:
    input_ids = None
else:
    input_ids = encoded_prompt

output_sequences = model.generate(
    input_ids=input_ids,
    max_length=args.length + len(encoded_prompt[0]),
    temperature=args.temperature,
    top_k=args.k,
    top_p=args.p,
    repetition_penalty=args.repetition_penalty,
    do_sample=True,
    num_return_sequences=args.num_return_sequences,
)




  
  
    
    
  
  


(just add a e.g. no_repeat_ngram_size=3, line in the arguments for the generate function)