Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 18
How to use kiel2/Kiel-2-Vector with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kiel2/Kiel-2-Vector")
sentences = [
"Name a style of hot yoga.",
"Bikram.",
"Tallahassee is the capital of Florida",
"I want a redhead woman with tattoos and big boobs and a big ass"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]Kiel-2-Vector is a dense embedding model based on BAAI/bge-small-en-v1.5. It maps inputs into a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
)
Direct Usage (Sentence Transformers)
First, install the Sentence Transformers library:
Bash
pip install -U sentence-transformers
Then load this model and run inference:
Python
from sentence_transformers import SentenceTransformer
# Load from the 🤗 Hub
model = SentenceTransformer("kiel2/Kiel-2-Vector")
# Run inference
sentences = [
'How often is The Australian Chess Championship held?',
'Every two years',
'Remove the - character and restore the split words in the markdown content.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# 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)",
}
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={[https://arxiv.org/abs/1807.03748](https://arxiv.org/abs/1807.03748)},
}
Base model
BAAI/bge-small-en-v1.5