Update README.md
Browse files
README.md
CHANGED
@@ -17,11 +17,15 @@ japanese-gpt-1b-PII-masking は、 [日本語事前学習済み1B GPTモデル](
|
|
17 |
import torch
|
18 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
|
22 |
model_name = "cameltech/japanese-gpt-1b-PII-masking"
|
23 |
-
model = AutoModelForCausalLM.from_pretrained(
|
24 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
25 |
|
26 |
if torch.cuda.is_available():
|
27 |
model = model.to("cuda")
|
@@ -36,7 +40,7 @@ input_text += tokenizer.eos_token
|
|
36 |
input_text = preprocess(input_text)
|
37 |
|
38 |
with torch.no_grad():
|
39 |
-
token_ids = tokenizer.encode(
|
40 |
|
41 |
output_ids = model.generate(
|
42 |
token_ids.to(model.device),
|
@@ -48,6 +52,11 @@ output = tokenizer.decode(output_ids.tolist()[0][token_ids.size(1) :], skip_spec
|
|
48 |
output = postprocess(output)
|
49 |
|
50 |
print(output)
|
|
|
|
|
|
|
|
|
|
|
51 |
```
|
52 |
|
53 |
# Licenese
|
|
|
17 |
import torch
|
18 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
19 |
|
20 |
+
instruction = "文中の個人情報をマスキングせよ\n\n"
|
21 |
+
text = """オペレーター:ありがとうございます。カスタマーサポートセンターでございます。お名前と生年月日、ご住所を市区町村まで教えていただけますか?
|
22 |
+
顧客:あ、はい。西山...すみません、西山俊之です。生年月日は、えーっと、1983年1月23日です。東京都練馬区在住です。
|
23 |
+
オペレーター:西山俊之様、1983年1月23日生まれ、東京都練馬区にお住まいですね。確認いたしました。お電話の件につきまして、さらにご本人様確認をさせていただきます。"""
|
24 |
+
input_text = instruction + text
|
25 |
|
26 |
model_name = "cameltech/japanese-gpt-1b-PII-masking"
|
27 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
28 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
29 |
|
30 |
if torch.cuda.is_available():
|
31 |
model = model.to("cuda")
|
|
|
40 |
input_text = preprocess(input_text)
|
41 |
|
42 |
with torch.no_grad():
|
43 |
+
token_ids = tokenizer.encode(input_text, add_special_tokens=False, return_tensors="pt")
|
44 |
|
45 |
output_ids = model.generate(
|
46 |
token_ids.to(model.device),
|
|
|
52 |
output = postprocess(output)
|
53 |
|
54 |
print(output)
|
55 |
+
"""
|
56 |
+
オペレーター:ありがとうございます。カスタマーサポートセンターでございます。お名前と生年月日、ご住所を<address>まで教えていただけますか?
|
57 |
+
顧客:あ、はい。<name>です。生年月日は、えーっと、<birthday>です。<address>在住です。
|
58 |
+
オペレーター:<name>様、<birthday>生まれ、<address>にお住まいですね。確認いたしました。お電話の件につきまして、さらにご本人様確認をさせていただきます。
|
59 |
+
"""
|
60 |
```
|
61 |
|
62 |
# Licenese
|