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

Change the default model revisions for ModelScope. #3609

Open
wants to merge 2 commits 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 fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,21 @@ def load_model(
# lazy import so that modelscope is not required for normal use.
try:
from modelscope.hub.snapshot_download import snapshot_download
from modelscope.hub.errors import NotExistError

if not os.path.exists(model_path):
model_path = snapshot_download(model_id=model_path, revision=revision)
try:
model_path = snapshot_download(
model_id=model_path, revision=revision
)
except NotExistError as e:
# Default model revision could be "master" when use ModelScope.
if revision == "main":
revision = "master"
kwargs["revision"] = revision
model_path = snapshot_download(
model_id=model_path, revision=revision
)
except ImportError as e:
warnings.warn(
"Use model from www.modelscope.cn need pip install modelscope"
Expand Down
Loading