:books: add documentation
Browse files
README.md
CHANGED
@@ -1,11 +1,93 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
tags:
|
4 |
-
- sentence-transformers
|
5 |
-
- feature-extraction
|
6 |
-
- sentence-similarity
|
7 |
---
|
8 |
|
9 |
-
# all_datasets_v3_MiniLM-L12
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language: en
|
|
|
|
|
|
|
|
|
3 |
---
|
4 |
|
|
|
5 |
|
6 |
+
# Model description
|
7 |
+
|
8 |
+
The project aims to train sentence embedding models on very large sentence level datasets using a self-supervised
|
9 |
+
contrastive learning objective. We used the pretrained [`MiniLM-L12`](https://huggingface.co/microsoft/MiniLM-L12-H384-uncased) model and fine-tuned in on a
|
10 |
+
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.
|
11 |
+
|
12 |
+
We developped this model during the
|
13 |
+
[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),
|
14 |
+
organized by Hugging Face. We developped this model as part of the project:
|
15 |
+
[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
|
16 |
+
as intervention from Google’s Flax, JAX, and Cloud team member about efficient deep learning frameworks.
|
17 |
+
|
18 |
+
## Intended uses
|
19 |
+
|
20 |
+
Our model is intented to be used as a sentence encoder. Given an input sentence, it ouptuts a vector which captures
|
21 |
+
the sentence semantic information. The sentence vector may be used for information retrieval, clustering or sentence
|
22 |
+
similarity tasks.
|
23 |
+
|
24 |
+
## How to use
|
25 |
+
|
26 |
+
Here is how to use this model to get the features of a given text using [SentenceTransformers](https://github.com/UKPLab/sentence-transformers) library:
|
27 |
+
|
28 |
+
```python
|
29 |
+
from sentence_transformers import SentenceTransformer
|
30 |
+
|
31 |
+
model = SentenceTransformer('flax-sentence-embeddings/all_datasets_v3_MiniLM-L12')
|
32 |
+
text = "Replace me by any text you'd like."
|
33 |
+
text_embbedding = model.encode(text)
|
34 |
+
# array([-0.01559514, 0.04046123, 0.1317083 , 0.00085931, 0.04585106,
|
35 |
+
# -0.05607086, 0.0138078 , 0.03569756, 0.01420381, 0.04266302 ...],
|
36 |
+
# dtype=float32)
|
37 |
+
```
|
38 |
+
|
39 |
+
# Training procedure
|
40 |
+
|
41 |
+
## Pre-training
|
42 |
+
|
43 |
+
We use the pretrained [`MiniLM-L12`](https://huggingface.co/microsoft/MiniLM-L12-H384-uncased). Please refer to the model
|
44 |
+
card for more detailed information about the pre-training procedure.
|
45 |
+
|
46 |
+
## Fine-tuning
|
47 |
+
|
48 |
+
The BERT model was pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
|
49 |
+
unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
|
50 |
+
headers).
|
51 |
+
|
52 |
+
### Hyper parameters
|
53 |
+
|
54 |
+
We trained ou model on a TPU v3-8. We train the model during 540k steps using a batch size of 1024 (128 per TPU core).
|
55 |
+
We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
|
56 |
+
a 2e-5 learning rate. The full training script is accessible in this current repository.
|
57 |
+
|
58 |
+
### Training data
|
59 |
+
|
60 |
+
We use the concatenation from multiple datasets to fine-tune our model. The total number of sentence pairs is above 1 billion sentences.
|
61 |
+
We sampled each dataset given a weighted probability which configuration is detailed in the `data_config.json` file.
|
62 |
+
|
63 |
+
|
64 |
+
| Dataset | Paper | Number of training tuples |
|
65 |
+
|:--------------------------------------------------------:|:----------------------------------------:|:--------------------------:|
|
66 |
+
| [GOOAQ: Open Question Answering with Diverse Answer Types](https://github.com/allenai/gooaq) | https://arxiv.org/pdf/2104.08727.pdf | 3,012,496 |
|
67 |
+
| [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_title_body_jsonl) | - | 364,001 |
|
68 |
+
| [Flickr 30k](https://shannon.cs.illinois.edu/DenotationGraph/) | https://transacl.org/ojs/index.php/tacl/article/view/229/33 | 317,695 |
|
69 |
+
| [COCO 2020](COCO 2020) | https://link.springer.com/chapter/10.1007%2F978-3-319-10602-1_48 | 828,395|
|
70 |
+
| [Code Search](https://huggingface.co/datasets/code_search_net) | - | 1,151,414 |
|
71 |
+
| [TriviaqQA](https://huggingface.co/datasets/trivia_qa) | - | 73,346 |
|
72 |
+
| [SQuAD2.0](https://rajpurkar.github.io/SQuAD-explorer/) | https://aclanthology.org/P18-2124.pdf | 87,599 |
|
73 |
+
| [Natural Questions (NQ)](https://ai.google.com/research/NaturalQuestions) | https://transacl.org/ojs/index.php/tacl/article/view/1455 | 100,231 |
|
74 |
+
| [Simple Wikipedia](https://cs.pomona.edu/~dkauchak/simplification/) | https://www.aclweb.org/anthology/P11-2117/ | 102,225 |
|
75 |
+
| [Quora Question Pairs](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) | - | 103,663 |
|
76 |
+
| [Altlex](https://github.com/chridey/altlex/) | https://aclanthology.org/P16-1135.pdf | 112,696 |
|
77 |
+
| [Wikihow](https://github.com/pvl/wikihow_pairs_dataset) | https://arxiv.org/abs/1810.09305 | 128,542 |
|
78 |
+
| [Sentence Compression](https://github.com/google-research-datasets/sentence-compression) | https://www.aclweb.org/anthology/D13-1155/ | 180,000 |
|
79 |
+
| AllNLI ([SNLI](https://nlp.stanford.edu/projects/snli/) and [MultiNLI](https://cims.nyu.edu/~sbowman/multinli/) | https://doi.org/10.18653/v1/d15-1075, https://doi.org/10.18653/v1/n18-1101 | 277,230 |
|
80 |
+
| [Eli5](https://huggingface.co/datasets/eli5) | https://doi.org/10.18653/v1/p19-1346 | 325,475 |
|
81 |
+
| [SPECTER](https://github.com/allenai/specter) | https://doi.org/10.18653/v1/2020.acl-main.207 | 684,100 |
|
82 |
+
| [S2ORC](https://github.com/allenai/s2orc) Title/Abstract | https://aclanthology.org/2020.acl-main.447/ | 41,769,185 |
|
83 |
+
| [S2ORC](https://github.com/allenai/s2orc) Citation/Citation | https://aclanthology.org/2020.acl-main.447/ | 52,603,982 |
|
84 |
+
| [S2ORC](https://github.com/allenai/s2orc) Citation/Abstract | https://aclanthology.org/2020.acl-main.447/ | 116,288,806 |
|
85 |
+
| [PAQ](https://github.com/facebookresearch/PAQ) | https://arxiv.org/abs/2102.07033 | 64,371,441 |
|
86 |
+
| [WikiAnswers](https://github.com/afader/oqa#wikianswers-corpus) | https://doi.org/10.1145/2623330.2623677 | 77,427,422 |
|
87 |
+
| SearchQA | - | 582,261 |
|
88 |
+
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) Title/Answer | https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html | 1,198,260 |
|
89 |
+
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) Title/Question | https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html | 659,896 |
|
90 |
+
| [Yahoo Answers](https://www.kaggle.com/soumikrakshit/yahoo-answers-dataset) Question/Answer | https://proceedings.neurips.cc/paper/2015/hash/250cf8b51c773f3f8dc8b4be867a9a02-Abstract.html | 681,164 |
|
91 |
+
| [MS MARCO](https://microsoft.github.io/msmarco/) | https://doi.org/10.1145/3404835.3462804 | 9,144,553 |
|
92 |
+
| [Reddit conversationnal](https://github.com/PolyAI-LDN/conversational-datasets/tree/master/reddit) | https://arxiv.org/abs/1904.06472 | 726,484,430 |
|
93 |
+
|