RinInori commited on
Commit
04ec6d0
1 Parent(s): 3c8004d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -6,7 +6,20 @@ from transformers import GenerationConfig, LlamaForCausalLM, LlamaTokenizer
6
  from transformers import Trainer
7
 
8
  BASE_MODEL = "TheBloke/stable-vicuna-13B-HF"
9
- model = LlamaForCausalLM.from_pretrained(BASE_MODEL, load_in_8bit=True, torch_dtype=torch.float16, device_map="auto", offload_folder="./cache")
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  tokenizer = LlamaTokenizer.from_pretrained(BASE_MODEL)
11
  tokenizer.pad_token_id = 0
12
  tokenizer.padding_side = "left"
 
6
  from transformers import Trainer
7
 
8
  BASE_MODEL = "TheBloke/stable-vicuna-13B-HF"
9
+
10
+ # Create a custom device map
11
+ # This will vary based on the architecture of your model and the memory capacity of your GPU and CPU
12
+ device_map = {0: [0, 1, 2], 1: [3, 4, 5]}
13
+
14
+ model = LlamaForCausalLM.from_pretrained(
15
+ BASE_MODEL,
16
+ load_in_8bit=True,
17
+ load_in_8bit_fp32_cpu_offload=True,
18
+ torch_dtype=torch.float16,
19
+ device_map=device_map,
20
+ offload_folder="./cache"
21
+ )
22
+
23
  tokenizer = LlamaTokenizer.from_pretrained(BASE_MODEL)
24
  tokenizer.pad_token_id = 0
25
  tokenizer.padding_side = "left"