Git Product home page Git Product logo

entity-linking's Introduction

Bi-Encoder Entity Linking

This repo implements a bi-encoder model for entity linking. The bi-encoder separately embeds mention and entity pairs into a shared vector space. The encoders in the bi-encoder model are pretrained transformers. We evaluate three different base encoder models on the retrieval rate metric. The retrieval rate is the rate at which the correct entity for a mention is included when generating k candidates for each mention in the test set. The HuggingFace names of the three base encoder models are:

  • bert-base-uncased
  • roberta-base
  • johngiorgi/declutr-base

The ML models in this repo are implemented using PyTorch and PyTorch-Lightning.

Bi-Encoder Model Illustration

bi-encoder model

Setup

  1. Install Miniconda
  2. Run conda env create -f environment.yml from inside the extracted directory. This creates a Conda environment called enli
  3. Run
    source activate enli
    
  4. Install requirements.
    pip install -r requirements.txt

Data Description

We use the Zeshel (zero-shot-entity-linking) dataset for training and evaluation. The Zeshel train/dev/test splits are completely non-overlapping and have the following numbers:

  • Train: 49275 labeled mentions covering 31502 entities
  • Val: 10000 labeled mentions covering 7513 entities
  • Test: 10000 labeled mentions covering 7218 entities

The train, val, and test sets do not share any entities at all between them.

Get the data

Download the training data from here.

Copy the downloaded file into the root folder of this repo and then run

tar -xvf zeshel.tar.bz2

Transform the Data

This step will require at least 20gb of memory.

python -m src.transform_zeshel --input-dir="./zeshel"

Training

To train on Google Cloud Platform (GCP), you must first build and push the training and evaluation docker image to your google cloud project. To do this edit scripts/build-images.sh with your own info.

Next, you can edit scripts/train-gcp.sh with your own google cloud project and then run

./scripts/train-gcp.sh

to submit a training job.

Evaluation

Similarly, edit scripts/eval-gcp.sh with your google cloud project id and run

./scripts/eval-gcp.sh

to submit the eval job.

Results

We find the using DeCLUTR embedding model (which is based on roberta) significantly outperforms both roberta-base and bert-base-uncased on the entity linking task. With DeCLUTR we achieved a retrieval-rate at k=64 of ~69%. Note that this score is measured on a test set of completely unseen entities.

The validation loss curves and retrieval rates for the three base model types are shown below.

validation loss image

retrieval rates image

entity-linking's People

Contributors

david-wb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.