transformers: Support returning raw logits in `generate`

Feature request

Support returning raw logits in generate by either:

  1. creating a new arg that enables return of raw logits
  2. or support callback that allow users to collect the raw logits

Motivation

  • Raw logits “would be the most understandable & consistent across generation methods” (@patrickvonplaten)
  • For testing, returning raw logits would help “identify which parts get wrong if any test failure occurs” (@ydshieh)
  • There’s concern about “rampant too many options” (@Narsil), thus I would prefer the second option to support this feature.
  • However, the second option still needs code change to support it. As the user provided logits_processor is appended to a new instance of LogitsProcessorList. As a result, users cannot get the raw logits using the current implementation even with a custom LogitsProcessor.

See further discussion in https://github.com/huggingface/transformers/issues/17424

Your contribution

I could open a PR to reorder how logits_processor is merged with the predefined list of LogitsProcessorList.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 19 (13 by maintainers)

Most upvoted comments

I could open a PR for this.

(see #28667)

I’m okay with this, let me know if you need any help @shijie-wu 😃