Commit
•
888d961
1
Parent(s):
a5e264f
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1 |
---
|
2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
+
tags:
|
4 |
+
- t5
|
5 |
+
- transformers
|
6 |
+
- pytorch
|
7 |
+
- text2text-generation
|
8 |
+
- seq2seq
|
9 |
+
language: ja
|
10 |
+
datasets: shunk031/CAMERA
|
11 |
+
pipeline_tag: text2text-generation
|
12 |
---
|
13 |
+
|
14 |
+
# タイトル生成
|
15 |
+
|
16 |
+
# 使い方 how to use
|
17 |
+
transformers, datasets, sentencepieceをinstallして、下記のコードを実行してください。
|
18 |
+
After install transformers, datasets and sentencepiece, please execute this code.
|
19 |
+
|
20 |
+
```python
|
21 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
22 |
+
import torch
|
23 |
+
|
24 |
+
tokenizer = T5Tokenizer.from_pretrained('sonoisa/t5-base-japanese')
|
25 |
+
model = T5ForConditionalGeneration.from_pretrained('Mizuiro-sakura/t5-CAMERA-title-generation')
|
26 |
+
|
27 |
+
text = "ニューラルネットワークとは人間の脳の神経回路の構造を数学的に表現する手法です。ニューラルネットワークはPythonによって構成されることが多いです。"
|
28 |
+
max_seq_length=256
|
29 |
+
token=tokenizer(text,
|
30 |
+
truncation=True,
|
31 |
+
max_length=max_seq_length,
|
32 |
+
padding="max_length")
|
33 |
+
|
34 |
+
output=model.generate(input_ids = torch.tensor(token['input_ids']).unsqueeze(0), attention_mask = torch.tensor(token['attention_mask']).unsqueeze(0))
|
35 |
+
output_decode=tokenizer.decode(output[0], skip_special_tokens=True)
|
36 |
+
|
37 |
+
print(output_decode)
|
38 |
+
```
|