Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +3 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/59d594003bf59880a884c574bf88ef7555bb0202.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/72b987fd805cfa2b58c4c8c952b274a11bfd5a00.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/8cfec92309f5626a223304af2423e332f6d31887.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/952a9b81c0bfd99800fabf352f69c7ccd46c5e43.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/c79f2b6a0cea6f4b564fed1938984bace9d30ff0.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/cb202bfe2e3c98645018a6d12f182a434c9d3e02.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/d1514c3162bbe87b343f565fadc62e6c06f04f03.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/e7b0375001f109a6b8873d756ad4f7bbb15fbaa5.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/fb140275c155a9c7c5a3b3e0e77a9e839594a938.lock +0 -0
- hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/fd1b291129c607e5d49799f87cb219b27f98acdf.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/065b011b76fe98894d8975acfa28f028085fa35b.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/0da3507018a1a1c625ff93179ff60bdb9202cc6c.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/2c3387be76557bd40970cec13153b3bbf80407865484b209e655e5e4729076b8.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/2ea7ad0e45a9d1d1591782ba7e29a703d0758831.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/5fd10429389515d3e5cccdeda08cae5fea1ae82e.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/b974b349cb2d419ada11181750a733ff82f291ad.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/c06d5b49495f044e6380e68a60538be17a6bd5d1.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/d1514c3162bbe87b343f565fadc62e6c06f04f03.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/eaa086f0ffee582aeb45b36e34cdd1fe2d6de2bef61f8a559a1bbc9bd955917b.lock +0 -0
- hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/f7640f94e81bb7f4f04daf1668850b38763a13d9.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/0204ed10c186a4c7c68f55dff8f26087a45898d6.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/226b0752cac7789c48f0cb3ec53eda48b7be36cc.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/4b1f9051605c296344c271b6d21c1e2e412a99e8.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/4bf7aed8ba4325d23fa7cd348d795a27f3b272682536f08aca4cdd62cde79293.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/5145e0895f2fe7f1ccb3eb9da69ec74ec9c680db.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/619b6765140cdfaa9b9d20619cae17643a28265f.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/6ac7b4364eba1fdd1d3981e4669aed01a2b0cec4.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/7debb4784a7d53328d4d021fc46314bec4af3833.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/84ef7fb594b5c0979e48bdeddb60a0adef33df0b.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/923ea295017e96fb15774a11a903f99adff3bd4b.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/98dd65a59581dac66a3601da9aadd1534f019006.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/a4878a2253d32f2dcd950cde16ebedffb9644ae6.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/ae1ab764382e24c65d906c16fba36650b634426a.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/b93162eb8252d2d937a69f17971c76b8be87aedd.lock +0 -0
- hub/.locks/models--vikhyatk--moondream2/c1148447551675ea739c440ee3e247df9f354d8f.lock +0 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/.no_exist/fa97f6e7cb1a59073dff9e6b13e2715cf7475ac9/adapter_config.json +0 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/.no_exist/fa97f6e7cb1a59073dff9e6b13e2715cf7475ac9/added_tokens.json +0 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db +3 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/59d594003bf59880a884c574bf88ef7555bb0202 +4 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/72b987fd805cfa2b58c4c8c952b274a11bfd5a00 +24 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/8cfec92309f5626a223304af2423e332f6d31887 +177 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/952a9b81c0bfd99800fabf352f69c7ccd46c5e43 +20 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/c79f2b6a0cea6f4b564fed1938984bace9d30ff0 +1 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/cb202bfe2e3c98645018a6d12f182a434c9d3e02 +0 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/d1514c3162bbe87b343f565fadc62e6c06f04f03 +7 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/e7b0375001f109a6b8873d756ad4f7bbb15fbaa5 +1 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/fb140275c155a9c7c5a3b3e0e77a9e839594a938 +0 -0
- hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/fd1b291129c607e5d49799f87cb219b27f98acdf +7 -0
.gitattributes
CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db filter=lfs diff=lfs merge=lfs -text
|
37 |
+
hub/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/blobs/eaa086f0ffee582aeb45b36e34cdd1fe2d6de2bef61f8a559a1bbc9bd955917b filter=lfs diff=lfs merge=lfs -text
|
38 |
+
hub/models--vikhyatk--moondream2/blobs/4bf7aed8ba4325d23fa7cd348d795a27f3b272682536f08aca4cdd62cde79293 filter=lfs diff=lfs merge=lfs -text
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/59d594003bf59880a884c574bf88ef7555bb0202.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/72b987fd805cfa2b58c4c8c952b274a11bfd5a00.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/8cfec92309f5626a223304af2423e332f6d31887.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/952a9b81c0bfd99800fabf352f69c7ccd46c5e43.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/c79f2b6a0cea6f4b564fed1938984bace9d30ff0.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/cb202bfe2e3c98645018a6d12f182a434c9d3e02.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/d1514c3162bbe87b343f565fadc62e6c06f04f03.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/e7b0375001f109a6b8873d756ad4f7bbb15fbaa5.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/fb140275c155a9c7c5a3b3e0e77a9e839594a938.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--all-MiniLM-L6-v2/fd1b291129c607e5d49799f87cb219b27f98acdf.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/065b011b76fe98894d8975acfa28f028085fa35b.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/0da3507018a1a1c625ff93179ff60bdb9202cc6c.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/2c3387be76557bd40970cec13153b3bbf80407865484b209e655e5e4729076b8.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/2ea7ad0e45a9d1d1591782ba7e29a703d0758831.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/5fd10429389515d3e5cccdeda08cae5fea1ae82e.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/b974b349cb2d419ada11181750a733ff82f291ad.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/c06d5b49495f044e6380e68a60538be17a6bd5d1.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/d1514c3162bbe87b343f565fadc62e6c06f04f03.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/eaa086f0ffee582aeb45b36e34cdd1fe2d6de2bef61f8a559a1bbc9bd955917b.lock
ADDED
File without changes
|
hub/.locks/models--sentence-transformers--paraphrase-multilingual-MiniLM-L12-v2/f7640f94e81bb7f4f04daf1668850b38763a13d9.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/0204ed10c186a4c7c68f55dff8f26087a45898d6.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/226b0752cac7789c48f0cb3ec53eda48b7be36cc.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/4b1f9051605c296344c271b6d21c1e2e412a99e8.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/4bf7aed8ba4325d23fa7cd348d795a27f3b272682536f08aca4cdd62cde79293.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/5145e0895f2fe7f1ccb3eb9da69ec74ec9c680db.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/619b6765140cdfaa9b9d20619cae17643a28265f.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/6ac7b4364eba1fdd1d3981e4669aed01a2b0cec4.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/7debb4784a7d53328d4d021fc46314bec4af3833.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/84ef7fb594b5c0979e48bdeddb60a0adef33df0b.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/923ea295017e96fb15774a11a903f99adff3bd4b.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/98dd65a59581dac66a3601da9aadd1534f019006.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/a4878a2253d32f2dcd950cde16ebedffb9644ae6.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/ae1ab764382e24c65d906c16fba36650b634426a.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/b93162eb8252d2d937a69f17971c76b8be87aedd.lock
ADDED
File without changes
|
hub/.locks/models--vikhyatk--moondream2/c1148447551675ea739c440ee3e247df9f354d8f.lock
ADDED
File without changes
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/.no_exist/fa97f6e7cb1a59073dff9e6b13e2715cf7475ac9/adapter_config.json
ADDED
File without changes
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/.no_exist/fa97f6e7cb1a59073dff9e6b13e2715cf7475ac9/added_tokens.json
ADDED
File without changes
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:53aa51172d142c89d9012cce15ae4d6cc0ca6895895114379cacb4fab128d9db
|
3 |
+
size 90868376
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/59d594003bf59880a884c574bf88ef7555bb0202
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 256,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/72b987fd805cfa2b58c4c8c952b274a11bfd5a00
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "nreimers/MiniLM-L6-H384-uncased",
|
3 |
+
"architectures": [
|
4 |
+
"BertModel"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"gradient_checkpointing": false,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.1,
|
10 |
+
"hidden_size": 384,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 1536,
|
13 |
+
"layer_norm_eps": 1e-12,
|
14 |
+
"max_position_embeddings": 512,
|
15 |
+
"model_type": "bert",
|
16 |
+
"num_attention_heads": 12,
|
17 |
+
"num_hidden_layers": 6,
|
18 |
+
"pad_token_id": 0,
|
19 |
+
"position_embedding_type": "absolute",
|
20 |
+
"transformers_version": "4.8.2",
|
21 |
+
"type_vocab_size": 2,
|
22 |
+
"use_cache": true,
|
23 |
+
"vocab_size": 30522
|
24 |
+
}
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/8cfec92309f5626a223304af2423e332f6d31887
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
license: apache-2.0
|
4 |
+
library_name: sentence-transformers
|
5 |
+
tags:
|
6 |
+
- sentence-transformers
|
7 |
+
- feature-extraction
|
8 |
+
- sentence-similarity
|
9 |
+
- transformers
|
10 |
+
datasets:
|
11 |
+
- s2orc
|
12 |
+
- flax-sentence-embeddings/stackexchange_xml
|
13 |
+
- ms_marco
|
14 |
+
- gooaq
|
15 |
+
- yahoo_answers_topics
|
16 |
+
- code_search_net
|
17 |
+
- search_qa
|
18 |
+
- eli5
|
19 |
+
- snli
|
20 |
+
- multi_nli
|
21 |
+
- wikihow
|
22 |
+
- natural_questions
|
23 |
+
- trivia_qa
|
24 |
+
- embedding-data/sentence-compression
|
25 |
+
- embedding-data/flickr30k-captions
|
26 |
+
- embedding-data/altlex
|
27 |
+
- embedding-data/simple-wiki
|
28 |
+
- embedding-data/QQP
|
29 |
+
- embedding-data/SPECTER
|
30 |
+
- embedding-data/PAQ_pairs
|
31 |
+
- embedding-data/WikiAnswers
|
32 |
+
pipeline_tag: sentence-similarity
|
33 |
+
---
|
34 |
+
|
35 |
+
|
36 |
+
# all-MiniLM-L6-v2
|
37 |
+
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
38 |
+
|
39 |
+
## Usage (Sentence-Transformers)
|
40 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
41 |
+
|
42 |
+
```
|
43 |
+
pip install -U sentence-transformers
|
44 |
+
```
|
45 |
+
|
46 |
+
Then you can use the model like this:
|
47 |
+
```python
|
48 |
+
from sentence_transformers import SentenceTransformer
|
49 |
+
sentences = ["This is an example sentence", "Each sentence is converted"]
|
50 |
+
|
51 |
+
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
|
52 |
+
embeddings = model.encode(sentences)
|
53 |
+
print(embeddings)
|
54 |
+
```
|
55 |
+
|
56 |
+
## Usage (HuggingFace Transformers)
|
57 |
+
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
|
58 |
+
|
59 |
+
```python
|
60 |
+
from transformers import AutoTokenizer, AutoModel
|
61 |
+
import torch
|
62 |
+
import torch.nn.functional as F
|
63 |
+
|
64 |
+
#Mean Pooling - Take attention mask into account for correct averaging
|
65 |
+
def mean_pooling(model_output, attention_mask):
|
66 |
+
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
|
67 |
+
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
68 |
+
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
69 |
+
|
70 |
+
|
71 |
+
# Sentences we want sentence embeddings for
|
72 |
+
sentences = ['This is an example sentence', 'Each sentence is converted']
|
73 |
+
|
74 |
+
# Load model from HuggingFace Hub
|
75 |
+
tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
76 |
+
model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
|
77 |
+
|
78 |
+
# Tokenize sentences
|
79 |
+
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
80 |
+
|
81 |
+
# Compute token embeddings
|
82 |
+
with torch.no_grad():
|
83 |
+
model_output = model(**encoded_input)
|
84 |
+
|
85 |
+
# Perform pooling
|
86 |
+
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
87 |
+
|
88 |
+
# Normalize embeddings
|
89 |
+
sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
|
90 |
+
|
91 |
+
print("Sentence embeddings:")
|
92 |
+
print(sentence_embeddings)
|
93 |
+
```
|
94 |
+
|
95 |
+
## Evaluation Results
|
96 |
+
|
97 |
+
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)
|
98 |
+
|
99 |
+
------
|
100 |
+
|
101 |
+
## Background
|
102 |
+
|
103 |
+
The project aims to train sentence embedding models on very large sentence level datasets using a self-supervised
|
104 |
+
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
|
105 |
+
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.
|
106 |
+
|
107 |
+
We developed this model during the
|
108 |
+
[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),
|
109 |
+
organized by Hugging Face. We developed this model as part of the project:
|
110 |
+
[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.
|
111 |
+
|
112 |
+
## Intended uses
|
113 |
+
|
114 |
+
Our model is intended to be used as a sentence and short paragraph encoder. Given an input text, it outputs a vector which captures
|
115 |
+
the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
|
116 |
+
|
117 |
+
By default, input text longer than 256 word pieces is truncated.
|
118 |
+
|
119 |
+
|
120 |
+
## Training procedure
|
121 |
+
|
122 |
+
### Pre-training
|
123 |
+
|
124 |
+
We use the pretrained [`nreimers/MiniLM-L6-H384-uncased`](https://huggingface.co/nreimers/MiniLM-L6-H384-uncased) model. Please refer to the model card for more detailed information about the pre-training procedure.
|
125 |
+
|
126 |
+
### Fine-tuning
|
127 |
+
|
128 |
+
We fine-tune the model using a contrastive objective. Formally, we compute the cosine similarity from each possible sentence pairs from the batch.
|
129 |
+
We then apply the cross entropy loss by comparing with true pairs.
|
130 |
+
|
131 |
+
#### Hyper parameters
|
132 |
+
|
133 |
+
We trained our model on a TPU v3-8. We train the model during 100k steps using a batch size of 1024 (128 per TPU core).
|
134 |
+
We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
|
135 |
+
a 2e-5 learning rate. The full training script is accessible in this current repository: `train_script.py`.
|
136 |
+
|
137 |
+
#### Training data
|
138 |
+
|
139 |
+
We use the concatenation from multiple datasets to fine-tune our model. The total number of sentence pairs is above 1 billion sentences.
|
140 |
+
We sampled each dataset given a weighted probability which configuration is detailed in the `data_config.json` file.
|
141 |
+
|
142 |
+
|
143 |
+
| Dataset | Paper | Number of training tuples |
|
144 |
+
|--------------------------------------------------------|:----------------------------------------:|:--------------------------:|
|
145 |
+
| [Reddit comments (2015-2018)](https://github.com/PolyAI-LDN/conversational-datasets/tree/master/reddit) | [paper](https://arxiv.org/abs/1904.06472) | 726,484,430 |
|
146 |
+
| [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Abstracts) | [paper](https://aclanthology.org/2020.acl-main.447/) | 116,288,806 |
|
147 |
+
| [WikiAnswers](https://github.com/afader/oqa#wikianswers-corpus) Duplicate question pairs | [paper](https://doi.org/10.1145/2623330.2623677) | 77,427,422 |
|
148 |
+
| [PAQ](https://github.com/facebookresearch/PAQ) (Question, Answer) pairs | [paper](https://arxiv.org/abs/2102.07033) | 64,371,441 |
|
149 |
+
| [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Titles) | [paper](https://aclanthology.org/2020.acl-main.447/) | 52,603,982 |
|
150 |
+
| [S2ORC](https://github.com/allenai/s2orc) (Title, Abstract) | [paper](https://aclanthology.org/2020.acl-main.447/) | 41,769,185 |
|
151 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Body) pairs | - | 25,316,456 |
|
152 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title+Body, Answer) pairs | - | 21,396,559 |
|
153 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Answer) pairs | - | 21,396,559 |
|
154 |
+
| [MS MARCO](https://microsoft.github.io/msmarco/) triplets | [paper](https://doi.org/10.1145/3404835.3462804) | 9,144,553 |
|
155 |
+
| [GOOAQ: Open Question Answering with Diverse Answer Types](https://github.com/allenai/gooaq) | [paper](https://arxiv.org/pdf/2104.08727.pdf) | 3,012,496 |
|
156 |
+
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Title, Answer) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 1,198,260 |
|
157 |
+
| [Code Search](https://huggingface.co/datasets/code_search_net) | - | 1,151,414 |
|
158 |
+
| [COCO](https://cocodataset.org/#home) Image captions | [paper](https://link.springer.com/chapter/10.1007%2F978-3-319-10602-1_48) | 828,395|
|
159 |
+
| [SPECTER](https://github.com/allenai/specter) citation triplets | [paper](https://doi.org/10.18653/v1/2020.acl-main.207) | 684,100 |
|
160 |
+
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Question, Answer) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 681,164 |
|
161 |
+
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) (Title, Question) | [paper](https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html) | 659,896 |
|
162 |
+
| [SearchQA](https://huggingface.co/datasets/search_qa) | [paper](https://arxiv.org/abs/1704.05179) | 582,261 |
|
163 |
+
| [Eli5](https://huggingface.co/datasets/eli5) | [paper](https://doi.org/10.18653/v1/p19-1346) | 325,475 |
|
164 |
+
| [Flickr 30k](https://shannon.cs.illinois.edu/DenotationGraph/) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/229/33) | 317,695 |
|
165 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles) | | 304,525 |
|
166 |
+
| AllNLI ([SNLI](https://nlp.stanford.edu/projects/snli/) and [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/) | [paper SNLI](https://doi.org/10.18653/v1/d15-1075), [paper MultiNLI](https://doi.org/10.18653/v1/n18-1101) | 277,230 |
|
167 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (bodies) | | 250,519 |
|
168 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles+bodies) | | 250,460 |
|
169 |
+
| [Sentence Compression](https://github.com/google-research-datasets/sentence-compression) | [paper](https://www.aclweb.org/anthology/D13-1155/) | 180,000 |
|
170 |
+
| [Wikihow](https://github.com/pvl/wikihow_pairs_dataset) | [paper](https://arxiv.org/abs/1810.09305) | 128,542 |
|
171 |
+
| [Altlex](https://github.com/chridey/altlex/) | [paper](https://aclanthology.org/P16-1135.pdf) | 112,696 |
|
172 |
+
| [Quora Question Triplets](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) | - | 103,663 |
|
173 |
+
| [Simple Wikipedia](https://cs.pomona.edu/~dkauchak/simplification/) | [paper](https://www.aclweb.org/anthology/P11-2117/) | 102,225 |
|
174 |
+
| [Natural Questions (NQ)](https://ai.google.com/research/NaturalQuestions) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/1455) | 100,231 |
|
175 |
+
| [SQuAD2.0](https://rajpurkar.github.io/SQuAD-explorer/) | [paper](https://aclanthology.org/P18-2124.pdf) | 87,599 |
|
176 |
+
| [TriviaQA](https://huggingface.co/datasets/trivia_qa) | - | 73,346 |
|
177 |
+
| **Total** | | **1,170,060,424** |
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/952a9b81c0bfd99800fabf352f69c7ccd46c5e43
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"idx": 0,
|
4 |
+
"name": "0",
|
5 |
+
"path": "",
|
6 |
+
"type": "sentence_transformers.models.Transformer"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"idx": 1,
|
10 |
+
"name": "1",
|
11 |
+
"path": "1_Pooling",
|
12 |
+
"type": "sentence_transformers.models.Pooling"
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"idx": 2,
|
16 |
+
"name": "2",
|
17 |
+
"path": "2_Normalize",
|
18 |
+
"type": "sentence_transformers.models.Normalize"
|
19 |
+
}
|
20 |
+
]
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/c79f2b6a0cea6f4b564fed1938984bace9d30ff0
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "name_or_path": "nreimers/MiniLM-L6-H384-uncased", "do_basic_tokenize": true, "never_split": null, "tokenizer_class": "BertTokenizer", "model_max_length": 512}
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/cb202bfe2e3c98645018a6d12f182a434c9d3e02
ADDED
The diff for this file is too large to render.
See raw diff
|
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/d1514c3162bbe87b343f565fadc62e6c06f04f03
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 384,
|
3 |
+
"pooling_mode_cls_token": false,
|
4 |
+
"pooling_mode_mean_tokens": true,
|
5 |
+
"pooling_mode_max_tokens": false,
|
6 |
+
"pooling_mode_mean_sqrt_len_tokens": false
|
7 |
+
}
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/e7b0375001f109a6b8873d756ad4f7bbb15fbaa5
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/fb140275c155a9c7c5a3b3e0e77a9e839594a938
ADDED
The diff for this file is too large to render.
See raw diff
|
|
hub/models--sentence-transformers--all-MiniLM-L6-v2/blobs/fd1b291129c607e5d49799f87cb219b27f98acdf
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "2.0.0",
|
4 |
+
"transformers": "4.6.1",
|
5 |
+
"pytorch": "1.8.1"
|
6 |
+
}
|
7 |
+
}
|