RexBERT: Encoders for a brave new world of E-Commerce

TL;DR

We present RexBERT, a family of domain-specialized text encoders for e-commerce, trained on 2.3T+ tokens, that combine a fully open-data, reproducible pre-training recipe with the architectural advances of ModernBERT. To catalyze further research, we release Ecom-niverse, a 350-billion token corpus drawn from diverse e-commerce text sources. Our methodology is model agnostic: the same procedure can be used to pre-train any context-specific encoder and deploy it out of the box on downstream tasks. Across a suite of state-of-the-art baselines, domain-specialized encoders trained with our recipe consistently outperform general purpose encoders that are 2–3× larger, underscoring the value of high quality in-domain data and targeted pre-training.

Introduction

Modern NLP discourse is dominated by large generative models, yet encoder-only architectures remain indispensable for production systems where latency, cost, and stability are paramount. In e-commerce, compact encoders quietly power mission-critical workflows such as high-recall search and re-ranking, product–product and query–product matching, attribute extraction and normalization, catalog deduplication, and policy/compliance routing delivering consistent quality under stringent throughput and memory budgets.

In this work, we introduce RexBERT, a BERT-style encoder that advances the state of the art on our e-commerce benchmarks, together with a modular, domain-agnostic data curation pipeline for pre-training. We target e-commerce as a proving ground because of its large economic impact and fine-grained semantic distinctions that stress-test representation quality.

Data Curation Methodology

We are releasing Ecom-niverse: a new e-commerce specific dataset with 350B+ tokens. The dataset is constructed by refining a broad web dataset to isolate content with retail or shopping context. This curated corpus is intended for continual pre-training of LLMs and other Encoder only models so they better understand product descriptions, prices, and other commerce related text.

Our starting point is the FineFineWeb dataset, an open-source web-scale corpus that organizes CommonCrawl web data into fine-grained topical domains. FineFineWeb consists of over 4.4 trillion tokens of English web text categorized into ~50 domains.

We leverage FineFineWeb as the raw data source. Each entry in FineFineWeb is a text snippet (document or paragraph) accompanied by metadata including its assigned domain label. Not all these domains are relevant to retail commerce, so the first step is to identify which domains likely contain e-commerce content.

Flow diagram titled Discipline Specific Data Curation Pipeline. Raw source: FineFineWeb, 4.4T tokens in about 50 domains. Step 1, domain focus: select relevant domains. Step 2, sampling: 100K to 500K items per domain. Step 3, LLM labels: Phi-4 marks each item relevant or not, with a QA check using Llama3-70B and a loop to refine prompts and labels if quality drops. Step 4: train a fastText classifier per domain. Step 5: validate on hold-out or cross-validation. Step 6, apply at scale: filter on a predicted-score threshold. Output: validated domain subset.
Figure 1. The discipline-specific data curation pipeline: FineFineWeb → domain focus → LLM labels → fastText → validated subset.

We identified 9 E-commerce overlapping domains which have significant amount of relevant tokens but required filtration. Below table list domains and their filtered size.

Table 1. The nine e-commerce overlapping domains and their filtered size.

DomainSize (GBs)
Hobby114
News66
Health66
Entertainment64
Travel52
Food22
Automotive19
Sports12
Music and Dance7

Additionally, there are 6 more domains which had almost complete overlap and were picked directly out of FineFineWeb.

Table 2. The six domains with almost complete overlap, picked directly out of FineFineWeb.

