vllm
vllm copied to clipboard
[Bugfix]: Fix messy code when using logprobs
FIX https://github.com/vllm-project/vllm/issues/19177
👋 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 fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.
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 ready label to the PR or enable auto-merge.
🚀
/cc @njhill PTAL
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)
[9707, 11, 1879, 0]
['Hello']
[',']
['Ġworld']
['!']
['Hello', ',', 'Ġworld', '!']
-----
Hello
,
world
!
-----
['Hello', ',', ' world', '!']
We can observe that using tokenizer.convert_ids_to_tokens() leads to messy code.
@DarkLight1337 @ywang96 @ProExpertProg PTAL.
Directly using tokenizer.convert_ids_to_tokens() does not produce human-readable text; it still needs to be passed through tokenizer.convert_tokens_to_string(). However, using tokenizer.decode() directly yields human-readable output.
The CI failures look related to detokenize changes, PTAL
The CI failures look related to detokenize changes,
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?
Hi, @ericg108 I was on vacation last week. I will complete this PR this week.
thank you for your kindly effort @chaunceyjiang
This pull request has merge conflicts that must be resolved before it can be merged. Please rebase the PR, @chaunceyjiang.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork
@DarkLight1337 @ywang96 The docker-build-image-cpu test failure is unrelated to my code. All other tests have passed.
PTAL.
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