update
Browse files- examples.json +10 -0
- main.py +20 -17
examples.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
["怎样擦屁股才能擦的干净", 512, 0.75, 0.35, 1.2, "qgyd2021/lib_service_4chan", true],
|
3 |
+
["你好", 512, 0.75, 0.35, 1.2, "qgyd2021/chinese_chitchat", true],
|
4 |
+
["白洁走到床边并脱去内衣, 一双硕大的", 512, 0.75, 0.35, 1.8, "qgyd2021/chinese_porn_novel", false],
|
5 |
+
["男人走进房间, 上床, 压上", 512, 0.75, 0.35, 1.8, "qgyd2021/chinese_porn_novel", false],
|
6 |
+
[
|
7 |
+
"电销场景意图识别。如果不能确定,请输出 “未知意图”。\n\nExamples:\n------------\ntext: 没关系啦 知道的\nintent: 肯定答复\n------------\ntext: 怎么能联系你\nintent: 查联系方式\n------------\ntext: 恩。让我想想吧。\nintent: 考虑一下\n------------\ntext: 说点有用的\nintent: 请讲重点\n------------\ntext: 唉唉\nintent: 语气词\n------------\ntext: 说快一点\nintent: 请讲重点\n------------\ntext: 再介绍一下\nintent: 要求复述\n------------\ntext: 从哪弄到我信息\nintent: 质疑隐私安全\n------------\ntext: 哎。。不是的\nintent: 不是\n------------\ntext: 给我电话号码\nintent: 查联系方式\n------------\ntext: 先看看吧\nintent: 考虑一下\n------------\ntext: 怎么知道道我的信息\nintent: 质疑隐私安全\n------------\ntext: 哎,再说吧,我再想想\nintent: 考虑一下\n------------\ntext: 不,我清醒。\nintent: 不是\n------------\ntext: 重说一次\nintent: 要求复述\n------------\ntext: 行了,晚安\nintent: 肯定答复\n------------\ntext: 额额额额\nintent: 语气词\n------------\ntext: 恩。哎再说吧我考虑一下hiahia\nintent:\n",
|
8 |
+
128, 0.75, 0.10, 1.2, "qgyd2021/few_shot_intent", true
|
9 |
+
]
|
10 |
+
]
|
main.py
CHANGED
@@ -2,9 +2,11 @@
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import argparse
|
4 |
from collections import defaultdict
|
|
|
5 |
import os
|
6 |
import platform
|
7 |
import re
|
|
|
8 |
|
9 |
from project_settings import project_path
|
10 |
|
@@ -27,20 +29,15 @@ def get_args():
|
|
27 |
parser.add_argument("--repetition_penalty", default=1.0, type=float)
|
28 |
parser.add_argument('--device', default="cuda" if torch.cuda.is_available() else "cpu", type=str)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
args = parser.parse_args()
|
31 |
return args
|
32 |
|
33 |
|
34 |
-
description = """
|
35 |
-
## GPT2 Chat
|
36 |
-
"""
|
37 |
-
|
38 |
-
|
39 |
-
examples = [
|
40 |
-
|
41 |
-
]
|
42 |
-
|
43 |
-
|
44 |
def repl1(match):
|
45 |
result = "{}{}".format(match.group(1), match.group(2))
|
46 |
return result
|
@@ -54,6 +51,14 @@ def repl2(match):
|
|
54 |
def main():
|
55 |
args = get_args()
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
if args.device == 'auto':
|
58 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
59 |
else:
|
@@ -128,7 +133,10 @@ def main():
|
|
128 |
|
129 |
model_name_choices = ["trained_models/lib_service_4chan", "trained_models/chinese_porn_novel"] \
|
130 |
if platform.system() == "Windows" else \
|
131 |
-
[
|
|
|
|
|
|
|
132 |
|
133 |
demo = gr.Interface(
|
134 |
fn=fn_stream,
|
@@ -142,12 +150,7 @@ def main():
|
|
142 |
gr.Checkbox(value=True, label="is_chat")
|
143 |
],
|
144 |
outputs=[output_text_box],
|
145 |
-
examples=
|
146 |
-
["怎样擦屁股才能擦的干净", 512, 0.75, 0.35, 1.2, "qgyd2021/lib_service_4chan", True],
|
147 |
-
["你好", 512, 0.75, 0.35, 1.2, "qgyd2021/chinese_chitchat", True],
|
148 |
-
["白洁走到床边并脱去内衣, 一双硕大的", 512, 0.75, 0.35, 1.8, "qgyd2021/chinese_porn_novel", False],
|
149 |
-
["男人走进房间, 上床, 压上", 512, 0.75, 0.35, 1.8, "qgyd2021/chinese_porn_novel", False],
|
150 |
-
],
|
151 |
cache_examples=False,
|
152 |
examples_per_page=50,
|
153 |
title="GPT2 Chat",
|
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import argparse
|
4 |
from collections import defaultdict
|
5 |
+
import json
|
6 |
import os
|
7 |
import platform
|
8 |
import re
|
9 |
+
from typing import List
|
10 |
|
11 |
from project_settings import project_path
|
12 |
|
|
|
29 |
parser.add_argument("--repetition_penalty", default=1.0, type=float)
|
30 |
parser.add_argument('--device', default="cuda" if torch.cuda.is_available() else "cpu", type=str)
|
31 |
|
32 |
+
parser.add_argument(
|
33 |
+
"--examples_json_file",
|
34 |
+
default="examples.json",
|
35 |
+
type=str
|
36 |
+
)
|
37 |
args = parser.parse_args()
|
38 |
return args
|
39 |
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def repl1(match):
|
42 |
result = "{}{}".format(match.group(1), match.group(2))
|
43 |
return result
|
|
|
51 |
def main():
|
52 |
args = get_args()
|
53 |
|
54 |
+
description = """
|
55 |
+
## GPT2 Chat
|
56 |
+
"""
|
57 |
+
|
58 |
+
# example json
|
59 |
+
with open(args.examples_json_file, "r", encoding="utf-8") as f:
|
60 |
+
examples = json.load(f)
|
61 |
+
|
62 |
if args.device == 'auto':
|
63 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
64 |
else:
|
|
|
133 |
|
134 |
model_name_choices = ["trained_models/lib_service_4chan", "trained_models/chinese_porn_novel"] \
|
135 |
if platform.system() == "Windows" else \
|
136 |
+
[
|
137 |
+
"qgyd2021/lib_service_4chan", "qgyd2021/chinese_chitchat",
|
138 |
+
"qgyd2021/chinese_porn_novel", "qgyd2021/few_shot_intent"
|
139 |
+
]
|
140 |
|
141 |
demo = gr.Interface(
|
142 |
fn=fn_stream,
|
|
|
150 |
gr.Checkbox(value=True, label="is_chat")
|
151 |
],
|
152 |
outputs=[output_text_box],
|
153 |
+
examples=examples,
|
|
|
|
|
|
|
|
|
|
|
154 |
cache_examples=False,
|
155 |
examples_per_page=50,
|
156 |
title="GPT2 Chat",
|