Zayt commited on
Commit
9fa79f6
1 Parent(s): 249512a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -0
README.md CHANGED
@@ -2,3 +2,28 @@
2
  license: apache-2.0
3
  ---
4
  Using LoRA to finetune [bigsciene/bloom-1b7](https://huggingface.co/bigscience/bloom-1b7) model with [oasst1](https://huggingface.co/datasets/OpenAssistant/oasst1) data.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  ---
4
  Using LoRA to finetune [bigsciene/bloom-1b7](https://huggingface.co/bigscience/bloom-1b7) model with [oasst1](https://huggingface.co/datasets/OpenAssistant/oasst1) data.
5
+
6
+ Sample code to run
7
+ ```python
8
+ from transformers import AutoTokenizer, AutoModelForCausalLM
9
+
10
+ tokenizer = AutoTokenizer.from_pretrained("Zayt/bloom-1b7-lora-merged-oasst")
11
+ model = AutoModelForCausalLM.from_pretrained("Zayt/bloom-1b7-lora-merged-oasst", device_map='auto', torch_dtype=torch.float16)
12
+
13
+ prompt_format = "### Input:\n{human}\n\n### Response:\n"
14
+ text = prompt_format.format(**{"human": "what is the weather today?"})
15
+ inputs = tokenizer(text, return_tensors='pt').to(model.device)
16
+ input_length = inputs.input_ids.shape[1]
17
+
18
+ with torch.no_grad():
19
+ outputs = model.generate(
20
+ **inputs, max_new_tokens=400, do_sample=True, temperature=0.5, top_k=50, return_dict_in_generate=True, no_repeat_ngram_size=5,
21
+ pad_token_id=tokenizer.pad_token_id,
22
+ bos_token_id=tokenizer.bos_token_id,
23
+ eos_token_id=tokenizer.eos_token_id
24
+ )
25
+ token = outputs.sequences[0, input_length:]
26
+ output_str = tokenizer.decode(token)
27
+
28
+ print(output_str)
29
+ ```