Views
No views yet
1# Load the tokenizer & the model
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3import torch
4
5tokenizer = AutoTokenizer.from_pretrained("line-corporation/line-distilbert-base-japanese", trust_remote_code=True)
6model = AutoModelForSequenceClassification.from_pretrained("liwii/fluency-score-classification-ja")
7
8# Make predictions
9input_tokens = tokenizer([
10 '黒い猫が',
11 '黒い猫がいます',
12 'あっちの方で黒い猫があくびをしています',
13 'あっちの方でで黒い猫ががあくびをしています',
14 'ある日の暮方の事である。一人の下人が、羅生門の下で雨やみを待っていた。'
15 ],
16 return_tensors='pt',
17 padding=True)
18
19output = model(**input_tokens)
20with torch.no_grad():
21 # Probabilities of [not_fluent, fluent]
22 probs = torch.nn.functional.softmax(
23 output.logits, dim=1)
24probs[:, 1] # => tensor([0.1007, 0.2416, 0.5635, 0.0453, 0.7701])| Training Loss | Epoch | Step | Validation Loss | Roc Auc |
|---|---|---|---|---|
| 0.4582 | 1.0 | 647 | 0.2887 | 0.9679 |
| 0.2664 | 2.0 | 1294 | 0.2224 | 0.9761 |
| 0.2177 | 3.0 | 1941 | 0.2047 | 0.9793 |
| 0.1899 | 4.0 | 2588 | 0.1944 | 0.9807 |
| 0.1865 | 5.0 | 3235 | 0.1912 | 0.9811 |