Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions python/mlc_llm/conversation_template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@
# decouple conversation template apply from the conversation protocol
# data structure


# model preset templates
from . import (
cohere,
deepseek,
dolly,
gemma,
glm,
gorilla,
gorrilla,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There appears to be a typo in the module name gorrilla. It should probably be gorilla.

Suggested change
gorrilla,
gorilla,

gpt,
hermes,
llama,
llava,
llm_jp,
ministral3,
ministral3_reasoning,
mistral,
nemotron,
oasst,
olmo,
orion,
phi,
qwen2,
qwen3_vl,
redpajama,
rwkv,
stablelm,
Expand Down
20 changes: 20 additions & 0 deletions python/mlc_llm/conversation_template/qwen3_vl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Qwen3-VL default templates"""

from mlc_llm.protocol.conversation_protocol import Conversation, MessagePlaceholders

from .registry import ConvTemplateRegistry

# Qwen3-VL
ConvTemplateRegistry.register_conv_template(
Conversation(
name="qwen3_vl",
system_template=f"<|im_start|>system\n{MessagePlaceholders.SYSTEM.value}<|im_end|>\n",
system_message="You are a helpful assistant.",
roles={"user": "<|im_start|>user", "assistant": "<|im_start|>assistant"},
seps=["<|im_end|>\n"],
role_content_sep="\n",
role_empty_sep="\n",
stop_str=["<|endoftext|>", "<|im_end|>"],
stop_token_ids=[151643, 151645],
)
)
34 changes: 12 additions & 22 deletions python/mlc_llm/interface/gen_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Generator of mlc-chat-config.json and tokenizer configuration."""

# pylint: disable=E1101
import dataclasses
import json
import re
import shutil
Expand Down Expand Up @@ -139,10 +138,6 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
pipeline_parallel_stages=getattr(model_config, "pipeline_parallel_stages", 1),
disaggregation=getattr(model_config, "disaggregation", False),
conv_template=conversation, # type: ignore
model_task=model.model_task,
embedding_metadata=(
dataclasses.asdict(model.embedding_metadata) if model.embedding_metadata else None
),
)
# Step 2. Load `generation_config.json` and `config.json` for text-generation related configs
for generation_config_filename in ["generation_config.json", "config.json"]:
Expand All @@ -153,12 +148,7 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
for key, value in generation_config_json.items():
if hasattr(mlc_chat_config, key) and getattr(mlc_chat_config, key) is None:
setattr(mlc_chat_config, key, value)
logger.info(
"[%s] Setting %s: %s",
generation_config_filename,
bold(key),
value,
)
logger.info("[%s] Setting %s: %s", generation_config_filename, bold(key), value)
else:
logger.info("%s %s: %s", NOT_FOUND, generation_config_filename, generation_config)

Expand All @@ -178,10 +168,7 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
for item in config.parent.iterdir():
if item.is_file() and pattern.match(item.name):
logger.info(
"%s RWKV vocab file: %s. Genetating %s",
FOUND,
item,
bold("tokenizer_model"),
"%s RWKV vocab file: %s. Genetating %s", FOUND, item, bold("tokenizer_model")
)
if item.name.endswith(".txt"):
txt2rwkv_tokenizer(item, output)
Expand All @@ -206,10 +193,7 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
fast_tokenizer = AutoTokenizer.from_pretrained(str(config.parent), use_fast=True)
fast_tokenizer.backend_tokenizer.save(str(tokenizer_json_save_dest))
mlc_chat_config.tokenizer_files.append("tokenizer.json")
logger.info(
"Successfully converted `tokenizer.model` to: %s",
tokenizer_json_save_dest,
)
logger.info("Successfully converted `tokenizer.model` to: %s", tokenizer_json_save_dest)
except Exception: # pylint: disable=broad-exception-caught
logger.warning(
"Converting to `tokenizer.json` %s with the exception below. "
Expand Down Expand Up @@ -309,23 +293,30 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
"chatml",
"chatml_nosystem",
"qwen2",
"qwen3_vl",
"open_hermes_mistral",
"neural_hermes_mistral",
"llama_default",
"llama-2",
"mistral_default",
"ministral3",
"ministral3_reasoning",
"gpt2",
"codellama_completion",
"codellama_instruct",
"vicuna_v1.1",
"conv_one_shot",
"redpajama_chat",
"rwkv_world",
"rwkv",
"gorilla",
"gorilla-openfunctions-v2",
"guanaco",
"dolly",
"oasst",
"stablelm",
"stablecode_completion",
"stablecode_instruct",
"minigpt",
"moss",
"LM",
"stablelm-3b",
"gpt_bigcode",
Expand All @@ -352,5 +343,4 @@ def gen_config( # pylint: disable=too-many-locals,too-many-arguments,too-many-b
"deepseek_r1_llama",
"olmo",
"nemotron",
"llm-jp",
}
Loading