Model Details of BioLORD-2023-M-Dutch-InContext-v1
In-Context Dutch Clinical Embeddings with BioLORD & MedMentions
Do mentions sharing the same text need to have the same embedding? No!
This model supports embedding biomedical entities in both English and Dutch, but allows the in-context embedding of concepts, using the following template:
mention text [SEP] (context: ... a textual example containing mention text and some more text on both sides ...)
It also supports embedding mentions without context, particularly in English.
NOTE:
Unlike other models in the series, this model uses the [CLS] token to embed the mention.
References
📖 BioLORD-2023: semantic textual representations fusing large language models and clinical knowledge graph insights
Journal of the American Medical Informatics Association, 2024
François Remy, Kris Demuynck, Thomas Demeester
view online
📖 Annotation-preserving machine translation of English corpora to validate Dutch clinical concept extraction tools
Under review, with a preprint available on Medrxiv.org, 2024
Tom Seinen, Jan Kors, Erik van Mulligen, Peter Rijnbeek
view online
@article{remy-etal-2023-biolord,
author = {Remy, François and Demuynck, Kris and Demeester, Thomas},
title = "{BioLORD-2023: semantic textual representations fusing large language models and clinical knowledge graph insights}",
journal = {Journal of the American Medical Informatics Association},
pages = {ocae029},
year = {2024},
month = {02},
issn = {1527-974X},
doi = {10.1093/jamia/ocae029},
url = {https://doi.org/10.1093/jamia/ocae029},
eprint = {https://academic.oup.com/jamia/advance-article-pdf/doi/10.1093/jamia/ocae029/56772025/ocae029.pdf},
}
Usage (Sentence-Transformers)
This is a
sentence-transformers
model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search. This model has been finentuned for the biomedical domain. While it preserves a good ability to produce embeddings for general-purpose text, it will be more useful to you if you are trying to process medical documents such as EHR records or clinical notes. Both sentences and phrases can be embedded in the same latent space.
from sentence_transformers import SentenceTransformer
sentences = ["wond door kattenscrab", "kattenkrabziekte", "bartonellosis"]
model = SentenceTransformer('FremyCompany/BioLORD-2023-M-Dutch-InContext-v1 ')
embeddings = model.encode(sentences)
print(embeddings)
Usage (HuggingFace Transformers)
Without
sentence-transformers
, you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
from transformers import AutoTokenizer, AutoModel
import torch
import torch.nn.functional as F
#Mean Pooling - Take attention mask into account for correct averagingdefmean_pooling(model_output, attention_mask):
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
# Sentences we want sentence embeddings for
sentences = ["wond door kattenscrab", "kattenkrabziekte", "bartonellosis"]
# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('FremyCompany/BioLORD-2023-M-Dutch-InContext-v1 ')
model = AutoModel.from_pretrained('FremyCompany/BioLORD-2023-M')
# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
# Compute token embeddingswith torch.no_grad():
model_output = model(**encoded_input)
# Perform pooling
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
# Normalize embeddings
sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
print("Sentence embeddings:")
print(sentence_embeddings)
License
My own contributions for this model are covered by the MIT license.
However, given the data used to train this model originates from UMLS and SnomedCT, you will need to ensure you have proper licensing of UMLS and SnomedCT before using this model. Both UMLS and SnomedCT are free of charge in most countries, but you might have to create an account and report on your usage of the data yearly to keep a valid license.
Runs of FremyCompany BioLORD-2023-M-Dutch-InContext-v1 on huggingface.co
273
Total runs
-3
24-hour runs
17
3-day runs
38
7-day runs
236
30-day runs
More Information About BioLORD-2023-M-Dutch-InContext-v1 huggingface.co Model
More BioLORD-2023-M-Dutch-InContext-v1 license Visit here:
BioLORD-2023-M-Dutch-InContext-v1 huggingface.co is an AI model on huggingface.co that provides BioLORD-2023-M-Dutch-InContext-v1's model effect (), which can be used instantly with this FremyCompany BioLORD-2023-M-Dutch-InContext-v1 model. huggingface.co supports a free trial of the BioLORD-2023-M-Dutch-InContext-v1 model, and also provides paid use of the BioLORD-2023-M-Dutch-InContext-v1. Support call BioLORD-2023-M-Dutch-InContext-v1 model through api, including Node.js, Python, http.
BioLORD-2023-M-Dutch-InContext-v1 huggingface.co is an online trial and call api platform, which integrates BioLORD-2023-M-Dutch-InContext-v1's modeling effects, including api services, and provides a free online trial of BioLORD-2023-M-Dutch-InContext-v1, you can try BioLORD-2023-M-Dutch-InContext-v1 online for free by clicking the link below.
FremyCompany BioLORD-2023-M-Dutch-InContext-v1 online free url in huggingface.co:
BioLORD-2023-M-Dutch-InContext-v1 is an open source model from GitHub that offers a free installation service, and any user can find BioLORD-2023-M-Dutch-InContext-v1 on GitHub to install. At the same time, huggingface.co provides the effect of BioLORD-2023-M-Dutch-InContext-v1 install, users can directly use BioLORD-2023-M-Dutch-InContext-v1 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
BioLORD-2023-M-Dutch-InContext-v1 install url in huggingface.co: