updating the inference section
Browse files
README.md
CHANGED
|
@@ -57,20 +57,24 @@ Users should:
|
|
| 57 |
## How to Get Started with the Model
|
| 58 |
|
| 59 |
```python
|
| 60 |
-
|
| 61 |
-
from peft import PeftModel
|
|
|
|
| 62 |
|
| 63 |
peft_model_id = "Jay24-AI/bloom-3b-lora-tagger"
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 66 |
|
| 67 |
-
# Load
|
| 68 |
-
model = PeftModel.from_pretrained(
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
```
|
| 75 |
|
| 76 |
## Training Details
|
|
|
|
| 57 |
## How to Get Started with the Model
|
| 58 |
|
| 59 |
```python
|
| 60 |
+
import torch
|
| 61 |
+
from peft import PeftModel, PeftConfig
|
| 62 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 63 |
|
| 64 |
peft_model_id = "Jay24-AI/bloom-3b-lora-tagger"
|
| 65 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
| 66 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map='auto')
|
| 67 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
| 68 |
|
| 69 |
+
# Load the Lora model
|
| 70 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
| 71 |
|
| 72 |
+
batch = tokenizer("“The only way to do great work is to love what you do.” ->:", return_tensors='pt')
|
| 73 |
+
|
| 74 |
+
with torch.cuda.amp.autocast():
|
| 75 |
+
output_tokens = model.generate(**batch, max_new_tokens=50)
|
| 76 |
+
|
| 77 |
+
print('\n\n', tokenizer.decode(output_tokens[0], skip_special_tokens=True))
|
| 78 |
```
|
| 79 |
|
| 80 |
## Training Details
|