Adapter solwol/roberta-sentiment-classifier-peft
for roberta-base
Usage
First, install transformers
and peft
:
pip install -U transformers peft
Now, the peft adapter can be loaded and activated like this:
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:
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}]
- Downloads last month
- 0
Inference API (serverless) does not yet support peft models for this pipeline type.