Views
No views yet
| Branch | Training Type | Role Embedding | Use Case |
|---|---|---|---|
main (default) | Prediction Dataset | ✅ With role embedding | Default version: training on prediction dataset, support role embedding |
role-free | Prediction Dataset | ❌ Without role embedding | Training on prediction dataset, without role embedding |
inference-default | Inference Dataset | ✅ With role embedding | Training on inference dataset, with role support |
inference-role-free | Inference Dataset | ❌ Without role embedding | Training on inference dataset, without role embeddings |
1from OnT import OntologyTransformer
2
3# Default version (main branch - OnTr with role embedding)
4ont = OntologyTransformer.from_pretrained("Hui97/OnT-MiniLM-L12-anatomy")
5
6# Role-free version (without role embedding)
7ont = OntologyTransformer.from_pretrained("Hui97/OnT-MiniLM-L12-anatomy", revision="role-free")
8
9# Inference version with role embedding
10ont = OntologyTransformer.from_pretrained("Hui97/OnT-MiniLM-L12-anatomy", revision="inference-default")
11
12# Inference version without role embedding
13ont = OntologyTransformer.from_pretrained("Hui97/OnT-MiniLM-L12-anatomy", revision="inference-role-free")OntologyTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)pip install sentence-transformers==3.4.0.dev01import torch
2from OnT import OntologyTransformer
3
4# Load the OnT model
5path = "Hui97/OnT-MiniLM-L12-anatomy"
6ont = OntologyTransformer.from_pretrained(path)
7
8# Entity names to be encoded
9entity_names = [
10 'alveolar atrium',
11 'organ part',
12 'superior recess of lesser sac',
13]
14
15# Get the entity embeddings in hyperbolic space
16entity_embeddings = ont.encode_concept(entity_names)
17print(entity_embeddings.shape)
18# [3, 384]
19
20# Role sentences to be encoded
21role_sentences = [
22 "application attribute",
23 "attribute",
24 "chemical modifier"
25]
26
27# Get the role embeddings (rotations and scalings)
28role_rotations, role_scalings = ont.encode_roles(role_sentences)1@article{yang2025language,
2 title={Language Models as Ontology Encoders},
3 author={Yang, Hui and Chen, Jiaoyan and He, Yuan and Gao, Yongsheng and Horrocks, Ian},
4 journal={arXiv preprint arXiv:2507.14334},
5 year={2025}
6}