Upload folder using huggingface_hub
Browse files- README.md +52 -0
- pytorch_model.bin +3 -0
README.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- flair
|
4 |
+
- entity-mention-linker
|
5 |
+
---
|
6 |
+
|
7 |
+
## biobert-ncbi-disease
|
8 |
+
|
9 |
+
Biomedical Entity Mention Linking for diseases
|
10 |
+
|
11 |
+
### Demo: How to use in Flair
|
12 |
+
|
13 |
+
Requires:
|
14 |
+
|
15 |
+
- **[Flair](https://github.com/flairNLP/flair/)>=0.14.0** (`pip install flair` or `pip install git+https://github.com/flairNLP/flair.git`)
|
16 |
+
|
17 |
+
```python
|
18 |
+
from flair.data import Sentence
|
19 |
+
from flair.nn import Classifier
|
20 |
+
from flair.models import EntityMentionLinker
|
21 |
+
|
22 |
+
sentence = Sentence("Behavioral abnormalities in the Fmr1 KO2 Mouse Model of Fragile X Syndrome")
|
23 |
+
|
24 |
+
# load hunflair to detect the entity mentions we want to link.
|
25 |
+
tagger = Classifier.load("hunflair-disease")
|
26 |
+
tagger.predict(sentence)
|
27 |
+
|
28 |
+
# load the linker and dictionary
|
29 |
+
linker = EntityMentionLinker.load("disease-linker")
|
30 |
+
dictionary = linker.dictionary
|
31 |
+
|
32 |
+
# find then candidates for the mentions
|
33 |
+
linker.predict(sentence)
|
34 |
+
|
35 |
+
# print the results for each entity mention:
|
36 |
+
for span in sentence.get_spans(tagger.label_type):
|
37 |
+
print(f"Span: {span.text}")
|
38 |
+
for candidate_label in span.get_labels(linker.label_type):
|
39 |
+
candidate = dictionary[candidate_label.value]
|
40 |
+
print(f"Candidate: {candidate.concept_name}")
|
41 |
+
```
|
42 |
+
|
43 |
+
As an alternative to downloading the already precomputed model (much storage). You can also build the model
|
44 |
+
and compute the embeddings for the dataset using:
|
45 |
+
|
46 |
+
```python
|
47 |
+
linker = EntityMentionLinker.build("dmis-lab/biosyn-biobert-ncbi-disease", dictionary_name_or_path="ctd-diseases", hybrid_search=True)
|
48 |
+
```
|
49 |
+
|
50 |
+
This will reduce the download requirements, at the cost of computation.
|
51 |
+
|
52 |
+
This EntityMentionLinker uses [https://huggingface.co/dmis-lab/biosyn-biobert-ncbi-disease](dmis-lab/biosyn-biobert-ncbi-disease) as embeddings for linking mentions to candidates.
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4ac11eb6e772f76f58f94970425e2692cc19470e839d0e7ec1389d1ded10baad
|
3 |
+
size 1161163878
|