Spaces:
Sleeping
Sleeping
Commit
·
55f12a0
1
Parent(s):
50a47fa
Add application file
Browse files- requirements.txt +6 -0
- sogo_demo.py +51 -0
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
accelerate
|
3 |
+
matplotlib
|
4 |
+
streamlit
|
5 |
+
gradio
|
6 |
+
vllm
|
sogo_demo.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from vllm import LLM, SamplingParams
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
llm = LLM(model="EQUES/JPharmatron-7B")
|
5 |
+
sampling_params = SamplingParams(temperature=0.0, max_tokens=512)
|
6 |
+
|
7 |
+
def compare_documents(doc_a, doc_b):
|
8 |
+
prompt = f"""
|
9 |
+
以下の2つの文書の間にある齟齬点(食い違い)を抽出してください。
|
10 |
+
内容の差異、言い回しの変更、意味が変わる部分に注目して簡潔にリスト化してください。
|
11 |
+
|
12 |
+
文書A:
|
13 |
+
{doc_a}
|
14 |
+
|
15 |
+
文書B:
|
16 |
+
{doc_b}
|
17 |
+
|
18 |
+
齟齬点:
|
19 |
+
"""
|
20 |
+
|
21 |
+
outputs = llm.generate(prompt, sampling_params)
|
22 |
+
res = outputs[0].outputs[0].text
|
23 |
+
res = res.split("\n\n")[0]
|
24 |
+
return res.strip()
|
25 |
+
|
26 |
+
|
27 |
+
# サンプル文挿入用の関数
|
28 |
+
def load_sample():
|
29 |
+
sample_text_a = "有効成分は37℃で30分間加熱処理した後、ろ過を行うこと。"
|
30 |
+
sample_text_b = "加熱処理後、ろ過を行う。加熱温度は35℃とする。"
|
31 |
+
return sample_text_a, sample_text_b
|
32 |
+
|
33 |
+
with gr.Blocks() as demo:
|
34 |
+
gr.Markdown("## 📝 文書齟齬チェックAI(Gradioデモ)")
|
35 |
+
|
36 |
+
with gr.Row():
|
37 |
+
sample_button = gr.Button("サンプル1を利用")
|
38 |
+
|
39 |
+
with gr.Row():
|
40 |
+
input_a = gr.Textbox(label="文書A(元文書)", lines=10, placeholder="ここに原文を入力")
|
41 |
+
input_b = gr.Textbox(label="文書B(比較対象)", lines=10, placeholder="ここに修正版を入力")
|
42 |
+
|
43 |
+
output = gr.Textbox(label="🔍 抽出された齟齬点", lines=10)
|
44 |
+
|
45 |
+
with gr.Row():
|
46 |
+
run_button = gr.Button("差分を確認する")
|
47 |
+
|
48 |
+
run_button.click(fn=compare_documents, inputs=[input_a, input_b], outputs=output)
|
49 |
+
sample_button.click(fn=load_sample, inputs=[], outputs=[input_a, input_b])
|
50 |
+
|
51 |
+
demo.launch()
|