098alzoro0 commited on
Commit
bf81ffa
·
verified ·
1 Parent(s): 687ec72

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +217 -25
README.md CHANGED
@@ -1,30 +1,222 @@
1
  ---
2
  library_name: pytorch
3
- tags: [embeddings, sentence-embeddings, encoder, custom-architecture]
4
  license: other
 
 
 
 
 
 
 
 
 
 
 
5
  ---
6
- # mine-embed-57M (57.8M params)
7
- Encoder-only text embedding model (10 layers, hidden 512, 8 heads, FFN 2048, pre-norm, GELU, GPT-2 BPE vocab 50,258, mean pooling + L2 norm, 128-token contrastive training).
8
- Custom architecture: load with `Embedder` in `model.py` (`from model import Embedder; Embedder(".").encode([...])`).
9
-
10
- ## Training
11
- 1. MLM pretraining (15% dynamic masking, 80/10/10, AdamW, peak LR 4e-4, cosine to 1e-5) on a mixed code / multilingual / math / security / corporate-text corpus.
12
- Large parts of that corpus are **synthetic or template-generated** (arithmetic, corporate-fact templates, security templates); the amount of distinct natural text is far below the nominal token count.
13
- 2. Contrastive fine-tuning (in-batch + hard-negative InfoNCE) on AllNLI, Quora and private domain-specific triplets.
14
-
15
- ## Evaluation (see eval_report.json)
16
- Per-domain held-out triplet accuracy is **in-distribution** and does not measure general embedding quality. STS-B test Spearman: {'dataset': 'sentence-transformers/stsb', 'n': 1379, 'spearman': 0.6860609574807518}.
17
-
18
- ## Licenses — MIXED, not a single license
19
- The weights are derived from data under several different licenses and terms. The builder's metadata is reproduced below; **verify each source's license and terms before any redistribution or commercial use**.
20
- - AllNLI = SNLI + MultiNLI: SNLI is CC BY-SA 4.0; MultiNLI has per-genre terms (check the MultiNLI release). Share-alike obligations may apply.
21
- - Quora Question Pairs: governed by Quora's own terms, not an open license; commercial use is unclear.
22
- - Pretraining corpus (code / web / multilingual): sources carry their own licenses (code in particular is often copyleft or attribution-required). Source list and licenses are in the dataset builder metadata below.
23
- - Private/domain-specific and synthetic data: owned by the author.
24
- Because of this mix the model is released under `license: other` and kept **private** until the license review is done.
25
-
26
- ### Dataset builder fingerprints
27
- ```
28
- {"fingerprint": "0db2e603ec2cc6a2", "target_tokens": 1000000000, "actual_windows": 878640}
29
- {"fingerprint": "d7706b95d8decdfd", "train": 471400, "val": 9620}
 
 
 
 
 
30
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: pytorch
3
+ pipeline_tag: sentence-similarity
4
  license: other
5
+ license_name: mixed-source-licenses
6
+ language:
7
+ - en
8
+ tags:
9
+ - embeddings
10
+ - sentence-embeddings
11
+ - encoder
12
+ - custom-architecture
13
+ - experimental
14
+ datasets:
15
+ - MineAITechnology/mine-embed-v1
16
  ---
17
+
18
+ # mine-embed-v1
19
+
20
+ > **Version 1: first experimental test release, private.** This is MineAI Technology's first embedding model,
21
+ > trained from scratch. It is published to document an early experiment, **not as a competitive or
22
+ > production-ready model**. On a 28-task MTEB subset it scores well below standard small embedding models
23
+ > (see [Evaluation](#5-evaluation)).
24
+
25
+ mine-embed-v1 is a 57.8M-parameter English text embedding model. It maps a sentence to a 512-dimensional unit vector;
26
+ cosine similarity between vectors measures how close two texts are in meaning. It uses a custom encoder
27
+ architecture (not a standard `transformers` model) and the GPT-2 byte-pair tokenizer.
28
+
29
+ ## 1. Quick start
30
+
31
+ The repository contains a custom `model.py`, so the model is loaded through its `Embedder` class, not
32
+ `AutoModel` or `SentenceTransformer`.
33
+
34
+ ```python
35
+ import sys
36
+ from huggingface_hub import snapshot_download # private repo: log in with an HF token first
37
+
38
+ folder = snapshot_download("MineAITechnology/mine-embed-v1")
39
+ sys.path.insert(0, folder)
40
+ from model import Embedder
41
+
42
+ e = Embedder(folder) # loads config.json + model.safetensors, GPT-2 tokenizer
43
+ vecs = e.encode(["A man is playing a guitar.", "Someone strums an instrument.", "Stocks fell today."])
44
+ print(vecs.shape) # torch.Size([3, 512]), already L2-normalised
45
+ print(vecs @ vecs.T) # cosine similarities
46
  ```
47
+
48
+ Requirements: `torch`, `transformers` (only for the tokenizer), `safetensors`, `huggingface_hub`.
49
+ `Embedder.encode(texts, max_len=128, bs=64)` truncates to 128 tokens by default. No query/passage prefixes are used.
50
+
51
+ ## 2. Model summary
52
+
53
+ | | |
54
+ |---|---|
55
+ | Parameters | 57,781,248 |
56
+ | Architecture | Encoder-only transformer: 10 layers, hidden 512, 8 heads, feed-forward 2048, pre-norm, GELU, learned position embeddings |
57
+ | Output | 512-dimensional, mean pooling over non-padding tokens + L2 normalisation |
58
+ | Tokenizer | GPT-2 BPE, vocabulary 50,258 (id 50256 = end-of-text/pad, id 50257 = mask) |
59
+ | Max positions | 1,024 (contrastive training used 128 tokens) |
60
+ | Language | English (GPT-2 BPE is weak on other languages) |
61
+ | Weights | `model.safetensors`, fp32, about 231 MB |
62
+ | Initialisation | **Random: trained from scratch** |
63
+
64
+ ## 3. Training
65
+
66
+ Two stages. The full data description is in the dataset card:
67
+ [`MineAITechnology/mine-embed-v1` (dataset)](https://huggingface.co/datasets/MineAITechnology/mine-embed-v1).
68
+
69
+ **Stage 1: masked language modelling (MLM).**
70
+ - 15% dynamic masking (80% mask, 10% random token, 10% unchanged), sequence length 512, 128 sequences per step.
71
+ - AdamW, peak learning rate 4e-4 with cosine decay to 1e-5, weight decay 0.01, fp16 on 2x Tesla T4.
72
+ - 22,118 steps (5.0 hours), about 1.8 passes over a corpus of roughly 895M tokens.
73
+ - The corpus is a mixture of code, multilingual text, math, security/alignment text and corporate-fact text.
74
+ **Large parts are synthetic or template-generated**, so the amount of distinct natural text is far below the nominal
75
+ token count, and general English prose is only a small share.
76
+
77
+ **Stage 2: contrastive fine-tuning.**
78
+ - In-batch and hard-negative InfoNCE on 471,400 triplets, mostly AllNLI with Quora duplicate questions and a small
79
+ amount of private domain-specific data, 128-token inputs.
80
+ - <!-- TODO: add batch size, learning rate, epochs and temperature from the training notebook -->
81
+
82
+ ## 4. Intended use
83
+
84
+ Suitable for experiments and baselines: sentence-similarity scoring on short English texts, studying
85
+ small-scale embedding training, and as a reference point for later versions. It is **not recommended** for retrieval,
86
+ clustering, or any production search system (see the limitations).
87
+
88
+ ## 5. Evaluation
89
+
90
+ ### Protocol
91
+ MTEB English subset of **28 tasks**: 9 STS, 4 classification, 3 clustering, 3 pair classification, 3 reranking and
92
+ 6 retrieval tasks. Every model was run with the same settings: max length 128, batch size 64, fp32, one Kaggle T4,
93
+ `mteb` 1.x. Scores are each task's main metric times 100. Competitors were loaded with their own prompts/prefixes.
94
+ QuoraRetrieval is excluded from averages because this model was fine-tuned on Quora.
95
+
96
+ ### Overall results
97
+
98
+ | Model | Params (M) | Dim | Avg (28) | STS | Classif. | Cluster | Pair | Rerank | Retrieval |
99
+ |---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
100
+ | bge-base-en-v1.5 | 109.5 | 768 | 66.25 | 78.51 | 66.69 | 39.68 | 86.56 | 67.77 | 49.94 |
101
+ | bge-small-en-v1.5 | 33.4 | 384 | 64.37 | 77.32 | 64.89 | 37.88 | 84.92 | 66.84 | 46.35 |
102
+ | gte-small | 33.4 | 384 | 63.95 | 76.66 | 62.72 | 39.15 | 83.55 | 66.21 | 47.17 |
103
+ | all-mpnet-base-v2 | 109.5 | 768 | 62.66 | 75.19 | 60.06 | 39.43 | 83.04 | 68.84 | 43.92 |
104
+ | all-MiniLM-L12-v2 | 33.4 | 384 | 61.60 | 74.56 | 59.79 | 37.56 | 82.46 | 67.58 | 41.99 |
105
+ | e5-small-v2 | 33.4 | 384 | 61.58 | 75.33 | 61.74 | 33.16 | 85.43 | 61.94 | 42.97 |
106
+ | all-MiniLM-L6-v2 | 22.7 | 384 | 61.14 | 73.67 | 59.28 | 37.08 | 82.37 | 67.12 | 42.04 |
107
+ | GloVe average (baseline) | 120.0 | 300 | 45.77 | 55.47 | 55.11 | 21.39 | 72.48 | 48.76 | 22.35 |
108
+ | **mine-embed-v1** | 57.8 | 512 | **37.78** | 59.63 | 43.84 | 11.19 | 54.06 | 40.76 | 4.64 |
109
+
110
+ mine-embed-v1 ranks last. It scores about 23 points below all-MiniLM-L6-v2 and 8 points below the GloVe baseline.
111
+
112
+ <details><summary>Per-task scores vs all-MiniLM-L6-v2 and GloVe</summary>
113
+
114
+ | Task | mine-embed-v1 | all-MiniLM-L6-v2 | GloVe average |
115
+ |---|---:|---:|---:|
116
+ | **STS (avg)** | **59.6** | **73.7** | **55.5** |
117
+ | STSBenchmark | 68.6 | **82.0** | 61.5 |
118
+ | STS12 | 62.6 | **72.4** | 54.6 |
119
+ | STS13 | 60.6 | **80.6** | 69.2 |
120
+ | STS14 | 58.6 | **75.6** | 60.8 |
121
+ | STS15 | 73.6 | **85.4** | 72.3 |
122
+ | STS16 | 68.6 | **79.0** | 65.3 |
123
+ | STS17 | 17.3 | **28.8** | 15.1 |
124
+ | SICK-R | 73.4 | **77.6** | 55.4 |
125
+ | BIOSSES | 53.5 | **81.6** | 44.9 |
126
+ | **Classification (avg)** | **43.8** | **59.3** | **55.1** |
127
+ | Banking77Classification | 47.5 | **80.0** | 67.8 |
128
+ | EmotionClassification | 24.6 | **40.8** | 37.6 |
129
+ | TweetSentimentExtractionClassification | 44.3 | **54.0** | 49.0 |
130
+ | ToxicConversationsClassification | 58.9 | 62.2 | **66.1** |
131
+ | **Clustering (avg)** | **11.2** | **37.1** | **21.4** |
132
+ | TwentyNewsgroupsClustering | 13.5 | **46.5** | 24.9 |
133
+ | BiorxivClusteringS2S | 5.4 | **32.9** | 18.7 |
134
+ | MedrxivClusteringS2S | 14.6 | **31.9** | 20.5 |
135
+ | **Pair classification (avg)** | **54.1** | **82.4** | **72.5** |
136
+ | SprintDuplicateQuestions | 49.8 | **94.6** | 87.0 |
137
+ | TwitterSemEval2015 | 43.5 | **67.9** | 53.1 |
138
+ | TwitterURLCorpus | 68.8 | **84.7** | 77.3 |
139
+ | **Reranking (avg)** | **40.8** | **67.1** | **48.8** |
140
+ | AskUbuntuDupQuestions | 45.6 | **63.5** | 49.6 |
141
+ | StackOverflowDupQuestions | 31.4 | **50.8** | 34.1 |
142
+ | SciDocsRR | 45.3 | **87.1** | 62.6 |
143
+ | **Retrieval (avg)** | **4.6** | **42.0** | **22.3** |
144
+ | SciFact | 8.1 | **62.4** | 29.6 |
145
+ | NFCorpus | 2.2 | **31.5** | 13.9 |
146
+ | FiQA2018 | 0.8 | **36.6** | 10.1 |
147
+ | ArguAna | 10.6 | **48.8** | 36.3 |
148
+ | SCIDOCS | 1.3 | **21.7** | 8.0 |
149
+ | TRECCOVID | 4.8 | **51.3** | 36.2 |
150
+
151
+ QuoraRetrieval (not in the averages, trained-on data): 74.1.
152
+
153
+ </details>
154
+
155
+ ### What it does well and badly
156
+ - **Best area: sentence similarity.** SICK-R 73.4 (within about 4 points of all-MiniLM-L6-v2), STS15 73.6,
157
+ STSBenchmark 68.6, and it beats the GloVe baseline on 7 of 9 STS tasks. This matches its AllNLI-style training data.
158
+ - **Weak areas: retrieval (4.6), clustering (11.2) and duplicate-question detection** (SprintDuplicateQuestions 49.8).
159
+ The contrastive stage used a small, narrow dataset, so the embeddings separate fine differences between similar
160
+ sentences but do not group texts by topic.
161
+
162
+ ### Training-time evaluation
163
+ - STS-B test Spearman: **0.686** (the MLM-only model before contrastive tuning scored 0.357).
164
+ - Held-out triplet accuracy (in-distribution, not a measure of general quality): AllNLI 0.977 (n=2,000),
165
+ Quora 0.969 (n=1,589), overall 0.974 (n=3,606); MLM-only baseline: 0.585, 0.844 and 0.700.
166
+ Three tiny extra domains (corporate, math/code, security: 6, 9 and 2 examples) are too small to report.
167
+
168
+ ### Inference-time variants (12-task subset)
169
+ Changing the maximum length, shrinking the embedding with truncation or PCA, centering, or removing top principal
170
+ components moved the average by between -2.0 and +0.15 points. None closes the gap to the standard models.
171
+ Details are in the benchmark report.
172
+
173
+ ### Efficiency (one Tesla T4, 128-token inputs, batch 64, fp32)
174
+ 389 sentences/s on GPU, 18.8 sentences/s on 2 CPU threads, peak GPU memory
175
+ 456 MB including weights.
176
+
177
+ ### Embedding geometry check
178
+ The average cosine similarity between random, mostly unrelated sentences is 0.047 (all-MiniLM-L6-v2: 0.059), so the
179
+ embeddings are not collapsed into a narrow cone.
180
+
181
+ ## 6. Limitations
182
+
183
+ - **Far below standard small embedding models** on general benchmarks (see the table).
184
+ - **Retrieval, clustering and duplicate detection are poor.** Do not use it for search or topic grouping.
185
+ - **Narrow training data.** Contrastive data is dominated by AllNLI and Quora; the MLM corpus is code/math/security
186
+ and synthetic-heavy with little natural English prose.
187
+ - **English only**, and the GPT-2 tokenizer is inefficient for non-English text.
188
+ - **Custom architecture:** needs `model.py`; it does not load with `AutoModel` or `SentenceTransformer`.
189
+ - **Short inputs:** contrastive training used 128 tokens.
190
+ - **License:** mixed sources, see below. Not cleared for commercial use.
191
+
192
+ ## 7. License and data terms
193
+
194
+ The weights are derived from data under several different licenses and terms, so the model is released under
195
+ `license: other` and kept **private** until a license review is finished. Not legal advice.
196
+
197
+ - AllNLI = SNLI (CC BY-SA 4.0) + MultiNLI (per-genre terms). Share-alike obligations may apply.
198
+ - Quora Question Pairs: governed by Quora's own terms; commercial use unclear.
199
+ - MLM corpus (code, web, multilingual, math, security): each source has its own license; code in particular is often
200
+ copyleft or attribution-required.
201
+ - Private domain-specific and synthetic data: owned by the author.
202
+
203
+ ## 8. Files in this repository
204
+
205
+ | File | Purpose |
206
+ |---|---|
207
+ | `model.safetensors` | Weights (231 MB) |
208
+ | `config.json` | Architecture settings (`encoder_config`) |
209
+ | `model.py` | Model definition and the `Embedder` class |
210
+ | `eval_report.json` | Training-time evaluation (triplet accuracy, STS-B) |
211
+ | `README.md` | This card |
212
+
213
+ ## 9. Citation
214
+
215
+ ```bibtex
216
+ @misc{mine_embed_v1_2026,
217
+ title = {mine-embed-v1: a 57.8M-parameter English text embedding model trained from scratch},
218
+ author = {{MineAI Technology}},
219
+ year = {2026},
220
+ howpublished = {Hugging Face model card}
221
+ }
222
+ ```