devvtaco commited on
Commit
531d477
ยท
verified ยท
1 Parent(s): 9e81870

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # ํ•œ๊ตญ์–ด ์ฑ„ํŒ… ๋ชจ๋ธ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ (์˜ˆ: KoAlpaca, LLaMA, Mistral ๋“ฑ)
5
+ chat = pipeline("text-generation", model="beomi/KoAlpaca-Polyglot-5.8B")
6
+
7
+ # ๋ถ„์„ ํ•จ์ˆ˜ ์ •์˜
8
+ def analyze_korean_text(text):
9
+ prompt = f"๋‹ค์Œ ๋ฌธ์žฅ์„ ๋ถ„์„ํ•˜๊ณ  ๋ฌด๋ก€ํ•˜๊ฑฐ๋‚˜ ๊ณผ๊ฒฉํ•œ ํ‘œํ˜„์ด ์žˆ์œผ๋ฉด ์ง€์ ํ•˜๊ณ , ๋” ์นœ์ ˆํ•˜๊ฒŒ ๋ฐ”๊ฟ”์ค˜:\n\n{text}"
10
+ response = chat(prompt, max_new_tokens=200)[0]['generated_text']
11
+ return response
12
+
13
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค
14
+ iface = gr.Interface(
15
+ fn=analyze_korean_text,
16
+ inputs=gr.Textbox(label="๋ถ„์„ํ•  ๋ฌธ์žฅ ์ž…๋ ฅ"),
17
+ outputs=gr.Textbox(label="๋ถ„์„ ๊ฒฐ๊ณผ"),
18
+ title="๋ฌธ์žฅ ๋ถ„์„๊ธฐ (์นœ์ ˆํ•˜๊ฒŒ ๋ฐ”๊ฟ”์ฃผ๋Š” AI)",
19
+ description="๋ฌธ์žฅ์„ ์ž…๋ ฅํ•˜๋ฉด ๋ฌด๋ก€ํ•œ ํ‘œํ˜„์„ ์ง€์ ํ•˜๊ณ  ๋” ์˜ˆ์˜ ์žˆ๊ฒŒ ๋ฐ”๊ฟ”์ฃผ๋Š” ๋„์šฐ๋ฏธ์ž…๋‹ˆ๋‹ค."
20
+ )
21
+
22
+ # ์‹คํ–‰
23
+ iface.launch()