Skip to content

The document of generation seems to wrongly describe the default value of top_p, top_k and temperature #35045

@Kamichanw

Description

@Kamichanw

System Info

The newest transformers

Who can help?

@stevhliu

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

The document of generation says that top_p, top_k and temperature will be set to a specific value.

However, as shown below, the settings of top_p, top_k, and temperature depend on the generation configuration of the model, which is not guaranteed to be consistent with the behavior described in the docstring.

if generation_config.temperature is not None and generation_config.temperature != 1.0:
processors.append(TemperatureLogitsWarper(generation_config.temperature))
if generation_config.top_k is not None and generation_config.top_k != 0:
processors.append(
TopKLogitsWarper(top_k=generation_config.top_k, min_tokens_to_keep=min_tokens_to_keep)
)
if generation_config.top_p is not None and generation_config.top_p < 1.0:
processors.append(
TopPLogitsWarper(top_p=generation_config.top_p, min_tokens_to_keep=min_tokens_to_keep)
)

Expected behavior

I'd like to know if I'm missing something, and if not, please make the docstring of "generation" and its behavior consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions