SchemaLink IE Engine
Schema-guided information extraction from biomedical text using Large Language Models.
The SchemaLink IE engine takes a schema developed with the SchemaLink webapp (SchemaLink.biodata.di.unimi.it) and a text as input to extract structured entities and relations — grounded to biomedical ontologies — that conform to the schema.
Overview
The SchemaLink IE engine implements a dependency-aware multi-step pipeline that:
- Parses the schema and builds a class-dependency DAG
- Runs topologically-sorted GPT calls — each step conditioned on the results of its dependencies
- Applies algorithmic post-processing rules (deduplication, cardinality, inheritance resolution)
- Optionally grounds extracted entities to biomedical ontologies via OAK
Schema ──┐
├──▶ SchemaLink Engine ──▶ Entities and Triples
Biomedical Text ┘ (LLM + DAG) (JSON / LinkML)
Installation
pip install schemalink-engine
Or from source:
git clone https://github.com/BioDataUniMI/schemalink-engine.git
cd schemalink-engine
pip install -e .
Set your OpenAI API key:
schemalink api-key set sk-your-key-here
Note: If the
OPENAI_API_KEYenvironment variable is set in your shell, it will always take priority over the key saved withapi-key set. Runschemalink api-key checkto see which source is being used. To use the key manager, unset the environment variable first:unset OPENAI_API_KEY
Quick Start
Given a schema file (schema.yaml, built with SchemaLink) and a text file (text.txt):
# Standard extraction — dependency-aware by default; prints the JSON result
schemalink extract schema.yaml text.txt
# With ontology grounding (recommended when the schema defines annotators)
schemalink extract schema.yaml text.txt --ground
# Flat extraction — all classes extracted independently, ignoring dependencies
schemalink extract schema.yaml text.txt --flat
# Hide the JSON result
schemalink extract schema.yaml text.txt --quiet
Example Schema (Drug–Disease)
id: https://example.org/ddi
name: drug_disease_schema
prefixes:
MONDO: https://purl.obolibrary.org/obo/mondo/mondo-international.owl
CHEBI: http://purl.obolibrary.org/obo/chebi.owl
imports:
- ontogpt:core
- linkml:types
classes:
DrugTreatsDiseaseRelationship:
is_a: Triple
slot_usage:
subject:
range: Drug
object:
range: Disease
predicate:
range: DrugTreatsDiseasePredicate
DrugTreatsDiseasePredicate:
is_a: RelationshipType
attributes:
id:
pattern: 'Treats'
Disease:
is_a: NamedEntity
id_prefixes: [MONDO]
annotations:
annotators: sqlite:obo:mondo
Drug:
is_a: NamedEntity
id_prefixes: [CHEBI]
annotations:
annotators: sqlite:obo:chebi
Example Output
{
"Disease": {
"mentions": [
{ "label": "Parkinson's disease", "id": "MONDO:0005180" }
]
},
"Drug": {
"mentions": [
{ "label": "levodopa", "id": "CHEBI:15765" },
{ "label": "carbidopa", "id": "CHEBI:3395" }
]
},
"DrugTreatsDiseaseRelationship": {
"mentions": [
{ "subject": "CHEBI:15765", "predicate": "Treats", "object": "MONDO:0005180" }
]
}
}
Python API
from schemalink_engine.pipeline import run_extraction_pipeline
# Dependency-aware extraction (default)
run_extraction_pipeline(
schema_path="schema.yaml",
text_path="text.txt",
with_dependencies=True, # True by default
)
# With ontology grounding
run_extraction_pipeline(
schema_path="schema.yaml",
text_path="text.txt",
ground_entities={"mode": "auto"},
)
Grounding
By default, extraction returns raw LLM labels with no ontology IDs. Pass --ground to enable grounding:
schemalink extract schema.yaml text.txt --ground
The grounding method is chosen automatically based on the annotators: field defined in the schema class:
| Annotator in schema | Grounding method |
|---|---|
sqlite:obo:mondo, sqlite:obo:chebi, etc. |
OAK exact match against a local ontology SQLite database |
cellosaurus, ncbigene, mesh_d, etc. |
Lookup against a local reference table |
OAK databases are downloaded automatically on first use from the bbop-sqlite S3 bucket and cached in ~/.data/oaklib/. If the OAK library is unavailable, the engine falls back to querying the .db files directly via SQLite. If no local database or lookup table is found, the entity is left ungrounded.
Classes with no annotators: field are always left ungrounded regardless of the --ground flag.
Web Interface
The SchemaLink IE engine ships with a Flask production server that exposes a REST API and a streaming SSE endpoint:
python production_server.py
# → http://localhost:15002/engine/api/v2/extract (streaming)
# → http://localhost:15002/engine/api/v1/extract (sync)
The full web application is available at SchemaLink.
Supported Ontologies
SchemaLink supports any ontology available as an OAK SQLite database, including:
chebi · go · mondo · hp · hgnc · pr · mesh · pw · doid · ncit · uberon · cl · ro · and 200+ more via the OBO Foundry
CLI Reference
schemalink extract <schema> <text> [options]
Options:
--ground Enable ontology grounding (method chosen automatically
from the annotators defined in the schema)
--flat Disable dependency-aware extraction — extract all
classes independently (default: dependency-aware ON)
--add_guidelines Include schema-level guidelines in prompts
--classes A B C Extract only specific classes
--model <name> Override the GPT model for this run
--quiet Do not print the extraction JSON (printed by default)
--verbose Show TRACE lines and internal pipeline logs
--show_prompts Print the prompts sent to the LLM (API call still made)
--json_schema Print the parsed JSON schema and exit
schemalink api-key set <key> Save your OpenAI API key
schemalink api-key check Check whether an API key is configured
schemalink api-key remove Remove the saved API key
schemalink model set <name> Set the default GPT model
schemalink models List all supported GPT models
Architecture
schemalink_engine/
├── cli.py # CLI entry point
├── pipeline.py # Main extraction pipeline
├── schema_convertor.py # LinkML YAML → JSON schema parser
├── api_key_manager.py # OpenAI key & model management
└── utils/
├── generate_dependencies.py # DAG construction from schema
├── dag_generator.py # DAG visualization
├── extract_named_entity_classes.py # NER class identification
├── process_named_entities.py # GPT-based NER
├── handle_inherited_classes.py # Inheritance resolution
├── process_inherited_entities.py # Inherited class extraction
├── handle_relationship_classes.py # Relation class identification
├── process_relationship_entities.py # GPT-based RE
├── grounding.py # OAK-based entity grounding
└── some_helper.py # Topological sort, utilities
Requirements
- Python ≥ 3.8
- OpenAI API key
- See
requirements.txtfor full dependency list
License
MIT License — see LICENSE for details.
Citation
If you use SchemaLink in your research, please cite:
@inproceedings{schemalinkIEengine2026,
author={Emanuele Cavalleri, Ali Rastegar Mojarad, J. Harry Caufield, Justin T. Reese, Christopher J. Mungall, and Marco Mesiti},
title = "{Schema-Driven Structured Information Extraction from Biomedical Literature via Large Language Models}",
year = {2026},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
booktitle = {Proceedings of the 35th ACM International Conference on Information and Knowledge Management},
location = {Rome, Italy},
series = {CIKM '26},
notes = {To appear.}
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file schemalink_engine-0.1.2.tar.gz.
File metadata
- Download URL: schemalink_engine-0.1.2.tar.gz
- Upload date:
- Size: 59.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b9a75d8af0703efc32f79afab363af5224b5906dcffdf499ca1ba1418e372fe
|
|
| MD5 |
8ebd0d126062b82f9c9b8cecc0017a1d
|
|
| BLAKE2b-256 |
2192088a2987947f1155c1c7bcc60d1c2d2920cdf92bf5b5447623dacf81ad98
|
File details
Details for the file schemalink_engine-0.1.2-py3-none-any.whl.
File metadata
- Download URL: schemalink_engine-0.1.2-py3-none-any.whl
- Upload date:
- Size: 67.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1aedb650e454e84628ff0b5bf95d7f39fe4abb0fde469f32f93c9f71065200b
|
|
| MD5 |
087d05d217550498158906f801f6552b
|
|
| BLAKE2b-256 |
c9aec4942fabe7d58b62d6ae7f2d5ab5fcb67a953943d1cdf7a5ba8deabcbe62
|