solwol's picture
Update README.md
2b95880 verified
---
tags:
- roberta
library_name: peft
datasets:
- rotten_tomatoes
pipeline_tag: text-classification
---
# Adapter `solwol/roberta-sentiment-classifier-peft` for roberta-base
<!-- PERT adapter for sentiment-classification. -->
## Usage
First, install `transformers` and `peft`:
```
pip install -U transformers peft
```
Now, the peft adapter can be loaded and activated like this:
```python
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSequenceClassification, RobertaConfig
config = RobertaConfig.from_pretrained(
"roberta-base",
id2label={0: "πŸ‘Ž", 1: "πŸ‘"}
)
model = AutoModelForSequenceClassification.from_pretrained("roberta-base", config=config)
model = PeftModel.from_pretrained(model, "solwol/roberta-sentiment-classifier-peft")
```
Next, to perform sentiment classification:
```python
from transformers import AutoTokenizer, TextClassificationPipeline
tokenizer = AutoTokenizer.from_pretrained("roberta-base")
classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
classifier("This is awesome!")
[{'label': 'πŸ‘', 'score': 0.9765560626983643}]
```