DomainSize (GBs)
Fashion37
Beauty37
Celebrity28
Movie26
Photo15
Painting2
Ecom-niverse by source domain, in GBFiltered for e-commerce content: Hobby 114 GB, News 66 GB, Health 66 GB, Entertainment 64 GB, Travel 52 GB, Food 22 GB, Automotive 19 GB, Sports 12 GB, Music and Dance 7 GB. Picked directly: Fashion 37 GB, Beauty 37 GB, Celebrity 28 GB, Movie 26 GB, Photo 15 GB, Painting 2 GB.Filtered for e-commerce content (Table 1)HobbyHobby: 114 GB, filtered for e-commerce content114NewsNews: 66 GB, filtered for e-commerce content66HealthHealth: 66 GB, filtered for e-commerce content66EntertainmentEntertainment: 64 GB, filtered for e-commerce content64TravelTravel: 52 GB, filtered for e-commerce content52FoodFood: 22 GB, filtered for e-commerce content22AutomotiveAutomotive: 19 GB, filtered for e-commerce content19SportsSports: 12 GB, filtered for e-commerce content12Music and DanceMusic and Dance: 7 GB, filtered for e-commerce content7Picked directly (Table 2)FashionFashion: 37 GB, picked directly37BeautyBeauty: 37 GB, picked directly37CelebrityCelebrity: 28 GB, picked directly28MovieMovie: 26 GB, picked directly26PhotoPhoto: 15 GB, picked directly15PaintingPainting: 2 GB, picked directly20255075100Size (GB)
Ecom-niverse by source domain, in GBFiltered for e-commerce content: Hobby 114 GB, News 66 GB, Health 66 GB, Entertainment 64 GB, Travel 52 GB, Food 22 GB, Automotive 19 GB, Sports 12 GB, Music and Dance 7 GB. Picked directly: Fashion 37 GB, Beauty 37 GB, Celebrity 28 GB, Movie 26 GB, Photo 15 GB, Painting 2 GB.Filtered for e-commerce content (Table 1)HobbyHobby: 114 GB, filtered for e-commerce content114NewsNews: 66 GB, filtered for e-commerce content66HealthHealth: 66 GB, filtered for e-commerce content66EntertainmentEntertainment: 64 GB, filtered for e-commerce content64TravelTravel: 52 GB, filtered for e-commerce content52FoodFood: 22 GB, filtered for e-commerce content22AutomotiveAutomotive: 19 GB, filtered for e-commerce content19SportsSports: 12 GB, filtered for e-commerce content12Music and DanceMusic and Dance: 7 GB, filtered for e-commerce content7Picked directly (Table 2)FashionFashion: 37 GB, picked directly37BeautyBeauty: 37 GB, picked directly37CelebrityCelebrity: 28 GB, picked directly28MovieMovie: 26 GB, picked directly26PhotoPhoto: 15 GB, picked directly15PaintingPainting: 2 GB, picked directly2050100Size (GB)
Figure 2. Ecom-niverse by source domain, in GB: the nine FineFineWeb domains that were filtered for e-commerce content (Table 1) and the six picked directly (Table 2).

Training Methodology

We train the model with a masked language modeling (MLM) objective and a curriculum that grows sequence length and steadily introduces domain-specific distributions. At a high level, MLM lets the encoder attend bidirectionally and learn fine-grained token dependencies: a random subset of tokens is replaced with [MASK], random tokens, or left intact, and the model predicts the original values. We use dynamic, span-aware masking rather than static, per-token masking so the model learns to reconstruct contiguous fragments (e.g., entities, attributes, or clauses), which better captures real document structure.

Our training comprises of three major phases:

The three training phases, to scale by tokensPhase 1, pre-training: 1.7T tokens at shorter contexts. Phase 2, context extension: 250B tokens, window lengthened to 8K. Phase 3, annealing toward Ecom-niverse: about 350B tokens at 8K. 2.3T tokens in all. RexBERT training starts at phase 3, from the published Phase-2 checkpoint.Phase 1, pre-training: 1.7T tokens, shorter contextsPhase 2, context extension: 250B tokens, 8K contextPhase 3, annealing toward Ecom-niverse: about 350B tokens, 8K contextPhase 1Pre-trainingPhase 2ContextextensionPhase 3Annealing towardEcom-niverse8K context1.7T tokens · shorter contexts250B≈ 350BRexBERT training starts here, from the published Phase-2 checkpoint
The three training phases, to scale by tokensPhase 1, pre-training: 1.7T tokens at shorter contexts. Phase 2, context extension: 250B tokens, window lengthened to 8K. Phase 3, annealing toward Ecom-niverse: about 350B tokens at 8K. 2.3T tokens in all. RexBERT training starts at phase 3, from the published Phase-2 checkpoint.Phase 1Pre-training1.7T · shorter contextsPhase 1, pre-training: 1.7T tokens, shorter contextsPhase 2Context extension250B · 8KPhase 2, context extension: 250B tokens, 8K contextRexBERT training starts here, from the published Phase-2 checkpointPhase 3Annealing toward Ecom-niverse≈ 350B · 8KPhase 3, annealing toward Ecom-niverse: about 350B tokens, 8K context
Figure 3. The three training phases, drawn to scale by tokens: 1.7T of general pre-training at shorter contexts, 250B of context extension to 8K, and about 350B of annealing toward Ecom-niverse at 8K. Block height marks the context window and is schematic.

