PEFT
flan
opt
crumb commited on
Commit
fba9215
1 Parent(s): c0b49d6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +58 -0
README.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - SirNeural/flan_v2
4
+ metrics:
5
+ - perplexity
6
+ tags:
7
+ - flan
8
+ - opt
9
+ - peft
10
+ ---
11
+
12
+ ## FLAN-OPT-1.3b-LoRA
13
+
14
+ OPT was first introduced in [Open Pre-trained Transformer Language Models](https://arxiv.org/abs/2205.01068) and first released in [metaseq's repository](https://github.com/facebookresearch/metaseq) on May 3rd 2022 by Meta AI.
15
+
16
+ This model is [facebook/opt-6.7b](https://hf.co/facebook/opt-6.7b) finetuned with low-rank adapters (https://arxiv.org/abs/2106.09685) on the FLAN datasets (https://arxiv.org/pdf/2210.11416.pdf).
17
+
18
+ Low-rank adapters (r=16) finetuned over 1.8m new tokens of a FLAN task mixture, with the start of each example cut off if it was too large to fit within a 256 token context.
19
+
20
+ The model reaches a train ppl of 5.92 and an eval ppl of 5.24.
21
+
22
+ ### Inference Example (Chain-of-Thought prompt):
23
+
24
+ ```python
25
+ # %pip install -qq transformers git+https://github.com/huggingface/peft accelerate bitsandbytes
26
+ from peft import PeftModel, PeftConfig
27
+ from transformers import AutoModelForCausalLM, AutoTokenizer
28
+ peft_model_id = "crumb/FLAN-OPT-1.3b-LoRA"
29
+
30
+ config = PeftConfig.from_pretrained(peft_model_id)
31
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, low_cpu_mem_usage=True, device_map='auto')
32
+ model = PeftModel.from_pretrained(model, peft_model_id)
33
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
34
+
35
+ import torch
36
+ prompt = """
37
+ Q: Answer the following yes/no question by reasoning step-by-step. Could a dandelion suffer from hepatitis?
38
+ A: Hepatitis only affects organisms with livers. Dandelions don’t have a liver. The answer is no.
39
+
40
+ Q: Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?
41
+ A: A haiku is a japanese three-line poem. That is short enough to fit in 280 characters. The answer is yes.
42
+
43
+ Q: Answer the following yes/no question by reasoning step-by-step. Can you reach space with a Cessna?
44
+ A:
45
+ """.strip()
46
+ inputs = tokenizer([prompt], return_tensors='pt')
47
+
48
+ with torch.autocast("cuda", dtype=torch.float16):
49
+ outputs = model.generate(
50
+ input_ids=inputs.input_ids.cuda(),
51
+ attention_mask=inputs.attention_mask.cuda(),
52
+ max_new_tokens=32,
53
+ top_k=4,
54
+ penalty_alpha=0.6
55
+ )
56
+ print("\n".join(tokenizer.decode(outputs[0]).split("\n")[:prompt.count("\n")+1]))
57
+ # Cessna is a brand of aircraft. Space is beyond the atmosphere. The answer is no.
58
+ ```