Sentence Similarity
sentence-transformers
PyTorch
TensorFlow
Rust
ONNX
Safetensors
OpenVINO
Transformers
English
bert
feature-extraction
Eval Results
text-embeddings-inference
Instructions to use sentence-transformers/all-MiniLM-L6-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use sentence-transformers/all-MiniLM-L6-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use sentence-transformers/all-MiniLM-L6-v2 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-MiniLM-L6-v2") model = AutoModel.from_pretrained("sentence-transformers/all-MiniLM-L6-v2", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
Moderation Challenge
#9
by woisme - opened
- .gitattributes +0 -1
- README.md +12 -11
- model.safetensors +0 -3
- onnx/model.onnx +0 -3
- onnx/model_O1.onnx +0 -3
- onnx/model_O2.onnx +0 -3
- onnx/model_O3.onnx +0 -3
- onnx/model_O4.onnx +0 -3
- onnx/model_qint8_arm64.onnx +0 -3
- onnx/model_qint8_avx512.onnx +0 -3
- onnx/model_qint8_avx512_vnni.onnx +0 -3
- onnx/model_quint8_avx2.onnx +0 -3
- openvino/openvino_model.bin +0 -3
- openvino/openvino_model.xml +0 -0
- openvino/openvino_model_qint8_quantized.bin +0 -3
- openvino/openvino_model_qint8_quantized.xml +0 -0
.gitattributes
CHANGED
|
@@ -25,4 +25,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
- nreimers/MiniLM-L6-H384-uncased
|
| 4 |
-
language: en
|
| 5 |
-
license: apache-2.0
|
| 6 |
-
library_name: sentence-transformers
|
| 7 |
tags:
|
| 8 |
- sentence-transformers
|
| 9 |
- feature-extraction
|
| 10 |
- sentence-similarity
|
| 11 |
-
|
|
|
|
| 12 |
datasets:
|
| 13 |
- s2orc
|
| 14 |
- flax-sentence-embeddings/stackexchange_xml
|
|
@@ -31,7 +28,7 @@ datasets:
|
|
| 31 |
- embedding-data/SPECTER
|
| 32 |
- embedding-data/PAQ_pairs
|
| 33 |
- embedding-data/WikiAnswers
|
| 34 |
-
|
| 35 |
---
|
| 36 |
|
| 37 |
|
|
@@ -94,6 +91,10 @@ print("Sentence embeddings:")
|
|
| 94 |
print(sentence_embeddings)
|
| 95 |
```
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
------
|
| 98 |
|
| 99 |
## Background
|
|
@@ -102,14 +103,14 @@ The project aims to train sentence embedding models on very large sentence level
|
|
| 102 |
contrastive learning objective. We used the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model and fine-tuned in on a
|
| 103 |
1B sentence pairs dataset. We use a contrastive learning objective: given a sentence from the pair, the model should predict which out of a set of randomly sampled other sentences, was actually paired with it in our dataset.
|
| 104 |
|
| 105 |
-
We
|
| 106 |
[Community week using JAX/Flax for NLP & CV](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104),
|
| 107 |
-
organized by Hugging Face. We
|
| 108 |
[Train the Best Sentence Embedding Model Ever with 1B Training Pairs](https://discuss.huggingface.co/t/train-the-best-sentence-embedding-model-ever-with-1b-training-pairs/7354). We benefited from efficient hardware infrastructure to run the project: 7 TPUs v3-8, as well as intervention from Googles Flax, JAX, and Cloud team member about efficient deep learning frameworks.
|
| 109 |
|
| 110 |
## Intended uses
|
| 111 |
|
| 112 |
-
Our model is
|
| 113 |
the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
|
| 114 |
|
| 115 |
By default, input text longer than 256 word pieces is truncated.
|
|
@@ -128,7 +129,7 @@ We then apply the cross entropy loss by comparing with true pairs.
|
|
| 128 |
|
| 129 |
#### Hyper parameters
|
| 130 |
|
| 131 |
-
We trained
|
| 132 |
We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
|
| 133 |
a 2e-5 learning rate. The full training script is accessible in this current repository: `train_script.py`.
|
| 134 |
|
|
|
|
| 1 |
---
|
| 2 |
+
pipeline_tag: sentence-similarity
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
- sentence-transformers
|
| 5 |
- feature-extraction
|
| 6 |
- sentence-similarity
|
| 7 |
+
language: en
|
| 8 |
+
license: apache-2.0
|
| 9 |
datasets:
|
| 10 |
- s2orc
|
| 11 |
- flax-sentence-embeddings/stackexchange_xml
|
|
|
|
| 28 |
- embedding-data/SPECTER
|
| 29 |
- embedding-data/PAQ_pairs
|
| 30 |
- embedding-data/WikiAnswers
|
| 31 |
+
|
| 32 |
---
|
| 33 |
|
| 34 |
|
|
|
|
| 91 |
print(sentence_embeddings)
|
| 92 |
```
|
| 93 |
|
| 94 |
+
## Evaluation Results
|
| 95 |
+
|
| 96 |
+
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=sentence-transformers/all-MiniLM-L6-v2)
|
| 97 |
+
|
| 98 |
------
|
| 99 |
|
| 100 |
## Background
|
|
|
|
| 103 |
contrastive learning objective. We used the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model and fine-tuned in on a
|
| 104 |
1B sentence pairs dataset. We use a contrastive learning objective: given a sentence from the pair, the model should predict which out of a set of randomly sampled other sentences, was actually paired with it in our dataset.
|
| 105 |
|
| 106 |
+
We developped this model during the
|
| 107 |
[Community week using JAX/Flax for NLP & CV](https://discuss.huggingface.co/t/open-to-the-community-community-week-using-jax-flax-for-nlp-cv/7104),
|
| 108 |
+
organized by Hugging Face. We developped this model as part of the project:
|
| 109 |
[Train the Best Sentence Embedding Model Ever with 1B Training Pairs](https://discuss.huggingface.co/t/train-the-best-sentence-embedding-model-ever-with-1b-training-pairs/7354). We benefited from efficient hardware infrastructure to run the project: 7 TPUs v3-8, as well as intervention from Googles Flax, JAX, and Cloud team member about efficient deep learning frameworks.
|
| 110 |
|
| 111 |
## Intended uses
|
| 112 |
|
| 113 |
+
Our model is intented to be used as a sentence and short paragraph encoder. Given an input text, it ouptuts a vector which captures
|
| 114 |
the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
|
| 115 |
|
| 116 |
By default, input text longer than 256 word pieces is truncated.
|
|
|
|
| 129 |
|
| 130 |
#### Hyper parameters
|
| 131 |
|
| 132 |
+
We trained ou model on a TPU v3-8. We train the model during 100k steps using a batch size of 1024 (128 per TPU core).
|
| 133 |
We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
|
| 134 |
a 2e-5 learning rate. The full training script is accessible in this current repository: `train_script.py`.
|
| 135 |
|
model.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db
|
| 3 |
-
size 90868376
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:6fd5d72fe4589f189f8ebc006442dbb529bb7ce38f8082112682524616046452
|
| 3 |
-
size 90405214
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_O1.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1391c6fc20b5530250bc15cbe1f47578ffeca55ab0551d335cc668b6299a88ec
|
| 3 |
-
size 90360328
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_O2.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1de3905029190b398c7d300b530e320cf4b5e7d3dfb9af1429ebd73fd9a16faf
|
| 3 |
-
size 90326566
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_O3.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a44f671e364dddbac31f203f07b91be6b0a35e51936e5ebfab65b6d9538b83ff
|
| 3 |
-
size 90326497
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_O4.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1667d7f3ba669048b13a96ee3a44456d5e42c8f44588ae8b603430e16160c485
|
| 3 |
-
size 45212349
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_qint8_arm64.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:4278337fd0ff3c68bfb6291042cad8ab363e1d9fbc43dcb499fe91c871902474
|
| 3 |
-
size 23026053
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_qint8_avx512.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:4278337fd0ff3c68bfb6291042cad8ab363e1d9fbc43dcb499fe91c871902474
|
| 3 |
-
size 23026053
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_qint8_avx512_vnni.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:4278337fd0ff3c68bfb6291042cad8ab363e1d9fbc43dcb499fe91c871902474
|
| 3 |
-
size 23026053
|
|
|
|
|
|
|
|
|
|
|
|
onnx/model_quint8_avx2.onnx
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b941bf19f1f1283680f449fa6a7336bb5600bdcd5f84d10ddc5cd72218a0fd21
|
| 3 |
-
size 23046789
|
|
|
|
|
|
|
|
|
|
|
|
openvino/openvino_model.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:8b86cab4722e2aefab310cf96d4d5a9eb3b187f7d9670a082afc55c7fa0d392a
|
| 3 |
-
size 90265744
|
|
|
|
|
|
|
|
|
|
|
|
openvino/openvino_model.xml
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
openvino/openvino_model_qint8_quantized.bin
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:c92ea4af3c6bc7b4a0f3b3d61b147c850f4dbdd7c9e7beee0c0c70dc12da289b
|
| 3 |
-
size 22933664
|
|
|
|
|
|
|
|
|
|
|
|
openvino/openvino_model_qint8_quantized.xml
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|