What it is
A course project for NLP: give the model a passage and a question, and it returns the span of the passage that answers it.
I started from bert-base-cased and fine-tuned it for extractive QA with the simpletransformers library on Google Colab. The model predicts a start and end token in the passage, and the span between them is the answer.
Data and training
- SQuAD 2.0, read from its nested JSON into flat tables.
- Exploration with word clouds and Word2Vec embeddings, after lowercasing, punctuation and stop-word removal, stemming and lemmatization.
- Training on a random sample of 5,000 passages.
- Testing on 1,000 other passages, which held 6,857 questions.
Results
| Outcome on 6,857 test questions | Count |
|---|---|
| Exact match | 4,000 (58.3%) |
| Close match | 2,431 |
| Wrong | 426 |
On hand-written passages it answered simple factual questions with high confidence, for example “Thomas Alva Edison” at 0.9999. It struggled with questions that need arithmetic, like adding up hours from two sentences.