-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
[Bugfix]: Fix messy code when using logprobs #19209
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
Conversation
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @chaunceyjiang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
As gemini-code-assist, I've reviewed this pull request. The primary goal of this PR, as indicated by the title and linked issue (#19177), is to fix an issue where the output, particularly when using log probabilities, appears "messy" or incorrectly formatted. The core change addresses this by modifying the detokenization logic within the vllm/transformers_utils/detokenizer_utils.py
file. Specifically, it switches from using tokenizer.convert_ids_to_tokens
to tokenizer.decode
to convert token IDs back into strings. This change is likely aimed at improving how special tokens, whitespace, and subword units are handled during the conversion process, leading to cleaner and more accurate text output, which is essential for correct logprob interpretation.
Highlights
- Bugfix: Addresses issue #19177 concerning messy output when log probabilities are enabled.
- Detokenization Logic Update: Changes the method used for converting token IDs back to strings in the
convert_ids_list_to_tokens
function.
Changelog
- vllm/transformers_utils/detokenizer_utils.py
- Modified the
convert_ids_list_to_tokens
function (line 92) to usetokenizer.decode(token_ids)
instead oftokenizer.convert_ids_to_tokens(token_ids)
for detokenization, aiming to fix output formatting issues related to logprobs.
- Modified the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
IDs flow from model,
Convert to text, a story told.
Decode makes it clean,
A bug fixed, a better scene.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request addresses an issue related to messy code when using log probabilities. The change replaces tokenizer.convert_ids_to_tokens
with tokenizer.decode
in the convert_ids_list_to_tokens
function. This seems like a reasonable fix. I have a minor suggestion.
Merge Readiness
The change appears to be a straightforward bug fix. The suggestion is minor and can be addressed before or after merging. I am unable to directly approve the pull request, and other reviewers should review and approve this code before merging.
e35828c
to
2da2408
Compare
/cc @njhill PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment - I think it also makes sense to add a unit test for this if possible, but we can probably leave it for a later PR
45852cd
to
f2834f6
Compare
test from transformers import AutoTokenizer
from vllm.transformers_utils.detokenizer_utils import convert_ids_list_to_tokens
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")
token_ids = tokenizer.encode("Hello, world!", add_special_tokens=True)
print(token_ids)
print(tokenizer.convert_ids_to_tokens([9707]))
print(tokenizer.convert_ids_to_tokens([11]))
print(tokenizer.convert_ids_to_tokens([1879]))
print(tokenizer.convert_ids_to_tokens([0]))
print(tokenizer.convert_ids_to_tokens(token_ids))
print("-----")
print(tokenizer.decode([9707]))
print(tokenizer.decode([11]))
print(tokenizer.decode([1879]))
print(tokenizer.decode([0]))
print("-----")
texts = convert_ids_list_to_tokens(tokenizer,[9707, 11, 1879, 0])
print(texts)
We can observe that using |
d320616
to
191897b
Compare
Directly using |
The CI failures look related to detokenize changes, PTAL |
Yes. I'm currently investigating this issue. |
@chaunceyjiang Hi, any update for this? thanks. |
Hi, @ericg108 I was on vacation last week. I will complete this PR this week. |
btw, is there any way to postprocess to get the expected token, like from the bytes array or messy code? |
thank you for your kindly effort @chaunceyjiang |
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
@DarkLight1337 @ywang96 The |
Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
I believe this PR broke mistral models: https://buildkite.com/organizations/vllm/analytics/suites/ci-1/tests/41bf2871-4779-8f39-b029-6db37181eed7?period=14days&tags=scm.branch%3Amain |
for token_id in token_ids: | ||
token_str = tokenizer.decode( | ||
[token_id], | ||
skip_special_tokens=skip_special_tokens, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mistral models don't support skip_special_tokens=False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's my mistake—I didn't notice that detail.
Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: Patrick von Platen <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]> Signed-off-by: avigny <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
Signed-off-by: chaunceyjiang <[email protected]>
FIX #19177