Downloads · 30 days
37
3% of all-time downloads
krasserm/perceiver-io-txt-clf-imdb
perceiver-io-txt-clf-imdb is a text classification model from krasserm. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
This model is a Perceiver IO sentiment analysis model fine-tuned on the IMDb dataset. It is a training example of the perceiver-io library.
Downloads · 30 days
37
3% of all-time downloads
All-time downloads
1.1K
Public
Parameters
201M
1.6 GB on disk
Likes
0
Public
Click a slice to open those files.
.bin803 MB · 50%
From the Hugging Face model README
This model is a Perceiver IO sentiment analysis model fine-tuned on the IMDb dataset. It is a training example of the perceiver-io library.
The configuration of the encoder is equal to the encoder configuration of krasserm/perceiver-io-mlm-imdb, the generic decoder is configured with a classification output adapter (see building blocks).
The model can be used for sentiment analysis of movie reviews.
Training details are described here. Encoder weights are initialized with the encoder weights of krasserm/perceiver-io-mlm-imdb decoder weights are randomly initialized. In a first step, only decoder weights are trained, with encoder weights frozen. In a second step, all weights are fine-tuned. Training was done with PyTorch Lightning and the resulting checkpoint was converted to this 🤗 model with a library-specific conversion utility.
To use this model you first need to install
the perceiver-io library with extension text.
pip install perceiver-io[text]
Then the model can be used with PyTorch. Either use the model and tokenizer directly
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from perceiver.model.text import classifier # auto-class registration
repo_id = "krasserm/perceiver-io-txt-clf-imdb"
model = AutoModelForSequenceClassification.from_pretrained(repo_id)
tokenizer = AutoTokenizer.from_pretrained(repo_id)
mini_reviews = [
"I've seen this movie yesterday and it was really boring.",
"I can recommend this movie to all fantasy movie lovers.",
]
encoding = tokenizer(mini_reviews, padding=True, return_tensors="pt")
logits = model(**encoding).logits
predictions = logits.argmax(dim=-1)
for r, p in zip(mini_reviews, predictions.numpy()):
print(f"{r} ({model.config.id2label[p]})")
I've seen this movie yesterday and it was really boring. (NEGATIVE)
I can recommend this movie to all fantasy movie lovers. (POSITIVE)
or use a sentiment-analysis pipeline:
from transformers import pipeline
from perceiver.model.text import classifier # auto-class registration
repo_id = "krasserm/perceiver-io-txt-clf-imdb"
mini_reviews = [
"I've seen this movie yesterday and it was really boring.",
"I can recommend this movie to all fantasy movie lovers.",
]
sentiment_pipeline = pipeline("sentiment-analysis", model=repo_id)
predictions = sentiment_pipeline(mini_reviews)
for r, p in zip(mini_reviews, predictions):
print(f"{r} ({p['label']})")
I've seen this movie yesterday and it was really boring. (NEGATIVE)
I can recommend this movie to all fantasy movie lovers. (POSITIVE)
The krasserm/perceiver-io-mlm-imdb model has been created from a training checkpoint with:
from perceiver.model.text.classifier import convert_imdb_classifier_checkpoint
convert_imdb_classifier_checkpoint(
save_dir="krasserm/perceiver-io-txt-clf-imdb",
ckpt_url="https://martin-krasser.com/perceiver/logs-0.8.0/txt_clf/version_1/checkpoints/epoch=006-val_loss=0.156.ckpt",
tokenizer_name="krasserm/perceiver-io-mlm",
push_to_hub=True,
)