1from sentence_transformers import SentenceTransformer
23# Download from the 🤗 Hub4model = SentenceTransformer("redis/langcache-embed-v3")5# Run inference6sentences =[7'"If you click ""like"" on an old post that someone made on your wall yet you\'re no longer Facebook friends, will they still receive a notification?"',8'"If you click ""like"" on an old post that someone made on your wall yet you\'re no longer Facebook friends, will they still receive a notification?"',9'"If your teenage son posted ""La commedia e finita"" on his Facebook wall, would you be concerned?"',10]11embeddings = model.encode(sentences)12print(embeddings.shape)13# [3, 768]1415# Get the similarity scores for the embeddings16similarities = model.similarity(embeddings, embeddings)17print(similarities)18# tensor([[1.0000, 1.0000, 0.6758],19# [1.0000, 1.0000, 0.6758],20# [0.6758, 0.6758, 1.0078]], dtype=torch.bfloat16)
Evaluation
Metrics
Custom Information Retrieval
Dataset: test
Evaluated with ir_evaluator.CustomInformationRetrievalEvaluator
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}