Phase 1: Pre-training (1.7T tokens)

We establish broad linguistic and world knowledge using a diverse mixture: curated web text, books, code, technical papers, and multilingual content (lightly). Shorter contexts speed up convergence and stabilize optimization.

Key details

Why it matters

Short windows produce fast iterations, letting the model learn token level statistics and robust attention patterns before we pay the quadratic attention cost of long sequences.

Phase 2: Context Extension (250B tokens)

We lengthen the window to 8K to model multi-section documents, specs, FAQs, contracts, and research papers.

Stability contributions

Phase 3: Annealing (≈ 350B tokens, context 8k)

We specialize without forgetting. Starting from the Phase-2 checkpoint, we anneal the training distribution toward Ecom-niverse.

We perform Annealed domain specialization with rehearsal which interprets as using e-commerce specific tokens domain alignment with regressing on learnings from Phase-1 and Phase 2.

What's different from ModernBERT

Model Details

Model Sizes

We train four size-scaled variants of RexBERT to span common latency & accuracy trade-offs encountered in production systems.

Table 3. The four size-scaled variants of RexBERT.

Parameter17M (Micro)68M (Mini)150M (Base)400M (Large)
Layers7192228
Hidden Size2565127681024
Intermediate Size38476811522624
Attention Heads481216
Learning Rate3e-33e-38e-45e-4
Weight Decay3e-43e-41e-51e-5

Performance Evaluation

We conduct a comprehensive evaluation on e-commerce specific datasets and tasks that mirror effectiveness of the models in the domain.

Token Classification

The study utilized textual data assets from the Amazon ESCI dataset to benchmark model performance. Evaluations were conducted using the 'Product Title' and 'Product Description' fields with three distinct context window sizes: 128, 256, and 512 tokens. A uniform masking rate of 15% of the total tokens was applied to each input instance. Predictive accuracy was subsequently quantified using top-k metrics, with k ∈ {1, 3, 5}, to assess the model's ability to correctly predict each masked token.

With 2–3x fewer parameters, RexBERT surpasses the performance of the ModernBERT series.

Grouped, stacked bar chart titled MLM - Token Classification. Six groups: Product Title and Product Description, each at context lengths 128, 256 and 512. In each group five bars, for RexBERT-large, ModernBERT-large, RexBERT-base, ModernBERT-base and RexBERT-mini, stack top-1, top-3 and top-5 accuracy in percent. Top-5 accuracy on Product Title at 128: 85.1, 78.2, 82.6, 74.1 and 79.7. On Product Description at 512: 92.1, 89.8, 90.4, 87.0 and 88.2. RexBERT-large is highest in every group.
Figure 4. Masked-token accuracy on Amazon ESCI product titles and product descriptions at context lengths 128, 256 and 512. Each bar stacks top-1 (darkest, at the bottom), top-3 and top-5 (lightest, at the top) accuracy.

Additionally, smaller RexBERT models: RexBERT-Mini and RexBERT-micro outperform their size counterparts DistilBERT and BERT-mini by huge margins.

Table of top-k token accuracy (k = 1, 3, 5) on Product Title and Product Description at block sizes 128, 256 and 512. Mini models, about 70M parameters: RexBERT-mini scores between 65.58 and 88.22, DistilBERT between 29.41 and 66.16. Micro models, 10 to 17M parameters: RexBERT-micro scores between 51.14 and 79.94, BERT-mini between 39.94 and 68.76. The RexBERT model is higher in every column.
Figure 5. Top-k token accuracy of the small models: RexBERT-mini against DistilBERT, and RexBERT-micro against BERT-mini.

RexBERT modelcomparison model

