MELODI: Similarity-Identity Decoupling for Lightweight Ranking

Quoc Phong Nguyen, Vuong Le, Volodymyr Vaskovych, Julien MonteilarXiv 2026

TL;DR

When a recommender system scores hundreds of items in milliseconds, it faces a brutal tug-of-war between understanding nuanced user history and beating the latency clock. MELODI resolves this by cleanly separating what an item is (its identity) from how well it matches your past (its similarity), using a clever algebraic property that lets the system pool your history first and compute complex interactions just once per candidate. The result is a lightweight ranker that beats heavier baselines in accuracy while slashing inference latency by up to 7.7× at scale.

What Problem Does This Paper Address?

Large-scale recommenders work in two stages: candidate generation whittles millions of items down to a shortlist of hundreds or thousands, and ranking scores that shortlist.

Suppose your recent shopping alternates between running shoes and camera lenses. A "target-agnostic" ranker squashes your entire history into one static summary vector, muddling both interests together. "Target-aware" rankers fix this by looking at the candidate item first—if they are scoring a tripod, they spotlight your photography clicks.

However, existing target-aware models pay a steep computational tax—either evaluating neural networks for every single (history item, candidate) pair (like DIN), or re-running a full Transformer over your history for every candidate. Furthermore, they tend to mash two distinct signals into a single vector: identity (e.g., holiday decorations sell well in December regardless of your past) and similarity (e.g., a power drill matches your recent paint and tool purchases). How do we keep these signals distinct and expressive without blowing up real-time serving budgets?

Methods

The authors introduce a similarity–identity decoupling framework and instantiate it as MELODI (Multi-head Efficient Lightweight Operator for Decoupling Identity and Similarity).

Figure 1: MELODI’s two-signal design. Top row: the similarity signal branch applies a shared embedding projection and layer normalization (LN) [1] (Stage 1), multi-head dot-product cross-attention producing {uℎ} (Stage 2), and a per-head gated cross layer without a residual connection producing c (Stage 3). Bottom row: the identity signal branch (dashed) applies a problem-dependent target-only transformation.

To make the similarity branch fast, they compare two ways of comparing a candidate item against $S$ history items:

  1. Similarity-then-Pool (SP): Compare the candidate to every history item individually, then take a weighted average. Great fidelity, expensive ($S$ operations per candidate).
  2. Pool-then-Similarity (PS): Take a candidate-conditioned weighted average of the history first, then run the similarity operator once. Much cheaper (1 operation per candidate).

The core mathematical hook is history-linearity: as long as the similarity operator is linear with respect to the history input, PS produces the exact same output as SP—even if the operator is wildly non-linear with respect to the candidate item!

MELODI builds on standard primitives (multi-head cross-attention and DCN-v2 cross networks) with three novel twists:

  • Reusable Cross-Attention (Stages 1 & 2): Projects normalized embeddings into multi-head dot-product cross-attention. Because the history isn't tangled up with the candidate via self-attention, history Keys and Values are computed once per user request and reused across all 1,000+ candidates.
  • History-Linear Gated Cross (Stage 3): Combines the pooled history and candidate using a mixture of low-rank experts with per-head softmax gates driven solely by the candidate. Crucially, they strip out the standard residual connection so the output remains a pure interaction signal.
  • Dedicated Identity Branch: Processes the candidate alone (via a DCN-v2 self-cross) before handing both signals to a final MLP scorer.

Datasets

MELODI is tested across two public benchmarks and two proprietary e-commerce logs:

  • Public: Steam (281k users, ~12k video games) and MovieLens-25M (162k users, ~33k movies), using frozen 384-dimensional MiniLM text embeddings and histories up to 50 items. Evaluated against 99 uniform negatives, 999 hard negatives, and the full item catalogue.
  • Industrial: Industrial-A (~591k candidate rows across 5,836 requests) and Industrial-B (~1.09M candidate rows across 5,625 requests). Unlike synthetic negative sampling, these contain real, hard-negative candidates that already survived upstream candidate generation, scored on binary purchase tasks.

