Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,41 +1,37 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
# νκ΅μ΄
|
| 5 |
generator = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
-
model="
|
| 8 |
-
tokenizer="
|
| 9 |
-
device_map="auto"
|
| 10 |
)
|
| 11 |
|
| 12 |
-
# μ
μ μ 보 μλ΅ ν¨μ
|
| 13 |
def answer_question(prompt):
|
| 14 |
system_prompt = (
|
| 15 |
-
"λλ νκ΅
|
| 16 |
-
"
|
| 17 |
-
"κ°λ₯νλ©΄ νκ΅λͺ
, μ νλͺ
, μ§μ쑰건 λ±μ ꡬ체μ μΌλ‘ μλ €μ€.\n\n"
|
| 18 |
)
|
| 19 |
-
|
| 20 |
system_prompt + prompt,
|
| 21 |
-
max_new_tokens=
|
| 22 |
temperature=0.7,
|
| 23 |
top_p=0.9,
|
| 24 |
do_sample=True
|
| 25 |
)
|
| 26 |
-
return
|
| 27 |
|
| 28 |
-
# Gradio μΈν°νμ΄μ€ μ€μ
|
| 29 |
app = gr.Interface(
|
| 30 |
fn=answer_question,
|
| 31 |
inputs=gr.Textbox(
|
| 32 |
lines=2,
|
| 33 |
-
label="μ
μ
|
| 34 |
-
placeholder="μ:
|
| 35 |
),
|
| 36 |
outputs=gr.Textbox(label="AI λ΅λ³"),
|
| 37 |
-
title="
|
| 38 |
-
description="
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# λΉ λ₯Έ νκ΅μ΄ GPT-2 λͺ¨λΈ λ‘λ
|
| 5 |
generator = pipeline(
|
| 6 |
"text-generation",
|
| 7 |
+
model="skt/kogpt2-base-v2",
|
| 8 |
+
tokenizer="skt/kogpt2-base-v2"
|
|
|
|
| 9 |
)
|
| 10 |
|
|
|
|
| 11 |
def answer_question(prompt):
|
| 12 |
system_prompt = (
|
| 13 |
+
"λλ νκ΅ μ
μμ 보λ₯Ό μλ €μ£Όλ AIμΌ. "
|
| 14 |
+
"μ§λ¬Έμ λ§κ² κ°λ¨λͺ
λ£νκ² μ€λͺ
ν΄μ€.\n\n"
|
|
|
|
| 15 |
)
|
| 16 |
+
response = generator(
|
| 17 |
system_prompt + prompt,
|
| 18 |
+
max_new_tokens=150,
|
| 19 |
temperature=0.7,
|
| 20 |
top_p=0.9,
|
| 21 |
do_sample=True
|
| 22 |
)
|
| 23 |
+
return response[0]["generated_text"].replace(system_prompt, "").strip()
|
| 24 |
|
|
|
|
| 25 |
app = gr.Interface(
|
| 26 |
fn=answer_question,
|
| 27 |
inputs=gr.Textbox(
|
| 28 |
lines=2,
|
| 29 |
+
label="μ
μ μ§λ¬Έ μ
λ ₯",
|
| 30 |
+
placeholder="μ: μλ₯ μΌμ / νκ΅κ³΅νλ λ
Όμ μ ν / κ°μ²λ λͺ¨μ§μΈμ"
|
| 31 |
),
|
| 32 |
outputs=gr.Textbox(label="AI λ΅λ³"),
|
| 33 |
+
title="μ
μμ 보 AI (λΉ λ₯Έ λ²μ )",
|
| 34 |
+
description="CPUμμλ λΉ λ₯΄κ² μλνλ μ
μμ λ¬Έ μ±λ΄μ
λλ€."
|
| 35 |
)
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|