Update README.md
Browse files
README.md
CHANGED
@@ -28,6 +28,33 @@ More information needed
|
|
28 |
|
29 |
More information needed
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
## Training procedure
|
32 |
|
33 |
### Training hyperparameters
|
|
|
28 |
|
29 |
More information needed
|
30 |
|
31 |
+
## How to use model
|
32 |
+
|
33 |
+
1. Loading the model
|
34 |
+
|
35 |
+
'''python
|
36 |
+
import torch
|
37 |
+
from peft import PeftModel, PeftConfig
|
38 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
39 |
+
|
40 |
+
# Load peft config for pre-trained checkpoint etc.
|
41 |
+
peft_model_id = "emonty777/QLoRA-Flan-T5-Small"
|
42 |
+
|
43 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
44 |
+
|
45 |
+
# load base LLM model and tokenizer / runs on CPU
|
46 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path)
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
48 |
+
|
49 |
+
# load base LLM model and tokenizer for GPU
|
50 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path, load_in_8bit=True, device_map={"":0})
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
52 |
+
|
53 |
+
# Load the Lora model
|
54 |
+
model = PeftModel.from_pretrained(model, peft_model_id, device_map={"":0})
|
55 |
+
model.eval()
|
56 |
+
'''
|
57 |
+
|
58 |
## Training procedure
|
59 |
|
60 |
### Training hyperparameters
|