Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 25, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6sentences = [
7 'The weather is lovely today.',
8 "It's so sunny outside!",
9 'He drove to the stadium.',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities)
18# tensor([[1.0000, 0.6914, 0.4062],
19# [0.6914, 1.0000, 0.3145],
20# [0.4062, 0.3145, 1.0000]], dtype=torch.bfloat16)1@article{remy-etal-2023-biolord,
2 author = {Remy, François and Demuynck, Kris and Demeester, Thomas},
3 title = "{BioLORD-2023: semantic textual representations fusing large language models and clinical knowledge graph insights}",
4 journal = {Journal of the American Medical Informatics Association},
5 pages = {ocae029},
6 year = {2024},
7 month = {02},
8 issn = {1527-974X},
9 doi = {10.1093/jamia/ocae029},
10 url = {https://doi.org/10.1093/jamia/ocae029},
11 eprint = {https://academic.oup.com/jamia/advance-article-pdf/doi/10.1093/jamia/ocae029/56772025/ocae029.pdf},
12}