Sentence Similarity
sentence-transformers
Safetensors
Norwegian
bert
feature-extraction
dense
Generated from Trainer
dataset_size:527098
loss:MultipleNegativesRankingLoss
Eval Results (legacy)
text-embeddings-inference
Instructions to use NbAiLab/nb-sbert-v2-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use NbAiLab/nb-sbert-v2-base with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("NbAiLab/nb-sbert-v2-base") sentences = [ "The man talked to a girl over the internet camera.", "A group of elderly people pose around a dining table.", "A teenager talks to a girl over a webcam.", "There is no 'still' that is not relative to some other object." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -8,6 +8,10 @@ tags:
|
|
| 8 |
- dataset_size:527098
|
| 9 |
- loss:MultipleNegativesRankingLoss
|
| 10 |
base_model: NbAiLab/nb-bert-base
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
widget:
|
| 12 |
- source_sentence: The man talked to a girl over the internet camera.
|
| 13 |
sentences:
|
|
@@ -64,7 +68,7 @@ model-index:
|
|
| 64 |
|
| 65 |
# SentenceTransformer based on NbAiLab/nb-bert-base
|
| 66 |
|
| 67 |
-
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [NbAiLab/nb-bert-base](https://huggingface.co/NbAiLab/nb-bert-base). It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
|
| 68 |
|
| 69 |
## Model Details
|
| 70 |
|
|
@@ -74,9 +78,12 @@ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [N
|
|
| 74 |
- **Maximum Sequence Length:** 512 tokens
|
| 75 |
- **Output Dimensionality:** 768 dimensions
|
| 76 |
- **Similarity Function:** Cosine Similarity
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
### Model Sources
|
| 82 |
|
|
@@ -108,7 +115,7 @@ Then you can load this model and run inference.
|
|
| 108 |
from sentence_transformers import SentenceTransformer
|
| 109 |
|
| 110 |
# Download from the 🤗 Hub
|
| 111 |
-
model = SentenceTransformer("
|
| 112 |
# Run inference
|
| 113 |
sentences = [
|
| 114 |
'While Queen may refer to both Queen regent (sovereign) or Queen consort, the King has always been the sovereign.',
|
|
@@ -157,7 +164,7 @@ You can finetune this model on your own dataset.
|
|
| 157 |
|
| 158 |
#### Semantic Similarity
|
| 159 |
|
| 160 |
-
* Dataset:
|
| 161 |
* Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
|
| 162 |
|
| 163 |
| Metric | Value |
|
|
@@ -165,6 +172,17 @@ You can finetune this model on your own dataset.
|
|
| 165 |
| pearson_cosine | 0.8478 |
|
| 166 |
| **spearman_cosine** | **0.8495** |
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
<!--
|
| 169 |
## Bias, Risks and Limitations
|
| 170 |
|
|
@@ -181,7 +199,7 @@ You can finetune this model on your own dataset.
|
|
| 181 |
|
| 182 |
### Training Dataset
|
| 183 |
|
| 184 |
-
####
|
| 185 |
|
| 186 |
* Size: 527,098 training samples
|
| 187 |
* Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
|
|
@@ -204,11 +222,12 @@ You can finetune this model on your own dataset.
|
|
| 204 |
"gather_across_devices": false
|
| 205 |
}
|
| 206 |
```
|
|
|
|
|
|
|
| 207 |
|
| 208 |
-
###
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
* Size: 1,500 evaluation samples
|
| 213 |
* Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
|
| 214 |
* Approximate statistics based on the first 1000 samples:
|
|
@@ -230,7 +249,7 @@ You can finetune this model on your own dataset.
|
|
| 230 |
"gather_across_devices": false
|
| 231 |
}
|
| 232 |
```
|
| 233 |
-
|
| 234 |
### Training Hyperparameters
|
| 235 |
#### Non-Default Hyperparameters
|
| 236 |
|
|
@@ -347,58 +366,58 @@ You can finetune this model on your own dataset.
|
|
| 347 |
</details>
|
| 348 |
|
| 349 |
### Training Logs
|
| 350 |
-
| Epoch | Step | Training Loss |
|
| 351 |
-
|:------:|:----:|:-------------:|:---------------
|
| 352 |
-
| 0.0243 | 100 | 1.8923 | -
|
| 353 |
-
| 0.0486 | 200 | 0.8525 | -
|
| 354 |
-
| 0.0729 | 300 | 0.6760 | -
|
| 355 |
-
| 0.0971 | 400 | 0.5891 | -
|
| 356 |
-
| 0.1000 | 412 | - |
|
| 357 |
-
| 0.1214 | 500 | 0.5567 | -
|
| 358 |
-
| 0.1457 | 600 | 0.5245 | -
|
| 359 |
-
| 0.1700 | 700 | 0.5024 | -
|
| 360 |
-
| 0.1943 | 800 | 0.4654 | -
|
| 361 |
-
| 0.2001 | 824 | - |
|
| 362 |
-
| 0.2186 | 900 | 0.4796 | -
|
| 363 |
-
| 0.2428 | 1000 | 0.4528 | -
|
| 364 |
-
| 0.2671 | 1100 | 0.4577 | -
|
| 365 |
-
| 0.2914 | 1200 | 0.4443 | -
|
| 366 |
-
| 0.3001 | 1236 | - |
|
| 367 |
-
| 0.3157 | 1300 | 0.4201 | -
|
| 368 |
-
| 0.3400 | 1400 | 0.4010 | -
|
| 369 |
-
| 0.3643 | 1500 | 0.4063 | -
|
| 370 |
-
| 0.3885 | 1600 | 0.3955 | -
|
| 371 |
-
| 0.4002 | 1648 | - |
|
| 372 |
-
| 0.4128 | 1700 | 0.3798 | -
|
| 373 |
-
| 0.4371 | 1800 | 0.3772 | -
|
| 374 |
-
| 0.4614 | 1900 | 0.3933 | -
|
| 375 |
-
| 0.4857 | 2000 | 0.3793 | -
|
| 376 |
-
| 0.5002 | 2060 | - |
|
| 377 |
-
| 0.5100 | 2100 | 0.3862 | -
|
| 378 |
-
| 0.5342 | 2200 | 0.3730 | -
|
| 379 |
-
| 0.5585 | 2300 | 0.3463 | -
|
| 380 |
-
| 0.5828 | 2400 | 0.3556 | -
|
| 381 |
-
| 0.6003 | 2472 | - |
|
| 382 |
-
| 0.6071 | 2500 | 0.3614 | -
|
| 383 |
-
| 0.6314 | 2600 | 0.3479 | -
|
| 384 |
-
| 0.6557 | 2700 | 0.3508 | -
|
| 385 |
-
| 0.6799 | 2800 | 0.3463 | -
|
| 386 |
-
| 0.7003 | 2884 | - |
|
| 387 |
-
| 0.7042 | 2900 | 0.3453 | -
|
| 388 |
-
| 0.7285 | 3000 | 0.3327 | -
|
| 389 |
-
| 0.7528 | 3100 | 0.3269 | -
|
| 390 |
-
| 0.7771 | 3200 | 0.3333 | -
|
| 391 |
-
| 0.8004 | 3296 | - |
|
| 392 |
-
| 0.8014 | 3300 | 0.3370 | -
|
| 393 |
-
| 0.8256 | 3400 | 0.3254 | -
|
| 394 |
-
| 0.8499 | 3500 | 0.3348 | -
|
| 395 |
-
| 0.8742 | 3600 | 0.3213 | -
|
| 396 |
-
| 0.8985 | 3700 | 0.3376 | -
|
| 397 |
-
| 0.9004 | 3708 | - |
|
| 398 |
-
| 0.9228 | 3800 | 0.3362 | -
|
| 399 |
-
| 0.9471 | 3900 | 0.3246 | -
|
| 400 |
-
| 0.9713 | 4000 | 0.3215 | -
|
| 401 |
-
| 0.9956 | 4100 | 0.3143 | -
|
| 402 |
|
| 403 |
|
| 404 |
### Framework Versions
|
|
|
|
| 8 |
- dataset_size:527098
|
| 9 |
- loss:MultipleNegativesRankingLoss
|
| 10 |
base_model: NbAiLab/nb-bert-base
|
| 11 |
+
datasets: NbAiLab/mnli-norwegian
|
| 12 |
+
license: apache-2.0
|
| 13 |
+
language:
|
| 14 |
+
- 'no'
|
| 15 |
widget:
|
| 16 |
- source_sentence: The man talked to a girl over the internet camera.
|
| 17 |
sentences:
|
|
|
|
| 68 |
|
| 69 |
# SentenceTransformer based on NbAiLab/nb-bert-base
|
| 70 |
|
| 71 |
+
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [NbAiLab/nb-bert-base](https://huggingface.co/NbAiLab/nb-bert-base). It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more. The easiest way is to simply measure the cosine distance between two sentences. Sentences that are close to each other in meaning, will have a small cosine distance and a similarity close to 1. The model is trained in such a way that similar sentences in different languages should also be close to each other. Ideally, an English-Norwegian sentence pair should have high similarity.
|
| 72 |
|
| 73 |
## Model Details
|
| 74 |
|
|
|
|
| 78 |
- **Maximum Sequence Length:** 512 tokens
|
| 79 |
- **Output Dimensionality:** 768 dimensions
|
| 80 |
- **Similarity Function:** Cosine Similarity
|
| 81 |
+
- **Training Dataset:** Subset of [NbAiLab/mnli-norwegian](https://huggingface.co/datasets/NbAiLab/mnli-norwegian)
|
| 82 |
+
- **Language:** Norwegian and English
|
| 83 |
+
- **License:** Apache 2.0
|
| 84 |
+
### EU AI Act
|
| 85 |
+
|
| 86 |
+
This release is a non-generative encoder model whose outputs are vectors/scores rather than language or media. Its intended functionality is limited to representation, retrieval, ranking, or classification support. On that basis, the release is preliminarily assessed as not falling within the provider obligations for GPAI models under the EU AI Act definitions, subject to legal confirmation if capability scope or marketed generality changes.
|
| 87 |
|
| 88 |
### Model Sources
|
| 89 |
|
|
|
|
| 115 |
from sentence_transformers import SentenceTransformer
|
| 116 |
|
| 117 |
# Download from the 🤗 Hub
|
| 118 |
+
model = SentenceTransformer("NbAiLab/nb-sbert-v2-base")
|
| 119 |
# Run inference
|
| 120 |
sentences = [
|
| 121 |
'While Queen may refer to both Queen regent (sovereign) or Queen consort, the King has always been the sovereign.',
|
|
|
|
| 164 |
|
| 165 |
#### Semantic Similarity
|
| 166 |
|
| 167 |
+
* Dataset: [STS Benchmark](https://public.ukp.informatik.tu-darmstadt.de/reimers/sentence-transformers/datasets/stsbenchmark.tsv.gz)
|
| 168 |
* Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
|
| 169 |
|
| 170 |
| Metric | Value |
|
|
|
|
| 172 |
| pearson_cosine | 0.8478 |
|
| 173 |
| **spearman_cosine** | **0.8495** |
|
| 174 |
|
| 175 |
+
#### [MTEB (Scandinavian)](https://embeddings-benchmark.github.io/mteb/)
|
| 176 |
+
|
| 177 |
+
| Metric | Value |
|
| 178 |
+
|:--------------------|:-----------|
|
| 179 |
+
| Mean (Task) | |
|
| 180 |
+
| Mean (TaskType) | |
|
| 181 |
+
| Bitext Mining | |
|
| 182 |
+
| Classification | |
|
| 183 |
+
| Clustering | |
|
| 184 |
+
| Retrieval | |
|
| 185 |
+
|
| 186 |
<!--
|
| 187 |
## Bias, Risks and Limitations
|
| 188 |
|
|
|
|
| 199 |
|
| 200 |
### Training Dataset
|
| 201 |
|
| 202 |
+
#### Subset of [NbAiLab/mnli-norwegian](https://huggingface.co/datasets/NbAiLab/mnli-norwegian)
|
| 203 |
|
| 204 |
* Size: 527,098 training samples
|
| 205 |
* Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
|
|
|
|
| 222 |
"gather_across_devices": false
|
| 223 |
}
|
| 224 |
```
|
| 225 |
+
<!-- Removing Evaluation results because they don't actually measure much-->
|
| 226 |
+
<!-- ### Evaluation Dataset
|
| 227 |
|
| 228 |
+
#### [STS Benchmark](https://public.ukp.informatik.tu-darmstadt.de/reimers/sentence-transformers/datasets/stsbenchmark.tsv.gz)
|
| 229 |
+
* Partition: dev
|
| 230 |
+
* Language: English
|
|
|
|
| 231 |
* Size: 1,500 evaluation samples
|
| 232 |
* Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
|
| 233 |
* Approximate statistics based on the first 1000 samples:
|
|
|
|
| 249 |
"gather_across_devices": false
|
| 250 |
}
|
| 251 |
```
|
| 252 |
+
-->
|
| 253 |
### Training Hyperparameters
|
| 254 |
#### Non-Default Hyperparameters
|
| 255 |
|
|
|
|
| 366 |
</details>
|
| 367 |
|
| 368 |
### Training Logs
|
| 369 |
+
| Epoch | Step | Training Loss | sts-dev_spearman_cosine |
|
| 370 |
+
|:------:|:----:|:-------------:|:-----------------------:|
|
| 371 |
+
| 0.0243 | 100 | 1.8923 | - |
|
| 372 |
+
| 0.0486 | 200 | 0.8525 | - |
|
| 373 |
+
| 0.0729 | 300 | 0.6760 | - |
|
| 374 |
+
| 0.0971 | 400 | 0.5891 | - |
|
| 375 |
+
| 0.1000 | 412 | - | 0.8397 |
|
| 376 |
+
| 0.1214 | 500 | 0.5567 | - |
|
| 377 |
+
| 0.1457 | 600 | 0.5245 | - |
|
| 378 |
+
| 0.1700 | 700 | 0.5024 | - |
|
| 379 |
+
| 0.1943 | 800 | 0.4654 | - |
|
| 380 |
+
| 0.2001 | 824 | - | 0.8390 |
|
| 381 |
+
| 0.2186 | 900 | 0.4796 | - |
|
| 382 |
+
| 0.2428 | 1000 | 0.4528 | - |
|
| 383 |
+
| 0.2671 | 1100 | 0.4577 | - |
|
| 384 |
+
| 0.2914 | 1200 | 0.4443 | - |
|
| 385 |
+
| 0.3001 | 1236 | - | 0.8455 |
|
| 386 |
+
| 0.3157 | 1300 | 0.4201 | - |
|
| 387 |
+
| 0.3400 | 1400 | 0.4010 | - |
|
| 388 |
+
| 0.3643 | 1500 | 0.4063 | - |
|
| 389 |
+
| 0.3885 | 1600 | 0.3955 | - |
|
| 390 |
+
| 0.4002 | 1648 | - | 0.8446 |
|
| 391 |
+
| 0.4128 | 1700 | 0.3798 | - |
|
| 392 |
+
| 0.4371 | 1800 | 0.3772 | - |
|
| 393 |
+
| 0.4614 | 1900 | 0.3933 | - |
|
| 394 |
+
| 0.4857 | 2000 | 0.3793 | - |
|
| 395 |
+
| 0.5002 | 2060 | - | 0.8499 |
|
| 396 |
+
| 0.5100 | 2100 | 0.3862 | - |
|
| 397 |
+
| 0.5342 | 2200 | 0.3730 | - |
|
| 398 |
+
| 0.5585 | 2300 | 0.3463 | - |
|
| 399 |
+
| 0.5828 | 2400 | 0.3556 | - |
|
| 400 |
+
| 0.6003 | 2472 | - | 0.8503 |
|
| 401 |
+
| 0.6071 | 2500 | 0.3614 | - |
|
| 402 |
+
| 0.6314 | 2600 | 0.3479 | - |
|
| 403 |
+
| 0.6557 | 2700 | 0.3508 | - |
|
| 404 |
+
| 0.6799 | 2800 | 0.3463 | - |
|
| 405 |
+
| 0.7003 | 2884 | - | 0.8471 |
|
| 406 |
+
| 0.7042 | 2900 | 0.3453 | - |
|
| 407 |
+
| 0.7285 | 3000 | 0.3327 | - |
|
| 408 |
+
| 0.7528 | 3100 | 0.3269 | - |
|
| 409 |
+
| 0.7771 | 3200 | 0.3333 | - |
|
| 410 |
+
| 0.8004 | 3296 | - | 0.8493 |
|
| 411 |
+
| 0.8014 | 3300 | 0.3370 | - |
|
| 412 |
+
| 0.8256 | 3400 | 0.3254 | - |
|
| 413 |
+
| 0.8499 | 3500 | 0.3348 | - |
|
| 414 |
+
| 0.8742 | 3600 | 0.3213 | - |
|
| 415 |
+
| 0.8985 | 3700 | 0.3376 | - |
|
| 416 |
+
| 0.9004 | 3708 | - | 0.8495 |
|
| 417 |
+
| 0.9228 | 3800 | 0.3362 | - |
|
| 418 |
+
| 0.9471 | 3900 | 0.3246 | - |
|
| 419 |
+
| 0.9713 | 4000 | 0.3215 | - |
|
| 420 |
+
| 0.9956 | 4100 | 0.3143 | - |
|
| 421 |
|
| 422 |
|
| 423 |
### Framework Versions
|