Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,30 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# โ
ํ๊ตญ์ด
|
| 5 |
generator = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
-
model="
|
| 8 |
-
device_map="auto"
|
| 9 |
)
|
| 10 |
|
| 11 |
-
# โ
์
์ ์ ๋ณด
|
| 12 |
def college_ai(question):
|
| 13 |
prompt = f"""๋๋ ํ๊ตญ ์
์ ์ ๋ฌธ๊ฐ์ผ.
|
| 14 |
-
ํ์์ด ์ง๋ฌธํ๋ฉด
|
| 15 |
-
|
| 16 |
|
| 17 |
์ง๋ฌธ: {question}
|
| 18 |
๋ต๋ณ:"""
|
|
|
|
| 19 |
response = generator(
|
| 20 |
prompt,
|
| 21 |
-
max_new_tokens=
|
| 22 |
do_sample=True,
|
| 23 |
-
temperature=0.
|
| 24 |
top_p=0.9,
|
| 25 |
-
repetition_penalty=1.
|
| 26 |
)
|
|
|
|
| 27 |
answer = response[0]["generated_text"].split("๋ต๋ณ:")[-1].strip()
|
| 28 |
return answer
|
| 29 |
|
|
@@ -32,12 +33,12 @@ demo = gr.Interface(
|
|
| 32 |
fn=college_ai,
|
| 33 |
inputs=gr.Textbox(
|
| 34 |
lines=2,
|
| 35 |
-
placeholder="์:
|
| 36 |
label="์
์ ๊ด๋ จ ์ง๋ฌธ ์
๋ ฅ"
|
| 37 |
),
|
| 38 |
outputs=gr.Textbox(label="AI ๋ต๋ณ"),
|
| 39 |
-
title="๐ ์
์์ ๋ณด AI (
|
| 40 |
-
description="ํ๊ตญ ๋ํ ์
์,
|
| 41 |
theme="default"
|
| 42 |
)
|
| 43 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# โ
์ด๊ฒฝ๋ ํ๊ตญ์ด ๋ชจ๋ธ (CPU์์๋ ๋น ๋ฆ)
|
| 5 |
generator = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
+
model="skt/kogpt2-base-v2"
|
|
|
|
| 8 |
)
|
| 9 |
|
| 10 |
+
# โ
์
์ ์ ๋ณด AI ํจ์
|
| 11 |
def college_ai(question):
|
| 12 |
prompt = f"""๋๋ ํ๊ตญ ์
์ ์ ๋ฌธ๊ฐ์ผ.
|
| 13 |
+
ํ์์ด ์ง๋ฌธํ๋ฉด ๊ฐ๋จํ๊ณ ์ ํํ๊ฒ ์๋ ค์ค.
|
| 14 |
+
๋๋ฌด ์ฅํฉํ์ง ๋ง๊ณ , 3~4๋ฌธ์ฅ ์ด๋ด๋ก ์ค๋ช
ํด์ค.
|
| 15 |
|
| 16 |
์ง๋ฌธ: {question}
|
| 17 |
๋ต๋ณ:"""
|
| 18 |
+
|
| 19 |
response = generator(
|
| 20 |
prompt,
|
| 21 |
+
max_new_tokens=80, # ๐น ์๋ ํฅ์
|
| 22 |
do_sample=True,
|
| 23 |
+
temperature=0.8,
|
| 24 |
top_p=0.9,
|
| 25 |
+
repetition_penalty=1.2
|
| 26 |
)
|
| 27 |
+
|
| 28 |
answer = response[0]["generated_text"].split("๋ต๋ณ:")[-1].strip()
|
| 29 |
return answer
|
| 30 |
|
|
|
|
| 33 |
fn=college_ai,
|
| 34 |
inputs=gr.Textbox(
|
| 35 |
lines=2,
|
| 36 |
+
placeholder="์: ๊ฐ์ฒ๋ ํ์๋ถ๊ต๊ณผ ์ ํ ๊ฒฝ์๋ฅ ์๋ ค์ค",
|
| 37 |
label="์
์ ๊ด๋ จ ์ง๋ฌธ ์
๋ ฅ"
|
| 38 |
),
|
| 39 |
outputs=gr.Textbox(label="AI ๋ต๋ณ"),
|
| 40 |
+
title="๐ ์
์์ ๋ณด AI (๋น ๋ฅธ ๋ฒ์ )",
|
| 41 |
+
description="ํ๊ตญ ๋ํ ์
์, ํ์๋ถ๊ต๊ณผยท์ข
ํฉยท๋
ผ์ ์ ํ ๊ด๋ จ ์ ๋ณด๋ฅผ ๋น ๋ฅด๊ฒ ์๋ ค์ฃผ๋ ์ธ๊ณต์ง๋ฅ์
๋๋ค.",
|
| 42 |
theme="default"
|
| 43 |
)
|
| 44 |
|