Local inference
Documentation to run models on-premises
The Ersilia Model Hub is conveniently offered as a python package through PyPi and CondaForge, and each model is individually packaged as a Docker container.
Installation in Linux/MacOS
Ersilia is only maintained for Linux and Mac Operating Systems. If you work in Windows please use a Windows Subsystem Linux.
Prerequisites
Python: we maintain Ersilia for Python 3.8 and above. Please make sure you have the right Python installation on your computer. Visit the official Python site to learn more.
Docker: Docker containers are an excellent way to share applications and simplify the management of system requirements and configurations. Please install Docker to ensure that all our AI/ML assets will work smoothly in your local device.
Install from PyPi
Install from CondaForge
Once the Ersilia Model Hub is installed, test that it works by running the --help command:
Model Usage
You can explore the available models through our website or by running the following command in the CLI:
Each model is identified by:
EOS-ID:
eos[1-9][a-z0-9]{3}
Slug: 1-3 word reference for the model
Title: brief description of the model
Throughout this documentation, we will use the model eos2r5a (retrosynthetic-accessibility) as an example. This model has been incorporated from the paper Retrosynthetic accessibility score (RAscore) – rapid machine learned synthesizability classification from AI driven retrosynthetic planning by Thakkar et al, 2021. The RA score is particularly useful to pre-screen large libraries of compounds, for example those produced by generative models.
To use a model, there are a few basic commands:
The fetch command will download the model from DockerHub. Please make sure to have Docker active in your system before fetching a model. The serve command will bring it alive anytime you want to use it, and with the run command you can pass the desired input and output files. Finally, close the model.
Input and output
The Ersilia Model Hub takes chemical structures as input, which should be specified as SMILES strings. To obtain the SMILES string of your compounds, you can use resources like PubChem. Ersilia also accepts InChIKey as molecular identifiers instead of SMILES.
The SMILES can be passed directly to the CLI:
You can make multiple predictions in batch mode. This is typically much faster than running predictions one by one in a loop:
The easiest, though, is to provide an input file instead. A simple .csv
file with one column is sufficient.
By default, predictions are returned in the standard output of the terminal. We favour the widely used JSON format because it offers great flexibility and interoperability. However, many of the model APIs return an output that can be naturally expressed in tabular format, for example, in a CSV file. If this is what you want, simply specify an output file with the .csv
extension.
Other interesting commands
You can also get more information through the model card:
Delete model
If you are sure you don't want to use a model anymore, you may want to remove it from your computer. This includes deleting all model files and specific dependencies:
As a Python package
Models can be fetched from the Ersilia Model Hub, served, and run as a Python package. The main class is called ErsiliaModel
:
Then, you can perform the same actions as in the CLI. To serve:
To make predictions for Halicin and Ibuprofen:
To close the model:
Using the with
statement
with
statementA more concise way to run prediction would be to use the with
clause:
Last updated