Abhaykoul commited on
Commit
681e020
Β·
verified Β·
1 Parent(s): 3341f20

Restore professional model card format matching commit f924ac24

Browse files
Files changed (1) hide show
  1. README.md +218 -62
README.md CHANGED
@@ -1,111 +1,267 @@
1
  ---
2
- license: mit
3
  language:
4
  - en
5
- pipeline_tag: feature-extraction
 
6
  tags:
7
- - lf4
8
- - 4-bit
9
- - static-embeddings
10
  - sentence-similarity
11
- - matryoshka
 
12
  - rag
 
 
 
 
13
  - code-search
14
- - tool-search
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
 
17
- # vtx-embed-7M
 
 
 
 
 
 
 
 
 
18
 
19
- `vtx-embed-7M` (Vortex-Embed v4.5) is an ultra-fast, native **4-Bit static embedding model** featuring **Matryoshka Representation Learning (MRL)** and zero precomputed table RAM overhead.
20
 
21
  ---
22
 
23
- ## ⚑ Key Highlights & Architecture
24
 
25
- - **Ultra-Compact Footprint**: 7,559,168 parameters packed into **4.72 MB RAM / Disk** using native 4-bit LF4 per-block FP16 scaling ($32 imes 8$ blocks).
26
- - **Zero FP32 Overhead**: Holds **0 dequantized FP32 matrices in RAM**. Unpacks nibbles on-the-fly only for active tokens in the current batch.
27
- - **Matryoshka Representation Learning (MRL)**: Supports dynamic truncation to `256`, `128`, or `64` dimensions without quality loss.
28
- - **Pure CPU Speed**: Uses vectorized `torch.index_add_` scatter operations on CPU achieving **> 1,000 documents/sec**.
29
- - **Multi-Domain Optimization**: Jointly trained on Sentence Similarity (AllNLI), Natural Language RAG QA, and Codebase / Tool Retrieval.
 
 
 
 
 
 
 
 
30
 
31
  ---
32
 
33
- ## πŸ“Š Benchmark Results
34
 
35
- ### 1. STS-B (Semantic Textual Similarity Benchmark)
36
- Evaluated on 1,379 official test pairs:
37
 
38
- | Representation / Dim | Spearman ρ (STS-B) | Single Document Latency | RAM Size |
39
- |---|---|---|---|
40
- | **Matryoshka 256-dim (Full)** | **0.7918** | **0.080 ms** | **4.72 MB** |
41
- | **Matryoshka 128-dim Slice** | **0.7753** | **0.055 ms** | **4.72 MB** |
42
- | **Matryoshka 64-dim Slice** | **0.7577** | **0.038 ms** | **4.72 MB** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  ---
45
 
46
- ### 2. Code Search & Agent Tool Selection (JARVIS Benchmark)
47
- Tested over **1,158 real codebase files** and **20 Agent Tool routing queries**:
 
48
 
49
- | Task / Evaluation Metric | Score |
50
- |---|---|
51
- | **20 Agent Tool Search (Top-1 Accuracy)** | **100.0% (20 / 20 correct)** |
52
- | **20 Agent Tool Search (Top-3 Accuracy)** | **100.0% (20 / 20 correct)** |
53
- | **Raw Encoding Throughput** | **878,578 Tokens / Sec (878.6 kTk/s)** |
54
- | **Code Search Recall@5** | **64.5%** |
 
 
 
55
 
56
  ---
57
 
58
- ## πŸ’» Quickstart Usage
59
 
60
- ### Installation
 
 
 
 
 
 
 
 
61
 
62
- Make sure you have `tokenizers`, `numpy`, and `safetensors` installed:
 
 
63
 
64
  ```bash
65
- pip install tokenizers numpy safetensors
66
  ```
67
 
68
- ### Python Inference
69
 
70
  ```python
71
- from vortex_embed.src.lf4_v4_5 import VortexEmbedV4_5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- # Load model directly from HuggingFace
74
- model = VortexEmbedV4_5.from_pretrained("VTXAI/vtx-embed-7M")
75
 
76
- # Input sentences
77
- texts = [
78
- "How to run fast vector similarity search?",
79
- "High performance C++ indexer for codebase retrieval",
80
- "Cooking pasta recipe with tomato sauce"
81
- ]
 
 
 
 
 
 
82
 
83
- # 1. Full 256-dim embeddings
84
- embeddings_256 = model.encode(texts, normalize=True, truncate_dim=256)
85
- print("256-dim shape:", embeddings_256.shape)
86
 
87
- # 2. Matryoshka 64-dim slice (Ultra-fast search)
88
- embeddings_64 = model.encode(texts, normalize=True, truncate_dim=64)
89
- print("64-dim shape:", embeddings_64.shape)
90
 
91
- # Cosine similarity matrix
92
- similarity = embeddings_256[0] @ embeddings_256[1].T
93
- print(f"Cosine Similarity (0 vs 1): {similarity:.4f}")
94
  ```
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  ---
97
 
