Automatic question-answering is a classical problem in natural language processing, which aims at designing systems that can automatically answer a question, in the same way as human does.
"Reading comprehension"
The machine has been given a paragraph, and questions will be asked from that paragraph only. The machine should be able to answer questions.
Create a model that 'reads' the paragraph and extracts the answer from that para itself by giving as output the starting index and the end index of the answer.
Paragraph: Lily was a little girl, afraid of the big wide world, she grew up within her castle walls. Now and then she tried to run, Now and then she tried to run and then on the night with the setting sun, she went in the woods away so afraid, all alone.
Question: Where did lily grow up?
OUTPUT FROM MODEL: Starting index: 14 , End index: 17
Answer: Within her castle walls.
Bi Directional Attention Flow (BiDAF)
Taken from the research paper of BiDAF
BERT (Bidirectional Encoder Representations from Transformers)
BERT (Bidirectional Encoder Representations from Transformers)
"Similar Question Selection"
The machine has been given a large corpus of questions and their corresponding answers. Given a new question, give the best answer possible from the list of answers.
Create a model that takes a question as an input and gets the most similar question from the corpus and returns its corresponding answer. It is similar to semantic search.
Universal Sentence Encoder
Question | Answer |
---|---|
What is Malaria? | It is a parasitic disease. |
How to impress girls? | Be rich :P |
Universal Sentence Encoder
Vector1
Vector2
While Training
Vector1
Vector2
Universal Sentence Encoder
"Tell me what is Malaria?"
Vector3
cosine sim.
similarity 1
= 0.9
similarity 2
= 0.01
>
Found most similar question: "What is malaria?"
During inference:
Train a model that takes a question as an input and retrieves the most similar answer from the corpus and returns it, i.e. question to answer similarity matching.
Question model
What is malaria?
Answer model
Answer model
Answer model
Malaria is a parasitic infection, caused by female anopheles mosquito.
Symptoms of malaria are fever, headache, shivering etc.
Covid-19 is the name of the disease caused by the novel coronavirus.
Fixed length question vector(q)
Fixed length answer vector (a_1)
Fixed length answer vector (a_2)
Fixed length answer vector (a_3)
}
Find maximum number (similarity)