helpmefindaname
commited on
Commit
•
3d9a755
1
Parent(s):
0a8d708
create model
Browse files- README.md +51 -0
- pytorch_model.bin +3 -0
README.md
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- flair
|
4 |
+
- entity-mention-linker
|
5 |
+
---
|
6 |
+
|
7 |
+
## diseases-exact-match
|
8 |
+
|
9 |
+
Biomedical Entity Mention Linking for diseases
|
10 |
+
|
11 |
+
### Demo: How to use in Flair
|
12 |
+
|
13 |
+
Requires:
|
14 |
+
- **[Flair](https://github.com/flairNLP/flair/)>=0.14.0** (`pip install flair` or `pip install git+https://github.com/flairNLP/flair.git`)
|
15 |
+
|
16 |
+
|
17 |
+
```python
|
18 |
+
from flair.data import Sentence
|
19 |
+
from flair.models import Classifier, EntityMentionLinker
|
20 |
+
|
21 |
+
sentence = Sentence("Behavioral abnormalities in the Fmr1 KO2 Mouse Model of Fragile X Syndrome")
|
22 |
+
|
23 |
+
# load hunflair to detect the entity mentions we want to link.
|
24 |
+
tagger = Classifier.load("hunflair")
|
25 |
+
tagger.predict(sentence)
|
26 |
+
|
27 |
+
# load the linker and dictionary
|
28 |
+
linker = EntityMentionLinker.load("helpmefindaname/flair-eml-diseases-exact-match")
|
29 |
+
dictionary = linker.dictionary
|
30 |
+
|
31 |
+
# find then candidates for the mentions
|
32 |
+
linker.predict(sentence)
|
33 |
+
|
34 |
+
# print the results for each entity mention:
|
35 |
+
for span in sentence.get_spans(linker.entity_label_type):
|
36 |
+
print(f"Span: {span.text}")
|
37 |
+
for candidate_label in span.get_labels(linker.label_type):
|
38 |
+
candidate = dictionary[candidate_label.value]
|
39 |
+
print(f"Candidate: {candidate.concept_name}")
|
40 |
+
```
|
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 |
+
```python
|
46 |
+
linker = EntityMentionLinker.build("exact-string-match", "diseases", dictionary_name_or_path="ctd-diseases", hybrid_search=False, entity_type="diseases-eml")
|
47 |
+
```
|
48 |
+
This will reduce the download requirements, at the cost of computation.
|
49 |
+
|
50 |
+
This EntityMentionLinker uses [https://huggingface.co/exact-string-match](exact-string-match) as embeddings for linking mentions to candidates.
|
51 |
+
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0bc10fe044bbb3197c73f919ccb9517587163aca3ba13ff7e0e16d92b5f3bea6
|
3 |
+
size 2068348
|