Sentence Similarity
sentence-transformers
Safetensors
xlm-roberta
feature-extraction
Generated from Trainer
dataset_size:80
loss:CoSENTLoss
Eval Results (legacy)
text-embeddings-inference
Instructions to use MahfoudAi/result_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use MahfoudAi/result_model with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("MahfoudAi/result_model") sentences = [ "Woman in white in foreground and a man slightly behind walking with a sign for John's Pizza and Gyro in the background.", "A man and a soman are eating together at John's Pizza and Gyro.", "A high school is hosting an event.", "A family of three is at the beach." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Embedding/hack_ai_embbedding_model
Browse files
README.md
CHANGED
|
@@ -8,37 +8,34 @@ tags:
|
|
| 8 |
- loss:CoSENTLoss
|
| 9 |
base_model: abdeljalilELmajjodi/model
|
| 10 |
widget:
|
| 11 |
-
- source_sentence: A woman in a green jacket and hood over her head looking towards
|
| 12 |
-
a valley.
|
| 13 |
-
sentences:
|
| 14 |
-
- The woman is cold.
|
| 15 |
-
- A person eating.
|
| 16 |
-
- A woman in white.
|
| 17 |
- source_sentence: Woman in white in foreground and a man slightly behind walking
|
| 18 |
with a sign for John's Pizza and Gyro in the background.
|
| 19 |
sentences:
|
| 20 |
-
- A man
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
- source_sentence: Woman in white in foreground and a man slightly behind walking
|
| 24 |
with a sign for John's Pizza and Gyro in the background.
|
| 25 |
sentences:
|
| 26 |
-
-
|
| 27 |
-
- A couple
|
| 28 |
-
-
|
| 29 |
-
- source_sentence:
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
sentences:
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
-
-
|
| 35 |
-
- source_sentence:
|
| 36 |
-
|
| 37 |
sentences:
|
| 38 |
-
- A
|
| 39 |
-
-
|
| 40 |
-
-
|
| 41 |
-
her.
|
| 42 |
pipeline_tag: sentence-similarity
|
| 43 |
library_name: sentence-transformers
|
| 44 |
metrics:
|
|
@@ -55,10 +52,10 @@ model-index:
|
|
| 55 |
type: pair-score-evaluator-dev
|
| 56 |
metrics:
|
| 57 |
- type: pearson_cosine
|
| 58 |
-
value: 0.
|
| 59 |
name: Pearson Cosine
|
| 60 |
- type: spearman_cosine
|
| 61 |
-
value: 0.
|
| 62 |
name: Spearman Cosine
|
| 63 |
---
|
| 64 |
|
|
@@ -112,9 +109,9 @@ from sentence_transformers import SentenceTransformer
|
|
| 112 |
model = SentenceTransformer("sentence_transformers_model_id")
|
| 113 |
# Run inference
|
| 114 |
sentences = [
|
| 115 |
-
'
|
| 116 |
-
'
|
| 117 |
-
'A
|
| 118 |
]
|
| 119 |
embeddings = model.encode(sentences)
|
| 120 |
print(embeddings.shape)
|
|
@@ -123,9 +120,9 @@ print(embeddings.shape)
|
|
| 123 |
# Get the similarity scores for the embeddings
|
| 124 |
similarities = model.similarity(embeddings, embeddings)
|
| 125 |
print(similarities)
|
| 126 |
-
# tensor([[1.0000, 0.
|
| 127 |
-
# [0.
|
| 128 |
-
# [0.
|
| 129 |
```
|
| 130 |
<!--
|
| 131 |
### Direct Usage (Transformers)
|
|
@@ -162,8 +159,8 @@ You can finetune this model on your own dataset.
|
|
| 162 |
|
| 163 |
| Metric | Value |
|
| 164 |
|:--------------------|:-----------|
|
| 165 |
-
| pearson_cosine | 0.
|
| 166 |
-
| **spearman_cosine** | **0.
|
| 167 |
|
| 168 |
<!--
|
| 169 |
## Bias, Risks and Limitations
|
|
@@ -190,13 +187,13 @@ You can finetune this model on your own dataset.
|
|
| 190 |
| | sentence1 | sentence2 | score |
|
| 191 |
|:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 192 |
| type | string | string | float |
|
| 193 |
-
| details | <ul><li>min: 10 tokens</li><li>mean:
|
| 194 |
* Samples:
|
| 195 |
-
| sentence1
|
| 196 |
-
|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
| 197 |
-
| <code>A
|
| 198 |
-
| <code>
|
| 199 |
-
| <code>
|
| 200 |
* Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
|
| 201 |
```json
|
| 202 |
{
|
|
@@ -216,13 +213,13 @@ You can finetune this model on your own dataset.
|
|
| 216 |
| | sentence1 | sentence2 | score |
|
| 217 |
|:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 218 |
| type | string | string | float |
|
| 219 |
-
| details | <ul><li>min:
|
| 220 |
* Samples:
|
| 221 |
-
| sentence1
|
| 222 |
-
|:-------------------------------------------------------------------------------------------------------------------------------------
|
| 223 |
-
| <code>A
|
| 224 |
-
| <code>
|
| 225 |
-
| <code>Woman in white in foreground and a man slightly behind walking with a sign for John's Pizza and Gyro in the background.</code>
|
| 226 |
* Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
|
| 227 |
```json
|
| 228 |
{
|
|
@@ -347,14 +344,14 @@ You can finetune this model on your own dataset.
|
|
| 347 |
### Training Logs
|
| 348 |
| Epoch | Step | Training Loss | Validation Loss | pair-score-evaluator-dev_spearman_cosine |
|
| 349 |
|:-------:|:------:|:-------------:|:---------------:|:----------------------------------------:|
|
| 350 |
-
| 0.1 | 1 | 2.
|
| 351 |
-
| 0.5 | 5 | 3.
|
| 352 |
-
| **1.0** | **10** | **3.
|
| 353 |
|
| 354 |
* The bold row denotes the saved checkpoint.
|
| 355 |
|
| 356 |
### Training Time
|
| 357 |
-
- **Training**: 4.
|
| 358 |
|
| 359 |
### Framework Versions
|
| 360 |
- Python: 3.12.13
|
|
|
|
| 8 |
- loss:CoSENTLoss
|
| 9 |
base_model: abdeljalilELmajjodi/model
|
| 10 |
widget:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
- source_sentence: Woman in white in foreground and a man slightly behind walking
|
| 12 |
with a sign for John's Pizza and Gyro in the background.
|
| 13 |
sentences:
|
| 14 |
+
- A man and a soman are eating together at John's Pizza and Gyro.
|
| 15 |
+
- A high school is hosting an event.
|
| 16 |
+
- A family of three is at the beach.
|
| 17 |
- source_sentence: Woman in white in foreground and a man slightly behind walking
|
| 18 |
with a sign for John's Pizza and Gyro in the background.
|
| 19 |
sentences:
|
| 20 |
+
- A married couple is walking next to each other.
|
| 21 |
+
- A married couple is sleeping.
|
| 22 |
+
- They are working for John's Pizza.
|
| 23 |
+
- source_sentence: A boy is jumping on skateboard in the middle of a red bridge.
|
| 24 |
+
sentences:
|
| 25 |
+
- The boy skates down the sidewalk.
|
| 26 |
+
- The woman is wearing black.
|
| 27 |
+
- An elderly man sits in a small shop.
|
| 28 |
+
- source_sentence: Two women who just had lunch hugging and saying goodbye.
|
| 29 |
sentences:
|
| 30 |
+
- There are two woman in this picture.
|
| 31 |
+
- Two adults walk across a street.
|
| 32 |
+
- A woman ordering pizza.
|
| 33 |
+
- source_sentence: High fashion ladies wait outside a tram beside a crowd of people
|
| 34 |
+
in the city.
|
| 35 |
sentences:
|
| 36 |
+
- A blond man getting a drink of water from a fountain in the park.
|
| 37 |
+
- A person is at a diner, ordering an omelette.
|
| 38 |
+
- The women do not care what clothes they wear.
|
|
|
|
| 39 |
pipeline_tag: sentence-similarity
|
| 40 |
library_name: sentence-transformers
|
| 41 |
metrics:
|
|
|
|
| 52 |
type: pair-score-evaluator-dev
|
| 53 |
metrics:
|
| 54 |
- type: pearson_cosine
|
| 55 |
+
value: 0.03573386095548956
|
| 56 |
name: Pearson Cosine
|
| 57 |
- type: spearman_cosine
|
| 58 |
+
value: 0.0572850816078118
|
| 59 |
name: Spearman Cosine
|
| 60 |
---
|
| 61 |
|
|
|
|
| 109 |
model = SentenceTransformer("sentence_transformers_model_id")
|
| 110 |
# Run inference
|
| 111 |
sentences = [
|
| 112 |
+
'High fashion ladies wait outside a tram beside a crowd of people in the city.',
|
| 113 |
+
'The women do not care what clothes they wear.',
|
| 114 |
+
'A blond man getting a drink of water from a fountain in the park.',
|
| 115 |
]
|
| 116 |
embeddings = model.encode(sentences)
|
| 117 |
print(embeddings.shape)
|
|
|
|
| 120 |
# Get the similarity scores for the embeddings
|
| 121 |
similarities = model.similarity(embeddings, embeddings)
|
| 122 |
print(similarities)
|
| 123 |
+
# tensor([[1.0000, 0.9959, 0.9963],
|
| 124 |
+
# [0.9959, 1.0000, 0.9936],
|
| 125 |
+
# [0.9963, 0.9936, 1.0000]])
|
| 126 |
```
|
| 127 |
<!--
|
| 128 |
### Direct Usage (Transformers)
|
|
|
|
| 159 |
|
| 160 |
| Metric | Value |
|
| 161 |
|:--------------------|:-----------|
|
| 162 |
+
| pearson_cosine | 0.0357 |
|
| 163 |
+
| **spearman_cosine** | **0.0573** |
|
| 164 |
|
| 165 |
<!--
|
| 166 |
## Bias, Risks and Limitations
|
|
|
|
| 187 |
| | sentence1 | sentence2 | score |
|
| 188 |
|:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 189 |
| type | string | string | float |
|
| 190 |
+
| details | <ul><li>min: 10 tokens</li><li>mean: 24.73 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 12.0 tokens</li><li>max: 29 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.51</li><li>max: 1.0</li></ul> |
|
| 191 |
* Samples:
|
| 192 |
+
| sentence1 | sentence2 | score |
|
| 193 |
+
|:-----------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------|:-----------------|
|
| 194 |
+
| <code>A couple playing with a little boy on the beach.</code> | <code>A couple are playing frisbee with a young child at the beach.</code> | <code>0.5</code> |
|
| 195 |
+
| <code>A Little League team tries to catch a runner sliding into a base in an afternoon game.</code> | <code>A team is trying to score the games winning out.</code> | <code>0.5</code> |
|
| 196 |
+
| <code>The school is having a special event in order to show the american culture on how other cultures are dealt with in parties.</code> | <code>A school is hosting an event.</code> | <code>1.0</code> |
|
| 197 |
* Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
|
| 198 |
```json
|
| 199 |
{
|
|
|
|
| 213 |
| | sentence1 | sentence2 | score |
|
| 214 |
|:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 215 |
| type | string | string | float |
|
| 216 |
+
| details | <ul><li>min: 16 tokens</li><li>mean: 29.75 tokens</li><li>max: 52 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 11.9 tokens</li><li>max: 20 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.47</li><li>max: 1.0</li></ul> |
|
| 217 |
* Samples:
|
| 218 |
+
| sentence1 | sentence2 | score |
|
| 219 |
+
|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------|:-----------------|
|
| 220 |
+
| <code>A person on a horse jumps over a broken down airplane.</code> | <code>A person is at a diner, ordering an omelette.</code> | <code>0.0</code> |
|
| 221 |
+
| <code>Two adults, one female in white, with shades and one male, gray clothes, walking across a street, away from a eatery with a blurred image of a dark colored red shirted person in the foreground.</code> | <code>Two adults walk across a street.</code> | <code>1.0</code> |
|
| 222 |
+
| <code>Woman in white in foreground and a man slightly behind walking with a sign for John's Pizza and Gyro in the background.</code> | <code>They are working for John's Pizza.</code> | <code>0.5</code> |
|
| 223 |
* Loss: [<code>CoSENTLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
|
| 224 |
```json
|
| 225 |
{
|
|
|
|
| 344 |
### Training Logs
|
| 345 |
| Epoch | Step | Training Loss | Validation Loss | pair-score-evaluator-dev_spearman_cosine |
|
| 346 |
|:-------:|:------:|:-------------:|:---------------:|:----------------------------------------:|
|
| 347 |
+
| 0.1 | 1 | 2.8066 | - | - |
|
| 348 |
+
| 0.5 | 5 | 3.3184 | - | - |
|
| 349 |
+
| **1.0** | **10** | **3.1168** | **2.7511** | **0.0573** |
|
| 350 |
|
| 351 |
* The bold row denotes the saved checkpoint.
|
| 352 |
|
| 353 |
### Training Time
|
| 354 |
+
- **Training**: 4.0 minutes
|
| 355 |
|
| 356 |
### Framework Versions
|
| 357 |
- Python: 3.12.13
|