Top-1 masked-token accuracy, four pairs of models on one scaleRexBERT-base vs ModernBERT-large, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-base: Product Title 69.2, 71.4, 72.6; Product Description 73.1, 75.5, 77.4. ModernBERT-large: Product Title 65.0, 68.4, 69.8; Product Description 71.9, 75.0, 77.4. RexBERT-mini vs ModernBERT-base, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. ModernBERT-base: Product Title 60.5, 64.2, 65.5; Product Description 67.8, 71.2, 74.0. RexBERT-mini vs DistilBERT, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. DistilBERT: Product Title 34.9, 33.5, 29.4; Product Description 48.2, 49.4, 49.1. RexBERT-micro vs BERT-mini, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-micro: Product Title 55.7, 55.5, 51.1; Product Description 57.2, 61.6, 64.0. BERT-mini: Product Title 39.9, 43.9, 46.1; Product Description 49.6, 52.4, 54.7.A. RexBERT-base vs ModernBERT-largeRexBERT-base vs ModernBERT-large, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-base: Product Title 69.2, 71.4, 72.6; Product Description 73.1, 75.5, 77.4. ModernBERT-large: Product Title 65.0, 68.4, 69.8; Product Description 71.9, 75.0, 77.4.A. RexBERT-base vs ModernBERT-largeagainst the ModernBERT one size up304050607080Top-1 accuracy (%)128256512128256512Product TitleProduct DescriptionModernBERT-large, Product Title, 128 tokens: 65.0%65.0ModernBERT-large, Product Title, 256 tokens: 68.4%68.4ModernBERT-large, Product Title, 512 tokens: 69.8%69.8ModernBERT-large, Product Description, 128 tokens: 71.9%71.9ModernBERT-large, Product Description, 256 tokens: 75.0%75.0ModernBERT-large, Product Description, 512 tokens: 77.4%77.4RexBERT-base, Product Title, 128 tokens: 69.2%69.2RexBERT-base, Product Title, 256 tokens: 71.4%71.4RexBERT-base, Product Title, 512 tokens: 72.6%72.6RexBERT-base, Product Description, 128 tokens: 73.1%73.1RexBERT-base, Product Description, 256 tokens: 75.5%75.5RexBERT-base, Product Description, 512 tokens: 77.4%77.4RexBERT-baseModernBERT-largeB. RexBERT-mini vs ModernBERT-baseRexBERT-mini vs ModernBERT-base, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. ModernBERT-base: Product Title 60.5, 64.2, 65.5; Product Description 67.8, 71.2, 74.0.B. RexBERT-mini vs ModernBERT-baseagainst the ModernBERT one size up304050607080128256512128256512Product TitleProduct DescriptionModernBERT-base, Product Title, 128 tokens: 60.5%60.5ModernBERT-base, Product Title, 256 tokens: 64.2%64.2ModernBERT-base, Product Title, 512 tokens: 65.5%65.5ModernBERT-base, Product Description, 128 tokens: 67.8%67.8ModernBERT-base, Product Description, 256 tokens: 71.2%71.2ModernBERT-base, Product Description, 512 tokens: 74.0%74.0RexBERT-mini, Product Title, 128 tokens: 65.6%65.6RexBERT-mini, Product Title, 256 tokens: 67.2%67.2RexBERT-mini, Product Title, 512 tokens: 66.8%66.8RexBERT-mini, Product Description, 128 tokens: 68.3%68.3RexBERT-mini, Product Description, 256 tokens: 72.0%72.0RexBERT-mini, Product Description, 512 tokens: 74.3%74.3RexBERT-miniModernBERT-baseContext length (tokens)C. RexBERT-mini vs DistilBERTRexBERT-mini vs DistilBERT, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. DistilBERT: Product Title 34.9, 33.5, 29.4; Product Description 48.2, 49.4, 49.1.C. RexBERT-mini vs DistilBERTmini models, ~70M parameters304050607080Top-1 accuracy (%)128256512128256512Product TitleProduct DescriptionDistilBERT, Product Title, 128 tokens: 34.9%34.9DistilBERT, Product Title, 256 tokens: 33.5%33.5DistilBERT, Product Title, 512 tokens: 29.4%29.4DistilBERT, Product Description, 128 tokens: 48.2%48.2DistilBERT, Product Description, 256 tokens: 49.4%49.4DistilBERT, Product Description, 512 tokens: 49.1%49.1RexBERT-mini, Product Title, 128 tokens: 65.6%65.6RexBERT-mini, Product Title, 256 tokens: 67.2%67.2RexBERT-mini, Product Title, 512 tokens: 66.8%66.8RexBERT-mini, Product Description, 128 tokens: 68.3%68.3RexBERT-mini, Product Description, 256 tokens: 72.0%72.0RexBERT-mini, Product Description, 512 tokens: 74.3%74.3RexBERT-miniDistilBERTD. RexBERT-micro vs BERT-miniRexBERT-micro vs BERT-mini, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-micro: Product Title 55.7, 55.5, 51.1; Product Description 57.2, 61.6, 64.0. BERT-mini: Product Title 39.9, 43.9, 46.1; Product Description 49.6, 52.4, 54.7.D. RexBERT-micro vs BERT-minimicro models, 10–17M parameters304050607080128256512128256512Product TitleProduct DescriptionBERT-mini, Product Title, 128 tokens: 39.9%39.9BERT-mini, Product Title, 256 tokens: 43.9%43.9BERT-mini, Product Title, 512 tokens: 46.1%46.1BERT-mini, Product Description, 128 tokens: 49.6%49.6BERT-mini, Product Description, 256 tokens: 52.4%52.4BERT-mini, Product Description, 512 tokens: 54.7%54.7RexBERT-micro, Product Title, 128 tokens: 55.7%55.7RexBERT-micro, Product Title, 256 tokens: 55.5%55.5RexBERT-micro, Product Title, 512 tokens: 51.1%51.1RexBERT-micro, Product Description, 128 tokens: 57.2%57.2RexBERT-micro, Product Description, 256 tokens: 61.6%61.6RexBERT-micro, Product Description, 512 tokens: 64.0%64.0RexBERT-microBERT-miniContext length (tokens)
Top-1 masked-token accuracy, four pairs of models on one scaleRexBERT-base vs ModernBERT-large, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-base: Product Title 69.2, 71.4, 72.6; Product Description 73.1, 75.5, 77.4. ModernBERT-large: Product Title 65.0, 68.4, 69.8; Product Description 71.9, 75.0, 77.4. RexBERT-mini vs ModernBERT-base, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. ModernBERT-base: Product Title 60.5, 64.2, 65.5; Product Description 67.8, 71.2, 74.0. RexBERT-mini vs DistilBERT, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. DistilBERT: Product Title 34.9, 33.5, 29.4; Product Description 48.2, 49.4, 49.1. RexBERT-micro vs BERT-mini, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-micro: Product Title 55.7, 55.5, 51.1; Product Description 57.2, 61.6, 64.0. BERT-mini: Product Title 39.9, 43.9, 46.1; Product Description 49.6, 52.4, 54.7.A. RexBERT-base vs ModernBERT-largeRexBERT-base vs ModernBERT-large, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-base: Product Title 69.2, 71.4, 72.6; Product Description 73.1, 75.5, 77.4. ModernBERT-large: Product Title 65.0, 68.4, 69.8; Product Description 71.9, 75.0, 77.4.A. RexBERT-base vs ModernBERT-largeagainst the ModernBERT one size up304050607080Top-1 accuracy (%)128256512128256512Product TitleProduct DescriptionModernBERT-large, Product Title, 128 tokens: 65.0%65.0ModernBERT-large, Product Title, 256 tokens: 68.4%68.4ModernBERT-large, Product Title, 512 tokens: 69.8%69.8ModernBERT-large, Product Description, 128 tokens: 71.9%71.9ModernBERT-large, Product Description, 256 tokens: 75.0%75.0ModernBERT-large, Product Description, 512 tokens: 77.4%77.4RexBERT-base, Product Title, 128 tokens: 69.2%69.2RexBERT-base, Product Title, 256 tokens: 71.4%71.4RexBERT-base, Product Title, 512 tokens: 72.6%72.6RexBERT-base, Product Description, 128 tokens: 73.1%73.1RexBERT-base, Product Description, 256 tokens: 75.5%75.5RexBERT-base, Product Description, 512 tokens: 77.4%77.4RexBERT-baseModernBERT-largeB. RexBERT-mini vs ModernBERT-baseRexBERT-mini vs ModernBERT-base, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. ModernBERT-base: Product Title 60.5, 64.2, 65.5; Product Description 67.8, 71.2, 74.0.B. RexBERT-mini vs ModernBERT-baseagainst the ModernBERT one size up304050607080Top-1 accuracy (%)128256512128256512Product TitleProduct DescriptionModernBERT-base, Product Title, 128 tokens: 60.5%60.5ModernBERT-base, Product Title, 256 tokens: 64.2%64.2ModernBERT-base, Product Title, 512 tokens: 65.5%65.5ModernBERT-base, Product Description, 128 tokens: 67.8%67.8ModernBERT-base, Product Description, 256 tokens: 71.2%71.2ModernBERT-base, Product Description, 512 tokens: 74.0%74.0RexBERT-mini, Product Title, 128 tokens: 65.6%65.6RexBERT-mini, Product Title, 256 tokens: 67.2%67.2RexBERT-mini, Product Title, 512 tokens: 66.8%66.8RexBERT-mini, Product Description, 128 tokens: 68.3%68.3RexBERT-mini, Product Description, 256 tokens: 72.0%72.0RexBERT-mini, Product Description, 512 tokens: 74.3%74.3RexBERT-miniModernBERT-baseC. RexBERT-mini vs DistilBERTRexBERT-mini vs DistilBERT, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-mini: Product Title 65.6, 67.2, 66.8; Product Description 68.3, 72.0, 74.3. DistilBERT: Product Title 34.9, 33.5, 29.4; Product Description 48.2, 49.4, 49.1.C. RexBERT-mini vs DistilBERTmini models, ~70M parameters304050607080Top-1 accuracy (%)128256512128256512Product TitleProduct DescriptionDistilBERT, Product Title, 128 tokens: 34.9%34.9DistilBERT, Product Title, 256 tokens: 33.5%33.5DistilBERT, Product Title, 512 tokens: 29.4%29.4DistilBERT, Product Description, 128 tokens: 48.2%48.2DistilBERT, Product Description, 256 tokens: 49.4%49.4DistilBERT, Product Description, 512 tokens: 49.1%49.1RexBERT-mini, Product Title, 128 tokens: 65.6%65.6RexBERT-mini, Product Title, 256 tokens: 67.2%67.2RexBERT-mini, Product Title, 512 tokens: 66.8%66.8RexBERT-mini, Product Description, 128 tokens: 68.3%68.3RexBERT-mini, Product Description, 256 tokens: 72.0%72.0RexBERT-mini, Product Description, 512 tokens: 74.3%74.3RexBERT-miniDistilBERTD. RexBERT-micro vs BERT-miniRexBERT-micro vs BERT-mini, top-1 accuracy in percent at context 128, 256 and 512. RexBERT-micro: Product Title 55.7, 55.5, 51.1; Product Description 57.2, 61.6, 64.0. BERT-mini: Product Title 39.9, 43.9, 46.1; Product Description 49.6, 52.4, 54.7.D. RexBERT-micro vs BERT-minimicro models, 10–17M parameters304050607080Top-1 accuracy (%)128256512128256512Product TitleProduct DescriptionBERT-mini, Product Title, 128 tokens: 39.9%39.9BERT-mini, Product Title, 256 tokens: 43.9%43.9BERT-mini, Product Title, 512 tokens: 46.1%46.1BERT-mini, Product Description, 128 tokens: 49.6%49.6BERT-mini, Product Description, 256 tokens: 52.4%52.4BERT-mini, Product Description, 512 tokens: 54.7%54.7RexBERT-micro, Product Title, 128 tokens: 55.7%55.7RexBERT-micro, Product Title, 256 tokens: 55.5%55.5RexBERT-micro, Product Title, 512 tokens: 51.1%51.1RexBERT-micro, Product Description, 128 tokens: 57.2%57.2RexBERT-micro, Product Description, 256 tokens: 61.6%61.6RexBERT-micro, Product Description, 512 tokens: 64.0%64.0RexBERT-microBERT-miniContext length (tokens)
Figure 6. Top-1 masked-token accuracy from Figures 4 and 5, one pair of models per panel, all on one scale. Top row: a RexBERT model against the ModernBERT one size larger. Bottom row: RexBERT-mini and RexBERT-micro against baselines of their own size.

