-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Model] Add Mistral Tokenization to improve robustness and chat encoding #7739
[Model] Add Mistral Tokenization to improve robustness and chat encoding #7739
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge). To run full CI, you can do one of these:
🚀 |
Correct, so normally when I run vllm I launch it with:
When I specify --tokenizer-mode mistral when launching this way, it will throw an hf-hub error since the model it is loading isn't a repo. |
Just fixed it - could you try again with newest commit? Think it should work now :-) |
Cool, just changed the interface to return |
Built with the updates and it works perfectly. Thank you! |
@patrickvonplaten After some testing, for some reason when using Mistral-Nemo-Instruct-2407 and using the mistral tokenizer mode I get the following error "POST /v1/chat/completions HTTP/1.1" 400 Bad Request when attempting to send a request. |
Thanks a bunch for testing it out again!! I think it should be fixed in this commit: 4e99ef4 . Can you pull again and give it a try? We usually don't allow to decode special tokens with Mistral's Nemo's tokenizer, but it seems like this is sometimes necessary for VLLM (e.g. when decoding the chat template). Changed the default policy now to ignore special tokens so that this error doesn't happen anymore. The following now works for me just fine:
with
|
Everything works properly now. It was tested with both types of tokenizers and could send chats successfully. Thank you so much for putting this together, Being able to use the Mistral Common and tokenizer directly has been something on my wishlist for a long time. |
To me it looks like the failing test is unrelated:
Any tips on how to move forward here @simon-mo ? |
…ing (vllm-project#7739) Signed-off-by: Alvant <[email protected]>
assert isinstance(prompt, list) and isinstance( | ||
prompt[0], int | ||
), "Prompt has to be either a string or a list of token ids" | ||
prompt_inputs = TextTokensPrompt( | ||
prompt=tokenizer.decode(prompt), prompt_token_ids=prompt) |
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'm currently working on refactoring some of the chat API code. @patrickvonplaten is there a particular reason why self._tokenize_prompt_input
doesn't work on the prompt tokens outputted by mistral tokenizer?
Add official MistralTokenizer
The official mistral models (from https://huggingface.co/mistralai) are not fully tested with HF tokenizers and
we it tends to happen that there are encoding / decoder and especially chat encoding problems.
Mistral models are only fully tested with https://github.com/mistralai/mistral-common which provides a robust
and simple API for encoding and chat encoding. It is designed in a very similar fashion as
openai
chat completiondesign and therefore simplifies the logic for Mistral models in
vllm/entrypoints/openai/serving_chat.py
significantly.Important: This PR is fully backwards compatible. By default Mistral models will still use Hugging Face tokenizers, however a warning is thrown when official Mistral models (those from https://huggingface.co/mistralai) are used to instead pass
--tokenizer-mode="mistral"
.The PR has been tested to work on both Tekkenizer and SPM models of Mistral. Both for offline inference and serve:
Offline Batched Inference
Completion
Chat
Server
Also both completion and chat completion server work when runnnig:
E.g. with:
TODO:
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!