wbi-sg commited on
Commit
8bffb98
1 Parent(s): c388674

Create README.md

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