Semantic Similarity

To assess how well general purpose language models transfer to a downstream semantic similarity task in e-commerce, we finetune them as text embedding models and evaluate their ability to recover similarity structure under a limited-data regime.

We use the Amazon ESCI dataset, which annotates query-product pairs with four relevance categories: Exact, Substitute, Complement, and Irrelevant. Rather than the original re-ranking objective, we construct a semantic similarity view by mapping labels to target similarity scores:

This monotonic mapping preserves the ordinal structure of ESCI while yielding dense supervision suitable for embedding learning. We filter to English and form training instances as paired texts (query-product title) with the corresponding target score.

Models are trained with CoSENT loss or AnglE Loss, which optimizes pairwise orderings in cosine-similarity space. Intuitively, CoSENT encourages a higher cosine similarity for pairs with larger target scores and enforces margins between positives and negatives, making it a natural fit for metric learning with graded labels. We operate in a limited-data setting to test sample efficiency: training uses a 'small' set of ESCI.

We compute Spearman’s rank correlation (ρ) between the model’s predicted cosine similarities and the target scores on a heldout test set. Spearman ρ evaluates whether the model preserves the correct ordering of semantic relatedness, which is the principal objective for downstream retrieval and clustering. We also monitor convergence behavior (stability of ρ across checkpoints) to gauge robustness in low resource training.