98
- ## πŸ”’ Memory Footprint Breakdown
99
 
100
- | Component | Dimensions | Byte Size |
101
- |---|---|---|
102
- | `embedding_packed` | 29,528 Γ— 128 | 3,779,584 bytes (~3.78 MB) |
103
- | `embedding_scales` | 29,528 Γ— 8 (FP16) | 472,448 bytes (~0.47 MB) |
104
- | `embedding_zeros` | 29,528 Γ— 8 (FP16) | 472,448 bytes (~0.47 MB) |
105
- | **TOTAL RAM** | β€” | **4.72 MB** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  ---
108
 
109
  ## πŸ“„ License
110
 
111
- [MIT License](https://opensource.org/licenses/MIT)
 
1
  ---
 
2
  language:
3
  - en
4
+ license: mit
5
+ library_name: tokenizers
6
  tags:
 
 
 
7
  - sentence-similarity
8
+ - feature-extraction
9
+ - embeddings
10
  - rag
11
+ - quantized
12
+ - 4-bit
13
+ - matryoshka
14
+ - ultra-lightweight
15
  - code-search
16
+ - retrieval
17
+ pipeline_tag: feature-extraction
18
+ metrics:
19
+ - spearman_cosine
20
+ model-index:
21
+ - name: vtx-embed-7M
22
+ results:
23
+ - task:
24
+ type: sts
25
+ name: Semantic Textual Similarity
26
+ dataset:
27
+ name: STSBenchmark
28
+ type: mteb/stsbenchmark-sts
29
+ metrics:
30
+ - type: cosine_spearman
31
+ value: 0.7918
32
+ - task:
33
+ type: sts
34
+ name: Semantic Textual Similarity
35
+ dataset:
36
+ name: SICK-R
37
+ type: mteb/sickr-sts
38
+ metrics:
39
+ - type: cosine_spearman
40
+ value: 0.6294
41
+ - task:
42
+ type: classification
43
+ name: Classification
44
+ dataset:
45
+ name: Banking77Classification
46
+ type: mteb/banking77
47
+ metrics:
48
+ - type: accuracy
49
+ value: 0.7043
50
+ - task:
51
+ type: classification
52
+ name: Classification
53
+ dataset:
54
+ name: AmazonCounterfactualClassification
55
+ type: mteb/amazon_counterfactual_classification
56
+ metrics:
57
+ - type: accuracy
58
+ value: 0.6679
59
+ - task:
60
+ type: clustering
61
+ name: Clustering
62
+ dataset:
63
+ name: TwentyNewsgroupsClustering
64
+ type: mteb/twentynewsgroups-clustering
65
+ metrics:
66
+ - type: v_measure
67
+ value: 0.2936
68
+ - task:
69
+ type: clustering
70
+ name: Clustering
71
+ dataset:
72
+ name: RedditClustering
73
+ type: mteb/reddit-clustering
74
+ metrics:
75
+ - type: v_measure
76
+ value: 0.388
77
  ---
78
 
79
+ <div align="center">
80
+
81
+ # πŸš€ vtx-embed-7M
82
+
83
+ **The world's most memory-efficient general-purpose embedding model.**
84
+ Native 4-Bit quantization Β· 4.72 MB RAM Β· Matryoshka MRL Β· Sub-millisecond CPU latency
85
+
86
+ [![HuggingFace](https://img.shields.io/badge/πŸ€—%20HuggingFace-VTXAI%2Fvtx--embed--7M-blue)](https://huggingface.co/VTXAI/vtx-embed-7M)
87
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
88
+ [![Python 3.8+](https://img.shields.io/badge/Python-3.8%2B-blue)](https://python.org)
89
 
90
+ </div>
91
 
92
  ---
93
 
94
+ ## πŸ“„ Model Details
95
 
96
+ | Property | Value |
97
+ | :--- | :--- |
98
+ | **Model Type** | Native 4-Bit Static Embedding (LF4) |
99
+ | **Total Parameters** | 7.55M (4-Bit packed) |
100
+ | **Tensor Storage Format** | `lf4` β€” 4-bit per-block with FP16 scale + zero |
101
+ | **In-RAM Memory** | **4.72 MB** |
102
+ | **On-Disk Size** | **4.72 MB** |
103
+ | **Vocabulary Size** | 29,528 |
104
+ | **Max Sequence Length** | 512 tokens |
105
+ | **Output Dimensions** | 256 *(Matryoshka: also 128, 64)* |
106
+ | **Pooling** | SIF IDF-weighted + PC-1 removal |
107
+ | **Similarity Metric** | Cosine |
108
+ | **License** | MIT |
109
 
110
  ---
111
 
112
+ ## πŸ“Š Official MTEB Benchmark Results
113
 
114
+ All scores below were produced by running the **official [MTEB](https://github.com/embeddings-benchmark/mteb) 2.18.7** evaluation framework directly against this model on CPU. No cheating β€” no overlap with training data.
 
115
 
116
+ ### Semantic Textual Similarity (STS)
117
+
118
+ | Dataset | Metric | **vtx-embed-7M** | MiniLM-L6-v2 (90 MB) | bge-small-en-v1.5 (134 MB) |
119
+ | :--- | :---: | :---: | :---: | :---: |
120
+ | **STSBenchmark** | Spearman ρ | **0.7918** | 0.8284 | 0.8278 |
121
+ | **SICK-R** | Spearman ρ | **0.6294** | 0.7572 | 0.7460 |
122
+
123
+ ### Classification
124
+
125
+ | Dataset | Metric | **vtx-embed-7M** | MiniLM-L6-v2 (90 MB) | bge-small-en-v1.5 (134 MB) |
126
+ | :--- | :---: | :---: | :---: | :---: |
127
+ | **Banking77Classification** | Accuracy | **0.7043** | 0.7451 | 0.7884 |
128
+ | **AmazonCounterfactualClassification** | Accuracy | **0.6679** | 0.7371 | 0.7279 |
129
+
130
+ ### Clustering
131
+
132
+ | Dataset | Metric | **vtx-embed-7M** | MiniLM-L6-v2 (90 MB) | bge-small-en-v1.5 (134 MB) |
133
+ | :--- | :---: | :---: | :---: | :---: |
134
+ | **TwentyNewsgroupsClustering** | V-Measure | **0.2936** | 0.3529 | 0.4419 |
135
+ | **RedditClustering** | V-Measure | **0.3880** | 0.4342 | 0.5376 |
136
 
137
  ---
138
 
139
+ ## ⚑ Efficiency Benchmark
140
+
141
+ *Compared against LiquidAI's LFM2.5-Embedding-350M (from their published benchmarks):*
142
 
143
+ | Model | RAM | Disk | CPU Latency p50 | CPU Latency p95 | Texts/sec |
144
+ | :--- | :-: | :-: | :-: | :-: | :-: |
145
+ | **vtx-embed-7M (256-dim)** | **4.72 MB** | **4.72 MB** | **0.575 ms** | **1.034 ms** | **18,151** |
146
+ | **vtx-embed-7M (64-dim)** | **4.72 MB** | **4.72 MB** | **0.312 ms** | **0.620 ms** | **~32,000** |
147
+ | LiquidAI/LFM2.5-Embedding-350M | ~700 MB | 708 MB | 7.30 ms | 9.60 ms | ~137 |
148
+ | sentence-transformers/all-MiniLM-L6-v2 | 90 MB | 90 MB | 12.4 ms | 18.0 ms | ~80 |
149
+ | BAAI/bge-small-en-v1.5 | 134 MB | 134 MB | 18.2 ms | 25.0 ms | ~55 |
150
+
151
+ > **vtx-embed-7M is 12.7Γ— faster and 148Γ— smaller in RAM than LFM2.5-Embedding-350M.**
152
 
153
  ---
154
 
155
+ ## 🎯 Matryoshka Representation Learning
156
 
157
+ vtx-embed-7M supports dynamic **truncation** of output vectors β€” encode once, use at any dimension:
158
+
159
+ | Dimension | Spearman ρ (STS-B) | Relative Speed | Use-case |
160
+ | :-: | :-: | :-: | :--- |
161
+ | **256** | **0.7918** | 1.0Γ— | Full quality RAG / semantic search |
162
+ | **128** | **0.7753** | 1.4Γ— | Balanced quality / storage |
163
+ | **64** | **0.7577** | 2.0Γ— | High-throughput edge / mobile |
164
+
165
+ ---
166
 
167
+ ## πŸ’» Quickstart
168
+
169
+ ### Installation
170
 
171
  ```bash
172
+ pip install numpy tokenizers safetensors huggingface_hub
173
  ```
174
 
175
+ ### Load & Encode
176
 
177
  ```python
178
+ from huggingface_hub import hf_hub_download
179
+ import importlib.util
180
+
181
+ # Download single-file client (no torch, no transformers needed!)
182
+ path = hf_hub_download("VTXAI/vtx-embed-7M", "vortex_embed_v4_5.py")
183
+ spec = importlib.util.spec_from_file_location("ve", path)
184
+ mod = importlib.util.module_from_spec(spec); spec.loader.exec_module(mod)
185
+
186
+ # Load model β€” strict 4.72 MB RAM
187
+ model = mod.VortexEmbedV4_5.from_pretrained("VTXAI/vtx-embed-7M")
188
+
189
+ # Encode
190
+ sentences = ["A plane is taking off.", "An airplane is ascending into the sky."]
191
+ embeddings = model.encode(sentences, normalize=True) # (2, 256) float32
192
+
193
+ # Cosine similarity
194
+ sim = (embeddings[0] * embeddings[1]).sum()
195
+ print(f"Similarity: {sim:.4f}") # ~0.84
196
+ ```
197
+
198
+ ### Matryoshka Truncation
199
+
200
+ ```python
201
+ emb_128 = model.encode(sentences, truncate_dim=128) # (2, 128)
202
+ emb_64 = model.encode(sentences, truncate_dim=64) # (2, 64)
203
+ ```
204
 
205
+ ### RAG / Code Search Pipeline
 
206
 
207
+ ```python
208
+ # Index a corpus
209
+ corpus = ["def search(q): ...", "class RAGEngine: ...", "import numpy as np"]
210
+ corpus_embs = model.encode(corpus, normalize=True) # (N, 256)
211
+
212
+ # Query
213
+ query_emb = model.encode("how to build a search engine", normalize=True) # (256,)
214
+ scores = corpus_embs @ query_emb
215
+ top_k = scores.argsort()[::-1][:3]
216
+ for i in top_k:
217
+ print(f"[{scores[i]:.3f}] {corpus[i][:60]}")
218
+ ```
219
 
220
+ ---
 
 
221
 
222
+ ## πŸ—οΈ Architecture
 
 
223
 
 
 
 
224
  ```
225
+ VortexEmbedV4_5
226
+ β”œβ”€β”€ Tokenizer BPE, vocab=29,528
227
+ β”œβ”€β”€ LF4 Embedding (29528, 128) uint8 packed β†’ 3.78 MB
228
+ β”‚ β”œβ”€β”€ scale_fp16 (29528, 8) float16 β†’ 0.47 MB
229
+ β”‚ └── zero_fp16 (29528, 8) float16 β†’ 0.47 MB
230
+ β”‚ └── Total RAM β†’ 4.72 MB
231
+ β”œβ”€β”€ Pooling SIF (sif_a=0.05, IDF-weighted mean)
232
+ β”œβ”€β”€ PCA Removal Top-1 principal component removed
233
+ └── Matryoshka Truncation to 256 / 128 / 64 dims
234
+ ```
235
+
236
+ **Quantization:** Each token embedding is stored as 128 packed 4-bit values across 8 groups. During inference, only active tokens per batch are dequantized on-the-fly β€” zero FP32/FP16 matrix ever stored in RAM.
237
 
238
  ---
239
 
240
+ ## πŸ“ˆ Why vtx-embed-7M?
241
 
242
+ | Scenario | Why it matters |
243
+ | :--- | :--- |
244
+ | **Edge / Mobile Deployment** | Fits entirely in 4.72 MB β€” runs on microcontrollers, Raspberry Pi, or embedded systems |
245
+ | **High-Throughput RAG** | 18,151 texts/sec on a single CPU core β€” no GPU needed |
246
+ | **Large Codebase Indexing** | Indexes 26,000+ code chunks in seconds; 885 chunks/sec |
247
+ | **Cost Reduction** | Eliminate GPU inference costs entirely for embedding workloads |
248
+ | **Matryoshka Flexibility** | One model, three vector sizes β€” no retraining needed |
249
+
250
+ ---
251
+
252
+ ## πŸ“œ Citation
253
+
254
+ ```bibtex
255
+ @misc{vtx-embed-7M,
256
+ title = {vtx-embed-7M: Native 4-Bit Sentence Embeddings with Matryoshka Representation Learning},
257
+ author = {VTXAI},
258
+ year = {2026},
259
+ url = {https://huggingface.co/VTXAI/vtx-embed-7M}
260
+ }
261
+ ```
262
 
263
  ---
264
 
265
  ## πŸ“„ License
266
 
267
+ MIT License β€” free for commercial and research use.