alanztymarqo commited on
Commit
1ea8cd9
1 Parent(s): 9bcf1a3

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +295 -7
README.md CHANGED
@@ -12,14 +12,302 @@ dataset_info:
12
  - name: position
13
  dtype: int64
14
  splits:
15
- - name: test
16
- num_bytes: 2212236284.504
17
- num_examples: 99808
18
- download_size: 2234691014
19
- dataset_size: 2212236284.504
20
  configs:
21
  - config_name: default
22
  data_files:
23
- - split: test
24
- path: data/test-*
25
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  - name: position
13
  dtype: int64
14
  splits:
15
+ - name: data
16
+ num_bytes: 22251545141.2
17
+ num_examples: 982700
18
+ download_size: 21955883446
19
+ dataset_size: 22251545141.2
20
  configs:
21
  - config_name: default
22
  data_files:
23
+ - split: data
24
+ path: data/data-*
25
  ---
26
+
27
+
28
+
29
+ <div style="display: flex; align-items: center; gap: 10px;">
30
+ <a href="https://www.marqo.ai/blog/introducing-marqos-ecommerce-embedding-models">
31
+ <img src="https://img.shields.io/badge/Model_Release-Blog-blue?logo=font-awesome&logoColor=white&style=flat&logo=pencil-alt" alt="Blog">
32
+ </a>
33
+ <a href="https://github.com/marqo-ai/marqo-ecommerce-embeddings">
34
+ <img src="https://img.shields.io/badge/GitHub-Repo-black?logo=github" alt="GitHub Repo">
35
+ </a>
36
+ <a href="https://www.marqo.ai/blog/how-to-build-an-ecommerce-image-search-application">
37
+ <img src="https://img.shields.io/badge/Ecommerce Search-Blog-red?logo=font-awesome&logoColor=white&style=flat&logo=pencil-alt" alt="Blog">
38
+ </a>
39
+ <a href="https://join.slack.com/t/marqo-community/shared_invite/zt-2b4nsvbd2-TDf8agPszzWH5hYKBMIgDA">
40
+ <img src="https://img.shields.io/badge/Slack-Join_Marqo_Community-purple?logo=Slack" alt=Slack Community">
41
+ </a>
42
+ </div>
43
+
44
+ # Marqo Ecommerce Embedding Models
45
+ **In this work, we introduce the GoogleShopping-1m dataset for evaluation.** This dataset comes with the release of our state-of-the-art embedding models for ecommerce products: [Marqo-Ecommerce-B](https://huggingface.co/Marqo/marqo-ecommerce-embeddings-B) and [Marqo-Ecommerce-L](https://huggingface.co/Marqo/marqo-ecommerce-embeddings-L).
46
+
47
+ **Released Content**:
48
+ 1) Marqo-Ecommerce-B and Marqo-Ecommerce-L embedding models
49
+ 2) GoogleShopping-1m and AmazonProducts-3m for evaluation
50
+ 3) Evaluation Code
51
+
52
+ The benchmarking results show that the Marqo-Ecommerce models consistently outperformed *all other models* across various metrics. Specifically, `marqo-ecommerce-L` achieved an average improvement of **17.6% in MRR** and **20.5% in nDCG@10** when compared with the current best open source model, `ViT-SO400M-14-SigLIP` across all three tasks in the `marqo-ecommerce-hard` dataset. When compared with the best private model, `Amazon-Titan-Multimodal`, we saw an average improvement of **38.9% in MRR** and **45.1% in nDCG@10** across all three tasks, and **35.9% in Recall** across the Text-to-Image tasks in the `marqo-ecommerce-hard` dataset.
53
+
54
+ <img src="https://raw.githubusercontent.com/marqo-ai/marqo-ecommerce-embeddings/main/performance.png" alt="multi split visual" width="700"/>
55
+
56
+ More benchmarking results can be found below.
57
+
58
+ ## Models
59
+
60
+ | **Embedding Model** | **#Params (m)** | **Dimension** | **HuggingFace** | **Download .pt** |
61
+ |---------------------| --- |---------------|------------------------------------|-------------------------------------------------------------------------------------------------------------|
62
+ | Marqo-Ecommerce-B | 203 | 768 | [Marqo/marqo-ecommerce-embeddings-B](https://huggingface.co/Marqo/marqo-ecommerce-embeddings-B) | [link](https://marqo-gcl-public.s3.us-west-2.amazonaws.com/marqo-general-ecomm/marqo-ecomm-embeddings-b.pt) |
63
+ | Marqo-Ecommerce-L | 652 | 1024 | [Marqo/marqo-ecommerce-embeddings-L](https://huggingface.co/Marqo/marqo-ecommerce-embeddings-L) | [link](https://marqo-gcl-public.s3.us-west-2.amazonaws.com/marqo-general-ecomm/marqo-ecomm-embeddings-l.pt) |
64
+
65
+ ### Load from HuggingFace with transformers
66
+ To load the models in Transformers, see below. The models are hosted on [Hugging Face](https://huggingface.co/collections/Marqo/marqo-ecommerce-embeddings-66f611b9bb9d035a8d164fbb) and loaded using [Transformers](https://github.com/huggingface/transformers).
67
+
68
+ ```python
69
+ from transformers import AutoModel, AutoProcessor
70
+ import torch
71
+ from PIL import Image
72
+ import requests
73
+
74
+ model_name= 'Marqo/marqo-ecommerce-embeddings-L'
75
+ # model_name = 'Marqo/marqo-ecommerce-embeddings-B'
76
+
77
+ model = AutoModel.from_pretrained(model_name, trust_remote_code=True)
78
+ processor = AutoProcessor.from_pretrained(model_name, trust_remote_code=True)
79
+
80
+ img = Image.open(requests.get('https://raw.githubusercontent.com/marqo-ai/marqo-ecommerce-embeddings/refs/heads/main/images/dining-chairs.png', stream=True).raw).convert("RGB")
81
+ image = [img]
82
+ text = ["dining chairs", "a laptop", "toothbrushes"]
83
+ processed = processor(text=text, images=image, padding='max_length', return_tensors="pt")
84
+ processor.image_processor.do_rescale = False
85
+ with torch.no_grad():
86
+ image_features = model.get_image_features(processed['pixel_values'], normalize=True)
87
+ text_features = model.get_text_features(processed['input_ids'], normalize=True)
88
+
89
+ text_probs = (100 * image_features @ text_features.T).softmax(dim=-1)
90
+
91
+ print(text_probs)
92
+ # [1.0000e+00, 8.3131e-12, 5.2173e-12]
93
+ ```
94
+
95
+ ### Load from HuggingFace with OpenCLIP
96
+ To load the models in OpenCLIP, see below. The models are hosted on [Hugging Face](https://huggingface.co/collections/Marqo/marqo-ecommerce-embeddings-66f611b9bb9d035a8d164fbb) and loaded using [OpenCLIP](https://github.com/mlfoundations/open_clip). You can also find this code inside `run_models.py`.
97
+
98
+ ```
99
+ pip install open_clip_torch
100
+ ```
101
+ ```python
102
+ from PIL import Image
103
+ import open_clip
104
+ import requests
105
+ import torch
106
+
107
+ # Specify model from Hugging Face Hub
108
+ model_name = 'hf-hub:Marqo/marqo-ecommerce-embeddings-L'
109
+ # model_name = 'hf-hub:Marqo/marqo-ecommerce-embeddings-B'
110
+
111
+ model, preprocess_train, preprocess_val = open_clip.create_model_and_transforms(model_name)
112
+ tokenizer = open_clip.get_tokenizer(model_name)
113
+
114
+ # Preprocess the image and tokenize text inputs
115
+ # Load an example image from a URL
116
+ img = Image.open(requests.get('https://raw.githubusercontent.com/marqo-ai/marqo-ecommerce-embeddings/refs/heads/main/images/dining-chairs.png', stream=True).raw)
117
+ image = preprocess_val(img).unsqueeze(0)
118
+ text = tokenizer(["dining chairs", "a laptop", "toothbrushes"])
119
+
120
+ # Perform inference
121
+ with torch.no_grad(), torch.cuda.amp.autocast():
122
+ image_features = model.encode_image(image, normalize=True)
123
+ text_features = model.encode_text(text, normalize=True)
124
+
125
+ # Calculate similarity probabilities
126
+ text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
127
+
128
+ # Display the label probabilities
129
+ print("Label probs:", text_probs)
130
+ # [1.0000e+00, 8.3131e-12, 5.2173e-12]
131
+ ```
132
+
133
+ ### Evaluation
134
+ [Generalised Contrastiove Learning](https://github.com/marqo-ai/GCL) (GCL) is used for the evaluation. The following code can also be found in `scripts`.
135
+
136
+ ```
137
+ git clone https://github.com/marqo-ai/GCL
138
+ ```
139
+ Install the packages required by GCL.
140
+
141
+ **1. GoogleShopping-Text2Image Retrieval.**
142
+ ```
143
+ cd ./GCL
144
+ MODEL=hf-hub:Marqo/marqo-ecommerce-B
145
+ outdir=/MarqoModels/GE/marqo-ecommerce-B/gs-title2image
146
+ hfdataset=Marqo/google-shopping-general-eval
147
+ python evals/eval_hf_datasets_v1.py \
148
+ --model_name $MODEL \
149
+ --hf-dataset $hfdataset \
150
+ --output-dir $outdir \
151
+ --batch-size 1024 \
152
+ --num_workers 8 \
153
+ --left-key "['title']" \
154
+ --right-key "['image']" \
155
+ --img-or-txt "[['txt'], ['img']]" \
156
+ --left-weight "[1]" \
157
+ --right-weight "[1]" \
158
+ --run-queries-cpu \
159
+ --top-q 4000 \
160
+ --doc-id-key item_ID \
161
+ --context-length "[[64], [0]]"
162
+ ```
163
+
164
+ **2. GoogleShopping-Category2Image Retrieval.**
165
+ ```
166
+ cd ./GCL
167
+ MODEL=hf-hub:Marqo/marqo-ecommerce-B
168
+ outdir=/MarqoModels/GE/marqo-ecommerce-B/gs-cat2image
169
+ hfdataset=Marqo/google-shopping-general-eval
170
+ python evals/eval_hf_datasets_v1.py \
171
+ --model_name $MODEL \
172
+ --hf-dataset $hfdataset \
173
+ --output-dir $outdir \
174
+ --batch-size 1024 \
175
+ --num_workers 8 \
176
+ --left-key "['query']" \
177
+ --right-key "['image']" \
178
+ --img-or-txt "[['txt'], ['img']]" \
179
+ --left-weight "[1]" \
180
+ --right-weight "[1]" \
181
+ --run-queries-cpu \
182
+ --top-q 4000 \
183
+ --doc-id-key item_ID \
184
+ --context-length "[[64], [0]]"
185
+ ```
186
+
187
+ **3. AmazonProducts-Category2Image Retrieval.**
188
+ ```
189
+ cd ./GCL
190
+ MODEL=hf-hub:Marqo/marqo-ecommerce-B
191
+ outdir=/MarqoModels/GE/marqo-ecommerce-B/ap-title2image
192
+ hfdataset=Marqo/amazon-products-eval
193
+ python evals/eval_hf_datasets_v1.py \
194
+ --model_name $MODEL \
195
+ --hf-dataset $hfdataset \
196
+ --output-dir $outdir \
197
+ --batch-size 1024 \
198
+ --num_workers 8 \
199
+ --left-key "['title']" \
200
+ --right-key "['image']" \
201
+ --img-or-txt "[['txt'], ['img']]" \
202
+ --left-weight "[1]" \
203
+ --right-weight "[1]" \
204
+ --run-queries-cpu \
205
+ --top-q 4000 \
206
+ --doc-id-key item_ID \
207
+ --context-length "[[64], [0]]"
208
+ ```
209
+
210
+ ## Detailed Performance
211
+ Our benchmarking process was divided into two distinct regimes, each using different datasets of ecommerce product listings: marqo-ecommerce-hard and marqo-ecommerce-easy. Both datasets contained product images and text and only differed in size. The "easy" dataset is approximately 10-30 times smaller (200k vs 4M products), and designed to accommodate rate-limited models, specifically Cohere-Embeddings-v3 and GCP-Vertex (with limits of 0.66 rps and 2 rps respectively). The "hard" dataset represents the true challenge, since it contains four million ecommerce product listings and is more representative of real-world ecommerce search scenarios.
212
+
213
+ Within both these scenarios, the models were benchmarked against three different tasks:
214
+
215
+ * Google Shopping Text-to-Image
216
+ * Google Shopping Category-to-Image
217
+ * Amazon Products Text-to-Image
218
+
219
+ ### Marqo-Ecommerce-Hard
220
+ Marqo-Ecommerce-Hard looks into the comprehensive evaluation conducted using the full 4 million dataset, highlighting the robust performance of our models in a real-world context.
221
+
222
+ **GoogleShopping-Text2Image Retrieval.**
223
+
224
+ | **Embedding Model** | **mAP** | **R@10** | **MRR** | **nDCG@10** |
225
+ |-------------------------|------|-------|------|---------|
226
+ | **Marqo-Ecommerce-L** | **0.682**| **0.878** | **0.683**| **0.726** |
227
+ | Marqo-Ecommerce-B | 0.623| 0.832 | 0.624| 0.668 |
228
+ | ViT-SO400M-14-SigLip | 0.573| 0.763 | 0.574| 0.613 |
229
+ | ViT-L-16-SigLip | 0.540| 0.722 | 0.540| 0.577 |
230
+ | ViT-B-16-SigLip | 0.476| 0.660 | 0.477| 0.513 |
231
+ | Amazon-Titan-MultiModal | 0.475| 0.648 | 0.475| 0.509 |
232
+ | Jina-V1-CLIP | 0.285| 0.402 | 0.285| 0.306 |
233
+
234
+ **GoogleShopping-Category2Image Retrieval.**
235
+
236
+ | **Embedding Model** | **mAP** | **P@10** | **MRR** | **nDCG@10** |
237
+ |-----------------------------|---------|----------|---------|-------------|
238
+ | **Marqo-Ecommerce-L** | **0.463** | **0.652** | **0.822** | **0.666** |
239
+ | Marqo-Ecommerce-B | 0.423 | 0.629 | 0.810 | 0.644 |
240
+ | ViT-SO400M-14-SigLip | 0.352 | 0.516 | 0.707 | 0.529 |
241
+ | ViT-L-16-SigLip | 0.324 | 0.497 | 0.687 | 0.509 |
242
+ | ViT-B-16-SigLip | 0.277 | 0.458 | 0.660 | 0.473 |
243
+ | Amazon-Titan-MultiModal | 0.246 | 0.429 | 0.642 | 0.446 |
244
+ | Jina-V1-CLIP | 0.123 | 0.275 | 0.504 | 0.294 |
245
+
246
+ **AmazonProducts-Text2Image Retrieval.**
247
+
248
+ | **Embedding Model** | **mAP** | **R@10** | **MRR** | **nDCG@10** |
249
+ |-----------------------------|---------|----------|---------|-------------|
250
+ | **Marqo-Ecommerce-L** | **0.658** | **0.854** | **0.663** | **0.703** |
251
+ | Marqo-Ecommerce-B | 0.592 | 0.795 | 0.597 | 0.637 |
252
+ | ViT-SO400M-14-SigLip | 0.560 | 0.742 | 0.564 | 0.599 |
253
+ | ViT-L-16-SigLip | 0.544 | 0.715 | 0.548 | 0.580 |
254
+ | ViT-B-16-SigLip | 0.480 | 0.650 | 0.484 | 0.515 |
255
+ | Amazon-Titan-MultiModal | 0.456 | 0.627 | 0.457 | 0.491 |
256
+ | Jina-V1-CLIP | 0.265 | 0.378 | 0.266 | 0.285 |
257
+
258
+ ### Marqo-Ecommerce-Easy
259
+ This dataset is about 10-30 times smaller than the Marqo-Ecommerce-Hard, and designed to accommodate rate-limited models, specifically Cohere-Embeddings-v3 and GCP-Vertex.
260
+
261
+ **GoogleShopping-Text2Image Retrieval.**
262
+
263
+ | **Embedding Model** | **mAP** | **R@10** | **MRR** | **nDCG@10** |
264
+ |-----------------------------|---------|----------|---------|-------------|
265
+ | **Marqo-Ecommerce-L** | **0.879** | **0.971** | **0.879** | **0.901** |
266
+ | Marqo-Ecommerce-B | 0.842 | 0.961 | 0.842 | 0.871 |
267
+ | ViT-SO400M-14-SigLip | 0.792 | 0.935 | 0.792 | 0.825 |
268
+ | GCP-Vertex | 0.740 | 0.910 | 0.740 | 0.779 |
269
+ | ViT-L-16-SigLip | 0.754 | 0.907 | 0.754 | 0.789 |
270
+ | ViT-B-16-SigLip | 0.701 | 0.870 | 0.701 | 0.739 |
271
+ | Amazon-Titan-MultiModal | 0.694 | 0.868 | 0.693 | 0.733 |
272
+ | Jina-V1-CLIP | 0.480 | 0.638 | 0.480 | 0.511 |
273
+ | Cohere-embedding-v3 | 0.358 | 0.515 | 0.358 | 0.389 |
274
+
275
+ **GoogleShopping-Category2Image Retrieval.**
276
+
277
+ | **Embedding Model** | **mAP** | **P@10** | **MRR** | **nDCG@10** |
278
+ |-----------------------------|---------|----------|---------|-------------|
279
+ | **Marqo-Ecommerce-L** | **0.515** | **0.358** | **0.764** | **0.590** |
280
+ | Marqo-Ecommerce-B | 0.479 | 0.336 | 0.744 | 0.558 |
281
+ | ViT-SO400M-14-SigLip | 0.423 | 0.302 | 0.644 | 0.487 |
282
+ | GCP-Vertex | 0.417 | 0.298 | 0.636 | 0.481 |
283
+ | ViT-L-16-SigLip | 0.392 | 0.281 | 0.627 | 0.458 |
284
+ | ViT-B-16-SigLip | 0.347 | 0.252 | 0.594 | 0.414 |
285
+ | Amazon-Titan-MultiModal | 0.308 | 0.231 | 0.558 | 0.377 |
286
+ | Jina-V1-CLIP | 0.175 | 0.122 | 0.369 | 0.229 |
287
+ | Cohere-embedding-v3 | 0.136 | 0.110 | 0.315 | 0.178 |
288
+
289
+ **AmazonProducts-Text2Image Retrieval.**
290
+
291
+ | **Embedding Model** | **mAP** | **R@10** | **MRR** | **nDCG@10** |
292
+ |-----------------------------|---------|----------|---------|-------------|
293
+ | **Marqo-Ecommerce-L** | **0.92** | **0.978** | **0.928** | **0.940** |
294
+ | Marqo-Ecommerce-B | 0.897 | 0.967 | 0.897 | 0.914 |
295
+ | ViT-SO400M-14-SigLip | 0.860 | 0.954 | 0.860 | 0.882 |
296
+ | ViT-L-16-SigLip | 0.842 | 0.940 | 0.842 | 0.865 |
297
+ | GCP-Vertex | 0.808 | 0.933 | 0.808 | 0.837 |
298
+ | ViT-B-16-SigLip | 0.797 | 0.917 | 0.797 | 0.825 |
299
+ | Amazon-Titan-MultiModal | 0.762 | 0.889 | 0.763 | 0.791 |
300
+ | Jina-V1-CLIP | 0.530 | 0.699 | 0.530 | 0.565 |
301
+ | Cohere-embedding-v3 | 0.433 | 0.597 | 0.433 | 0.465 |
302
+
303
+ ## Citation
304
+ ```
305
+ @software{zhu2024marqoecommembed_2024,
306
+ author = {Tianyu Zhu and and Jesse Clark},
307
+ month = oct,
308
+ title = {{Marqo Ecommerce Embeddings - Foundation Model for Product Embeddings}},
309
+ url = {https://github.com/marqo-ai/marqo-ecommerce-embeddings/},
310
+ version = {1.0.0},
311
+ year = {2024}
312
+ }
313
+ ```