helpmefindaname commited on
Commit
95dbd78
1 Parent(s): 54818d2

create model

Browse files
Files changed (2) hide show
  1. README.md +51 -0
  2. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - flair
4
+ - entity-mention-linker
5
+ ---
6
+
7
+ ## sapbert-bc5cdr-disease
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-sapbert-bc5cdr-disease")
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("dmis-lab/biosyn-sapbert-bc5cdr-disease", "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/dmis-lab/biosyn-sapbert-bc5cdr-disease](dmis-lab/biosyn-sapbert-bc5cdr-disease) 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:aae934b427d141e0fec853b0efc0fc3d13d19d36146bb8a22e8f78b7884d8d06
3
+ size 514871927