Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
|
@@ -5,6 +5,29 @@ colorFrom: yellow
|
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
license: apache-2.0
|
| 9 |
---
|
| 10 |
|
| 11 |
+
Hierarchy Transformers (HiTs) are capable of interpreting and encoding hierarchies explicitly.
|
| 12 |
+
|
| 13 |
+
The relevant code in [HierarchyTransformers](https://github.com/KRR-Oxford/HierarchyTransformers) extends from [Sentence-Transformers](https://huggingface.co/sentence-transformers).
|
| 14 |
+
|
| 15 |
+
Example usage:
|
| 16 |
+
|
| 17 |
+
```python
|
| 18 |
+
from hierarchy_transformers import HierarchyTransformer
|
| 19 |
+
from hierarchy_transformers.utils import get_torch_device
|
| 20 |
+
|
| 21 |
+
# set up the device (use cpu if no gpu found)
|
| 22 |
+
gpu_id = 0
|
| 23 |
+
device = get_torch_device(gpu_id)
|
| 24 |
+
|
| 25 |
+
# load the model
|
| 26 |
+
model = HierarchyTransformer.load_pretrained('Hierarchy-Transformers/HiT-MiniLM-L12-WordNet')
|
| 27 |
+
|
| 28 |
+
# entity names to be encoded.
|
| 29 |
+
entity_names = ["computer", "personal computer", "laptop"]
|
| 30 |
+
|
| 31 |
+
# get the entity embeddings
|
| 32 |
+
entity_embeddings = model.encode(entity_names)
|
| 33 |
+
```
|