Skip to content

Conversation

jessthebp
Copy link
Contributor

What does this PR do?

Adds an example to the docstring of HammingDiversityLogitsProcessor class definition in this file.

Part of the docs work on Generate: have an example on each logits processor class docstring

Changes -

  • Added example
  • Added some more info about beam search and how hamming diversity works with it
  • Added warning/tip about resources

Happy to edit it all down a bit if it's too much stuff!

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline, Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.

Who can review?

@gante

@jessthebp
Copy link
Contributor Author

@gante -- hey! Currently, the checks are failing because of some changes in the docs, but not sure if I can/should fix those-- using black, the files I've changed seem to be formatted correctly? Is there something I need to change in the docs to have this merge?

Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening the PR! The descriptions are very thorough, I wish I had them when I first read about group beam search 🔥

I have two requests, before we merge the PR:

  1. You should be able to fix the CI errors if you run make fixup in your terminal, commit the changes, and then push them :)
  2. Although the example is good, it would be even better if it could be done entirely with generate calls, as opposed to with some group_beam_search calls! Most users stay at a generate level, so an example using generate is much more powerful 💪

@jessthebp
Copy link
Contributor Author

@gante Fixes made! :)

Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(the doc preview should work after correcting the syntax in the warning block)

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🔥

There are two rendering nits that should be fixed, but other than that I'm happy with the PR. Thank you for documenting this complex logits processor! 💛

Example: the below example shows a comparison before and after applying Hamming Diversity.
```python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final nit 1: let's remove indentation in the example, it shows up awkwardly in the rendered docs (see here the preview)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to add >>> before the code as it is done for every other logit processor.

    Examples:

    ```python
    >>> from transformers import AutoTokenizer, AutoModelForCausalLM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yeah, and the missing >>> / ..., good catch!

# summary 1: the solar system formed 4.6 billion years ago from the collapse of a giant interstellar molecular cloud.
# summary 2: the solar system formed 4.6 billion years ago from the collapse of a giant interstellar molecular cloud.
```
For more details, see [Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final nit 2: let's move this to above the example, and decrease the indentation -- it is not rendering correctly (see here the preview)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, sorry. Just autoaccepted the formatting suggestions from the CLI. I'll revert the weird/unnecessary changes + fix the formatting for the logits comment.

@gante gante requested a review from ArthurZucker August 22, 2023 15:42
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

Example: the below example shows a comparison before and after applying Hamming Diversity.
```python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to add >>> before the code as it is done for every other logit processor.

    Examples:

    ```python
    >>> from transformers import AutoTokenizer, AutoModelForCausalLM

jesspeck and others added 8 commits August 23, 2023 11:39
…tyLogitsProcessor' into dev-documentation-HammingDiversityLogitsProcessor

# Conflicts:
#	src/transformers/generation/logits_process.py
@gante gante merged commit c6a84b7 into huggingface:main Aug 25, 2023
@gante
Copy link
Member

gante commented Aug 25, 2023

@jesspeck thank for you iterating and thank you for the contribution 🤗

@jessthebp jessthebp deleted the dev-documentation-HammingDiversityLogitsProcessor branch August 25, 2023 13:20
parambharat pushed a commit to parambharat/transformers that referenced this pull request Sep 26, 2023
…5481)

* updated logits processor text

* Update logits_process.py

* fixed formatting with black

* fixed formatting with black

* fixed formatting with Make Fixup

* more formatting fixes

* Update src/transformers/generation/logits_process.py

Co-authored-by: Joao Gante <[email protected]>

* Update src/transformers/generation/logits_process.py

Co-authored-by: Joao Gante <[email protected]>

* Revert "fixed formatting with Make Fixup"

This reverts commit 4764308

* Revert "fixed formatting with black"

This reverts commit bfb1536.

* Revert "fixed formatting with Make Fixup"

This reverts commit 4764308

* Revert "fixed formatting with Make Fixup"

This reverts commit 4764308

* Revert "fixed formatting with black"

This reverts commit ad6ceb6

* Revert "fixed formatting with black"

This reverts commit ad6ceb6.

* Update src/transformers/generation/logits_process.py

Co-authored-by: Arthur <[email protected]>

* Revert "fixed formatting with Make Fixup"

This reverts commit 4764308

* formatted logits_process with make fixup

---------

Co-authored-by: jesspeck <[email protected]>
Co-authored-by: Joao Gante <[email protected]>
Co-authored-by: Arthur <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants