Spaces:
Paused
Paused
CountingMstar
commited on
Commit
โข
5f6fcc3
1
Parent(s):
9dab2e1
Update app.py
Browse files
app.py
CHANGED
@@ -26,22 +26,17 @@ def submit(context, question):
|
|
26 |
answer = question_answer(context, question)
|
27 |
return answer
|
28 |
|
29 |
-
|
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
|
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 |
-
|
36 |
-
question_textbox = gr.Textbox("Question", placeholder="Enter question here")
|
37 |
|
38 |
-
input_section = gr.Row([input_textbox, question_textbox])
|
39 |
|
40 |
-
|
41 |
-
"""
|
42 |
# AI Tutor BERT
|
43 |
์ด ๋ชจ๋ธ์ ์ธ๊ณต์ง๋ฅ(AI) ๊ด๋ จ ์ฉ์ด ๋ฐ ์ค๋ช
์ ํ์ธํ๋(fine-tuning)ํ BERT ๋ชจ๋ธ์
๋๋ค.
|
44 |
-
|
45 |
## Model
|
46 |
https://huggingface.co/bert-base-uncased
|
47 |
๋ชจ๋ธ์ ๊ฒฝ์ฐ ์์ฐ์ด ์ฒ๋ฆฌ ๋ชจ๋ธ ์ค ๊ฐ์ฅ ์ ๋ช
ํ Google์์ ๊ฐ๋ฐํ BERT๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ์์ธํ ์ค๋ช
์ ์ ์ฌ์ดํธ๋ฅผ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค. ์ง์์๋ต์ด ์ฃผ์ธ ๊ณผ์ธ ์ ์๋๋ต๊ฒ, BERT ์ค์์๋ ์ง์์๋ต์ ํนํ๋ Question and Answering ๋ชจ๋ธ์ ์ฌ์ฉํ์์ต๋๋ค.
|
@@ -54,19 +49,18 @@ gr.Markdown(
|
|
54 |
### Adrien Beaulieu
|
55 |
https://product.house/100-ai-glossary-terms-explained-to-the-rest-of-us/
|
56 |
ํ์ต ๋ฐ์ดํฐ์
์ ์ธ๊ณต์ง๋ฅ ๊ด๋ จ ๋ฌธ๋งฅ, ์ง๋ฌธ, ๊ทธ๋ฆฌ๊ณ ์๋ต ์ด๋ ๊ฒ 3๊ฐ์ง๋ก ๊ตฌ์ฑ์ด ๋์ด์์ต๋๋ค. ์๋ต(์ ๋ต) ๋ฐ์ดํฐ๋ ๋ฌธ๋งฅ ๋ฐ์ดํฐ ์์ ํฌํจ๋์ด ์๊ณ , ๋ฌธ๋งฅ ๋ฐ์ดํฐ์ ๋ฌธ์ฅ ์์๋ฅผ ๋ฐ๊ฟ์ฃผ์ด ๋ฐ์ดํฐ๋ฅผ ์ฆ๊ฐํ์์ต๋๋ค. ์ง๋ฌธ ๋ฐ์ดํฐ๋ ์ฃผ์ ๊ฐ ๋๋ ์ธ๊ณต์ง๋ฅ ์ฉ์ด๋ก ์ค์ ํ์ต๋๋ค. ์์ ์์๋ฅผ ๋ณด์๋ฉด ์ดํดํ์๊ธฐ ํธํ์ค ๊ฒ๋๋ค. ์ด ๋ฐ์ดํฐ ์๋ 3300์ฌ ๊ฐ๋ก data ํด๋์ pickle ํ์ผ ํํ๋ก ์ ์ฅ๋์ด ์๊ณ , ๋ฐ์ดํฐ๋ Wikipedia ๋ฐ ๋ค๋ฅธ ์ฌ์ดํธ๋ค์ ์์ html์ ์ด์ฉํ์ฌ ์ถ์ถ ๋ฐ ๊ฐ๊ณตํ์ฌ ์ ์ํ์์ต๋๋ค. ํด๋น ์ถ์ฒ๋ ์์ ๊ฐ์ต๋๋ค.
|
57 |
-
|
58 |
## How to use
|
59 |
์
๋ ฅ ์์ ๋ 'Examples'์ ํ๊ธฐํด ๋์์ต๋๋ค.
|
60 |
๊ด๋ จ ๋ฌธ์ฅ๊ณผ ์ ์๋ฅผ ์๊ณ ์ถ์ ๋จ์ด๋ฅผ ๊ฐ๊ฐ 'Contexts', 'Question'์ ์
๋ ฅํ ํ 'Submit' ๋ฒํผ์ ๋๋ฅด๋ฉด ํด๋น ๋จ์ด์ ๋ํ ์ค๋ช
์ด ๋์ต๋๋ค.
|
61 |
-
"""
|
62 |
-
|
63 |
iface = gr.Interface(
|
64 |
fn=submit,
|
65 |
-
inputs=
|
66 |
outputs=gr.Textbox("Answer"),
|
67 |
-
examples=
|
68 |
-
live=True,
|
69 |
-
title="BERT Question Answering"
|
70 |
)
|
71 |
|
72 |
iface.launch()
|
|
|
26 |
answer = question_answer(context, question)
|
27 |
return answer
|
28 |
|
29 |
+
examples = [
|
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 |
|
|
|
36 |
|
37 |
+
markdown_text = """
|
|
|
38 |
# AI Tutor BERT
|
39 |
์ด ๋ชจ๋ธ์ ์ธ๊ณต์ง๋ฅ(AI) ๊ด๋ จ ์ฉ์ด ๋ฐ ์ค๋ช
์ ํ์ธํ๋(fine-tuning)ํ BERT ๋ชจ๋ธ์
๋๋ค.
|
|
|
40 |
## Model
|
41 |
https://huggingface.co/bert-base-uncased
|
42 |
๋ชจ๋ธ์ ๊ฒฝ์ฐ ์์ฐ์ด ์ฒ๋ฆฌ ๋ชจ๋ธ ์ค ๊ฐ์ฅ ์ ๋ช
ํ Google์์ ๊ฐ๋ฐํ BERT๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ์์ธํ ์ค๋ช
์ ์ ์ฌ์ดํธ๋ฅผ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค. ์ง์์๋ต์ด ์ฃผ์ธ ๊ณผ์ธ ์ ์๋๋ต๊ฒ, BERT ์ค์์๋ ์ง์์๋ต์ ํนํ๋ Question and Answering ๋ชจ๋ธ์ ์ฌ์ฉํ์์ต๋๋ค.
|
|
|
49 |
### Adrien Beaulieu
|
50 |
https://product.house/100-ai-glossary-terms-explained-to-the-rest-of-us/
|
51 |
ํ์ต ๋ฐ์ดํฐ์
์ ์ธ๊ณต์ง๋ฅ ๊ด๋ จ ๋ฌธ๋งฅ, ์ง๋ฌธ, ๊ทธ๋ฆฌ๊ณ ์๋ต ์ด๋ ๊ฒ 3๊ฐ์ง๋ก ๊ตฌ์ฑ์ด ๋์ด์์ต๋๋ค. ์๋ต(์ ๋ต) ๋ฐ์ดํฐ๋ ๋ฌธ๋งฅ ๋ฐ์ดํฐ ์์ ํฌํจ๋์ด ์๊ณ , ๋ฌธ๋งฅ ๋ฐ์ดํฐ์ ๋ฌธ์ฅ ์์๋ฅผ ๋ฐ๊ฟ์ฃผ์ด ๋ฐ์ดํฐ๋ฅผ ์ฆ๊ฐํ์์ต๋๋ค. ์ง๋ฌธ ๋ฐ์ดํฐ๋ ์ฃผ์ ๊ฐ ๋๋ ์ธ๊ณต์ง๋ฅ ์ฉ์ด๋ก ์ค์ ํ์ต๋๋ค. ์์ ์์๋ฅผ ๋ณด์๋ฉด ์ดํดํ์๊ธฐ ํธํ์ค ๊ฒ๋๋ค. ์ด ๋ฐ์ดํฐ ์๋ 3300์ฌ ๊ฐ๋ก data ํด๋์ pickle ํ์ผ ํํ๋ก ์ ์ฅ๋์ด ์๊ณ , ๋ฐ์ดํฐ๋ Wikipedia ๋ฐ ๋ค๋ฅธ ์ฌ์ดํธ๋ค์ ์์ html์ ์ด์ฉํ์ฌ ์ถ์ถ ๋ฐ ๊ฐ๊ณตํ์ฌ ์ ์ํ์์ต๋๋ค. ํด๋น ์ถ์ฒ๋ ์์ ๊ฐ์ต๋๋ค.
|
|
|
52 |
## How to use
|
53 |
์
๋ ฅ ์์ ๋ 'Examples'์ ํ๊ธฐํด ๋์์ต๋๋ค.
|
54 |
๊ด๋ จ ๋ฌธ์ฅ๊ณผ ์ ์๋ฅผ ์๊ณ ์ถ์ ๋จ์ด๋ฅผ ๊ฐ๊ฐ 'Contexts', 'Question'์ ์
๋ ฅํ ํ 'Submit' ๋ฒํผ์ ๋๋ฅด๋ฉด ํด๋น ๋จ์ด์ ๋ํ ์ค๋ช
์ด ๋์ต๋๋ค.
|
55 |
+
"""
|
56 |
+
input_col = gr.Column([gr.Textbox("Context"), gr.Textbox("Question"), gr.Markdown(markdown_text)])
|
57 |
iface = gr.Interface(
|
58 |
fn=submit,
|
59 |
+
inputs=input_col,
|
60 |
outputs=gr.Textbox("Answer"),
|
61 |
+
examples=examples,
|
62 |
+
live=True, # Set live to True to use the submit button
|
63 |
+
title="BERT Question Answering",
|
64 |
)
|
65 |
|
66 |
iface.launch()
|