alfredplpl commited on
Commit
26cfd11
·
verified ·
1 Parent(s): 99e5e8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -36,11 +36,8 @@ def judge(message: str) -> dict:
36
  return {"判定": "—", "P(unsafe)": "-", "注意": "入力が空です"}
37
  enc = _tok(message, truncation=True, max_length=512, return_tensors="pt").to(DEVICE)
38
  p = float(torch.softmax(_model(**enc).logits, dim=-1)[0, 1])
39
- return {
40
- "判定": "⚠️ unsafe" if p >= 0.5 else "✅ safe",
41
- "P(unsafe)": f"{p:.4f}",
42
- "注意": "",
43
- }
44
 
45
 
46
  EXAMPLES = [
@@ -60,7 +57,7 @@ with gr.Blocks(title="FinGuard Input 310M Demo") as demo:
60
  )
61
  msg = gr.Textbox(label="ユーザー入力 (判定対象)", placeholder="顧客情報を扱う発話を入力...", lines=3)
62
  btn = gr.Button("判定する", variant="primary")
63
- out = gr.JSON(label="判定結果")
64
  gr.Examples(EXAMPLES, inputs=[msg])
65
  btn.click(judge, inputs=[msg], outputs=out)
66
 
 
36
  return {"判定": "—", "P(unsafe)": "-", "注意": "入力が空です"}
37
  enc = _tok(message, truncation=True, max_length=512, return_tensors="pt").to(DEVICE)
38
  p = float(torch.softmax(_model(**enc).logits, dim=-1)[0, 1])
39
+ result = "⚠️ 有害。" if p >= 0.5 else "✅ 安全。"
40
+ return result+"※本判定は金融ドメインに限ったものであり、一般的な有害性に対応したものではありません。"
 
 
 
41
 
42
 
43
  EXAMPLES = [
 
57
  )
58
  msg = gr.Textbox(label="ユーザー入力 (判定対象)", placeholder="顧客情報を扱う発話を入力...", lines=3)
59
  btn = gr.Button("判定する", variant="primary")
60
+ out = gr.Textbox(label="判定結果")
61
  gr.Examples(EXAMPLES, inputs=[msg])
62
  btn.click(judge, inputs=[msg], outputs=out)
63