We evaluate a family of RexBERT models across sizes alongside competitive baselines in a comparable parameter range, including EmbeddingGemma-300M. All models are fine-tuned under the same data, objective, and evaluation pipeline to ensure a fair comparison.

Scatter plot titled Pareto Efficiency: Parameters vs Spearman. Horizontal axis: parameters in millions, 0 to 400. Vertical axis: Spearman correlation, 0.25 to 0.45. From lowest to highest score: Ettin-encoder-17M, RexBERT-micro, Ettin-encoder-68M, ModernBERT-base, ModernBERT-large, RexBERT-mini, RexBERT-base, EmbeddingGemma-300M and RexBERT-large, which is highest at about 0.46. A shaded region marks the area above the line from RexBERT-micro to RexBERT-large; RexBERT-mini and RexBERT-base lie inside it, the Ettin and ModernBERT models lie below it.
Figure 7. Parameters against Spearman correlation on the English ESCI similarity task.

Across the English ESCI similarity task, the RexBERT series consistently outperforms other models within a similar parameter budget. Notably, RexBERT-large achieves the strongest performance, surpassing EmbeddingGemma-300M under identical training and evaluation conditions. These results indicate that the RexBERT architecture, when trained with CoSENT on ESCI, learns an embedding space that better reflects graded semantic relations in e-commerce text, reinforcing strength of our pre-training. We are making the Evaluation Dashboard available publicly.

