Sentence Similarity
sentence-transformers
Safetensors
English
modernbert
feature-extraction
dense
securebert
IR
docembedding
Generated from Trainer
dataset_size:35705
loss:MultipleNegativesRankingLoss
text-embeddings-inference
Instructions to use cisco-ai/SecureBERT2.0-biencoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use cisco-ai/SecureBERT2.0-biencoder with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("cisco-ai/SecureBERT2.0-biencoder") sentences = [ "What is the primary responsibility of the Information Security Oversight Committee in an organization?", "Least privilege", "By searching for repeating ciphertext sequences at fixed displacements.", "Ensuring and supporting information protection awareness and training programs" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Inference
- Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -81,6 +81,8 @@ pip install -U sentence-transformers
|
|
| 81 |
```
|
| 82 |
|
| 83 |
Then you can load this model and run inference.
|
|
|
|
|
|
|
| 84 |
```python
|
| 85 |
from sentence_transformers import SentenceTransformer
|
| 86 |
|
|
@@ -104,6 +106,25 @@ print(similarities)
|
|
| 104 |
# [ 0.0078, -0.0407, 1.0000]])
|
| 105 |
```
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
## Training Details
|
| 109 |
|
|
|
|
| 81 |
```
|
| 82 |
|
| 83 |
Then you can load this model and run inference.
|
| 84 |
+
|
| 85 |
+
#### Semantic Similarity:
|
| 86 |
```python
|
| 87 |
from sentence_transformers import SentenceTransformer
|
| 88 |
|
|
|
|
| 106 |
# [ 0.0078, -0.0407, 1.0000]])
|
| 107 |
```
|
| 108 |
|
| 109 |
+
#### Doc/Query Embedding
|
| 110 |
+
|
| 111 |
+
```python
|
| 112 |
+
from sentence_transformers import CrossEncoder, util
|
| 113 |
+
from transformers import AutoTokenizer, TFAutoModel
|
| 114 |
+
|
| 115 |
+
# Load the bi-encoder
|
| 116 |
+
tokenizer = AutoTokenizer.from_pretrained("/teamspace/studios/this_studio/secure_modern_bert/Models/reranker-securebert2-biencoder/final")
|
| 117 |
+
model = TFAutoModel.from_pretrained("/teamspace/studios/this_studio/secure_modern_bert/Models/reranker-securebert2-biencoder/final")
|
| 118 |
+
|
| 119 |
+
# Encode queries and documents
|
| 120 |
+
query_embedding = model(tokenizer("Example query", return_tensors="tf"))[0]
|
| 121 |
+
doc_embedding = model(tokenizer("Candidate document", return_tensors="tf"))[0]
|
| 122 |
+
|
| 123 |
+
# Compute similarity
|
| 124 |
+
import tensorflow as tf
|
| 125 |
+
similarity = tf.keras.losses.cosine_similarity(query_embedding, doc_embedding)
|
| 126 |
+
print(similarity)
|
| 127 |
+
```
|
| 128 |
|
| 129 |
## Training Details
|
| 130 |
|