M5Product: Self-harmonized Contrastive Learning for E-commercial Multi-modal Pretraining
- Publication
- CVPR 2022Conference
- First submitted to arXiv
- arXiv:2109.04275
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{retailproductm5product2021,
title = {{M5Product: Self-harmonized Contrastive Learning for E-commercial Multi-modal Pretraining}},
author = {Xiao Dong and Xunlin Zhan and Yangxin Wu and Yunchao Wei and Michael C. Kampffmeyer and Xiaoyong Wei and Minlong Lu and Yaowei Wang and Xiaodan Liang},
year = {2021},
eprint = {2109.04275},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2109.04275}
}
Open an e-commerce product page and scroll down.
At the top are a few product images, next to a long title stuffed with keywords. Further down is a spec table with brand, material, color and intended use laid out cell by cell. Some products also come with an introduction video, with a shop assistant's voice explaining the product.
A product page is multimodal by nature. Yet multimodal pretraining at the time used almost nothing but images and text, and product datasets were no different. A few months earlier, the team behind this paper had published Product1M, more than a million image-text cosmetics records; this time they scaled up five-fold, went from two modalities to five, and built M5Product.
Problem Definition

The authors want to answer two questions.
First, do more modalities actually help? A spec table states the material and intended use, and a video shows the product in use and gives a sense of its size; images and titles do not necessarily carry this information. But if the extra modalities only repeat what the images and text already say, adding them just adds computation.
Second, with more modalities, how do you balance them? Contrastive learning between two modalities is intuitive: an image and its own title are a positive pair, and the image with other products' titles are negatives. Five modalities give ten pairings, and each pairing differs in how much information and how much noise it carries. Some products have no video at all; some spec tables were filled in carelessly by the merchant. If all ten pairings are treated the same, the noisy ones will drag the whole model in the wrong direction.
The Dataset
The data was scraped from a large e-commerce website, and the authors say they have the company's permission to share it. The paper does not say which company; one of the co-authors is from Alibaba.
In total there are 6,313,067 products in 6,232 categories, covering clothing, cosmetics, musical instruments and more. The five modalities are:
- Image: the main product image.
- Title: the product name, usually a long string of keywords.
- Spec table: attributes and values filled in by the merchant, 5,679 kinds of attribute and over twenty-four million values.
- Video: the product introduction video.
- Audio: the sound extracted from the video.
This is not a tidy dataset. About 5% of products have only a single modality, and many lack a video; spec tables are filled in by merchants themselves and vary widely in quality; the category distribution is long-tailed. The authors keep all of this as part of the real world.
For comparison with other datasets, Product1M has 1.18 million records in 458 categories; the RPC checkout dataset has 30,000 in 200 categories; CC12M, the largest image-text dataset at the time, has twelve million records but no category information.
Solution

The model is called SCALE (Self-harmonized ContrAstive LEarning), and its overall architecture is single-stream.
Five Encoders
Each modality is first encoded on its own. The title and the spec table are both text and each get a standard Transformer; images go through Faster R-CNN to extract 10 to 36 region features, as in Product1M's CAPTURE; videos are taken as a few ordered frames; audio is converted to MFCC features.
Why not merge the spec table and the title into one Transformer? In the authors' comparison, concatenating both into a single passage for one encoder gives a classification accuracy of 84.61%, and encoding them separately gives 85.50%. Their guess is that, when merged, the more expressive title drowns out the spec table.
The token features of all modalities are then concatenated and fed into a joint Transformer (JCT), letting tokens from different modalities attend to each other. The single-modality encoders and the JCT have 6 layers each, 12 in total.
When a modality is missing, it is filled with zeros, so every record can be used.
Five Masked Tasks
Each modality has its own masked prediction task: masked language modeling (MLM) for text, masked region prediction (MRP) for images, masked frame prediction for video and masked audio modeling for audio, each masking 15% and predicting it back.
The masked task for the spec table is a bit special and is called MEM (mask entity modeling). Ordinary MLM masks a random 15% of tokens; MEM masks whole entities. In "Material: Wood", for example, the whole of "Wood" is masked, rather than half a word. That way the model has to really understand the attribute to guess it. On the spec table, MEM gives 1.45 points higher classification accuracy than MLM.
Letting the Modalities Harmonize Themselves

The core is SIMCL (self-harmonized inter-modality contrastive learning). Contrastive learning runs once for every pair of modalities, which makes ten pairs for five modalities. Each pair uses standard InfoNCE: the two modalities of the same product are the positive pair, and the pairings with other products in the batch are negatives.
How are the weights of the ten pairs decided? The paper describes a alignment score matrix , initialized to zero and learned as free parameters, with the weights obtained from ; the upper triangle weights the ten inter-modality contrastive losses and the diagonal weights the five masked tasks.
Open the official code and the implementation differs from this description. There is no separately learned in the code; the weights are computed on the fly for each sample.
The code takes the features of one product's five modalities and computes the cosine similarity between every pair, giving a matrix. Each row first goes through softmax, is then multiplied element-wise with the original similarities, and finally each row is normalized to unit length. The -th value multiplies the logits of the InfoNCE for modalities and ; the code also keeps a commented-out line that multiplies the loss directly instead. This is consistent with the abstract's statement that "the importance of each modality is learned directly from the modality embeddings".
Take one product and suppose the similarities between its title and the five modalities (the title itself, image, spec table, video, audio) are 1.0, 0.8, 0.9, 0.3 and 0.1. Following the steps above, the weights in the title's row come out as 0.69, 0.45, 0.56, 0.10 and 0.03.
The logits of the title–spec table pair are multiplied by 0.56, and those of the title–audio pair by 0.03. Shrinking the logits amounts to raising the softmax temperature: the scores of positives and negatives get squeezed close together, and this pair's contrastive loss can barely move the model.
In other words, for this product, the modality that doesn't resemble the others much (for example, background music unrelated to the product) automatically gets a quieter voice in contrastive learning. It is a sensible design, but the mechanism differs from the one described in the paper's text, so anyone reproducing it should go by the code.
Discussion
There are four downstream tasks, all evaluated on M5Product: multimodal retrieval (the same category counts as correct), fine-grained retrieval (only the same product counts as correct), multimodal classification (1,805 classes) and multimodal clustering.
More Modalities, Better Results
| Modalities | Subset acc. | Subset mAP@1 | Full acc. | Full mAP@1 |
|---|---|---|---|---|
| Title | 77.42 | 47.70 | 81.11 | 55.82 |
| + Image | 79.58 | 51.47 | 83.68 | 59.81 |
| + Spec table | 82.83 | 57.14 | 84.63 | 61.32 |
| + Video | 84.31 | 58.57 | 84.90 | 62.65 |
| + Audio | 85.50 | 58.72 | 86.57 | 63.56 |
Source: Table 3 of the paper; mAP@1 is the post-pretraining figure.
Every added modality pushes the scores up. On the subset, adding the spec table gives the biggest jump, +3.25 in accuracy and +5.67 in mAP@1; video and audio help less.
The authors argue that on large, complex data the benefit of complementary modalities is more pronounced. Going by this table, though, the cumulative gain on the subset (accuracy +8.08, mAP@1 +11.02) is actually larger than on the full dataset (+5.46, +7.74).
Text Is the Star
Another table tries every combination of modalities (subset, classification accuracy):
| Combination | Acc. |
|---|---|
| Image + audio | 27.67 |
| Image + video | 34.57 |
| Image + spec table | 62.00 |
| Image + title | 79.58 |
| Image + title + spec table | 82.83 |
| All five | 85.50 |
Source: Table 4 of the paper, excerpt.
The image-only baseline has an accuracy of 27.67%; adding audio still gives 27.67%, no change at all. Adding video gives 7 more points, adding the spec table 34 more, adding the title 52 more.
In this 1,805-class product classification, the main information comes from text. The title and the spec table are both text, and together they deliver nearly all of the performance; on top of the text, image, video and audio each add another point or two.
Against Other Pretraining Methods
To keep it fair, this comparison uses only two modalities, image and title:
| Method | mAP@1 | Acc. | NMI |
|---|---|---|---|
| Image only | 15.17 | 27.67 | 63.62 |
| BERT (text only) | 47.70 | 77.42 | 76.35 |
| CLIP | 49.39 | 78.35 | 81.75 |
| UNITER | 49.87 | 78.54 | 82.71 |
| CAPTURE | 50.30 | 78.69 | 83.06 |
| SCALE | 51.47 | 79.58 | 84.23 |
Source: Table 5 of the paper, subset.
In accuracy, every image-text model is only one to two points above text-only BERT, and in mAP@1 two to four points; the clustering NMI gap is larger, five to eight points. SCALE beats CAPTURE, the same team's earlier work, by only about 1 point on all three metrics. On this dataset, switching to a different image-text fusion architecture matters far less than adding one more text modality.
In the ablations, removing both SIMCL and the masked tasks gives an accuracy of 83.77%; with both, 85.50%.
Where Is the Video?
In November 2026, someone asked in the official code's issues about the fine-grained retrieval query set and gallery: in the annotation files, the video field of these products is empty, yet Table 4 of the paper reports fine-grained retrieval results for several combinations that include video, so they wanted to know whether video was also zero-filled at test time (issue #3). There has been no reply as of this writing.
If that observation holds, the "video" in those combinations' fine-grained retrieval results may be nothing but zero vectors filled in.
Conclusion
The authors say M5Product is the first public large-scale e-commerce dataset with more than two modalities: over six million records, over six thousand categories, five modalities, and it keeps the flaws of real data such as missing modalities, noise and a long tail. SCALE runs contrastive learning separately for each pair of modalities and then automatically adjusts the strength of each pair according to the similarity between modalities in each sample at that moment.
The experiments answer "does multimodality help" clearly: yes, and the most useful modality is structured text like the spec table. Images play a smaller role in this task than you might expect, and video and audio smaller still.
So when organizing product data, don't rush off to grab videos; take care of the spec table the merchant filled in first. Dry fields like "Material: Wood, Applicable Scene: Study", learned by masking whole entities the MEM way, were far more useful in this paper's experiments than a product video.