Yoshiii commited on
Commit
70c3583
1 Parent(s): 42e83e7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -1
README.md CHANGED
@@ -157,4 +157,31 @@ print('\n\n', tokenizer.decode(output_tokens[0], skip_special_tokens=True))
157
  This output is like the training data. If you run without applying the Lora, it will usually look worse. If you retrain the lora, know that your new lora is not going to output the same results, despite you using the same settings.
158
  Inference should usually be deterministic when using the same lora, or using without lora.
159
 
160
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  This output is like the training data. If you run without applying the Lora, it will usually look worse. If you retrain the lora, know that your new lora is not going to output the same results, despite you using the same settings.
158
  Inference should usually be deterministic when using the same lora, or using without lora.
159
 
160
+
161
+
162
+
163
+ Also, If you want to download and use the loras from a visible folder, here's the inference script:
164
+
165
+ ```
166
+ import torch
167
+ from peft import PeftModel, PeftConfig
168
+ from transformers import AutoModelForCausalLM, AutoTokenizer
169
+
170
+ peft_model_id = "./loramodel"
171
+ config = PeftConfig.from_pretrained(peft_model_id)
172
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map='auto')
173
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
174
+
175
+ # Load the Lora model
176
+ model = PeftModel.from_pretrained(model, peft_model_id)
177
+
178
+
179
+ batch = tokenizer("Two things are infinite: ", return_tensors='pt')
180
+
181
+ with torch.cuda.amp.autocast():
182
+ output_tokens = model.generate(**batch, max_new_tokens=50)
183
+
184
+ print('\n\n', tokenizer.decode(output_tokens[0], skip_special_tokens=True))
185
+ ```
186
+
187
+ add your adapter_config.json and your adapter_model.bin to a folder in your current directory named `loramodel`, or whatever you choose.