Whisper model support & /v1/audio/transcriptions endpoint & benchmark (#16983)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com> Co-authored-by: MahmoudAshraf97 <hassouna97.ma@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
MahmoudAshraf97
gemini-code-assist[bot]
parent
3a11e7dad9
commit
581bf53e03
@@ -1027,6 +1027,23 @@ register_conv_template(
|
||||
)
|
||||
)
|
||||
|
||||
# Whisper speech-to-text template
|
||||
# Whisper uses special tokens: <|startoftranscript|>, <|en|>, <|transcribe|>, etc.
|
||||
# Audio features are processed by encoder separately, not inserted into text
|
||||
# The decoder start tokens (task, language) should be set via generation config
|
||||
register_conv_template(
|
||||
Conversation(
|
||||
name="whisper",
|
||||
system_template="",
|
||||
system_message="",
|
||||
roles=("", ""),
|
||||
sep_style=SeparatorStyle.NO_COLON_SINGLE,
|
||||
sep="",
|
||||
stop_str=["<|endoftext|>"],
|
||||
audio_token="", # Empty - audio is handled by encoder, not as text token
|
||||
)
|
||||
)
|
||||
|
||||
MODEL_TYPE_TO_TEMPLATE = {
|
||||
"internvl_chat": "internvl-2-5",
|
||||
"deepseek_vl_v2": "deepseek-vl2",
|
||||
@@ -1036,6 +1053,7 @@ MODEL_TYPE_TO_TEMPLATE = {
|
||||
"minicpmo": "minicpmo",
|
||||
"deepseek-ocr": "deepseek-ocr",
|
||||
"paddleocr_vl": "paddle-ocr",
|
||||
"whisper": "whisper",
|
||||
}
|
||||
|
||||
|
||||
@@ -1129,3 +1147,11 @@ def match_paddle_ocr(model_path: str):
|
||||
return "paddle-ocr"
|
||||
model_type = get_model_type(model_path)
|
||||
return MODEL_TYPE_TO_TEMPLATE.get(model_type)
|
||||
|
||||
|
||||
@register_conv_template_matching_function
|
||||
def match_whisper(model_path: str):
|
||||
if "whisper" in model_path.lower():
|
||||
return "whisper"
|
||||
model_type = get_model_type(model_path)
|
||||
return MODEL_TYPE_TO_TEMPLATE.get(model_type)
|
||||
|
||||
Reference in New Issue
Block a user