Skip to content

Commit

Permalink
✨ Improve model name sanitization for Hugging Face formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Luodian committed Sep 22, 2024
1 parent b198dd7 commit 21a906a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lmms_eval/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ def sanitize_model_name(model_name: str, full_path: bool = False) -> str:
if full_path:
return re.sub(r"[\"<>:/\|\\?\*\[\]]+", "__", model_name)
else:
return re.sub(r"[\"<>:/\|\\?\*\[\]]+", "__", model_name.split("/")[-1])
parts = model_name.split("/")
last_two = "/".join(parts[-2:]) if len(parts) > 1 else parts[-1] # accommondate for models that are in Hugging Face Hub format like lmms-lab/llava-onevision-qwen2-0.5b
return re.sub(r"[\"<>:/\|\\?\*\[\]]+", "__", last_two)


def sanitize_task_name(task_name: str) -> str:
Expand Down

0 comments on commit 21a906a

Please sign in to comment.