ruwan commited on
Commit
57291d6
·
1 Parent(s): 4ff76cb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +24 -0
README.md CHANGED
@@ -1,3 +1,27 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+ note : use original open llama tokenizer
5
+
6
+ #model_path = 'openlm-research/open_llama_3b'
7
+ model_path = 'ruwan/open-llama-sharded-1GB-7B-alpaca-vmware'
8
+ # model_path = 'openlm-research/open_llama_13b_600bt'
9
+
10
+ tokenizer = LlamaTokenizer.from_pretrained("openlm-research/open_llama_7b")
11
+ model = LlamaForCausalLM.from_pretrained(
12
+ model_path, torch_dtype=torch.float16, device_map='auto',load_in_8bit=True
13
+ )
14
+
15
+
16
+ prompt_template = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{instruction}\n\n### Response:"
17
+
18
+ prompt= 'Explain in simple terms how the attention mechanism of a transformer model works'
19
+
20
+
21
+ inputt = prompt_template.format(instruction= prompt)
22
+ input_ids = tokenizer(inputt, return_tensors="pt").input_ids.to("cuda")
23
+
24
+ output1 = model.generate(input_ids, max_length=512)
25
+ input_length = input_ids.shape[1]
26
+ output1 = output1[:, input_length:]
27
+ output= tokenizer.decode(output1[0])