Skip to main content

Saber: Sequence Annotator for Biomedical Entities and Relations

Project description


Travis CI Codacy Status Coverage Status Spacy Version PRs Welcome License Colab

Saber (Sequence Annotator for Biomedical Entities and Relations) is a deep-learning based tool for information extraction in the biomedical domain.



To install Saber, you will need python>=3.5. If not already installed, python>=3.5 can be installed via

(OPTIONAL) Activate your virtual environment (see below for help)

$ conda activate saber
# Notice your command prompt has changed to indicate that the environment is active
(saber) $

then install Saber

(saber) $ pip install saber

To get the latest development version of Saber, install it right from this repository with pip

(saber) $ pip install

or by cloning the repository and then using pip to install the package

(saber) $ git clone
(saber) $ cd saber
(saber) $ pip install .

For now, you will need to install the required Spacy model and the keras-contrib repository (even if you installed with pip install saber)

# keras-contrib
(saber) $ pip install git+
# NeuralCoref medium model built on top of Spacy, this might take a few minutes to download!
(saber) $ pip install

(OPTIONAL) Creating and activating virtual environments

When using pip it is generally recommended to install packages in a virtual environment to avoid modifying system state. To create a virtual environment named saber

Using virtualenv or venv

Using virtualenv

$ virtualenv --python=python3 /path/to/new/venv/saber

Using venv

$ python3 -m venv /path/to/new/venv/saber

Next, you need to activate the environment

$ source /path/to/new/venv/saber/bin/activate
# Notice your command prompt has changed to indicate that the environment is active
(saber) $

Using Conda

If you use Conda, you can create an environment named saber by running

$ conda create -n saber python=3.6

then activate the environment with

$ conda activate saber
# Again, your command prompt should change to indicate that the environment is active
(saber) $


If your goal is to use Saber to annotate biomedical text, then you can either use the web-service or a pre-trained model. If you simply want to check Saber out, without installing anything locally, try the Google Colaboratory notebook.

Google Colaboratory

The fastest way to check out Saber is by following along with the Google Colaboratory notebook (Colab). In order to be able to run the cells, select "Open in Playground" or, alternatively, save a copy to your own Google Drive account (File > Save a copy in Drive).


To use Saber as a local web-service, run

(saber) $ python -m

or, if you prefer, you can pull & run the Saber image from Docker Hub

# Pull Saber image from Docker Hub
$ docker pull pathwaycommons/saber
# Run docker (use `-dt` instead of `-it` to run container in background)
$ docker run -it --rm -p 5000:5000 --name saber pathwaycommons/saber

There are currently two endpoints, /annotate/text and /annotate/pmid. Both expect a POST request with a JSON payload, e.g.,

  "text": "The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53."


  "pmid": 11835401

For example, running the web-service locally and using cURL

$ curl -X POST 'http://localhost:5000/annotate/text' \
--data '{"text": "The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53."}'

Documentation for the Saber web-service API can be found here.

Pre-trained models

First, import the Saber class. This is the interface to Saber

from saber.saber import Saber

To load a pre-trained model, first create a Saber object

saber = Saber()

and then load the model of our choice


You can see all the pre-trained models in the web-service API docs or, the saber/pretrained_models folder in this repository, or by running the following line of code

from saber.constants import ENTITIES; print(list(ENTITIES.keys()))

To annotate text with the model, just call the Saber.annotate() method

saber.annotate("The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53.")

See the documentation for more details.


Documentation for the Saber API can be found here. The web-service API has its own documentation here. Finally, we provide a jupyter notebook which introduces the main ways of using Saber. See here for help setting up JupyterLab.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saber-0.1.0.tar.gz (39.7 MB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page