# Big \`generate()\` refactor

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbig-generate-refactor%2F1857%3E%5C
**Category:** 🤗Transformers\
**Created:** [November 2, 2020, 12:49pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbig-generate-refactor%2F1857 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJung)%5C
**Post date:** [December 23, 2020, 2:34am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbig-generate-refactor%2F1857%2F6 "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](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fbig-generate-refactor%2F1857)._
