Fix: spm.model is missing

This commit is contained in:
tsukumi
2024-12-19 12:05:33 +09:00
parent 2833fb5eeb
commit ebd249bca8
3 changed files with 19 additions and 8 deletions

View File

@@ -87,6 +87,15 @@ def load_model(
revision=revision,
)
)
# 英語用 BERT のみ、spm.model もダウンロードする
# Fast 版の BERT トークナイザーでは不要なはずだが、念のため
if language == Languages.EN:
hf_hub_download(
repo_id=pretrained_model_name_or_path,
filename="spm.model",
cache_dir=cache_dir,
revision=revision,
)
# pretrained_model_name_or_path にファイルパスが指定された場合:
# 既にダウンロード済みという前提のもと、モデルへのローカルパスを model_path に格納する
else:
@@ -138,7 +147,7 @@ def load_tokenizer(
revision (str): モデルの Hugging Face 上の Git リビジョン。指定しない場合は最新の main ブランチの内容が利用される (デフォルト: None)
Returns:
Union[PreTrainedTokenizer, PreTrainedTokenizerFast, DebertaV2Tokenizer]: ロード済みの BERT トークナイザー
Union[PreTrainedTokenizer, PreTrainedTokenizerFast, DebertaV2TokenizerFast]: ロード済みの BERT トークナイザー
"""
# すでにロード済みの場合はそのまま返す