Downloads · 30 days
147
1% of all-time downloads
Formzu/bert-base-japanese-jsnli
bert-base-japanese-jsnli is a text classification model from Formzu. 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-sa-4.0.
This model is a fine-tuned version of cl-tohoku/bert-base-japanese-v2 on the JSNLI dataset. It achieves the following results on the evaluation set:
Downloads · 30 days
147
1% of all-time downloads
All-time downloads
14.3K
Public
Repo size
890 MB
Likes
0
Public
Click a slice to open those files.
.bin445 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of cl-tohoku/bert-base-japanese-v2 on the JSNLI dataset. It achieves the following results on the evaluation set:
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="Formzu/bert-base-japanese-jsnli")
sequence_to_classify = "いつか世界を見る。"
candidate_labels = ['旅行', '料理', '踊り']
out = classifier(sequence_to_classify, candidate_labels, hypothesis_template="この例は{}です。")
print(out)
#{'sequence': 'いつか世界を見る。',
# 'labels': ['旅行', '料理', '踊り'],
# 'scores': [0.6758995652198792, 0.22110949456691742, 0.1029909998178482]}
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model_name = "Formzu/bert-base-japanese-jsnli"
model = AutoModelForSequenceClassification.from_pretrained(model_name).to(device)
tokenizer = AutoTokenizer.from_pretrained(model_name)
premise = "いつか世界を見る。"
label = '旅行'
hypothesis = f'この例は{label}です。'
input = tokenizer.encode(premise, hypothesis, return_tensors='pt').to(device)
with torch.no_grad():
logits = model(input)["logits"][0]
probs = logits.softmax(dim=-1)
print(probs.cpu().numpy(), logits.cpu().numpy())
#[0.68940836 0.29482093 0.01577068] [ 1.7791482 0.92968255 -1.998533 ]
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| 0.4054 | 1.0 | 16657 | 0.2141 | 0.9216 |
| 0.3297 | 2.0 | 33314 | 0.2145 | 0.9236 |
| 0.2645 | 3.0 | 49971 | 0.2085 | 0.9288 |