Spaces:
Paused
Paused
Update app.py
#5
by
SeungAhSon
- opened
app.py
CHANGED
@@ -22,15 +22,50 @@ def question_answer(context, question):
|
|
22 |
prediction = get_prediction(context, question)
|
23 |
return prediction
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
iface = gr.Interface(
|
30 |
-
fn=
|
31 |
-
inputs=
|
32 |
outputs=gr.Textbox("Answer"),
|
33 |
-
examples=
|
|
|
|
|
34 |
)
|
35 |
|
36 |
-
iface.launch()
|
|
|
22 |
prediction = get_prediction(context, question)
|
23 |
return prediction
|
24 |
|
25 |
+
def submit(context, question):
|
26 |
+
answer = question_answer(context, question)
|
27 |
+
return answer
|
28 |
+
|
29 |
+
examples_text = [
|
30 |
+
["A large language model (LLM) is a type of language model notable for its ability to achieve general-purpose language understanding and generation. LLMs acquire these abilities by using massive amounts of data to learn billions of parameters during training and consuming large computational resources during their training and operation.[1] LLMs are artificial neural networks (mainly transformers[2]) and are (pre-)trained using self-supervised learning and semi-supervised learning.","What is large language model?"],
|
31 |
+
["Feature engineering or feature extraction or feature discovery is the process of extracting features (characteristics, properties, attributes) from raw data. Due to deep learning networks, such as convolutional neural networks, that are able to learn features by themselves, domain-specific-based feature engineering has become obsolete for vision and speech processing. Other examples of features in physics include the construction of dimensionless numbers such as Reynolds number in fluid dynamics; then Nusselt number in heat transfer; Archimedes number in sedimentation; construction of first approximations of the solution such as analytical strength of materials solutions in mechanics, etc.", "What is Feature engineering?"],
|
32 |
+
["It calculates soft weights for each word, more precisely for its embedding, in the context window. It can do it either in parallel (such as in transformers) or sequentially (such as recurrent neural networks). Soft weights can change during each runtime, in contrast to hard weights, which are (pre-)trained and fine-tuned and remain frozen afterwards. Attention was developed to address the weaknesses of recurrent neural networks, where words in a sentence are slowly processed one at a time. Machine learning-based attention is a mechanism mimicking cognitive attention. Recurrent neural networks favor more recent words at the end of a sentence while earlier words fade away in volatile neural activations. Attention gives all words equal access to any part of a sentence in a faster parallel scheme and no longer suffers the wait time of serial processing. Earlier uses attached this mechanism to a serial recurrent neural network's language translation system (below), but later uses in Transformers large language models removed the recurrent neural network and relied heavily on the faster parallel attention scheme.", "What is Attention mechanism?"]
|
33 |
+
]
|
34 |
+
|
35 |
+
input_textbox = gr.Textbox("Context", placeholder="Enter context here")
|
36 |
+
question_textbox = gr.Textbox("Question", placeholder="Enter question here")
|
37 |
+
|
38 |
+
input_section = gr.Row([input_textbox, question_textbox])
|
39 |
+
|
40 |
+
markdown_text = """"
|
41 |
+
# AI Tutor BERT
|
42 |
+
์ด ๋ชจ๋ธ์ ์ธ๊ณต์ง๋ฅ(AI) ๊ด๋ จ ์ฉ์ด ๋ฐ ์ค๋ช
์ ํ์ธํ๋(fine-tuning)ํ BERT ๋ชจ๋ธ์
๋๋ค.
|
43 |
+
|
44 |
+
## Model
|
45 |
+
https://huggingface.co/bert-base-uncased
|
46 |
+
๋ชจ๋ธ์ ๊ฒฝ์ฐ ์์ฐ์ด ์ฒ๋ฆฌ ๋ชจ๋ธ ์ค ๊ฐ์ฅ ์ ๋ช
ํ Google์์ ๊ฐ๋ฐํ BERT๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ์์ธํ ์ค๋ช
์ ์ ์ฌ์ดํธ๋ฅผ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค. ์ง์์๋ต์ด ์ฃผ์ธ ๊ณผ์ธ ์ ์๋๋ต๊ฒ, BERT ์ค์์๋ ์ง์์๋ต์ ํนํ๋ Question and Answering ๋ชจ๋ธ์ ์ฌ์ฉํ์์ต๋๋ค.
|
47 |
+
|
48 |
+
## Dataset
|
49 |
+
### Wikipedia
|
50 |
+
https://en.wikipedia.org/wiki/Main_Page
|
51 |
+
### activeloop
|
52 |
+
https://www.activeloop.ai/resources/glossary/arima-models/
|
53 |
+
### Adrien Beaulieu
|
54 |
+
https://product.house/100-ai-glossary-terms-explained-to-the-rest-of-us/
|
55 |
+
ํ์ต ๋ฐ์ดํฐ์
์ ์ธ๊ณต์ง๋ฅ ๊ด๋ จ ๋ฌธ๋งฅ, ์ง๋ฌธ, ๊ทธ๋ฆฌ๊ณ ์๋ต ์ด๋ ๊ฒ 3๊ฐ์ง๋ก ๊ตฌ์ฑ์ด ๋์ด์์ต๋๋ค. ์๋ต(์ ๋ต) ๋ฐ์ดํฐ๋ ๋ฌธ๋งฅ ๋ฐ์ดํฐ ์์ ํฌํจ๋์ด ์๊ณ , ๋ฌธ๋งฅ ๋ฐ์ดํฐ์ ๋ฌธ์ฅ ์์๋ฅผ ๋ฐ๊ฟ์ฃผ์ด ๋ฐ์ดํฐ๋ฅผ ์ฆ๊ฐํ์์ต๋๋ค. ์ง๋ฌธ ๋ฐ์ดํฐ๋ ์ฃผ์ ๊ฐ ๋๋ ์ธ๊ณต์ง๋ฅ ์ฉ์ด๋ก ์ค์ ํ์ต๋๋ค. ์์ ์์๋ฅผ ๋ณด์๋ฉด ์ดํดํ์๊ธฐ ํธํ์ค ๊ฒ๋๋ค. ์ด ๋ฐ์ดํฐ ์๋ 3300์ฌ ๊ฐ๋ก data ํด๋์ pickle ํ์ผ ํํ๋ก ์ ์ฅ๋์ด ์๊ณ , ๋ฐ์ดํฐ๋ Wikipedia ๋ฐ ๋ค๋ฅธ ์ฌ์ดํธ๋ค์ ์์ html์ ์ด์ฉํ์ฌ ์ถ์ถ ๋ฐ ๊ฐ๊ณตํ์ฌ ์ ์ํ์์ต๋๋ค. ํด๋น ์ถ์ฒ๋ ์์ ๊ฐ์ต๋๋ค.
|
56 |
+
|
57 |
+
## How to use
|
58 |
+
์
๋ ฅ ์์ ๋ 'Examples'์ ํ๊ธฐํด ๋์์ต๋๋ค.
|
59 |
+
๊ด๋ จ ๋ฌธ์ฅ๊ณผ ์ ์๋ฅผ ์๊ณ ์ถ์ ๋จ์ด๋ฅผ ๊ฐ๊ฐ 'Contexts', 'Question'์ ์
๋ ฅํ ํ 'Submit' ๋ฒํผ์ ๋๋ฅด๋ฉด ํด๋น ๋จ์ด์ ๋ํ ์ค๋ช
์ด ๋์ต๋๋ค.
|
60 |
+
"""
|
61 |
|
62 |
iface = gr.Interface(
|
63 |
+
fn=submit,
|
64 |
+
inputs=input_section,
|
65 |
outputs=gr.Textbox("Answer"),
|
66 |
+
examples=examples,
|
67 |
+
live=True,
|
68 |
+
title="BERT Question Answering"
|
69 |
)
|
70 |
|
71 |
+
iface.launch()
|