Commit
·
ea2c349
1
Parent(s):
61f41b6
Update README.md
Browse files
README.md
CHANGED
@@ -24,10 +24,13 @@ LUKE achieves state-of-the-art results on five popular NLP benchmarks including
|
|
24 |
-------------------------------------------------------------
|
25 |
|
26 |
import torch
|
|
|
27 |
from transformers import MLukeTokenizer
|
|
|
28 |
from torch import nn
|
29 |
|
30 |
tokenizer = MLukeTokenizer.from_pretrained('studio-ousia/luke-japanese-base-lite')
|
|
|
31 |
model = torch.load('C:\\[My_luke_model_pn.pthのあるディレクトリ]\\My_luke_model_pn.pth')
|
32 |
|
33 |
text=input()
|
@@ -40,10 +43,13 @@ encoded_dict = tokenizer.encode_plus(
|
|
40 |
|
41 |
pre = model(encoded_dict['input_ids'], token_type_ids=None, attention_mask=encoded_dict['attention_mask'])
|
42 |
SOFTMAX=nn.Softmax(dim=0)
|
|
|
43 |
num=SOFTMAX(pre.logits[0])
|
|
|
44 |
if num[1]>0.5:
|
45 |
print(str(num[1]))
|
46 |
print('ポジティブ')
|
|
|
47 |
else:
|
48 |
print(str(num[1]))
|
49 |
print('ネガティブ')
|
|
|
24 |
-------------------------------------------------------------
|
25 |
|
26 |
import torch
|
27 |
+
|
28 |
from transformers import MLukeTokenizer
|
29 |
+
|
30 |
from torch import nn
|
31 |
|
32 |
tokenizer = MLukeTokenizer.from_pretrained('studio-ousia/luke-japanese-base-lite')
|
33 |
+
|
34 |
model = torch.load('C:\\[My_luke_model_pn.pthのあるディレクトリ]\\My_luke_model_pn.pth')
|
35 |
|
36 |
text=input()
|
|
|
43 |
|
44 |
pre = model(encoded_dict['input_ids'], token_type_ids=None, attention_mask=encoded_dict['attention_mask'])
|
45 |
SOFTMAX=nn.Softmax(dim=0)
|
46 |
+
|
47 |
num=SOFTMAX(pre.logits[0])
|
48 |
+
|
49 |
if num[1]>0.5:
|
50 |
print(str(num[1]))
|
51 |
print('ポジティブ')
|
52 |
+
|
53 |
else:
|
54 |
print(str(num[1]))
|
55 |
print('ネガティブ')
|