Penalise n-gram repetition in generated sequences
# 🚀 Feature request

As per this [forum post](https://discuss.huggingface.co/t/force-decoder-to-avoid-repetition-between-generated-sentences/625) sometimes it's helpful to have a parameter that can increase the diversity amongst different generated sentences. This can be a penalty on the number of repeated n-grams between each generated sentence.

## Motivation

If a generation model is being used and `num_returned_sequences` is greater than `1` there are a number of use cases that make it beneficial to be able to have a parameter that can increase the diversity amongst generated sentences or at least avoid exact replicas. For example when trying to create different paraphrases of the same sentence or question.

Example:
Original Question ::
What is the expected close date of the opportunity

Paraphrased Questions Generated by T5::
0: What will be the expected close date of the opportunity?
1: What is the expected closing date for the opportunity that you are considering?
2: What is the expected close date of the opportunity?
3: What is the expected close date on the opportunity?
4: When would be the expected close date of the opportunity?

## Your contribution

I'm happy to submit a PR to work on this if it makes sense to add this as a feature. I would just appreciate a steer on where the best place would be to add this penalty.

@patil-suraj @patrickvonplaten 
Hi @KMFODA 

The `generate` method already supports penalizing n-gram repetition, this can be done by passing the argument `no_repeat_ngram_size` , if it's passed it will ensure that all n-grams of the given size will only occur once.

This however does not mean that the different `num_returned_sequences` sequences will be diverse since AFAIK in beam search usually the sequences are very close to each other. 

You could try using beam sampling bypassing `do_sample=True`  which will use sampling in each beam, which could introduce some diversity.

There's also an option of using [diverse beam search](https://arxiv.org/abs/1610.02424) which can be enabled using the option `diversity_penalty`.<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.