Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,21 @@
|
|
1 |
-
import
|
2 |
-
import boto3
|
3 |
-
from sagemaker.huggingface import HuggingFace
|
4 |
|
5 |
-
|
6 |
-
role = sagemaker.get_execution_role()
|
7 |
-
except ValueError:
|
8 |
-
iam = boto3.client('iam')
|
9 |
-
role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']
|
10 |
-
|
11 |
-
hyperparameters = {
|
12 |
-
'model_name_or_path':'INSAIT-Institute/BgGPT-7B-Instruct-v0.1',
|
13 |
-
'output_dir':'/opt/ml/model'
|
14 |
-
# add your remaining hyperparameters
|
15 |
-
# more info here https://github.com/huggingface/transformers/tree/v4.37.0/examples/pytorch/language-modeling
|
16 |
-
}
|
17 |
|
18 |
-
#
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
role=role,
|
28 |
-
git_config=git_config,
|
29 |
-
transformers_version='4.37.0',
|
30 |
-
pytorch_version='2.1.0',
|
31 |
-
py_version='py310',
|
32 |
-
hyperparameters = hyperparameters
|
33 |
-
)
|
34 |
|
35 |
-
|
36 |
-
|
|
|
|
1 |
+
from huggingface_hub import hf_hub_download
|
|
|
|
|
2 |
|
3 |
+
HUGGING_FACE_API_KEY = "<hugging-face-api-key-goes-here>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
# Replace this if you want to use a different model
|
6 |
+
model_id = "lmsys/fastchat-t5-3b-v1.0"
|
7 |
+
filenames = [
|
8 |
+
"pytorch_model.bin", "added_tokens.json", "config.json", "generation_config.json",
|
9 |
+
"special_tokens_map.json", "spiece.model", "tokenizer_config.json"
|
10 |
+
]
|
11 |
|
12 |
+
for filename in filenames:
|
13 |
+
downloaded_model_path = hf_hub_download(
|
14 |
+
repo_id=model_id,
|
15 |
+
filename=filename,
|
16 |
+
token=HUGGING_FACE_API_KEY
|
17 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
print(downloaded_model_path)
|
20 |
+
|
21 |
+
print(downloaded_model_path)
|