kakitsubata commited on
Commit
bd17397
·
verified ·
1 Parent(s): 2a5ee2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -1,20 +1,18 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # 軽量な日本語モデルを使用
5
- chatbot = pipeline("text-generation", model="rinna/japanese-gpt2-medium")
6
 
7
- def chat_fn(message):
8
- prompt = f"ユーザー: {message}\nアシスタント:"
9
- output = chatbot(prompt, max_new_tokens=100, do_sample=True, temperature=0.7)
10
- reply = output[0]["generated_text"].split("アシスタント:")[-1].strip()
11
- return reply
12
 
13
- demo = gr.Interface(
14
- fn=chat_fn,
15
- inputs=gr.Textbox(label="質問を入力"),
16
- outputs=gr.Textbox(label="返答"),
17
- )
18
 
19
- if __name__ == "__main__":
20
- demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # 日本語T5モデルをロード
5
+ pipe = pipeline("text2text-generation", model="sonoisa/t5-base-japanese")
6
 
7
+ def format_report(memo):
8
+ # プロンプトに「事故報告書風に整えてください」と指示を入れる
9
+ input_text = f"以下のメモを事故報告書の文章に整えてください:\n{memo}"
10
+ result = pipe(input_text, max_length=512, do_sample=False)
11
+ return result[0]["generated_text"]
12
 
13
+ iface = gr.Interface(fn=format_report,
14
+ inputs="text",
15
+ outputs="text",
16
+ title="事故報告書整理AI")
 
17
 
18
+ iface.launch()