An implementation of the NER model described in Template-Based Named Entity Recognition Using BART (Cui, Leyang et al., 2021) as well as a NER Chrome browser extension and server to highlight named entities on webpages.
- Python
- PyTorch
- Node.js
- Typescript
- Javascript
- Python 3 (Tested with 3.11)
- Node.js (Tested with Node 18)
In template-ner:
Steps 1-2 are optional but recommended to avoid package conficts
-
Create a python virtual environment by running:
python -m venv .venv
-
Activate the virtual environment.
For Linux (bash):
. ./.venv/bin/activateFor Windows:
. ./.venv/Scripts/activate -
Install dependencies by running:
pip install -r requirements.txt
-
Download dataset by running:
python dl_dataset.py
-
Train model by running:
python train.py
Model will be saved in folder named
best_model -
Test model and calculate F-1 by running:
python test.py
In ner-browser-extension:
-
Install dependencies by running:
npm install
-
Build extension by running:
npm run build
Note for development:
npm run devcan be used to watch files and continuously rebuild extension on update -
The extension is now built in the
distdirectory. Add the extension to Chrome
In ner-backend:
Steps 1-2 are optional but recommended to avoid package conficts
-
Create a python virtual environment by running:
python -m venv .venv
-
Activate the virtual environment.
For Linux (bash):
. ./.venv/bin/activateFor Windows:
. ./.venv/Scripts/activate -
Install dependencies by running:
pip install -r requirements.txt
-
Ensure a bart model is avaliable in a directory named
best_model. Copying over the model you just trained is is recommended. -
Start the server by running:
python server.py
The server will now be listening on
localhost:8080
With the server running and extension installed in Chrome:
-
Open a webpage
-
Click
Runwhen NER prompt popup shows up -
Wait for labels to be generated. See console for errors if they don't show up.
- Note: it might take a significant amount of time to label the entire page depending on your computer's capabilities