Sentence Similarity
sentence-transformers
Safetensors
roberta
feature-extraction
dense
text-embeddings-inference
Instructions to use kiel2/Kiel-2-Matrix with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use kiel2/Kiel-2-Matrix with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("kiel2/Kiel-2-Matrix") sentences = [ "But Close wondered whether the package would be worth the cost of licensing the third-party software , along with Salesforce.com 's rental price .", "Close also questions whether it would be worth the cost of licensing third-party software , along with Salesforce.com 's rental price .", "No tumors were detected ; rather , empty cavities and scar tissue were found in their place .", "A race observer sits in the passenger seat of the follow vehicle to record any broken rules and also keep track of the car 's time ." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
metadata
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dense
base_model: microsoft/codebert-base
widget:
- source_sentence: >-
But Close wondered whether the package would be worth the cost of
licensing the third-party software , along with Salesforce.com 's rental
price .
sentences:
- >-
Close also questions whether it would be worth the cost of licensing
third-party software , along with Salesforce.com 's rental price .
- >-
No tumors were detected ; rather , empty cavities and scar tissue were
found in their place .
- >-
A race observer sits in the passenger seat of the follow vehicle to
record any broken rules and also keep track of the car 's time .
- source_sentence: >-
Almihdhar and Alhazmi were aboard American Airlines Flight 77 , which
crashed into the Pentagon .
sentences:
- >-
Both have been identified as some of the hijackers who flew American
Airlines Flight 77 into the Pentagon .
- >-
" The Congress of the United States has never — ever — outlawed a
medical procedure , " said Rep. Louise McIntosh Slaughter ( D-N.Y. ) .
- >-
The agency wants him to return the illegal proceeds with interest and
pay civil monetary penalties .
- source_sentence: >-
He also called Hovan a " person of good reputation " who had worked as a
bus driver since 1967 .
sentences:
- >-
The other victim , Michael Walker , of 550 Barbey Street , was struck in
the neck .
- >-
The Fijian military installed an all-indigenous government led by Mr
Qarase , who won democratic elections in September 2001 .
- >-
Hovan , a resident of Trumbull , Conn . , had worked as a bus driver
since 1967 and had no prior criminal record .
- source_sentence: >-
Had the creditors turned down the bailout plan , LG Group might have been
forced to close down its credit card business .
sentences:
- >-
If the creditors turn down the bailout plan , LG Group may have to
closedown its card business .
- >-
Passengers on that cruise are to be given a refund and voucher for
another trip .
- >-
" People who were on their way home , all of a sudden taken from us , "
Mr. Bloomberg said of the collision .
- source_sentence: >-
" Any decision on Charleroi will have huge implications for regional
airports in France , " he said .
sentences:
- >-
" A bad decision on Charleroi would have huge implications for
state-owned regional airports in France .
- >-
Launched from space shuttle Atlantis ( news - web sites ) in 1989 ,
Galileo will have traveled about 2.8 billion miles by the time it hits
Jupiter .
- >-
He said the ferry 's crew will be interviewed and tested for drugs and
alcohol .
pipeline_tag: sentence-similarity
library_name: sentence-transformers
Kiel-2-Matrix
Kiel-2-Matrix is a specialized dense embedding model based on microsoft/codebert-base for code and text representation.
This is a sentence-transformers model that maps sentences and code blocks into a 768-dimensional dense vector space optimized for semantic textual similarity, semantic search, and clustering tasks.
Model Details
Model Description
- Model Type: Sentence Transformer / Dense Embedding Backbone
- Base Model: microsoft/codebert-base
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text & Code
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face Hub: kiel2/Kiel-2-Matrix
Full Model Architecture
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'RobertaModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)
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-Matrix")
# Run inference
sentences = [
'" Any decision on Charleroi will have huge implications for regional airports in France , " he said .',
'" A bad decision on Charleroi would have huge implications for state-owned regional airports in France .',
"He said the ferry 's crew will be interviewed and tested for drugs and alcohol .",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# 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)",
}