Update app.py
Browse files
app.py
CHANGED
@@ -4,42 +4,49 @@ from transformers import pipeline
|
|
4 |
|
5 |
auth_token = os.environ.get("access_token")
|
6 |
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-qa-detector-distil",use_auth_token=auth_token)
|
7 |
-
|
8 |
-
|
9 |
|
10 |
|
11 |
def predict_en(q,a):
|
12 |
res = pipeline_en({"text":q, "text_pair":a})
|
13 |
return res['label'],res['score']
|
14 |
|
15 |
-
def predict_zh(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
|
23 |
with gr.Blocks() as demo:
|
24 |
gr.Markdown("""
|
25 |
-
## ChatGPT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
""")
|
27 |
with gr.Tab("English"):
|
28 |
q1 = gr.Textbox(lines=2, label='Question',value="What stops a restaurant from noting down my credit card info and using it ? No offense to restaurants . Can be generalized to anyone who I give my credit card info to . Explain like I'm five.")
|
29 |
a1 = gr.Textbox(lines=5, label='Answer',value="There are a few things that can help protect your credit card information from being misused when you give it to a restaurant or any other business:\n\nEncryption: Many businesses use encryption to protect your credit card information when it is being transmitted or stored. This means that the information is transformed into a code that is difficult for anyone to read without the right key.")
|
30 |
-
label = gr.Textbox(lines=1, label='Predicted Label 🎃')
|
31 |
-
score = gr.Textbox(lines=1, label='Prob')
|
32 |
button1 = gr.Button("🤖 Predict!")
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
-
button1.click(predict_en, inputs=[q1,a1], outputs=[label,score])
|
43 |
-
# button2.click(predict_zh, inputs=input2, outputs=output2)
|
44 |
|
45 |
demo.launch()
|
|
|
4 |
|
5 |
auth_token = os.environ.get("access_token")
|
6 |
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-qa-detector-distil",use_auth_token=auth_token)
|
7 |
+
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-qa-detector-chinese",use_auth_token=auth_token)
|
8 |
+
|
9 |
|
10 |
|
11 |
def predict_en(q,a):
|
12 |
res = pipeline_en({"text":q, "text_pair":a})
|
13 |
return res['label'],res['score']
|
14 |
|
15 |
+
def predict_zh(q,a):
|
16 |
+
res = pipeline_en({"text":q, "text_pair":a})
|
17 |
+
return res['label'],res['score']
|
18 |
+
|
19 |
+
|
|
|
20 |
|
21 |
|
22 |
with gr.Blocks() as demo:
|
23 |
gr.Markdown("""
|
24 |
+
## ChatGPT Detector 🔬 (QA version)
|
25 |
+
Visit our project on Github: [chatgpt-comparison-detection project](https://github.com/Hello-SimpleAI/chatgpt-comparison-detection)<br>
|
26 |
+
欢迎在 Github 上关注我们的 [ChatGPT 对比与检测项目](https://github.com/Hello-SimpleAI/chatgpt-comparison-detection)
|
27 |
+
|
28 |
+
This is the **QA version** detector, to detect whether an **answer** is generated by ChatGPT for certain **question**, using PLM-based classifiers.<br>
|
29 |
+
您现在使用的是**问答版**的检测器,用来判断某个问题的回答是否由ChatGPT生成,使用基于PTM的分类器来开发。
|
30 |
+
|
31 |
+
We also provide other two versions / 我们还提供了另外两种版本:
|
32 |
+
- [Sinlge-text version / 独立文本版](https://huggingface.co/spaces/Hello-SimpleAI/chatgpt-detector-single): detect whether a piece of text is ChatGPT generated, using PLM-based classifiers / 判断单条文本是否由ChatGPT生成,使用基于PTM的分类器来开发;
|
33 |
+
- [Linguistic version / 语言学版](https://huggingface.co/spaces/Hello-SimpleAI/chatgpt-detector-ling): detect whether a piece of text is ChatGPT generated, using linguistic features / 判断单条文本是否由ChatGPT生成,使用基于语言学特征的模型来开发;
|
34 |
""")
|
35 |
with gr.Tab("English"):
|
36 |
q1 = gr.Textbox(lines=2, label='Question',value="What stops a restaurant from noting down my credit card info and using it ? No offense to restaurants . Can be generalized to anyone who I give my credit card info to . Explain like I'm five.")
|
37 |
a1 = gr.Textbox(lines=5, label='Answer',value="There are a few things that can help protect your credit card information from being misused when you give it to a restaurant or any other business:\n\nEncryption: Many businesses use encryption to protect your credit card information when it is being transmitted or stored. This means that the information is transformed into a code that is difficult for anyone to read without the right key.")
|
|
|
|
|
38 |
button1 = gr.Button("🤖 Predict!")
|
39 |
+
label1 = gr.Textbox(lines=1, label='Predicted Label 🎃')
|
40 |
+
score1 = gr.Textbox(lines=1, label='Prob')
|
41 |
+
with gr.Tab("中文版"):
|
42 |
+
q2 = gr.Textbox(lines=2, label='问题',value="What stops a restaurant from noting down my credit card info and using it ? No offense to restaurants . Can be generalized to anyone who I give my credit card info to . Explain like I'm five.")
|
43 |
+
a2 = gr.Textbox(lines=5, label='回答',value="There are a few things that can help protect your credit card information from being misused when you give it to a restaurant or any other business:\n\nEncryption: Many businesses use encryption to protect your credit card information when it is being transmitted or stored. This means that the information is transformed into a code that is difficult for anyone to read without the right key.")
|
44 |
+
button2 = gr.Button("🤖 预测!")
|
45 |
+
label2 = gr.Textbox(lines=1, label='预测结果 🎃')
|
46 |
+
score2 = gr.Textbox(lines=1, label='模型概率')
|
47 |
+
|
48 |
+
button1.click(predict_en, inputs=[q1,a1], outputs=[label1,score1])
|
49 |
+
button1.click(predict_zh, inputs=[q2,a2], outputs=[label2,score2])
|
50 |
|
|
|
|
|
51 |
|
52 |
demo.launch()
|