Skip to content

Use a BERT model to retrieve the correct context for each question from SQuAD dataset.

Notifications You must be signed in to change notification settings

sducouedic/BERT-for-context-retrieval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Find Best Context With SQuAD

Installation

  • In the root directory, create a new python environment and install all the requirements
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
  • Download and unzip BERT pretrained for passage reranking in /models/. You should now have the following files:
    • /models/BERT_for_passage_ranking/config.json
    • /models/BERT_for_passage_ranking/pytorch_model.bin

The model is taken from link which adapted BERT for passage ranking. The model is converted to PyTorch using Hugging Face's transformers library.

Inference

  • Go to src/ folder and run main.py with the desired question. The algorithm will print his best guess for the context:
cd src
python3 main.py --question "In what country is Normandy located?"

Future work

I didn't have the time to finish all I planned, here is what is missing:

  • Fasten the computation by using batches and doing inference using torch tensor (see src/eval.py)
  • Get feedback on the actual rank of the correct context
  • Implement MRR evaluation metric on dataset
  • Fine-tuning the model
  • Add new arguments to the parser to handle test dataset

About

Use a BERT model to retrieve the correct context for each question from SQuAD dataset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published