model: Minicpmo (#3023)
This commit is contained in:
@@ -15,6 +15,7 @@ class ChatTemplate:
|
||||
role_prefix_and_suffix: Dict[str, Tuple[str, str]]
|
||||
stop_str: List[str] = ()
|
||||
image_token: str = "<image>"
|
||||
audio_token: str = "<audio>"
|
||||
style: ChatTemplateStyle = ChatTemplateStyle.PLAIN
|
||||
|
||||
def get_prefix_and_suffix(
|
||||
@@ -253,6 +254,22 @@ register_chat_template(
|
||||
)
|
||||
)
|
||||
|
||||
# https://huggingface.co/openbmb/MiniCPM-o-2_6
|
||||
register_chat_template(
|
||||
ChatTemplate(
|
||||
name="minicpmo",
|
||||
default_system_prompt=None,
|
||||
role_prefix_and_suffix={
|
||||
"system": ("", " "),
|
||||
"user": ("user:", " "),
|
||||
"assistant": ("assistant:", "</s>"),
|
||||
},
|
||||
stop_str=("<|im_end|>", "<|endoftext|>"),
|
||||
image_token="(<image>./</image>)",
|
||||
audio_token="(<audio>./</audio>)",
|
||||
)
|
||||
)
|
||||
|
||||
# The difference between "llama-3-instruct-llava" and "llama-3-instruct" is that llava uses a different image_token.
|
||||
register_chat_template(
|
||||
ChatTemplate(
|
||||
@@ -474,12 +491,6 @@ def match_chat_ml(model_path: str):
|
||||
return get_chat_template("chatml-llava")
|
||||
|
||||
|
||||
@register_chat_template_matching_function
|
||||
def match_chat_minicpm(model_path: str):
|
||||
if "minicpm" in model_path:
|
||||
return get_chat_template("minicpmv")
|
||||
|
||||
|
||||
@register_chat_template_matching_function
|
||||
def match_chat_yi(model_path: str):
|
||||
model_path = model_path.lower()
|
||||
@@ -499,8 +510,10 @@ def match_gemma_it(model_path: str):
|
||||
@register_chat_template_matching_function
|
||||
def match_openbmb_minicpm(model_path: str):
|
||||
model_path = model_path.lower()
|
||||
if "minicpm" in model_path:
|
||||
if "minicpm-v" in model_path:
|
||||
return get_chat_template("minicpmv")
|
||||
elif "minicpm-o" in model_path:
|
||||
return get_chat_template("minicpmo")
|
||||
|
||||
|
||||
@register_chat_template_matching_function
|
||||
|
||||
Reference in New Issue
Block a user