Spaces:
Runtime error
Runtime error
Create app.py
Browse files
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()
|