README / README.md
lawhy's picture
Update README.md
f55ed24 verified
|
raw
history blame
909 Bytes
metadata
title: README
emoji: πŸ‘
colorFrom: yellow
colorTo: yellow
sdk: static
pinned: false
license: apache-2.0

Hierarchy Transformers (HiTs) are capable of interpreting and encoding hierarchies explicitly.

The relevant code in HierarchyTransformers extends from Sentence-Transformers.

Example usage:

from hierarchy_transformers import HierarchyTransformer
from hierarchy_transformers.utils import get_torch_device

# set up the device (use cpu if no gpu found)
gpu_id = 0
device = get_torch_device(gpu_id)

# load the model
model = HierarchyTransformer.load_pretrained('Hierarchy-Transformers/HiT-MiniLM-L12-WordNet')

# entity names to be encoded.
entity_names = ["computer", "personal computer", "laptop"]

# get the entity embeddings
entity_embeddings = model.encode(entity_names)