Skip to main content

OntoGPT

Project description

OntoGPT

OntoGPT Logo

DOI PyPI

Introduction

OntoGPT is a Python package for extracting structured information from text with large language models (LLMs), instruction prompts, and ontology-based grounding.

For more details, please see the full documentation.

Quick Start

OntoGPT runs on the command line, though there's also a minimal web app interface (see Web Application section below).

  1. Ensure you have Python 3.9 or greater installed.

  2. Install with pip:

    pip install ontogpt
    
  3. Set your OpenAI API key:

    runoak set-apikey -e openai <your openai api key>
    
  4. See the list of all OntoGPT commands:

    ontogpt --help
    
  5. Try a simple example of information extraction:

    echo "One treatment for high blood pressure is carvedilol." > example.txt
    ontogpt extract -i example.txt -t drug
    

    OntoGPT will retrieve the necessary ontologies and output results to the command line. Your output will provide all extracted objects under the heading extracted_object.

Web Application

There is a bare bones web application for running OntoGPT and viewing results.

First, install the required dependencies with pip by running the following command:

pip install ontogpt[web]

Then run this command to start the web application:

web-ontogpt

NOTE: We do not recommend hosting this webapp publicly without authentication.

Model APIs

OntoGPT uses the litellm package (https://litellm.vercel.app/) to interface with LLMs.

This means most APIs are supported, including OpenAI, Azure, Anthropic, Mistral, Replicate, and beyond.

The model name to use may be found from the command ontogpt list-models - use the name in the first column with the --model option.

In most cases, this will require setting the API key for a particular service as above:

runoak set-apikey -e anthropic-key <your anthropic api key>

Some endpoints, such as OpenAI models through Azure, require setting additional details. These may be set similarly:

runoak set-apikey -e azure-key <your azure api key>
runoak set-apikey -e azure-base <your azure endpoint url>
runoak set-apikey -e azure-version <your azure api version, e.g. "2023-05-15">

These details may also be set as environment variables as follows:

export AZURE_API_KEY="my-azure-api-key"
export AZURE_API_BASE="https://example-endpoint.openai.azure.com"
export AZURE_API_VERSION="2023-05-15"

Open Models

Open LLMs may be retrieved and run through the ollama package (https://ollama.com/).

You will need to install ollama (see the GitHub repo), and you may need to start it as a service with a command like ollama serve or sudo systemctl start ollama.

Then retrieve a model with ollama pull <modelname>, e.g., ollama pull llama3.

The model may then be used in OntoGPT by prefixing its name with ollama/, e.g., ollama/llama3, along with the --model option.

Some ollama models may not be listed in ontogpt list-models but the full list of downloaded LLMs can be seen with ollama list command.

Evaluations

OntoGPT's functions have been evaluated on test data. Please see the full documentation for details on these evaluations and how to reproduce them.

Related Projects

  • TALISMAN, a tool for generating summaries of functions enriched within a gene set. TALISMAN uses OntoGPT to work with LLMs.

Tutorials and Presentations

  • Presentation: "Staying grounded: assembling structured biological knowledge with help from large language models" - presented by Harry Caufield as part of the AgBioData Consortium webinar series (September 2023)
  • Presentation: "Transforming unstructured biomedical texts with large language models" - presented by Harry Caufield as part of the BOSC track at ISMB/ECCB 2023 (July 2023)
  • Presentation: "OntoGPT: A framework for working with ontologies and large language models" - talk by Chris Mungall at Joint Food Ontology Workgroup (May 2023)

Citation

The information extraction approach used in OntoGPT, SPIRES, is described further in: Caufield JH, Hegde H, Emonet V, Harris NL, Joachimiak MP, Matentzoglu N, et al. Structured prompt interrogation and recursive extraction of semantics (SPIRES): A method for populating knowledge bases using zero-shot learning. Bioinformatics, Volume 40, Issue 3, March 2024, btae104, https://doi.org/10.1093/bioinformatics/btae104.

Acknowledgements

This project is part of the Monarch Initiative. We also gratefully acknowledge Bosch Research for their support of this research project.

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

ontogpt-1.0.8.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

ontogpt-1.0.8-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file ontogpt-1.0.8.tar.gz.

File metadata

  • Download URL: ontogpt-1.0.8.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ontogpt-1.0.8.tar.gz
Algorithm Hash digest
SHA256 3287fc5d7f8744dbf7cebe3b938830a47a2ba3dad1cd22a7e2448165eac54c92
MD5 035b2ae96e8cafd760b82cb97372b700
BLAKE2b-256 b26180cf8a26857696eb72b5402073d38b101b6cda83a928a6d03f124685901d

See more details on using hashes here.

File details

Details for the file ontogpt-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: ontogpt-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for ontogpt-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 22460eec9013b3d41ce2e217018ff9cfc2a594dd9d7bb987a39884350d6f8dc3
MD5 1b71060c56042efaeed48ea0cbd79f36
BLAKE2b-256 1d1f0ecdc24436d9a2fd8739516b0eeb10eb6791868611ed762f07fa51d89ec0

See more details on using hashes here.

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