0xk1h0 commited on
Commit
2f68d0b
1 Parent(s): 01436c9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md CHANGED
@@ -1,6 +1,46 @@
1
  ---
2
  library_name: peft
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ## Training procedure
5
 
6
 
 
1
  ---
2
  library_name: peft
3
  ---
4
+
5
+ ## Model Usage
6
+
7
+ ```python
8
+ import torch
9
+ import transformers
10
+ from finetune_peft import get_peft_config, PEFTArguments
11
+ from peft import get_peft_model
12
+
13
+ model_path = 'EleutherAI/pythia-6.9b-deduped'
14
+ # peft_path = 'models/codegen25_7b/checkpoint'
15
+ peft_path = '0xk1h0/pythia-6.9b-deduped-py150k-r20-LoRA'
16
+ # peft_path = 'models/alpaca-llama-7b-peft/params.p'
17
+
18
+ torch.set_default_tensor_type(torch.cuda.HalfTensor)
19
+ model = transformers.AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, cache_dir='models')
20
+ peft_config = get_peft_config(peft_args=PEFTArguments(peft_mode="lora"))
21
+ model = get_peft_model(model, peft_config)
22
+ # model.load_state_dict(torch.load(peft_path), strict=False)
23
+ torch.set_default_tensor_type(torch.cuda.FloatTensor)
24
+
25
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
26
+ batch = tokenizer("""
27
+ ### Generate AES MODE encrypt function.
28
+ """, return_tensors="pt")
29
+
30
+ with torch.no_grad():
31
+ out = model.generate(
32
+ input_ids=batch["input_ids"],
33
+ attention_mask=torch.ones_like(batch["input_ids"]),
34
+ max_length=256,
35
+ do_sample=True,
36
+ temperature = 0.4,
37
+ top_p=0.95
38
+
39
+ )
40
+ print(tokenizer.decode(out[0]))
41
+ ```
42
+
43
+
44
  ## Training procedure
45
 
46