GithubHelp home page GithubHelp logo

sducouedic / bert-for-context-retrieval Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 25.01 MB

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

Jupyter Notebook 78.46% Python 21.54%

bert-for-context-retrieval's Introduction

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

bert-for-context-retrieval's People

Contributors

sducouedic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.