Update app.py
Browse files
app.py
CHANGED
@@ -136,33 +136,25 @@ def load_model(model_name):
|
|
136 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
137 |
tokenizer.pad_token = tokenizer.eos_token
|
138 |
|
139 |
-
# PEFT
|
140 |
-
|
141 |
-
# TODO: LoRA, QLoRA
|
142 |
-
|
143 |
-
#peft_model = PeftModel.from_pretrained(
|
144 |
-
# model,
|
145 |
-
# adapter_name="lora",
|
146 |
-
#)
|
147 |
-
|
148 |
-
#print("### PEFT")
|
149 |
-
#peft_model.print_trainable_parameters() # trainable params: 6,815,744 || all params: 8,037,076,992 || trainable%: 0.0848
|
150 |
-
#print("###")
|
151 |
|
152 |
###
|
153 |
print("111")
|
154 |
peft_config = LoraConfig(
|
155 |
-
lora_alpha=16,
|
156 |
-
lora_dropout=0,
|
157 |
r=64,
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
160 |
)
|
161 |
print("222")
|
162 |
model = PeftModel.from_pretrained(base_model, "new_model", peft_config=peft_config)
|
163 |
print("333")
|
164 |
model = model.merge_and_unload()
|
165 |
print("444")
|
|
|
|
|
166 |
###
|
167 |
|
168 |
return model, tokenizer
|
|
|
136 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
137 |
tokenizer.pad_token = tokenizer.eos_token
|
138 |
|
139 |
+
# PEFT, LoRA, QLoRA, see https://huggingface.co/blog/mlabonne/sft-llama3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
###
|
142 |
print("111")
|
143 |
peft_config = LoraConfig(
|
|
|
|
|
144 |
r=64,
|
145 |
+
# TODO
|
146 |
+
#bias="none",
|
147 |
+
#lora_alpha=16,
|
148 |
+
#lora_dropout=0,
|
149 |
+
#task_type="CAUSAL_LM",
|
150 |
)
|
151 |
print("222")
|
152 |
model = PeftModel.from_pretrained(base_model, "new_model", peft_config=peft_config)
|
153 |
print("333")
|
154 |
model = model.merge_and_unload()
|
155 |
print("444")
|
156 |
+
model.print_trainable_parameters() # trainable params: 6,815,744 || all params: 8,037,076,992 || trainable%: 0.0848
|
157 |
+
print("555")
|
158 |
###
|
159 |
|
160 |
return model, tokenizer
|