[model] add qwen3 nothink (#8869)
This commit is contained in:
@@ -96,7 +96,7 @@ class Template:
|
||||
|
||||
def add_thought(self, content: str = "") -> str:
|
||||
r"""Add empty thought to assistant message."""
|
||||
return f"{self.thought_words[0]}\n\n{self.thought_words[1]}\n\n" + content
|
||||
return f"{self.thought_words[0]}{self.thought_words[1]}" + content
|
||||
|
||||
def remove_thought(self, content: str) -> str:
|
||||
r"""Remove thought from assistant message."""
|
||||
@@ -518,7 +518,7 @@ def register_template(
|
||||
format_prefix=format_prefix or default_prefix_formatter,
|
||||
default_system=default_system,
|
||||
stop_words=stop_words or [],
|
||||
thought_words=thought_words or ("<think>", "</think>"),
|
||||
thought_words=thought_words or ("<think>\n", "\n</think>\n\n"),
|
||||
efficient_eos=efficient_eos,
|
||||
replace_eos=replace_eos,
|
||||
replace_jinja_template=replace_jinja_template,
|
||||
@@ -579,7 +579,7 @@ def parse_template(tokenizer: "PreTrainedTokenizer") -> "Template":
|
||||
format_prefix=EmptyFormatter(slots=[prefix]) if prefix else EmptyFormatter(),
|
||||
default_system=default_system,
|
||||
stop_words=[],
|
||||
thought_words=("<think>", "</think>"),
|
||||
thought_words=("<think>\n", "\n</think>\n\n"),
|
||||
efficient_eos=False,
|
||||
replace_eos=False,
|
||||
replace_jinja_template=False,
|
||||
@@ -1750,6 +1750,22 @@ register_template(
|
||||
)
|
||||
|
||||
|
||||
# copied from qwen template
|
||||
register_template(
|
||||
name="qwen3_nothink",
|
||||
format_user=StringFormatter(slots=["<|im_start|>user\n{{content}}<|im_end|>\n<|im_start|>assistant\n"]),
|
||||
format_assistant=StringFormatter(slots=["{{content}}<|im_end|>\n"]),
|
||||
format_system=StringFormatter(slots=["<|im_start|>system\n{{content}}<|im_end|>\n"]),
|
||||
format_function=FunctionFormatter(slots=["{{content}}<|im_end|>\n"], tool_format="qwen"),
|
||||
format_observation=StringFormatter(
|
||||
slots=["<|im_start|>user\n<tool_response>\n{{content}}\n</tool_response><|im_end|>\n<|im_start|>assistant\n"]
|
||||
),
|
||||
format_tools=ToolFormatter(tool_format="qwen"),
|
||||
stop_words=["<|im_end|>"],
|
||||
replace_eos=True,
|
||||
)
|
||||
|
||||
|
||||
# copied from chatml template
|
||||
register_template(
|
||||
name="qwen2_audio",
|
||||
|
||||
@@ -2767,10 +2767,6 @@ register_model_group(
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-4B",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-4B",
|
||||
},
|
||||
"Qwen3-4B-Instruct-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-4B-Instruct-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-4B-Instruct-2507",
|
||||
},
|
||||
"Qwen3-4B-Thinking-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-4B-Thinking-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-4B-Thinking-2507",
|
||||
@@ -2791,10 +2787,6 @@ register_model_group(
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-30B-A3B",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-30B-A3B",
|
||||
},
|
||||
"Qwen3-30B-A3B-Instruct-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-30B-A3B-Instruct-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-30B-A3B-Instruct-2507",
|
||||
},
|
||||
"Qwen3-30B-A3B-Thinking-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-30B-A3B-Thinking-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-30B-A3B-Thinking-2507",
|
||||
@@ -2803,10 +2795,6 @@ register_model_group(
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-235B-A22B",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-235B-A22B",
|
||||
},
|
||||
"Qwen3-235B-A22B-Instruct-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-235B-A22B-Instruct-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-235B-A22B-Instruct-2507",
|
||||
},
|
||||
"Qwen3-235B-A22B-Thinking-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-235B-A22B-Thinking-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-235B-A22B-Thinking-2507",
|
||||
@@ -2848,6 +2836,25 @@ register_model_group(
|
||||
)
|
||||
|
||||
|
||||
register_model_group(
|
||||
models={
|
||||
"Qwen3-4B-Instruct-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-4B-Instruct-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-4B-Instruct-2507",
|
||||
},
|
||||
"Qwen3-30B-A3B-Instruct-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-30B-A3B-Instruct-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-30B-A3B-Instruct-2507",
|
||||
},
|
||||
"Qwen3-235B-A22B-Instruct-2507": {
|
||||
DownloadSource.DEFAULT: "Qwen/Qwen3-235B-A22B-Instruct-2507",
|
||||
DownloadSource.MODELSCOPE: "Qwen/Qwen3-235B-A22B-Instruct-2507",
|
||||
},
|
||||
},
|
||||
template="qwen3_nothink",
|
||||
)
|
||||
|
||||
|
||||
register_model_group(
|
||||
models={
|
||||
"Qwen2-Audio-7B": {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from dataclasses import asdict, dataclass, field
|
||||
from typing import Any, Literal, Optional, Union
|
||||
from typing import Any, Literal, Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -50,7 +50,7 @@ class RayArguments:
|
||||
default="PACK",
|
||||
metadata={"help": "The placement strategy for Ray training. Default is PACK."},
|
||||
)
|
||||
ray_init_kwargs: Optional[dict] = field(
|
||||
ray_init_kwargs: Optional[Union[dict, str]] = field(
|
||||
default=None,
|
||||
metadata={"help": "The arguments to pass to ray.init for Ray training. Default is None."},
|
||||
)
|
||||
@@ -59,10 +59,14 @@ class RayArguments:
|
||||
self.use_ray = use_ray()
|
||||
if isinstance(self.resources_per_worker, str) and self.resources_per_worker.startswith("{"):
|
||||
self.resources_per_worker = _convert_str_dict(json.loads(self.resources_per_worker))
|
||||
|
||||
if isinstance(self.ray_init_kwargs, str) and self.ray_init_kwargs.startswith("{"):
|
||||
self.ray_init_kwargs = _convert_str_dict(json.loads(self.ray_init_kwargs))
|
||||
|
||||
if self.ray_storage_filesystem is not None:
|
||||
if self.ray_storage_filesystem not in ["s3", "gs", "gcs"]:
|
||||
raise ValueError(
|
||||
f"ray_storage_filesystem must be one of ['s3', 'gs', 'gcs'], got {self.ray_storage_filesystem}"
|
||||
f"ray_storage_filesystem must be one of ['s3', 'gs', 'gcs'], got {self.ray_storage_filesystem}."
|
||||
)
|
||||
|
||||
import pyarrow.fs as fs
|
||||
|
||||
Reference in New Issue
Block a user