Key Insights and Ideas

  • Non-linearity is free—if you put it on the target: You don't have to sacrifice complex feature crossing to get fast pooling. By restricting non-linearities (like softmax expert gating) strictly to the candidate side, you get rich, target-conditioned similarity at a fraction of the compute cost.
  • Request-local caching changes the scaling game: When scoring 1,000 candidates, computing history Keys and Values once per request drops MELODI's latency by 14.2× to 14.7× compared to re-encoding flattened rows, turning history processing into a tiny ~3% overhead.
  • A massive hidden bug in sequential baselines: Simply applying shared Layer Normalization to target embeddings boosted the classic target-agnostic SASRec baseline's MRR by 15.4% on Steam and 41.6% on ML-25M—fixing a dot-product scale mismatch larger than most architectural inventions!
  • Candidate count dictates the winner: For small candidate sets ($C \le 100$), classic DIN is actually faster because its pairwise tensor operations vectorize neatly in memory. Beyond $C \approx 500$, DIN's memory footprint balloons and MELODI pulls decisively ahead.

Key Results

Quality gain (NDCG@10) vs. relative latency at 1,000 candidates on Steam and ML-25M, showing reused MELODI dominating the upper-left frontier.

Quality gain (NDCG@10) vs. relative latency at 1,000 candidates on Steam and ML-25M, showing reused MELODI dominating the upper-left frontier.
  • Public Ranking Quality: Over three seeds, MELODI beats all baselines (SASRec, Target-Aware Transformer, DIN, DIN+DCN-v2) on every metric. It improves mean MRR over DIN by +3.5% on Steam (0.4720 vs. 0.4561) and +4.4% on ML-25M (0.7017 vs. 0.6719), and continues to lead under full-catalogue ranking and against CAN and DIEN.
  • Public Speedups: At $C = 1,000$ candidates with history reuse, MELODI scores a request in ~2.0 ms on a 32-vCPU machine—making it 6.9×–7.7× faster than a 1-layer Target-Aware Transformer (~13.7–15.1 ms) and ~5.0× faster than DIN (~9.9 ms).
  • Industrial Transfer: Relative to production tabular baselines, MELODI lifts AUPRC by +25.0% (NDCG@20 by +11.3%) on Industrial-A, and AUPRC by +7.8% (NDCG@20 by +3.2%) on Industrial-B. With history reuse, it runs 13.0×–28.7× faster than the Target-Aware Transformer and 5.2×–11.1× faster than DIN.

Limitations and Future Work

  • Offline-only evaluation: All experiments are offline; the model has not yet been validated in a live, online A/B test.
  • Exposure bias: Industrial models were trained on logged purchases of displayed items without debiasing, meaning MELODI can inherit the logging policy's position and exposure biases (the authors suggest pairing the framework with inverse-propensity weighting in future work).
  • Hardware scope & small-batch overhead: Latency was benchmarked on a single CPU architecture (32 virtual cores) rather than GPUs/accelerators, and for small candidate shortlists ($C \le 500$), DIN remains faster. Additionally, single-run ablation differences of a few thousandths in MRR are too small to treat as definitive.

Summary updated

Abstract

For latency-constrained candidate ranking, we propose a similarity-identity decoupling framework that separates target-history compatibility from target-only information. We study two orders for computing pooled similarity, similarity-then-pool and pool-then-similarity, and identify linearity of the similarity operator in its history argument, for each fixed target, as sufficient for their equivalence, justifying the cheaper pool-then-similarity form. We instantiate the framework as multi-head efficient lightweight operator for decoupling identity and similarity (MELODI), whose similarity branch combines target-conditioned multi-head history pooling with a single residual-free cross layer that is linear in its pooled-history input and whose identity branch is problem-dependent. On public benchmark datasets, MELODI matches or surpasses the evaluated target-aware and target-agnostic baselines. On two large-scale industrial datasets, its area under the precision-recall curve (AUPRC), normalised discounted cumulative gain (NDCG), and recall values are equal to or higher than those of the evaluated target-aware baselines. Processor measurements show lower latency than the evaluated candidate-conditioned baselines at large candidate counts, further reduced by request-local history reuse.
BibTeX
@misc{nguyen2026melodi,
  author = {Quoc Phong Nguyen and Vuong Le and Volodymyr Vaskovych and Julien Monteil},
  title = {{MELODI: Similarity-Identity Decoupling for Lightweight Ranking}},
  year = {2026},
  eprint = {2611.31940},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.31940},
}

Loading related content...

Figure