Package: radboud-el
REL: Radboud Entity LinkerREL is a modular Entity Linking package that is provided as a Python package as well as a web API. REL has various meanings -  one might first notice that it stands for relation, which is a suiting name for the problems that can be tackled with this package. Additionally, in Dutch a 'rel' means a disturbance of the public order, which is exactly what we aim to achieve with the release of this package.REL utilizesEnglishWikipedia as a knowledge base and can be used for the following tasks:Entity linking (EL): Given a text, the system outputs a list of mention-entity pairs, where each mention is a n-gram from text and each entity is an entity in the knowledge base.Entity Disambiguation (ED): Given a text and a list of mentions, the system assigns an entity (or NIL) to each mention.Documentation:https://rel.readthedocs.ioREL variantsREL comes in two variants for identifying entity mentions:Case-sensitive: This setup is suitable for properly written texts (e.g., news articles) and is the default setup of the REL package. In this setup, we use thener-fastFLAIR model, which is case-sensitive. The results reported in the REL paper are based on this model.Case-insensitive: This setup is well suited for noisy texts (e.g., queries), where entity mentions can be (often) lowercased. In this setup, we use thener-fast-with-lowercasemodel, which is thener-fastFLAIR architucture trained on randomly cased and uncased text. This variant is the default setup of our API.Below is a comparison of these two models onCoNLL-2003 NERdataset.ModelCoNLL-2003 testF1ner-fastoriginal92.78ner-fastlower-cased58.42ner-fastrandom70.64ner-fast-with-lowercaseoriginal91.53ner-fast-with-lowercaselower-cased89.73ner-fast-with-lowercaserandom89.66SeeNotes on using custom modelsfor further information on switiching between these variants.Calling our APIUsers may access our API by using the example script below.
For EL, thespansfield needs to be set to an empty list. For ED, however, thespansfield should consist of a list of tuples, where each tuple refers to the start position and length of a mention.importrequestsAPI_URL="https://rel.cs.ru.nl/api"text_doc="If you're going to try, go all the way - Charles Bukowski"# Example EL.el_result=requests.post(API_URL,json={"text":text_doc,"spans":[]}).json()# Example ED.ed_result=requests.post(API_URL,json={"text":text_doc,"spans":[(41,16)]}).json()Setup packageThis section describes how to deploy REL on a local machine and setup the API. If you want to do anything more than simply running our API locally, you can skip the Docker steps and continue with installation from source.Option 1: Installation using DockerFirst, download the necessary data; you need the generic files and a Wikipedia version (2014 or 2019) (seeDownload). Extract them anywhere, we will bind the directories to the Docker container as volumes../scripts/download_data.sh./datagenericwiki_2019Prebuilt imagesTo use our prebuilt default image, run:dockerpullinformagi/relTo run the API locally:# Map container port 5555 to local port 5555, and use Wikipedia 2019# Also map the generic and wiki_2019 folders to directories in Docker containerdockerrun\-p5555:5555\-v$PWD/data/:/workspace/data\--rm-itinformagi/rel\python-mREL.server--bind0.0.0.0--port5555/workspace/datawiki_2019Now you can make requests tohttp://localhost:5555(or another port if you
use a different mapping) in the format described in the example above.Build your own Docker imageTo build the Docker image yourself, run:# Clone the repositorygitclonehttps://github.com/informagi/REL&&cdREL# Build the Docker imagedockerbuild.-tinformagi/relTo run the API locally, use the same commands as mentioned in the previous section.Option 2: Installation from source codeRun the following command in a terminal to install REL:pipinstallgit+https://github.com/informagi/RELYou will also need to manually download the files described in the next section.Download dataThe files used for this project can be divided into three categories. The first is a generic set of documents and embeddings that was used throughout the project. This folder includes the GloVe embeddings and the unprocessed datasets that were used to train the ED model. The second and third category are Wikipedia corpus related files, which in our case either originate from a 2014 or 2019 corpus. Alternatively, users may use their own corpus, for which we refer to the tutorials.Download generic filesDownload Wikipedia corpus (2014)Download ED model 2014Download Wikipedia corpus (2019)Download ED model 2019TutorialsTo promote usage of this package we developed varioustutorials. If you simply want to use our API, then
we refer to the section above. If you feel one is missing or unclear, then please create anissue, which is much appreciated :)!The first two tutorials are
for users who simply want to use our package for EL/ED and will be using the data files that we provide.
The remainder of the tutorials are optional and for users who wish to e.g. train their own Embeddings.How to get started (project folder and structure).End-to-End Entity Linking.Evaluate on GERBIL.Deploy REL for a new Wikipedia corpus:Reproducing our resultsREL as systemd serviceNotes on using custom modelsEfficiency of RELWe measured the efficiency of REL on a per-document basis. We ran our API with 50 documents from AIDA-B with > 200 words, which is 323 (± 105) words and 42 (± 19) mentions per document. The results are added to the table below.ModelTime MDTime EDWith GPU0.44±0.220.24±0.08Without GPU2.41±1.240.18±0.09As our package has changed overtime, we refer to one of ourearlier commitsfor reproducing the results in the table above. To reproduce the results above, perform the following steps:Start the server. As can be seen inserver.py, we addedcheckpoints in our server callsto measure time taken per call.Once the server is started, run theefficiency test. Do not forget to update thebase_urlto specify where the data is located in the filesystem. This directory refers to where all project-related data is stored (see ourtutorial on how to get startedFinally, process theefficiency results.DevelopmentCheck out ourContributing Guidelinesto get started with development.CiteIf you are using REL, please cite the following paper:@inproceedings{vanHulst:2020:REL,author={van Hulst, Johannes M. and Hasibi, Faegheh and Dercksen, Koen and Balog, Krisztian and de Vries, Arjen P.},title={REL: An Entity Linker Standing on the Shoulders of Giants},booktitle={Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval},series={SIGIR '20},year={2020},publisher={ACM}}ContactIf you find any bugs or experience difficulties when using REL, please create a issue on this Github page. If you have any specific questions with respect to our research with REL, please emailMick van Hulst.AcknowledgementsOur thanks go out to the authors that open-sourced their code, enabling us to create this package that can hopefully be of service to many.