Downloads · 30 days
17
5% of all-time downloads
katsutaku/wrime-sentiment-analyzer
wrime-sentiment-analyzer is a text classification model from katsutaku. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as cc-by-nc-4.0.
このモデルは、日本語の文章に対して −1 (ネガティブ) 〜 +1 (ポジティブ) の感情スコアを予測する回帰モデルです。
Downloads · 30 days
17
5% of all-time downloads
All-time downloads
368
Public
Parameters
111M
890 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors445 MB · 100%
From the Hugging Face model README
このモデルは、日本語の文章に対して −1 (ネガティブ) 〜 +1 (ポジティブ) の感情スコアを予測する回帰モデルです。
tohoku-nlp/bert-base-japanese-v3をベースに、WRIME v2 データセットの読者の平均感情スコア(avg_readers.sentiment) を用いてファインチューニングしています。
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_id = "katsutaku/wrime-sentiment-analyzer"
tokenizer = AutoTokenizer.from_pretrained(model_id)
# trust_remote_code=True は必須.モデルが独自のクラス(TanhBertRegressor)を使用
model = AutoModelForSequenceClassification.from_pretrained(model_id, trust_remote_code=True)
model.to(device)
model.eval()
text = "とても助かりました、ありがとうございます!"
inputs = tokenizer(text, return_tensors="pt",
truncation=True,
max_length=512)
inputs.to(device)
with torch.no_grad():
outputs = model(**inputs)
score = outputs.logits.squeeze().item()