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

feat: download only necessary model files #58

Open
wants to merge 1 commit into
base: main
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
14 changes: 13 additions & 1 deletion src/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,19 @@ def load_model(
return None
logger.info("Repo is a full fine-tuned model, loading model directly")
model = AutoModelForCausalLM.from_pretrained(
model_name_or_path, token=HF_TOKEN, **model_kwargs
model_name_or_path,
token=HF_TOKEN,
**model_kwargs,
subfolder="",
allow_patterns=[
"adapter_config.json",
"adapter_model.safetensors",
"special_tokens_map.json",
"tokenizer.json",
"tokenizer_config.json",
"training_args.bin",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need training_args to run successfully?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not always needed. Can help those that want to run custom validation scripts and usually just a few kBs. I'll remove it though for now.

"tokenizer.model",
],
Comment on lines +157 to +169
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace 'token' with 'use_auth_token' in 'from_pretrained'

The AutoModelForCausalLM.from_pretrained method does not accept a token argument. Instead, use use_auth_token=HF_TOKEN to properly authenticate with Hugging Face for private or gated models.

Apply this diff to correct the argument:

 model = AutoModelForCausalLM.from_pretrained(
     model_name_or_path,
-    token=HF_TOKEN,
+    use_auth_token=HF_TOKEN,
     **model_kwargs,
     subfolder="",
     allow_patterns=[
         "adapter_config.json",
         "adapter_model.safetensors",
         "special_tokens_map.json",
         "tokenizer.json",
         "tokenizer_config.json",
         "training_args.bin",
         "tokenizer.model",
     ],
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
model_name_or_path,
token=HF_TOKEN,
**model_kwargs,
subfolder="",
allow_patterns=[
"adapter_config.json",
"adapter_model.safetensors",
"special_tokens_map.json",
"tokenizer.json",
"tokenizer_config.json",
"training_args.bin",
"tokenizer.model",
],
model_name_or_path,
use_auth_token=HF_TOKEN,
**model_kwargs,
subfolder="",
allow_patterns=[
"adapter_config.json",
"adapter_model.safetensors",
"special_tokens_map.json",
"tokenizer.json",
"tokenizer_config.json",
"training_args.bin",
"tokenizer.model",
],

)

if "output_router_logits" in model.config.to_dict():
Expand Down