fonshartendorp commited on
Commit
f73c1c6
1 Parent(s): c47dee9

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -0
README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - nl
4
+ tags:
5
+ - Biomedical entity linking
6
+ - sapBERT
7
+ - bioNLP
8
+ - embeddings
9
+ - representation learning
10
+ ---
11
+ ## Dutch Biomedical Entity Linking
12
+
13
+ ### Summary
14
+ - RoBERTa-based basemodel that is trained from scratch on Dutch hospital notes ([medRoBERTa.nl](https://huggingface.co/CLTL/MedRoBERTa.nl)).
15
+ - 2nd-phase pretrained using [self-alignment](https://doi.org/10.48550/arXiv.2010.11784) on UMLS-derived Dutch biomedical ontology.
16
+ - fine-tuned on automatically generated weakly labelled corpus from Wikipedia.
17
+ - evaluation results on [Mantra GSC](https://doi.org/10.1093/jamia/ocv037) corpus can be found in the [report](https://github.com/fonshartendorp/dutch_biomedical_entity_linking/blob/main/report/report.pdf)
18
+
19
+
20
+ All code can be found on [github](https://github.com/fonshartendorp/dutch_biomedical_entity_linking).
21
+
22
+ ### Usage
23
+
24
+ The following script (reused the original [sapBERT repository](https://huggingface.co/cambridgeltl/SapBERT-from-PubMedBERT-fulltext?text=kidney)) computes the embeddings for a list of input entities (strings)
25
+
26
+ ```
27
+ import numpy as np
28
+ import torch
29
+ from tqdm.auto import tqdm
30
+ from transformers import AutoTokenizer, AutoModel
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained("fonshartendorp/dutch_biomedical_entity_linking)")
33
+ model = AutoModel.from_pretrained("fonshartendorp/dutch_biomedical_entity_linking").cuda()
34
+
35
+ # replace with your own list of entity names
36
+ dutch_biomedical_entities = ["versnelde ademhaling", "Coronavirus infectie", "aandachtstekort/hyperactiviteitstoornis", "hartaanval"]
37
+
38
+ bs = 128 # batch size during inference
39
+ all_embs = []
40
+ for i in tqdm(np.arange(0, len(dutch_biomedical_entities), bs)):
41
+ toks = tokenizer.batch_encode_plus(dutch_biomedical_entities[i:i+bs],
42
+ padding="max_length",
43
+ max_length=25,
44
+ truncation=True,
45
+ return_tensors="pt")
46
+ toks_cuda = {}
47
+ for k,v in toks.items():
48
+ toks_cuda[k] = v.cuda()
49
+ cls_rep = model(**toks_cuda)[0][:,0,:] # use CLS representation as the embedding
50
+ all_embs.append(cls_rep.cpu().detach().numpy())
51
+
52
+ all_embs = np.concatenate(all_embs, axis=0)
53
+ ```
54
+
55
+ For (Dutch) biomedical entity linking, the following steps should be performed:
56
+
57
+ 1. Request UMLS (and SNOMED NL) license
58
+ 2. Precompute embeddings for all entities in the UMLS with the fine-tuned model
59
+ 3. Compute embedding of the new, unseen mention with the fine-tuned model
60
+ 4. Perform nearest-neighbour search (or search FAISS-index) for linking the embedding of the new mention to its most similar embedding from the UMLS