# Big \`generate()\` refactor

**URL:** <https://discuss.huggingface.co/t/big-generate-refactor/1857>\
**Category:** 🤗Transformers\
**Created:** [November 2, 2020, 12:49pm UTC](https://discuss.huggingface.co/t/big-generate-refactor/1857 "2020-11-02T12:49:48Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Jung](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jung/32/21989_2.png) [@Jung](https://discuss.huggingface.co/u/Jung)\
**Post date:** [December 23, 2020, 2:34am UTC](https://discuss.huggingface.co/t/big-generate-refactor/1857/6 "2020-12-23T02:34:49Z")

</div>

Hi you can use the new diverse beam generation easily by just adding the two new parameters into `generate()`.  
Two new parameters on diverse beam are `num_beam_group` and `diversity_penalty` where `num_beam_group <= num_beams`

**Example**

```
outputs = model.generate(input_ids, min_length=1, max_length=200,
                                  no_repeat_ngram_size=3, num_beams=5, early_stopping=True,
                                  do_sample=False, num_return_sequences=5,
                                  num_beam_groups=5, diversity_penalty=2.0
                                 )
```

---

_[View the full topic](https://discuss.huggingface.co/t/big-generate-refactor/1857)._
