Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 18
How to use kiel2/KielEmbed-Pro with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kiel2/KielEmbed-Pro")
sentences = [
"The total number of new cases in China was fewer than 100 for the third day in a row .",
"The American Anglican Council , which represents Episcopalian conservatives , said it will seek authorization to create a separate group in North America .",
"On Monday , the number of SARS cases in China passed 5,000 , hitting a total of 5,013 .",
"Grant , a 22-year Monsanto veteran , also has been elected to the company 's board of directors , Monsanto said in a statement ."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]A flagship, high-performance dense embedding model fine-tuned for enterprise retrieval and semantic similarity tasks.
This is a sentence-transformers model fine-tuned from BAAI/bge-large-en-v1.5. It maps sentences and paragraphs into a high-fidelity 1024-dimensional dense vector space optimized for cross-domain retrieval.
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': 1024, 'pooling_mode': 'cls', 'include_prompt': True})
(2): Normalize({})
)
UsageDirect Usage (Sentence Transformers)First, install the Sentence Transformers library:Bashpip install -U sentence-transformers
Then load the model and run inference:Pythonfrom sentence_transformers import SentenceTransformer
# Load your custom cloud-hosted flagship embedder
model = SentenceTransformer("kiel/KielEmbed-Pro")
# Run inference
sentences = [
'Many conservatives have staunchly opposed condom programs , saying they send the wrong message and encourage and enable teens to have sex before marriage .',
'Some conservative groups have staunchly opposed such programs , saying they send the wrong message and in effect encourage and enable teens to have sex before marriage .',
"It 's just a matter of time , said Frank McDonald , of the University of Maryland .",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
Training DetailsTraining DatasetKiel Multi-Domain CorpusSize: 20,000 training samplesColumns: anchor and positiveApproximate Token Statistics (First 1,000 samples):Anchor: Min: 10 tokens | Mean: 27.34 tokens | Max: 51 tokensPositive: Min: 10 tokens | Mean: 27.39 tokens | Max: 51 tokensLoss Function: MultipleNegativesRankingLoss with parameters:JSON{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
Training HyperparametersPer Device Train Batch Size: 2Gradient Accumulation Steps: 16 (Effective batch size = 32)Learning Rate: 2e-05Number of Epochs: 1Warmup Steps: 0.1Mixed Precision: FP16 EnabledGradient Checkpointing: EnabledOptimizer: adamw_torch_fusedTraining LogsEpochStepTraining Loss0.16500.01770.321000.01350.481500.00710.642000.00740.82500.00940.963000.0097Total Training Time: 1.2 hoursFramework VersionsPython: 3.12.13Sentence Transformers: 5.4.1Transformers: 5.0.0PyTorch: 2.10.0+cu128Accelerate: 1.13.0Datasets: 5.0.0Tokenizers: 0.22.2CitationBibTeXSentence TransformersCode 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)",
}
MultipleNegativesRankingLossCode snippet@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-large-en-v1.5