Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- squad_v2
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
metrics:
|
7 |
+
- accuracy
|
8 |
+
library_name: transformers
|
9 |
+
pipeline_tag: question-answering
|
10 |
+
tags:
|
11 |
+
- question-answering
|
12 |
+
---
|
13 |
+
# AnswerMind
|
14 |
+
AnswerMind is a Question Answering Model. This model is a lighter version of any of the question-answering models out there.
|
15 |
+
The base architecture is BERT for Question-Answering.
|
16 |
+
|
17 |
+
## Dataset
|
18 |
+
The Stanford Question Answering Dataset (SQuAD) is a widely used benchmark dataset for the task of machine reading comprehension. It consists of over 100,000 question-answer pairs based on a set of Wikipedia articles. The goal is to train models that can answer questions based on their understanding of the given text passages. SQuAD has played a significant role in advancing the state-of-the-art in this field and remains a popular choice for researchers and practitioners alike.
|
19 |
+
Due to GPU limitations, this version is trained on `30k samples` from the Stanford Question Answering Dataset.
|
20 |
+
|
21 |
+
<details>
|
22 |
+
<summary><i>Structure of the Data Dictonary</i></summary>
|
23 |
+
<!--All you need is a blank line-->
|
24 |
+
|
25 |
+
{
|
26 |
+
"data":[
|
27 |
+
{
|
28 |
+
"title":"Article Title",
|
29 |
+
"paragraphs":[
|
30 |
+
{
|
31 |
+
"context":"The context text of the paragraph",
|
32 |
+
"qas":[
|
33 |
+
{
|
34 |
+
"question":"The question asked about the context",
|
35 |
+
"id":"A unique identifier for the question",
|
36 |
+
"answers":[
|
37 |
+
{
|
38 |
+
"text":"The answer to the question",
|
39 |
+
"answer_start":"The starting index of the answer in the context"
|
40 |
+
}
|
41 |
+
]
|
42 |
+
}
|
43 |
+
]
|
44 |
+
}
|
45 |
+
]
|
46 |
+
}
|
47 |
+
],
|
48 |
+
"version":"The version of the SQuAD dataset"
|
49 |
+
}
|
50 |
+
</details>
|
51 |
+
|
52 |
+
## Model
|
53 |
+
BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained transformer-based model for natural language processing tasks such as question answering. BERT is fine-tuned for question answering by adding a linear layer on top of the pre-trained BERT representations to predict the start and end of the answer in the input context. BERT has achieved state-of-the-art results on multiple benchmark datasets, including the Stanford Question Answering Dataset (SQuAD). The fine-tuning process allows BERT to effectively capture the relationships between questions and answers and generate accurate answers.
|
54 |
+
<img src="https://imgs.search.brave.com/F8m-nwp6EIG5vq--OmJLrCDpIkuX6tEQ_kyFKQjlUTs/rs:fit:1200:1200:1/g:ce/aHR0cHM6Ly9ibG9n/LmdyaWRkeW5hbWlj/cy5jb20vY29udGVu/dC9pbWFnZXMvMjAy/MC8xMC9TbGljZS0x/OC5wbmc">
|
55 |
+
For more detail about this read [Understanding QABERT]()
|
56 |
+
|
57 |
+
|
58 |
+
## Inference
|
59 |
+
_Load model_
|
60 |
+
```python
|
61 |
+
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
|
62 |
+
|
63 |
+
QAtokenizer = AutoTokenizer.from_pretrained("SRDdev/QABERT-small")
|
64 |
+
|
65 |
+
QAmodel = AutoModelForQuestionAnswering.from_pretrained("SRDdev/QABERT-small")
|
66 |
+
```
|
67 |
+
|
68 |
+
_context_
|
69 |
+
```text
|
70 |
+
Extractive Question Answering is the task of extracting an answer from a text given a question. An example of a
|
71 |
+
question-answering dataset is the SQuAD dataset, which is entirely based on that task. If you would like to fine-tune
|
72 |
+
a model on a SQuAD task, you may leverage the examples/pytorch/question-answering/run_squad.py script.
|
73 |
+
```
|
74 |
+
|
75 |
+
|
76 |
+
_Build Pipeline_
|
77 |
+
```python
|
78 |
+
from transformers import pipeline
|
79 |
+
|
80 |
+
ask = pipeline("question-answering", model= QAmodel , tokenizer = QAtokenizer)
|
81 |
+
|
82 |
+
result = ask(question="What is a good example of a question answering dataset?", context=context)
|
83 |
+
|
84 |
+
print(f"Answer: '{result['answer']}'")
|
85 |
+
```
|
86 |
+
|
87 |
+
## Contributing
|
88 |
+
|
89 |
+
Pull requests are welcome. For major changes, please open an issue first
|
90 |
+
to discuss what you would like to change.
|
91 |
+
Please make sure to update tests as appropriate.
|
92 |
+
|
93 |
+
## Citations
|
94 |
+
```
|
95 |
+
@citation{ QA-BERT-small,
|
96 |
+
author = {Shreyas Dixit},
|
97 |
+
year = {2023},
|
98 |
+
url = {https://huggingface.co/SRDdev/QA-BERT-small}
|
99 |
+
}
|
100 |
+
```
|