-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Changes from all commits
f64f664
99abde0
441628b
3d13b50
b2f2b2f
e2b4f29
d6bb4d8
3d046b6
cfbe3cd
8c7d0cf
fb092dc
9e2df7b
662e1ce
a56425e
a3744fe
513b4f5
6981440
373bbe7
bd00d7d
1ae7b5b
ba4d770
59dd456
73a8341
0221276
2dee65b
f32c3db
a7a282d
5460ab6
ba290a4
1780de7
e0e9de1
7034e3a
4e543f8
0a3ccb4
dd943da
5dd4458
5c469d6
9e6e239
18cff00
f711795
31a04a9
7a02d3b
b921956
ec3f035
d18dc1a
908beed
39a9234
911ec07
002d0cf
ba25ce7
4dbf270
e1a190c
50296c5
cb48bfc
3d43014
1481229
4963015
25ceeb1
4e99ef4
91e5027
61c1817
daf9a25
e3c8046
eba5658
ba08ee6
b905f1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,15 +388,21 @@ def chat( | |
conversations, _ = parse_chat_messages(messages, model_config, | ||
tokenizer) | ||
|
||
prompts = apply_chat_template( | ||
prompt = apply_chat_template( | ||
tokenizer, | ||
conversations, | ||
chat_template=chat_template, | ||
add_generation_prompt=add_generation_prompt) | ||
|
||
inputs: PromptInputs | ||
if isinstance(prompt, list) and isinstance(prompt[0], int): | ||
inputs = TokensPrompt(prompt_token_ids=prompt) | ||
else: | ||
inputs = TextPrompt(prompt=prompt) | ||
|
||
return self.generate( | ||
prompts, | ||
sampling_params, | ||
inputs, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. passing prompts as string was deprecated anyways I believe |
||
sampling_params=sampling_params, | ||
use_tqdm=use_tqdm, | ||
lora_request=lora_request, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ | |
FunctionCall, ToolCall, UsageInfo) | ||
from vllm.entrypoints.openai.serving_engine import (LoRAModulePath, | ||
OpenAIServing, | ||
PromptAdapterPath) | ||
PromptAdapterPath, | ||
TextTokensPrompt) | ||
from vllm.inputs import TokensPrompt | ||
from vllm.logger import init_logger | ||
from vllm.multimodal import MultiModalDataDict | ||
|
@@ -130,13 +131,22 @@ async def create_chat_completion( | |
guided_decode_logits_processor = ( | ||
await self._guided_decode_logits_processor(request, tokenizer)) | ||
|
||
prompt_inputs = self._tokenize_prompt_input( | ||
request, | ||
tokenizer, | ||
prompt, | ||
truncate_prompt_tokens=request.truncate_prompt_tokens, | ||
add_special_tokens=request.add_special_tokens, | ||
) | ||
if isinstance(prompt, str): | ||
prompt_inputs = self._tokenize_prompt_input( | ||
request, | ||
tokenizer, | ||
prompt, | ||
truncate_prompt_tokens=request.truncate_prompt_tokens, | ||
add_special_tokens=request.add_special_tokens, | ||
) | ||
else: | ||
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) | ||
Comment on lines
+143
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
assert prompt_inputs is not None | ||
|
||
sampling_params = request.to_sampling_params( | ||
tokenizer, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
from vllm.transformers_utils.tokenizers.baichuan import BaichuanTokenizer | ||
from vllm.transformers_utils.tokenizers.mistral import MistralTokenizer | ||
|
||
__all__ = [ | ||
"BaichuanTokenizer", | ||
] | ||
__all__ = ["BaichuanTokenizer", "MistralTokenizer"] |
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.
Tested and passes with tokenizer_mode="mistral"