Instructions to use sensein/layalink with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Laya
How to use sensein/layalink with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
LayaLink
LayaLink is a typed decisions for concept mapping and alignment. It is finetuned on convaiinnovations/laya.
| Task | Input (state) |
Questions and answers |
|---|---|---|
| ontology_alignment | a source and a target concept (label, definition, parents, ontology) | relation: equivalent, source_narrower (source is a subclass of target), source_broader, related, no_match, insufficient; exact_match: P(same meaning and scope) |
| entity_linking | a text mention, its sentence, one candidate concept | mapping: match, no_match, insufficient; accept: P(enough evidence to accept) |
| concept_selection | a mention, its sentence, a list of candidate concepts | concept: the matching candidate's id or none; resolvable: P(some candidate matches) |
LayaLink judges candidates you supply; it does not search an ontology.
Installation
pip install "laya @ git+https://github.com/NandhaKishorM/laya.git@80a1da1fa5448ea12163f4d977935625a0aea670"
or
pip install laya==0.4.34
This is the laya version LayaLink was trained and tested with (Python 3.10+).
Quickstart
import laya
agent = laya.Agent("sensein/layalink", device="cuda") # or "mps" (Apple Silicon) / "cpu"
# a local copy works the same way: laya.Agent("path/to/LayaLink")
If loading hangs and TensorFlow is installed, set USE_TF=0 (as for the base model).
Ask the questions with exactly the wording below: it is the wording LayaLink was trained on. For
concept_selection, build criteria from your candidates (id: "label (ONTOLOGY)", plus none).
Ontology alignment: how does SOURCE relate to TARGET? (equivalent)
A real row from the held-out oaei_anatomy test set (provenance: oaei_reference).
state = {'source': {'label': 'urinary bladder urothelium',
'definition': '',
'synonyms': ['transitional epithelium'],
'ontology': 'Adult Mouse Anatomy'},
'target': {'label': 'Bladder Transitional Cell Epithelium',
'definition': '',
'synonyms': ['Bladder Urothelium', 'Bladder Transitional Epithelium'],
'parents': ['Urothelium'],
'ontology': 'NCI Thesaurus (anatomy)'}}
questions = {'relation': {'type': 'choice',
'instructions': 'Classify SOURCE relative to TARGET using the supplied '
'definitions. Subclass direction matters. Association is not '
'equivalence. Missing information means insufficient.',
'criteria': {'equivalent': 'Same class meaning and scope.',
'source_narrower': 'Source is a proper subclass of target.',
'source_broader': 'Target is a proper subclass of source.',
'related': 'Explicit association but neither equivalence nor '
'subclass.',
'no_match': 'Definitions establish different concepts; no mapping '
'is supported.',
'insufficient': 'Available evidence cannot determine the '
'relation.'}},
'exact_match': {'type': 'noul',
'instructions': 'Do the supplied definitions establish that source and target '
'have the same class meaning and scope? False includes '
'insufficient evidence.'}}
result = agent.predict(state, questions)
LayaLink's answer (from the evaluation run), with the gold label:
result['answers']['relation'] # -> 'equivalent' (gold: 'equivalent') {'equivalent': 0.9993, 'source_broader': 0.0002, 'source_narrower': 0.0001, 'related': 0.0001, 'no_match': 0.0001, 'insufficient': 0.0001}
result['answers']['exact_match'] # -> 'true' (gold: 'true') {'true': 0.9997, 'false': 0.0003}
Ontology alignment: how does SOURCE relate to TARGET? (source_narrower)
A real row from the held-out bioml2026 test set (provenance: derived_hierarchy).
state = {'source': {'label': 'Hyperlipoproteinemia, Type II',
'definition': 'An inheritable form of hyperlipidemia, in which there are excess lipids '
'in the blood.',
'synonyms': ['Type II Hyperlipidemia'],
'parents': ['Hyperlipoproteinemia'],
'ontology': 'NCI Thesaurus'},
'target': {'label': 'familial hyperlipidemia',
'definition': 'A lipid metabolism disease that is characterized by elevated levels of '
'lipids in the blood.',
'synonyms': ['familial hyperlipoproteinemia', 'hyperlipemia', 'hyperlipidaemia'],
'parents': ['lipid metabolism disorder'],
'ontology': 'Disease Ontology'}}
questions = {'relation': {'type': 'choice',
'instructions': 'Classify SOURCE relative to TARGET using the supplied '
'definitions. Subclass direction matters. Association is not '
'equivalence. Missing information means insufficient.',
'criteria': {'equivalent': 'Same class meaning and scope.',
'source_narrower': 'Source is a proper subclass of target.',
'source_broader': 'Target is a proper subclass of source.',
'related': 'Explicit association but neither equivalence nor '
'subclass.',
'no_match': 'Definitions establish different concepts; no mapping '
'is supported.',
'insufficient': 'Available evidence cannot determine the '
'relation.'}},
'exact_match': {'type': 'noul',
'instructions': 'Do the supplied definitions establish that source and target '
'have the same class meaning and scope? False includes '
'insufficient evidence.'}}
result = agent.predict(state, questions)
LayaLink's answer (from the evaluation run), with the gold label:
result['answers']['relation'] # -> 'source_narrower' (gold: 'source_narrower') {'source_narrower': 0.9991, 'equivalent': 0.0002, 'source_broader': 0.0002, 'related': 0.0002, 'no_match': 0.0002, 'insufficient': 0.0002}
result['answers']['exact_match'] # -> 'false' (gold: 'false') {'false': 0.9997, 'true': 0.0003}
Entity linking: does this candidate match the mention in context?
A real row from the held-out ncbi_corpora test set (provenance: corpus_gold).
state = {'mention': 'metrizoate',
'context': 'Frequencies of ventricular fibrillation were significantly lower (p less than 0.05) '
'after iopentol (0%) and iohexol (3%) than after metrizoate (22%).',
'candidate': {'label': 'Metrizoic Acid',
'definition': 'A diagnostic radiopaque that usually occurs as the sodium salt.',
'synonyms': ['Benzoic acid, 3-(acetylamino)-5-(acetylmethylamino)-2,4,6-triiodo-'],
'ontology': 'MeSH'}}
questions = {'mapping': {'type': 'choice',
'instructions': 'Does the candidate match the meaning of the mention in this '
'context?',
'criteria': {'match': 'Candidate matches the contextual meaning.',
'no_match': 'Candidate has a different meaning.',
'insufficient': 'Context does not resolve the mention.'}},
'accept': {'type': 'noul',
'instructions': 'Does the context provide enough evidence to accept this candidate '
'as the mention meaning?'}}
result = agent.predict(state, questions)
LayaLink's answer (from the evaluation run), with the gold label:
result['answers']['mapping'] # -> 'match' (gold: 'match') {'match': 0.9999, 'no_match': 0.0000, 'insufficient': 0.0000}
result['answers']['accept'] # -> 'true' (gold: 'true') {'true': 0.9993, 'false': 0.0007}
Concept selection: which candidate (or none) matches the mention?
A real row from the held-out ner_bionlp/BC2GM test set (provenance: silver_exact).
state = {'mention': 'Insulin',
'context': 'Insulin-stimulated glucose transport in adipocytes is mediated by the insulin '
'receptor.',
'entity_type': 'gene or protein',
'candidates': [{'id': 'pr:000050339',
'label': 'insulin hormone',
'ontology': 'PR',
'definition': 'A proinsulin that has had the propeptide (C-peptide) excised, '
'leaving the...'},
{'id': 'pr:P01315',
'label': 'insulin (pig)',
'ontology': 'PR',
'definition': 'A protein that is a translation product of the INS gene in pig.'},
{'id': 'pr:P01326',
'label': 'insulin-2 (mouse)',
'ontology': 'PR',
'definition': 'An insulin-2 that is encoded in the genome of mouse.'},
{'id': 'pr:P15127',
'label': 'insulin receptor (rat)',
'ontology': 'PR',
'definition': 'An insulin receptor that is encoded in the genome of rat.'},
{'id': 'pr:000050340',
'label': 'insulin hormone (human)',
'ontology': 'PR',
'definition': 'An insulin hormone in human.'}]}
questions = {'concept': {'type': 'choice',
'instructions': 'Which candidate concept matches the meaning of the mention in '
'this context? Choose none when no listed candidate matches.',
'criteria': {'pr:000050339': 'insulin hormone (PR)',
'pr:P01315': 'insulin (pig) (PR)',
'pr:P01326': 'insulin-2 (mouse) (PR)',
'pr:P15127': 'insulin receptor (rat) (PR)',
'pr:000050340': 'insulin hormone (human) (PR)',
'none': 'None of the listed candidate concepts matches the '
'mention.'}},
'resolvable': {'type': 'noul',
'instructions': 'Does any listed candidate concept match the meaning of the '
'mention in this context?'}}
result = agent.predict(state, questions)
LayaLink's answer (from the evaluation run), with the gold label:
result['answers']['concept'] # -> 'pr:000050339' (gold: 'pr:000050339') {'pr:000050339': 0.7554, 'none': 0.2191, 'pr:P01315': 0.0182, 'pr:P01326': 0.0025, 'pr:000050340': 0.0025, 'pr:P15127': 0.0024}
result['answers']['resolvable'] # -> 'true' (gold: 'true') {'true': 0.8884, 'false': 0.1116}
Many inputs at once
results = agent.predict_batch([state_1, state_2, state_3], questions, batch_size=64) # one shared question set
for r in results:
print(r["answers"])
Each answer has choice + probabilities (choice questions) or noul = P(yes) (yes/no questions), plus confidence.
Using with Router
from laya import Router
router = Router(models={"english": "sensein/layalink", "multilingual": "sensein/layalink"}, max_loaded=1, device="cuda")
state = {'source': {'label': 'urinary bladder urothelium',
'definition': '',
'synonyms': ['transitional epithelium'],
'ontology': 'Adult Mouse Anatomy'},
'target': {'label': 'Bladder Transitional Cell Epithelium',
'definition': '',
'synonyms': ['Bladder Urothelium', 'Bladder Transitional Epithelium'],
'parents': ['Urothelium'],
'ontology': 'NCI Thesaurus (anatomy)'}}
questions = {'relation': {'type': 'choice',
'instructions': 'Classify SOURCE relative to TARGET using the supplied '
'definitions. Subclass direction matters. Association is not '
'equivalence. Missing information means insufficient.',
'criteria': {'equivalent': 'Same class meaning and scope.',
'source_narrower': 'Source is a proper subclass of target.',
'source_broader': 'Target is a proper subclass of source.',
'related': 'Explicit association but neither equivalence nor '
'subclass.',
'no_match': 'Definitions establish different concepts; no mapping '
'is supported.',
'insufficient': 'Available evidence cannot determine the '
'relation.'}},
'exact_match': {'type': 'noul',
'instructions': 'Do the supplied definitions establish that source and target '
'have the same class meaning and scope? False includes '
'insufficient evidence.'}}
result = router.predict(state, questions)
print(result["routing"]["repo"]) # should print sensein/layalink
import json
print(json.dumps(result, indent=2))
Output
{
"model": "laya-rl-agent",
"answers": {
"relation": {
"type": "choice",
"choice": "equivalent",
"probabilities": {
"equivalent": 0.9993,
"source_narrower": 0.0001,
"source_broader": 0.0002,
"related": 0.0001,
"no_match": 0.0001,
"insufficient": 0.0001
},
"confidence": 0.9964,
"answer_confidence": 0.9993,
"action": {
"act_probability": 1.0
}
},
"exact_match": {
"type": "noul",
"noul": 0.9997,
"confidence": 0.9997,
"answer_confidence": 0.9997,
"action": {
"act_probability": 1.0
}
}
},
"usage": {
"input_tokens": 371,
"output_tokens": 0,
"state_tokens": 106,
"state_tokens_dropped": 0,
"truncated": false,
"truncated_questions": []
},
"routing": {
"model": "multilingual",
"repo": "sensein/layalink",
"reason": "Latin script, language not identified and no non-English letters; using default (multilingual)",
"detection": {
"script": "latin",
"script_profile": {
"latin": 1.0
},
"language": null,
"is_english": true,
"language_undecided": true,
"diacritic_rate": 0.0,
"non_latin_fraction": 0.0,
"mixed_segment": null
},
"workflow": null
}
}
Results
All test sets pooled
Measured right after training on every data/test/* set together (each question counted once). "Calibrated" applies the temperatures fitted on the calibration split.
| Probabilities | Decisions | Accuracy | ECE | Brier | Mean confidence |
|---|---|---|---|---|---|
| raw | 25254 | 0.9647 | 0.0339 | 0.0420 | 0.9552 |
| calibrated | 25254 | 0.9647 | 0.0751 | 0.0490 | 0.9053 |
Per test set
From evaluation/run_evaluation.sh (results/LayaLink-20261115-214357). Accuracy and macro-F1 over the labels of each question; ECE = expected calibration error (lower is better). ner_bionlp labels are silver (lexical/semantic evidence), the others gold.
| Test set | Task / question | n | Accuracy | Macro-F1 | ECE |
|---|---|---|---|---|---|
| bioml2026 | ontology_alignment/exact_match | 603 | 0.974 | 0.961 | 0.0256 |
| bioml2026 | ontology_alignment/relation | 603 | 0.939 | 0.947 | 0.0534 |
| mappings | ontology_alignment/exact_match | 224 | 0.951 | 0.944 | 0.0471 |
| mappings | ontology_alignment/relation | 224 | 0.951 | 0.959 | 0.0436 |
| ncbi_corpora | entity_linking/accept | 1043 | 0.932 | 0.931 | 0.0647 |
| ncbi_corpora | entity_linking/mapping | 1043 | 0.937 | 0.955 | 0.0601 |
| ner_bionlp/BC2GM | concept_selection/concept | 162 | 0.765 | 0.836 | 0.2149 |
| ner_bionlp/BC2GM | concept_selection/resolvable | 162 | 0.895 | 0.894 | 0.0608 |
| ner_bionlp/BC2GM | entity_linking/accept | 785 | 0.977 | 0.827 | 0.1213 |
| ner_bionlp/BC2GM | entity_linking/mapping | 785 | 0.978 | 0.840 | 0.1136 |
| ner_bionlp/BC4CHEMD | concept_selection/concept | 176 | 0.869 | 0.909 | 0.2005 |
| ner_bionlp/BC4CHEMD | concept_selection/resolvable | 176 | 0.943 | 0.933 | 0.0731 |
| ner_bionlp/BC4CHEMD | entity_linking/accept | 798 | 0.961 | 0.906 | 0.0819 |
| ner_bionlp/BC4CHEMD | entity_linking/mapping | 798 | 0.959 | 0.900 | 0.0703 |
| ner_bionlp/BC5CDR-chem | concept_selection/concept | 224 | 0.862 | 0.884 | 0.1794 |
| ner_bionlp/BC5CDR-chem | concept_selection/resolvable | 224 | 0.964 | 0.925 | 0.0773 |
| ner_bionlp/BC5CDR-chem | entity_linking/accept | 947 | 0.963 | 0.933 | 0.0845 |
| ner_bionlp/BC5CDR-chem | entity_linking/mapping | 947 | 0.962 | 0.932 | 0.0766 |
| ner_bionlp/BC5CDR-disease | concept_selection/concept | 178 | 0.972 | 0.972 | 0.1869 |
| ner_bionlp/BC5CDR-disease | concept_selection/resolvable | 178 | 0.966 | 0.966 | 0.0751 |
| ner_bionlp/BC5CDR-disease | entity_linking/accept | 820 | 0.988 | 0.970 | 0.0447 |
| ner_bionlp/BC5CDR-disease | entity_linking/mapping | 820 | 0.992 | 0.979 | 0.0415 |
| ner_bionlp/JNLPBA | concept_selection/concept | 221 | 0.869 | 0.880 | 0.2261 |
| ner_bionlp/JNLPBA | concept_selection/resolvable | 221 | 0.928 | 0.924 | 0.0555 |
| ner_bionlp/JNLPBA | entity_linking/accept | 1100 | 0.986 | 0.869 | 0.0909 |
| ner_bionlp/JNLPBA | entity_linking/mapping | 1100 | 0.983 | 0.845 | 0.0801 |
| ner_bionlp/NCBI-disease | concept_selection/concept | 163 | 0.902 | 0.910 | 0.2037 |
| ner_bionlp/NCBI-disease | concept_selection/resolvable | 163 | 0.914 | 0.914 | 0.0851 |
| ner_bionlp/NCBI-disease | entity_linking/accept | 746 | 0.984 | 0.956 | 0.0622 |
| ner_bionlp/NCBI-disease | entity_linking/mapping | 746 | 0.980 | 0.945 | 0.0485 |
| ner_bionlp/linnaeus | concept_selection/concept | 334 | 0.973 | 0.983 | 0.2420 |
| ner_bionlp/linnaeus | concept_selection/resolvable | 334 | 0.997 | 0.997 | 0.1415 |
| ner_bionlp/linnaeus | entity_linking/accept | 1612 | 0.999 | 0.995 | 0.0713 |
| ner_bionlp/linnaeus | entity_linking/mapping | 1612 | 0.998 | 0.990 | 0.0624 |
| ner_bionlp/s800 | concept_selection/concept | 317 | 0.937 | 0.943 | 0.2935 |
| ner_bionlp/s800 | concept_selection/resolvable | 317 | 0.937 | 0.936 | 0.1093 |
| ner_bionlp/s800 | entity_linking/accept | 1535 | 0.996 | 0.989 | 0.0940 |
| ner_bionlp/s800 | entity_linking/mapping | 1535 | 0.997 | 0.991 | 0.0816 |
| oaei_anatomy | ontology_alignment/exact_match | 561 | 0.959 | 0.943 | 0.0399 |
| oaei_anatomy | ontology_alignment/relation | 561 | 0.868 | 0.886 | 0.1080 |
| oaei_conference | ontology_alignment/exact_match | 78 | 0.808 | 0.808 | 0.1921 |
| oaei_conference | ontology_alignment/relation | 78 | 0.756 | 0.756 | 0.2200 |
| bioml2026-benchmark/ncit-doid | ontology_alignment/exact_match | 2400 | 0.973 | 0.969 | 0.0249 |
| bioml2026-benchmark/ncit-doid | ontology_alignment/relation | 2400 | 0.942 | 0.965 | 0.0480 |
Bio-ML 2026 local ranking (OAEI)
Rank the 100 released candidates per source concept; public valid split, scored exactly like the track's scoring_kit/score_local.py. The test gold is hidden: official test numbers come only from the organisers (CodaBench).
| System | Pair | Queries | MRR | Hits@1 | Hits@5 | Hits@10 |
|---|---|---|---|---|---|---|
| LayaLink | ncit-doid | 634 | 0.9044 | 0.8675 | 0.9464 | 0.9606 |
| fuzzy label baseline | ncit-doid | 634 | 0.8985 | 0.8659 | 0.9322 | 0.9527 |
The test sets are this project's own held-out splits (grouped so no concept, pair or sentence is shared with training), not official benchmarks, except the Bio-ML ranking above.
Data Sources
The LayaLink training dataset integrates ontology alignment, biomedical entity normalization, and named entity recognition (NER) resources to support both concept-to-concept alignment and mention-to-concept mapping.
Data Sources
The dataset combines the following resources:
| Source | Datasets | Description |
|---|---|---|
| OAEI 2025 | oaei_anatomy, oaei_conference |
Reference alignments from the Anatomy and Conference tracks |
| OAEI Bio-ML 2026 | bioml2026 |
NCITโDOID training reference alignments only |
| Biomappings | mappings |
Curated biomedical concept mappings |
| NCBI Normalization Corpora | ncbi_corpora |
Entity normalization annotations from NCBI-disease and BC5CDR |
| BioNLP-Corpus | ner_bionlp/* |
Biomedical entity mentions from eight NER datasets, linked to candidate ontology concepts using lexical and semantic matching |
The BioNLP-Corpus collection includes:
BC2GMโ Gene and protein mentionsBC4CHEMDโ Chemical and drug mentionsBC5CDR-chemโ Chemical mentionsBC5CDR-diseaseโ Disease mentionsJNLPBAโ Biomedical entity mentionsNCBI-diseaseโ Disease mentionslinnaeusโ Species mentionss800โ Species mentions
Training Infrastructure
LayaLink was fine-tuned using two NVIDIA H100 GPUs, leveraging multi-GPU acceleration for training on the combined ontology alignment and biomedical entity mapping datasets.
| Component | Configuration |
|---|---|
| GPU | 2 ร NVIDIA H100 |
| Training | Multi-GPU fine-tuning |
| Training data | Ontology alignments and biomedical entity mappings |
| Data split | 80% training / 10% calibration / 10% testing |
Benchmark compliance: In accordance with the OAEI Bio-ML 2026 rules, MONDO and UMLS were not used.
Limitations
- A probability is a model estimate, not proof of logical equivalence. Check the logical consequences before asserting
owl:equivalentClass.
License
LayaLink is released under the Apache License 2.0 (Apache-2.0).
The license permits commercial use, modification, distribution, and redistribution, subject to its terms.
See the Apache License 2.0 for details.
Note: The Apache-2.0 license applies to the LayaLink model and original code. Third-party datasets, ontologies, and other resources retain their respective licenses and usage restrictions.
- Downloads last month
- 46
Model tree for sensein/layalink
Base model
convaiinnovations/laya