Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 18
How to use kiel2/Kiel-2-Optic with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kiel2/Kiel-2-Optic")
sentences = [
"On Oct. 10 , an 18-year-old freshman member of the men 's swim team jumped from the same 10th-floor ledge .",
"\" It 's a blond-haired woman wearing a Cartier watch on her wrist , \" the source said .",
"He was sentenced to more than seven years in prison after pleading guilty to charges including securities fraud .",
"On Oct. 10 , an 18-year-old freshman from Dayton , Ohio , climbed over the same 10th-floor ledge and plunged to his death ."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]Kiel-2-Optic is a specialized multimodal text and image embedding model based on sentence-transformers/clip-ViT-B-32.
This is a sentence-transformers model that maps text and images into a shared 512-dimensional dense vector space optimized for multimodal semantic similarity, zero-shot classification, and image-text retrieval tasks.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'get_text_features', 'method_output_name': 'pooler_output'}, 'image': {'method': 'get_image_features', 'method_output_name': 'pooler_output'}}, 'module_output_name': 'sentence_embedding', 'architecture': 'CLIPModel'})
)
Direct Usage (Sentence Transformers)
First, install the Sentence Transformers library:
Bash
pip install -U sentence-transformers
Then load your model and run inference:
Python
from sentence_transformers import SentenceTransformer
# Load your model from the Hugging Face Hub
model = SentenceTransformer("kiel2/Kiel-2-Optic")
# Run inference
sentences = [
'Tornadoes , up to a foot of rain and hail as big as cantaloupes pounded southern Nebraska and northern Kansas , killing one man and destroying at least four homes .',
'Up to a foot of rain and at least seven tornadoes pounded southern Nebraska and northern Kansas , killing a man and destroying at least four homes .',
'The move follows a recent proposal by Mr Vajpayee , whoended an 18-month chill in relations by ordering normalisation of diplomatic links and restoration of air services with Pakistan .',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 512]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
Citation
Code snippet
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "[https://arxiv.org/abs/1908.10084](https://arxiv.org/abs/1908.10084)",
}
Base model
sentence-transformers/clip-ViT-B-32