Downloads · 30 days
7
19% of all-time downloads
mab/GPT2-German-sentiment
GPT2-German-sentiment is a text classification model from mab. Use it when you need a label for a piece of text. It is set up for transformers.
from transformers import AutoTokenizer, GPT2ForSequenceClassification
Downloads · 30 days
7
19% of all-time downloads
All-time downloads
36
Public
Repo size
2 GB
Likes
1
Public
Click a slice to open those files.
.pt1 GB · 66%
From the Hugging Face model README
from transformers import AutoTokenizer, GPT2ForSequenceClassification
import torch
model_name= "mab/GPT2-German-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = GPT2ForSequenceClassification.from_pretrained(model_name)
inputs = tokenizer("Mein Hund ist wunderschön", return_tensors="pt")
with torch.no_grad(): logits = model(**inputs).logits
predicted_class_id = logits.argmax().item()
class_label = model.config.id2label[predicted_class_id]
print(class_label)