Skip to content

Commit e152f29

Browse files
khluuEC2 Default User
and
EC2 Default User
authored
[misc] Reduce number of config file requests to HuggingFace (vllm-project#12797)
Signed-off-by: EC2 Default User <[email protected]> Signed-off-by: <> Co-authored-by: EC2 Default User <[email protected]>
1 parent c786e75 commit e152f29

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

vllm/transformers_utils/config.py

+23-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Any, Dict, Optional, Type, Union
88

99
import huggingface_hub
10-
from huggingface_hub import (file_exists, hf_hub_download,
10+
from huggingface_hub import (file_exists, hf_hub_download, list_repo_files,
1111
try_to_load_from_cache)
1212
from huggingface_hub.utils import (EntryNotFoundError, HfHubHTTPError,
1313
LocalEntryNotFoundError,
@@ -395,18 +395,28 @@ def get_sentence_transformer_tokenizer_config(model: str,
395395
- dict: A dictionary containing the configuration parameters
396396
for the Sentence Transformer BERT model.
397397
"""
398-
for config_name in [
399-
"sentence_bert_config.json",
400-
"sentence_roberta_config.json",
401-
"sentence_distilbert_config.json",
402-
"sentence_camembert_config.json",
403-
"sentence_albert_config.json",
404-
"sentence_xlm-roberta_config.json",
405-
"sentence_xlnet_config.json",
406-
]:
407-
encoder_dict = get_hf_file_to_dict(config_name, model, revision)
408-
if encoder_dict:
409-
break
398+
sentence_transformer_config_files = [
399+
"sentence_bert_config.json",
400+
"sentence_roberta_config.json",
401+
"sentence_distilbert_config.json",
402+
"sentence_camembert_config.json",
403+
"sentence_albert_config.json",
404+
"sentence_xlm-roberta_config.json",
405+
"sentence_xlnet_config.json",
406+
]
407+
try:
408+
# If model is on HuggingfaceHub, get the repo files
409+
repo_files = list_repo_files(model, revision=revision, token=HF_TOKEN)
410+
except Exception as e:
411+
logger.debug("Error getting repo files", e)
412+
repo_files = []
413+
414+
encoder_dict = None
415+
for config_name in sentence_transformer_config_files:
416+
if config_name in repo_files or Path(model).exists():
417+
encoder_dict = get_hf_file_to_dict(config_name, model, revision)
418+
if encoder_dict:
419+
break
410420

411421
if not encoder_dict:
412422
return None

0 commit comments

Comments
 (0)