Update README.md
Browse files
README.md
CHANGED
|
@@ -25,18 +25,20 @@ pip install -U peft
|
|
| 25 |
Now, the peft adapter can be loaded and activated like this:
|
| 26 |
|
| 27 |
```python
|
|
|
|
|
|
|
| 28 |
|
|
|
|
|
|
|
| 29 |
```
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
[More Information Needed]
|
| 35 |
-
|
| 36 |
-
## Model Card Authors [optional]
|
| 37 |
-
|
| 38 |
-
[More Information Needed]
|
| 39 |
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
| 25 |
Now, the peft adapter can be loaded and activated like this:
|
| 26 |
|
| 27 |
```python
|
| 28 |
+
from peft import PeftModel, PeftConfig
|
| 29 |
+
from transformers import AutoModelForSequenceClassification
|
| 30 |
|
| 31 |
+
model = AutoModelForSequenceClassification.from_pretrained("roberta-base")
|
| 32 |
+
model = PeftModel.from_pretrained(model, "solwol/roberta-sentiment-classifier-peft")
|
| 33 |
```
|
| 34 |
|
| 35 |
+
Now, to perform sentiment classification:
|
| 36 |
|
| 37 |
+
```python
|
| 38 |
+
from transformers import AutoTokenizer, TextClassificationPipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
tokenizer = AutoTokenizer.from_pretrained("roberta-base")
|
| 41 |
+
classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
|
| 42 |
|
| 43 |
+
classifier("This is awesome!")
|
| 44 |
+
```
|