mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-12-16 20:00:36 +08:00
[model] support GLM4.6v (#9586)
This commit is contained in:
@@ -199,9 +199,12 @@ class Template:
|
||||
logger.info_rank0(f"Add pad token: {tokenizer.pad_token}")
|
||||
|
||||
if stop_words:
|
||||
num_added_tokens = tokenizer.add_special_tokens(
|
||||
dict(additional_special_tokens=stop_words), replace_additional_special_tokens=False
|
||||
)
|
||||
try:
|
||||
num_added_tokens = tokenizer.add_special_tokens(
|
||||
dict(additional_special_tokens=stop_words), replace_additional_special_tokens=False
|
||||
)
|
||||
except TypeError:
|
||||
num_added_tokens = tokenizer.add_special_tokens(dict(additional_special_tokens=stop_words))
|
||||
logger.info_rank0("Add {} to stop words.".format(",".join(stop_words)))
|
||||
if num_added_tokens > 0:
|
||||
logger.warning_rank0("New tokens have been added, make sure `resize_vocab` is True.")
|
||||
|
||||
@@ -969,6 +969,14 @@ register_model_group(
|
||||
DownloadSource.DEFAULT: "zai-org/GLM-4.1V-9B-Thinking",
|
||||
DownloadSource.MODELSCOPE: "ZhipuAI/GLM-4.1V-9B-Thinking",
|
||||
},
|
||||
"GLM-4.6V": {
|
||||
DownloadSource.DEFAULT: "zai-org/GLM-4.6V",
|
||||
DownloadSource.MODELSCOPE: "ZhipuAI/GLM-4.6V",
|
||||
},
|
||||
"GLM-4.6V-Flash": {
|
||||
DownloadSource.DEFAULT: "zai-org/GLM-4.6V-Flash",
|
||||
DownloadSource.MODELSCOPE: "ZhipuAI/GLM-4.6V-Flash",
|
||||
},
|
||||
},
|
||||
template="glm4v",
|
||||
multimodal=True,
|
||||
|
||||
@@ -78,8 +78,11 @@ def run_sft(
|
||||
|
||||
# Compatible with Transformers v4 and Transformers v5
|
||||
if is_transformers_version_greater_than("5.0.0RC0"):
|
||||
extra_special_tokens = getattr(tokenizer, "_extra_special_tokens", [])
|
||||
extra_ids = tokenizer.convert_tokens_to_ids(extra_special_tokens)
|
||||
extra_ids = getattr(tokenizer, "additional_special_tokens_ids", None)
|
||||
if not isinstance(extra_ids, list):
|
||||
extra_special_tokens = getattr(tokenizer, "_extra_special_tokens", [])
|
||||
string_tokens = [str(t) for t in extra_special_tokens]
|
||||
extra_ids = tokenizer.convert_tokens_to_ids(string_tokens)
|
||||
all_eos_ids = [tokenizer.eos_token_id] + [i for i in extra_ids if i != -1]
|
||||
unique_eos_ids = list(dict.fromkeys(all_eos_ids))
|
||||
gen_kwargs["eos_token_id"] = unique_eos_ids
|
||||
|
||||
Reference in New Issue
Block a user