Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to read sentence.bpe.model from local folder #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion trankit/adapter_transformers/tokenization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,15 @@ def _from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs)
if pretrained_model_name_or_path in s3_models:
# Get the vocabulary from AWS S3 bucket
for file_id, map_list in cls.pretrained_vocab_files_map.items():
vocab_files[file_id] = map_list[pretrained_model_name_or_path]
basename_from_s3 = os.path.basename(map_list[pretrained_model_name_or_path])
model_prefix = slice(len(pretrained_model_name_or_path) + 1, None)
fname = basename_from_s3 [model_prefix] # filename as mentioned on hf.co/models
model_folder_exists = os.path.isdir(pretrained_model_name_or_path)
fname_exists = os.path.exists(os.path.join(pretrained_model_name_or_path, fname))
if model_folder_exists and fname_exists:
vocab_files[file_id] = os.path.join(pretrained_model_name_or_path, fname)
else:
vocab_files[file_id] = map_list[pretrained_model_name_or_path]
if (
cls.pretrained_init_configuration
and pretrained_model_name_or_path in cls.pretrained_init_configuration
Expand Down