taronaeo commited on
Commit
40d4b86
·
verified ·
1 Parent(s): ff5016f

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +205 -0
README.md ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - s390x
11
+ - mainframe
12
+ - z15
13
+ - z16
14
+ - z17
15
+ datasets:
16
+ - s2orc
17
+ - flax-sentence-embeddings/stackexchange_xml
18
+ - ms_marco
19
+ - gooaq
20
+ - yahoo_answers_topics
21
+ - code_search_net
22
+ - search_qa
23
+ - eli5
24
+ - snli
25
+ - multi_nli
26
+ - wikihow
27
+ - natural_questions
28
+ - trivia_qa
29
+ - embedding-data/sentence-compression
30
+ - embedding-data/flickr30k-captions
31
+ - embedding-data/altlex
32
+ - embedding-data/simple-wiki
33
+ - embedding-data/QQP
34
+ - embedding-data/SPECTER
35
+ - embedding-data/PAQ_pairs
36
+ - embedding-data/WikiAnswers
37
+ pipeline_tag: sentence-similarity
38
+ base_model:
39
+ - sentence-transformers/all-MiniLM-L6-v2
40
+ ---
41
+
42
+ # all-MiniLM-L6-v2 Big-Endian GGUF
43
+ - Model Creator: [Sentence Transformers](https://huggingface.co/sentence-transformers)
44
+ - Original Model: [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
45
+
46
+ ### Description
47
+ This repository contains the GGUF format model for [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2), compiled for Big-Endian architectures. The model is supplied as‑is, without any warranty, including, without limitation, the implied warranties of merchantability or fitness for a particular purpose. Use is at your own risk.
48
+
49
+ ### Provided Files
50
+ | Name | Quant Method | Bits | Size | Use Case |
51
+ | -------------------------------------------------------------------------------------------------------------------------------- | ------------ | ---- | ---- | ---------------------------------------------------------------------- |
52
+ | [all-minilm-l6-v2-be.Q2_K.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q2_K.gguf) | Q2_K | 2 | 19M | smallest, significant quality loss - not recommended for most purposes |
53
+ | [all-minilm-l6-v2-be.Q3_K_S.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q3_K_S.gguf) | Q3_K_S | 3 | 19M | very small, high quality loss |
54
+ | [all-minilm-l6-v2-be.Q3_K_M.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q3_K_M.gguf) | Q3_K_M | 3 | 20M | very small, high quality loss |
55
+ | [all-minilm-l6-v2-be.Q3_K_L.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q3_K_L.gguf) | Q3_K_L | 3 | 20M | small, substantial quality loss |
56
+ | [all-minilm-l6-v2-be.Q4_0.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q4_0.gguf) | Q4_0 | 4 | 20M | legacy; small, very high quality loss - prefer using Q3_K_M |
57
+ | [all-minilm-l6-v2-be.Q4_K_S.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q4_K_S.gguf) | Q4_K_S | 4 | 20M | small, greater quality loss |
58
+ | [all-minilm-l6-v2-be.Q4_K_M.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q4_K_M.gguf) | Q4_K_M | 4 | 21M | medium, balanced quality - recommended |
59
+ | [all-minilm-l6-v2-be.Q5_0.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q5_0.gguf) | Q5_0 | 5 | 21M | legacy; medium, balanced quality - prefer using Q4_K_M |
60
+ | [all-minilm-l6-v2-be.Q5_K_S.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q5_K_S.gguf) | Q5_K_S | 5 | 21M | large, low quality loss - recommended |
61
+ | [all-minilm-l6-v2-be.Q5_K_M.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q5_K_M.gguf) | Q5_K_M | 5 | 21M | large, very low quality loss - recommended |
62
+ | [all-minilm-l6-v2-be.Q6_K.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q6_K.gguf) | Q6_K | 6 | 24M | very large, extremely low quality loss |
63
+ | [all-minilm-l6-v2-be.Q8_0.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.Q8_0.gguf) | Q8_0 | 8 | 25M | very large, extremely low quality loss - not recommended |
64
+ | [all-minilm-l6-v2-be.F16.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.F16.gguf) | F16 | 16 | 45M | very large, extremely low quality loss - not recommended |
65
+ | [all-minilm-l6-v2-be.F32.gguf](https://huggingface.co/taronaeo/all-MiniLM-L6-v2-BE/blob/main/all-minilm-l6-v2-be.F32.gguf) | F32 | 32 | 87M | very large, extremely low quality loss - not recommended |
66
+
67
+
68
+ # all-MiniLM-L6-v2
69
+ 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.
70
+
71
+ ## Usage (Sentence-Transformers)
72
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
73
+
74
+ ```
75
+ pip install -U sentence-transformers
76
+ ```
77
+
78
+ Then you can use the model like this:
79
+ ```python
80
+ from sentence_transformers import SentenceTransformer
81
+ sentences = ["This is an example sentence", "Each sentence is converted"]
82
+
83
+ model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
84
+ embeddings = model.encode(sentences)
85
+ print(embeddings)
86
+ ```
87
+
88
+ ## Usage (HuggingFace Transformers)
89
+ 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.
90
+
91
+ ```python
92
+ from transformers import AutoTokenizer, AutoModel
93
+ import torch
94
+ import torch.nn.functional as F
95
+
96
+ #Mean Pooling - Take attention mask into account for correct averaging
97
+ def mean_pooling(model_output, attention_mask):
98
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
99
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
100
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
101
+
102
+
103
+ # Sentences we want sentence embeddings for
104
+ sentences = ['This is an example sentence', 'Each sentence is converted']
105
+
106
+ # Load model from HuggingFace Hub
107
+ tokenizer = AutoTokenizer.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
108
+ model = AutoModel.from_pretrained('sentence-transformers/all-MiniLM-L6-v2')
109
+
110
+ # Tokenize sentences
111
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
112
+
113
+ # Compute token embeddings
114
+ with torch.no_grad():
115
+ model_output = model(**encoded_input)
116
+
117
+ # Perform pooling
118
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
119
+
120
+ # Normalize embeddings
121
+ sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
122
+
123
+ print("Sentence embeddings:")
124
+ print(sentence_embeddings)
125
+ ```
126
+
127
+ ------
128
+
129
+ ## Background
130
+
131
+ The project aims to train sentence embedding models on very large sentence level datasets using a self-supervised
132
+ 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
133
+ 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.
134
+
135
+ We developed this model during the
136
+ [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),
137
+ organized by Hugging Face. We developed this model as part of the project:
138
+ [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.
139
+
140
+ ## Intended uses
141
+
142
+ Our model is intended to be used as a sentence and short paragraph encoder. Given an input text, it outputs a vector which captures
143
+ the semantic information. The sentence vector may be used for information retrieval, clustering or sentence similarity tasks.
144
+
145
+ By default, input text longer than 256 word pieces is truncated.
146
+
147
+
148
+ ## Training procedure
149
+
150
+ ### Pre-training
151
+
152
+ 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.
153
+
154
+ ### Fine-tuning
155
+
156
+ We fine-tune the model using a contrastive objective. Formally, we compute the cosine similarity from each possible sentence pairs from the batch.
157
+ We then apply the cross entropy loss by comparing with true pairs.
158
+
159
+ #### Hyper parameters
160
+
161
+ 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).
162
+ We use a learning rate warm up of 500. The sequence length was limited to 128 tokens. We used the AdamW optimizer with
163
+ a 2e-5 learning rate. The full training script is accessible in this current repository: `train_script.py`.
164
+
165
+ #### Training data
166
+
167
+ We use the concatenation from multiple datasets to fine-tune our model. The total number of sentence pairs is above 1 billion sentences.
168
+ We sampled each dataset given a weighted probability which configuration is detailed in the `data_config.json` file.
169
+
170
+
171
+ | Dataset | Paper | Number of training tuples |
172
+ |--------------------------------------------------------|:----------------------------------------:|:--------------------------:|
173
+ | [Reddit comments (2015-2018)](https://github.com/PolyAI-LDN/conversational-datasets/tree/master/reddit) | [paper](https://arxiv.org/abs/1904.06472) | 726,484,430 |
174
+ | [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Abstracts) | [paper](https://aclanthology.org/2020.acl-main.447/) | 116,288,806 |
175
+ | [WikiAnswers](https://github.com/afader/oqa#wikianswers-corpus) Duplicate question pairs | [paper](https://doi.org/10.1145/2623330.2623677) | 77,427,422 |
176
+ | [PAQ](https://github.com/facebookresearch/PAQ) (Question, Answer) pairs | [paper](https://arxiv.org/abs/2102.07033) | 64,371,441 |
177
+ | [S2ORC](https://github.com/allenai/s2orc) Citation pairs (Titles) | [paper](https://aclanthology.org/2020.acl-main.447/) | 52,603,982 |
178
+ | [S2ORC](https://github.com/allenai/s2orc) (Title, Abstract) | [paper](https://aclanthology.org/2020.acl-main.447/) | 41,769,185 |
179
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Body) pairs | - | 25,316,456 |
180
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title+Body, Answer) pairs | - | 21,396,559 |
181
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) (Title, Answer) pairs | - | 21,396,559 |
182
+ | [MS MARCO](https://microsoft.github.io/msmarco/) triplets | [paper](https://doi.org/10.1145/3404835.3462804) | 9,144,553 |
183
+ | [GOOAQ: Open Question Answering with Diverse Answer Types](https://github.com/allenai/gooaq) | [paper](https://arxiv.org/pdf/2104.08727.pdf) | 3,012,496 |
184
+ | [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 |
185
+ | [Code Search](https://huggingface.co/datasets/code_search_net) | - | 1,151,414 |
186
+ | [COCO](https://cocodataset.org/#home) Image captions | [paper](https://link.springer.com/chapter/10.1007%2F978-3-319-10602-1_48) | 828,395|
187
+ | [SPECTER](https://github.com/allenai/specter) citation triplets | [paper](https://doi.org/10.18653/v1/2020.acl-main.207) | 684,100 |
188
+ | [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 |
189
+ | [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 |
190
+ | [SearchQA](https://huggingface.co/datasets/search_qa) | [paper](https://arxiv.org/abs/1704.05179) | 582,261 |
191
+ | [Eli5](https://huggingface.co/datasets/eli5) | [paper](https://doi.org/10.18653/v1/p19-1346) | 325,475 |
192
+ | [Flickr 30k](https://shannon.cs.illinois.edu/DenotationGraph/) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/229/33) | 317,695 |
193
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles) | | 304,525 |
194
+ | 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 |
195
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (bodies) | | 250,519 |
196
+ | [Stack Exchange](https://huggingface.co/datasets/flax-sentence-embeddings/stackexchange_xml) Duplicate questions (titles+bodies) | | 250,460 |
197
+ | [Sentence Compression](https://github.com/google-research-datasets/sentence-compression) | [paper](https://www.aclweb.org/anthology/D13-1155/) | 180,000 |
198
+ | [Wikihow](https://github.com/pvl/wikihow_pairs_dataset) | [paper](https://arxiv.org/abs/1810.09305) | 128,542 |
199
+ | [Altlex](https://github.com/chridey/altlex/) | [paper](https://aclanthology.org/P16-1135.pdf) | 112,696 |
200
+ | [Quora Question Triplets](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) | - | 103,663 |
201
+ | [Simple Wikipedia](https://cs.pomona.edu/~dkauchak/simplification/) | [paper](https://www.aclweb.org/anthology/P11-2117/) | 102,225 |
202
+ | [Natural Questions (NQ)](https://ai.google.com/research/NaturalQuestions) | [paper](https://transacl.org/ojs/index.php/tacl/article/view/1455) | 100,231 |
203
+ | [SQuAD2.0](https://rajpurkar.github.io/SQuAD-explorer/) | [paper](https://aclanthology.org/P18-2124.pdf) | 87,599 |
204
+ | [TriviaQA](https://huggingface.co/datasets/trivia_qa) | - | 73,346 |
205
+ | **Total** | | **1,170,060,424** |