Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Text Generation] Avoid mutating the original logits in-place when mapping from logits to token. #1414

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

dbogunowicz
Copy link
Contributor

@dbogunowicz dbogunowicz commented Nov 17, 2023

Feature Description

TokenGenerator.generate(logits: numpy.ndarray) takes a logits array and, if do_sample=True, optionally mutates them to enforce the appropriate sampling strategy.

This results in the correct generation of tokens, but an in-place modification of the logits array. Logits array is then returned to the user in the mutated form. This can be confusing for the users who are interested in logits value, specially when returned together with prompt logits:

image

First column before: the generated logits returned to the user are mutated (the distribution is spikier, arguably close to Dirac distribution)

Second column after: the generated logits are the non-mutatated, original logits, consistent with the prompt logits.

@mgoin mgoin merged commit 9383653 into main Nov 20, 2023
13 checks passed
@mgoin mgoin deleted the feature/damian/logits_copy branch November 20, 2023 14:39
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.

None yet

2 participants