dnanhkhoa / PRISM-APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PRISM-APIs

https://github.com/aistairc/PRISM-APIs

This repository contains the source code and data files of the following items:

  • Web application for our named entity recognition model. It uses the named entity recognition model from the repository PRISM-EL.
  • Web application for our bio entity linking model. It uses the entity linking model from the repository PRISM-EL.
  • Web application for our relation extraction model. It uses the relation extraction model from the repository PRISM-DeepEM.
  • Web application for our event extraction model. It uses the event extraction model from the repository PRISM-DeepEM.
  • Web application for our disease network
  • API Services

Currently, all the models provided above were trained on our IPF Genes corpus. Please also note that this repository is just for visualizing the output of our NLP models in different ways, so it does not include the source code for training those models from scratch. If you would like to retrain those models on your own data, please check out the corresponding repositories mentioned above.

For the API services, we also have another repository API Usage Examples containing code examples for our end-users to help interact with our API endpoints properly.

Requirements

# On ABCI, please first run the following commands (the version numbers must be the same):
# module load gcc/7.4.0

# Create a virtual environment
conda create -y -n api python=3.8

# Activate the virtual environment
conda activate api

# Install required packages
conda install -y ruby -c conda-forge
conda install -y faiss-cpu==1.7.0 -c conda-forge

pip install torch==1.8.1
pip install overrides==3.1.0
pip install allennlp==0.9.0
pip install loguru==0.6.0
pip install sqlitedict==2.0.0
pip install Bootstrap-Flask==1.5.1
pip install fastapi==0.73.0
pip install "uvicorn[standard]==0.17.1"
pip install pandas==1.2.3
pip install tabulate==0.8.7
pip install pytorch-nlp==0.5.0
pip install python-igraph==0.9.6
pip install plotly==5.1.0

# Compile Geniass model
cd "tools/geniass" && make && cd "../.."

Then, please download our trained models using this link api-data.zip and then unpack all of them into the root folder of this repository.

In case you are training models from scratch and also using your own UMLS knowledge base, you should run this command once to create a cache file. Please modify the paths in config.ini file and then run:

python init_cache.py

Then you also need to run this command once to normalize your UMLS concept embeddings:

python normalize_concept_embeddings.py

Deploy web applications and APIs

In order to deploy web applications for our models named entity recognition, entity linking, relation extraction, and event extraction, please run this command:

FLASK_APP=wsgi flask run --host=0.0.0.0 -p 9091

The web applications can be accessible at these links:

In order to deploy web application for our Disease Network, please run this command:

FLASK_APP=disease-network flask run --host=0.0.0.0 -p 9092

Then, you can access the web application using this link:

http://127.0.0.1:9092/disease_network/

For API services, we need to start both two versions for different purposes:

uvicorn api:app --host 0.0.0.0 --port 9093
uvicorn api_for_openplatform:app --host 0.0.0.0 --port 9094

Then, you can access it via the following links:

http://127.0.0.1:9093/api
http://127.0.0.1:9094/api-for-openplatform

About


Languages

Language:Python 51.8%Language:JavaScript 29.6%Language:CSS 6.5%Language:HTML 5.5%Language:C++ 3.8%Language:C 1.1%Language:Roff 0.9%Language:Ruby 0.3%Language:Perl 0.3%Language:Shell 0.1%Language:Dockerfile 0.1%Language:Makefile 0.0%