Upload folder using huggingface_hub
Browse files- README.md +53 -0
- pytorch_model.bin +3 -0
README.md
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- flair
|
4 |
+
- entity-mention-linker
|
5 |
+
---
|
6 |
+
|
7 |
+
## biosyn-sapbert-bc5cdr-chemical
|
8 |
+
|
9 |
+
Biomedical Entity Mention Linking for chemical:
|
10 |
+
|
11 |
+
- Model: [dmis-lab/biosyn-sapbert-bc5cdr-chemical](https://huggingface.co/dmis-lab/biosyn-sapbert-bc5cdr-chemical)
|
12 |
+
- Dictionary: [CTD Chemicals](https://ctdbase.org/voc.go?type=chemical) (See License)
|
13 |
+
|
14 |
+
### Demo: How to use in Flair
|
15 |
+
|
16 |
+
Requires:
|
17 |
+
|
18 |
+
- **[Flair](https://github.com/flairNLP/flair/)>=0.14.0** (`pip install flair` or `pip install git+https://github.com/flairNLP/flair.git`)
|
19 |
+
|
20 |
+
```python
|
21 |
+
from flair.data import Sentence
|
22 |
+
from flair.models import Classifier, EntityMentionLinker
|
23 |
+
from flair.tokenization import SciSpacyTokenizer
|
24 |
+
|
25 |
+
sentence = Sentence(
|
26 |
+
"The mutation in the ABCD1 gene causes X-linked adrenoleukodystrophy, "
|
27 |
+
"a neurodegenerative disease, which is exacerbated by exposure to high "
|
28 |
+
"levels of mercury in dolphin populations.",
|
29 |
+
use_tokenizer=SciSpacyTokenizer()
|
30 |
+
)
|
31 |
+
|
32 |
+
# load hunflair to detect the entity mentions we want to link.
|
33 |
+
tagger = Classifier.load("hunflair-chemical")
|
34 |
+
tagger.predict(sentence)
|
35 |
+
|
36 |
+
# load the linker and dictionary
|
37 |
+
linker = EntityMentionLinker.load("chemical-linker")
|
38 |
+
linker.predict(sentence)
|
39 |
+
|
40 |
+
# print the results for each entity mention:
|
41 |
+
for span in sentence.get_spans(tagger.label_type):
|
42 |
+
for link in span.get_labels(linker.label_type):
|
43 |
+
print(f"{span.text} -> {link.value}")
|
44 |
+
```
|
45 |
+
|
46 |
+
As an alternative to downloading the already precomputed model (much storage). You can also build the model
|
47 |
+
and compute the embeddings for the dataset using:
|
48 |
+
|
49 |
+
```python
|
50 |
+
linker = EntityMentionLinker.build("dmis-lab/biosyn-sapbert-bc5cdr-chemical", dictionary_name_or_path="ctd-chemicals", hybrid_search=True)
|
51 |
+
```
|
52 |
+
|
53 |
+
This will reduce the download requirements, at the cost of computation.
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:023ec61893bb7e0a64fb9110c59732fbe5003bd377d379aca7df3c95cff59af5
|
3 |
+
size 4623832667
|