Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,24 @@
|
|
| 1 |
-
from transformers import AutoTokenizer,
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
model_name = "
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 6 |
-
model =
|
| 7 |
-
fill_mask = pipeline("fill-mask", model=model, tokenizer=tokenizer)
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
gr.Interface(fn=answer,
|
| 15 |
inputs="text",
|
| 16 |
outputs="text",
|
| 17 |
-
title="μ
μ AI
|
| 18 |
-
description="
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, AutoModelForQuestionAnswering, pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
model_name = "nlpai-lab/kobert-base-v1"
|
| 5 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 6 |
+
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
|
|
|
| 7 |
|
| 8 |
+
qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer)
|
| 9 |
+
|
| 10 |
+
context = """
|
| 11 |
+
μλ₯μ λ§€λ
11μ μ
μ§Έ μ£Ό λͺ©μμΌμ μνλ©λλ€.
|
| 12 |
+
νκ΅μ₯νμ¬λ¨μ λνμμκ² κ΅κ°μ₯νκΈκ³Ό νμκΈλμΆμ μ 곡ν©λλ€.
|
| 13 |
+
μ μλͺ¨μ§μ μλ₯ μ±μ μμ£Όλ‘, μμλͺ¨μ§μ νμλΆλ λ©΄μ μΌλ‘ μ λ°ν©λλ€.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
def answer(question):
|
| 17 |
+
result = qa_pipeline(question=question, context=context)
|
| 18 |
+
return result["answer"]
|
| 19 |
|
| 20 |
gr.Interface(fn=answer,
|
| 21 |
inputs="text",
|
| 22 |
outputs="text",
|
| 23 |
+
title="μ
μ λμ°λ―Έ AI",
|
| 24 |
+
description="μ
μ κ΄λ ¨ μ§λ¬Έμ ν΄λ³΄μΈμ. μ: 'μλ₯μ μΈμ μΌ?'").launch()
|