ruwan commited on
Commit
9f2101a
·
1 Parent(s): 57291d6

Update README.md

Browse files

note : use original open llama tokenizer

#model_path = 'openlm-research/open_llama_3b'
model_path = 'ruwan/open-llama-sharded-1GB-7B-alpaca-vmware'
# model_path = 'openlm-research/open_llama_13b_600bt'

tokenizer = LlamaTokenizer.from_pretrained("openlm-research/open_llama_7b")
model = LlamaForCausalLM.from_pretrained(
model_path, torch_dtype=torch.float16, device_map='auto',load_in_8bit=True
)


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:"

prompt= 'Explain in simple terms how the attention mechanism of a transformer model works'


inputt = prompt_template.format(instruction= prompt)
input_ids = tokenizer(inputt, return_tensors="pt").input_ids.to("cuda")

output1 = model.generate(input_ids, max_length=512)
input_length = input_ids.shape[1]
output1 = output1[:, input_length:]
output= tokenizer.decode(output1[0])

Files changed (1) hide show
  1. README.md +0 -24
README.md CHANGED
@@ -1,27 +1,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])
 
1
  ---
2
  license: apache-2.0
3
  ---