Files
Lize CaiandGitHub fab85e09c2 update fluid kserve sample to use huggingface servingruntime (#3907)
* update fluid kserve demo to use huggingface servingruntime and other model.

Signed-off-by: Lize Cai <[email protected]>

* fix lint

Signed-off-by: Lize Cai <[email protected]>

* explicitly set custom servingruntime, update devshm.

Signed-off-by: Lize Cai <[email protected]>

* update the args in custom kserve hfserver

Signed-off-by: Lize Cai <[email protected]>

* address comments

Signed-off-by: Lize Cai <[email protected]>

* add return of line

Signed-off-by: Lize Cai <[email protected]>

---------

Signed-off-by: Lize Cai <[email protected]>
2024-09-23 07:00:02 -04:00

53 lines
1.5 KiB
Python

# Copyright 2023, SAP SE or an SAP affiliate company and KServe contributors
import argparse
from pathlib import Path
from huggingface_hub import snapshot_download
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_name",
default="bigscience/bloom-560m",
help="model name from huggingface",
)
parser.add_argument(
"--model_dir",
default="./models",
help="dir to download the model",
)
parser.add_argument(
"--revision",
default="main",
help="revision of the model",
)
args = vars(parser.parse_args())
model_name = args["model_name"]
revision = args["revision"]
out_dir = args["model_dir"]
tmp_model_name = model_name.replace("/", "--")
model_dir = Path(out_dir, f"models--{tmp_model_name}", "snapshots", revision)
# check the model repo and update it accordingly
allow_patterns = ["*.json", "*.safetensors", "*.model"]
# here safetensors is the preferred format.
ignore_patterns = ["*.msgpack", "*.h5", "*.bin"]
# set the path to download the model
models_path = Path(model_dir)
models_path.mkdir(parents=True, exist_ok=True)
# download the snapshot
output_dir = snapshot_download(
repo_id=model_name,
revision=revision,
allow_patterns=allow_patterns,
ignore_patterns=ignore_patterns,
local_dir=models_path,
)
print(output_dir)