[model] adds semantic initialization support for special tokens (#9267)

Co-authored-by: ximingxing <ximingxing@tencent.com>
This commit is contained in:
Ximing Xing
2025-10-14 17:00:48 +08:00
committed by GitHub
parent 3dbca4b533
commit c867e28093
4 changed files with 264 additions and 7 deletions

View File

@@ -175,7 +175,12 @@ def patch_model(
prepare_valuehead_model(model)
if model_args.resize_vocab:
resize_embedding_layer(model, tokenizer)
resize_embedding_layer(
model,
tokenizer,
new_special_tokens_config=getattr(model_args, "_special_token_descriptions", None),
init_special_tokens=model_args.init_special_tokens,
)
if is_trainable:
if getattr(model.config, "model_type", None) == "gemma3n":