Iceman08 commited on
Commit
5bde9fe
1 Parent(s): 75106f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -32
app.py CHANGED
@@ -1,36 +1,21 @@
1
- import sagemaker
2
- import boto3
3
- from sagemaker.huggingface import HuggingFace
4
 
5
- try:
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
- # git configuration to download our fine-tuning script
19
- git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.37.0'}
 
 
 
 
20
 
21
- # creates Hugging Face estimator
22
- huggingface_estimator = HuggingFace(
23
- entry_point='run_clm.py',
24
- source_dir='./examples/pytorch/language-modeling',
25
- instance_type='ml.p3.2xlarge',
26
- instance_count=1,
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
- # starting the train job
36
- huggingface_estimator.fit()
 
 
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)