Following the evaluation protocol outlined in the ModernBERT paper, we trained RexBERT-Base and ModernBERT-Base on the MS MARCO dataset (1.25M pairs) for both general retrieval and semantic similarity. On the MTEB v2 (English) benchmark, the two models achieved comparable performance. These results indicate that our strategy of constructing a balanced, multi-domain corpus enriched with context specific token distributions improves performance on context-dependent tasks while maintaining SOTA results on general benchmarks. Due to limited computational resources, we were unable to extend experiments to the full RexBERT model family.

Usage Example

from transformers import AutoTokenizer, AutoModel

# Load encoder for classification/embeddings
tokenizer = AutoTokenizer.from_pretrained("thebajajra/RexBERT-base")
model = AutoModel.from_pretrained("thebajajra/RexBERT-base")

def predict_masked_token(text):
    inputs = tokenizer(text, return_tensors="pt")
    with torch.no_grad():
        outputs = model(**inputs)

    # Get predictions for [MASK] tokens
    mask_indices = torch.where(inputs["input_ids"] == tokenizer.mask_token_id)
    predictions = outputs.logits[mask_indices]

    # Get top 5 predictions
    top_tokens = torch.topk(predictions, 5, dim=-1)
    return [tokenizer.decode(token) for token in top_tokens.indices[0]]

# Example
masked_text = "Our healing jelly is clinically proven to protect, help heal, and lock in [MASK] for dry, cracked skin"
predictions = predict_masked_token(masked_text)
print(f"Predictions: {predictions}")

Acknowledgement

We gratefully acknowledge Orion et al., Seq vs Seq: An Open Suite of Paired Encoders and Decoders. Since our Phase-1 and Phase-2 procedures closely mirror their methodology, we initialized our training from the final Phase-2 checkpoint provided in that suite and then conducted Phase-3 training on our Ecom-niverse corpus. We thank the authors for making their checkpoints and code available for us to bootstrap our work.

References

Originally published on Hugging Face on Sep 20, 2025.