jaymojnidar commited on
Commit
5c9adbd
1 Parent(s): 7138f42

logging in

Browse files
Files changed (1) hide show
  1. model.py +13 -2
model.py CHANGED
@@ -1,21 +1,32 @@
 
1
  from threading import Thread
2
  from typing import Iterator
3
 
4
  import torch
5
  from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
 
6
 
7
  # model_id = 'meta-llama/Llama-2-13b-chat-hf'
8
  model_id = 'meta-llama/Llama-2-7b-chat-hf'
9
 
10
  if not torch.cuda.is_available():
11
- config = AutoConfig.from_pretrained(model_id)
 
 
 
 
 
 
 
 
12
  config.pretraining_tp = 1
13
  model = AutoModelForCausalLM.from_pretrained(
14
  model_id,
15
  config=config,
16
  torch_dtype=torch.float16,
17
  load_in_4bit=True,
18
- device_map='auto'
 
19
  )
20
  else:
21
  model = None
 
1
+ import os
2
  from threading import Thread
3
  from typing import Iterator
4
 
5
  import torch
6
  from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
7
+ from huggingface_hub import login
8
 
9
  # model_id = 'meta-llama/Llama-2-13b-chat-hf'
10
  model_id = 'meta-llama/Llama-2-7b-chat-hf'
11
 
12
  if not torch.cuda.is_available():
13
+ tok = os.environ['HF_TOKEN']
14
+ login(new_session=True,
15
+ write_permission=False,
16
+ token=tok
17
+
18
+ #, token="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"
19
+ )
20
+
21
+ config = AutoConfig.from_pretrained(model_id, use_auth_token=True)
22
  config.pretraining_tp = 1
23
  model = AutoModelForCausalLM.from_pretrained(
24
  model_id,
25
  config=config,
26
  torch_dtype=torch.float16,
27
  load_in_4bit=True,
28
+ device_map='auto',
29
+ use_auth_token=True
30
  )
31
  else:
32
  model = None