---
title: 'RecJPQ: Joint PQ for Recommenders'
url: https://www.emergentmind.com/topics/recjpq
type: topic
---

# RecJPQ: Joint PQ for Recommenders

RecJPQ is a recommendation-oriented adaptation of Joint Product Quantisation for large-catalogue recommendation, introduced as a replacement for the conventional item embedding tensor in sequential recommenders such as SASRec, BERT4Rec, and GRU4Rec. Its central mechanism is to replace each item’s full embedding with a short tuple of shared sub-item identifiers and to reconstruct the item representation by concatenating learned sub-embeddings, thereby changing the dominant learnable item-side parameter count from $|I|d$ to $bd$, plus fixed code storage of order $O(|I|m)$ [2312.06165]. In subsequent work, the same representation became the basis for exact parallel scoring, safe dynamic pruning, sub-ID-level popularity modeling, and multimodal top-$k$ recommendation [2408.09992] [2505.00560] [2508.05198] [2606.23291].

## 1. Origin and problem formulation

RecJPQ was introduced to address a specific systems bottleneck in sequential recommendation: modern Transformer backbones generate a sequence representation and then score every catalogue item against an item embedding matrix. In the standard formulation, a user history is encoded as $\phi \in \mathbb{R}^d$, item scores are computed as $r=W\phi$, and the item matrix $W \in \mathbb{R}^{|I|\times d}$ becomes the dominant memory cost when $|I|$ reaches hundreds of thousands or millions [2408.09992]. In the original RecJPQ paper, this bottleneck is framed as affecting both input embedding lookup and output scoring, because the same item embedding tensor is used to represent historical items and to score candidate items [2312.06165].

The method is explicitly derived from Product Quantisation and Joint Product Quantisation. Standard PQ splits a vector into subspaces and approximates each subvector by a centroid from a small codebook; JPQ differs in assigning codes before end-to-end training so that the model never needs to learn the full dense embedding table. RecJPQ transfers that idea to recommendation and adds recommendation-specific code assignment strategies based on interaction data rather than text-side pretraining [2312.06165].

The original paper also presents RecJPQ as conceptually analogous to tokenisation in language models: items are split into “sub-item entities” before recommender training. This framing is not merely metaphorical. It captures the core inductive bias of the method: parameter sharing is imposed at the level of discrete latent components rather than learned post hoc by compression [2312.06165].

## 2. Compositional representation and code assignment

In RecJPQ, each item $i$ receives a code
\[
g_i=\{g_{i1},g_{i2},\ldots,g_{im}\},
\]
where $m$ is the code length and each $g_{ij}$ is a sub-item ID drawn from a split-specific codebook of size $b$. The scheme can therefore represent up to $b^m$ distinct item codes. With the common setting $b=256$, each code component fits in one byte [2312.06165].

For each split $j$, RecJPQ learns a sub-item embedding table of dimension $d/m$. The item embedding is reconstructed by concatenating the selected sub-embeddings. Later formalizations write this as
\[
w_i = \psi_{1,g_{i1}} \mathbin\Vert \psi_{2,g_{i2}} \mathbin\Vert \cdots \mathbin\Vert \psi_{m,g_{im}},
\]
with codebook matrix
\[
G\in\mathbb{N}^{|I|\times m}
\]
and split-specific sub-item embedding matrices
\[
\Psi_k \in \mathbb{R}^{b\times\frac{d}{m}}.
\]
If the sequence embedding is partitioned compatibly as $\phi=\phi_1\mathbin\Vert\cdots\mathbin\Vert\phi_m$, then item scoring decomposes additively:
\[
r_i = w_i\cdot \phi = \sum_{k=1}^m \psi_{k,g_{ik}}\cdot\phi_k.
\]
Defining sub-ID scores
\[
s_{k,j}=\psi_{k,j}\cdot\phi_k,
\]
one obtains the operational scoring identity
\[
r_i=\sum_{k=1}^m s_{k,g_{ik}}.
\]
This is the algebraic basis of all later RecJPQ inference work [2408.09992].

The learnable parameter reduction follows directly. A standard item table needs $|I|d$ trainable parameters. RecJPQ replaces this with $m\cdot b \cdot \frac{d}{m}=bd$ learnable parameters, while storing the discrete item-to-code assignments separately [2312.06165].

The original paper defines three offline assignment strategies. The simplest is random code assignment. The main recommendation-specific strategy is discrete truncated SVD: construct the binary sequence–item interaction matrix $M$, compute truncated SVD with $m$ latent components,
\[
M \approx U \times \Sigma \times V^T,
\]
min-max normalize the item matrix $V$, perturb it with tiny Gaussian noise $\mathcal{N}(0,10^{-5})$, and discretize each latent dimension into $b$ quantiles; those quantized values become the item’s sub-item IDs. A third strategy applies the same discretization pipeline to item embeddings learned by an offline BPR matrix factorization model [2312.06165].

## 3. Integration into recommendation architectures

RecJPQ is presented as a model-agnostic replacement for the item embedding tensor rather than a new sequence encoder. In the original formulation, SASRec retains its self-attention sequence model, BERT4Rec retains its bidirectional Transformer encoder, and the GRU-based baseline retains its recurrent backbone; what changes is the way item representations are stored, looked up, and reused for output scoring [2312.06165].

This replacement is deliberately lightweight at the training-objective level. The original paper states that RecJPQ does not modify the base model loss. BERT4Rec continues to use its original masked-item prediction objective, SASRec its original next-item objective, and the GRU-based model the LambdaRank configuration of the authors’ prior implementation. The compression is therefore architectural rather than loss-based [2312.06165].

This design choice remained stable in later work. The PQTopK paper explicitly states that RecJPQ changes the item representation layer while PQTopK changes only the inference-time scoring head; the Transformer backbone and learning objective are not altered [2408.09992]. The same modularity underlies later extensions such as sub-ID popularity re-ranking and multimodal quantization.

A notable generalization appears in URecJPQ, which extends the RecJPQ idea from item-only quantization in sequential recommendation to user-and-item quantization in top-$k$ recommendation. In that setting, a vanilla model with embedding dimension $k$ has $(\#\text{users}+\#\text{items})\cdot k$ trainable embedding parameters, whereas URecJPQ reduces the trainable embedding component to shared codebooks of size $256\cdot k$ per side, or $2\cdot256\cdot k$ for both users and items when the codebook length is 256 per subspace [2606.23291].

## 4. Empirical behavior and regularization

The original RecJPQ evaluation used MovieLens-1M, Booking.com, and Gowalla. Its central empirical pattern is that RecJPQ is most compelling on large, sparse, long-tail catalogues. On Booking.com, BERT4Rec with SVD-based RecJPQ improved NDCG@10 from $0.376$ to $0.379$ while reducing model size to $63.3\%$ of the baseline, which the paper highlights as a $+0.96\%$ NDCG@10 improvement. On Gowalla, base SASRec achieved NDCG@10 $=0.110$, while RecJPQ-Random achieved $0.173$ at $2.9\%$ of the original checkpoint size [2312.06165].

The same study reports a clear size–performance frontier. On MovieLens-1M, the largest vanilla SASRec reaches roughly the same performance as a $4.9\times$ smaller RecJPQ variant, $71$ MB versus $15$ MB. On Gowalla, comparable SASRec performance is reported with a $47.94\times$ smaller RecJPQ model, $3.2$ GB versus $69$ MB [2312.06165]. The paper also reports that training and inference time were not noticeably harmed in its setting; on Booking.com, base BERT4Rec required $18.8$ hours while RecJPQ-SVD BERT4Rec required $16.1$ hours [2312.06165].

The original paper interprets some of the quality gains as a regularization effect. Because many long-tail items have very few interactions, learning a fully independent dense vector per item can overfit. RecJPQ forces items to share sub-embeddings, reducing memorization of idiosyncratic item-specific parameters and improving generalization on sparse data [2312.06165]. The ablations support this interpretation: longer codes, hence weaker sharing, help on denser MovieLens-1M, whereas shorter codes, hence stronger sharing, help on sparse long-tail Gowalla [2312.06165].

This regularization reading reappears in later work. URecJPQ reports that on large-scale multimodal datasets it can reduce checkpoint size by $86\%$ to $98\%$ and trainable parameters by $98\%$ to $99\%$, with an average decrease of $8.5\%$ in Recall and $16\%$ in NDCG, but in some cases even performance improvements of up to $85\%$, especially in the baby-products domain [2606.23291].

## 5. Inference, pruning, and system-scale retrieval

The algebraic decomposition of RecJPQ scores led to a second research line focused on exact inference efficiency. The key observation is that one can precompute the $m\times b$ sub-ID score matrix $S$ once per user and then assemble each item score by $m$ lookups and additions rather than by a full $d$-dimensional dot product [2408.09992].

The PQTopK paper argues that the original RecJPQ implementation left speed on the table because it used per-item score accumulators in a split-first loop order, which limited parallelization. PQTopK reorders the computation so that each item’s final score is computed independently as
\[
score[item\_id] \gets \sum_{k=1}^{m} S[k,G[item\_id,k]],
\]
followed by exact top-$K$ selection. On Gowalla with $1{,}271{,}638$ items, this reduced SASRec scoring mean response time from $131.35$ ms for default scoring to $10.03$ ms and total inference from $156.07$ ms to $34.72$ ms, yielding the widely cited $4.5\times$ end-to-end speedup over default SASRec and $1.56\times$ over the original RecJPQ scoring head [2408.09992].

RecJPQPrune extends this line from faster exhaustive scoring to exact non-exhaustive retrieval. It introduces inverted indexes over sub-item IDs, orders sub-ID scores within each split, maintains a top-$K$ threshold $\theta$, and stops when the upper bound
\[
\sigma = \sum_{m=1}^M S_{m,Q[m][P[m]]}
\]
satisfies $\sigma \le \theta$, because no unscored item can then enter the final top $K$. The method is described as safe-up-to-rank $K$: it returns exactly the same top-$K$ as exhaustive scoring and preserves effectiveness [2505.00560].

On Tmall with $2.2$M items and SASRecJPQ, the paper reports median scoring times of $204.18$ ms for Transformer Default, $16.72$ ms for PQTopK, and $3.18$ ms for RecJPQPrune, corresponding to about $64\times$ speedup over Transformer Default and about $5.3\times$ over PQTopK. It also states that RecJPQPrune can score $2$ million items in under $10$ milliseconds without GPUs and without ANN, while maintaining identical NDCG@10 across scoring methods [2505.00560].

These inference papers also clarify an important misconception. Neither PQTopK nor RecJPQPrune is an approximate nearest-neighbor method in the reported form. PQTopK is still exhaustive, but parallel and sub-ID-based; RecJPQPrune is non-exhaustive, but exact because it prunes only when the provable upper bound on unseen items falls below the current threshold [2408.09992] [2505.00560].

## 6. Later extensions, trade-offs, and limitations

Several later papers repurposed the RecJPQ sub-ID structure beyond memory-efficient sequential scoring.

| Work | Focus | Representative reported result |
|---|---|---|
| PQTopK [2408.09992] | Parallel exact scoring | $4.5\times$ faster total SASRec inference on Gowalla |
| RecJPQPrune [2505.00560] | Safe dynamic pruning | $64\times$ faster than Transformer Default on Tmall |
| sPPS [2508.05198] | Sub-ID popularity re-ranking | higher personalised novelty without compromising recommendation accuracy |
| URecJPQ [2606.23291] | User+item quantization for multimodal top-$k$ | $86\%$–$98\%$ checkpoint and $98\%$–$99\%$ parameter reduction |

In music recommendation, the sub-ID structure was reinterpreted as a finer-grained popularity signal. If an item has code
\[
\mathrm{code}(i)=[z_1^{(i)},\dots,z_m^{(i)}],
\]
and the user-specific count of sub-ID $k$ in split $j$ is
\[
c_j^{(u)}[k]=\sum_{i\in\mathcal S_u}\mathbf{1}\{z_j^{(i)}=k\},
\]
then the sub-ID-based personalised popularity score is
\[
\mathrm{sPPS}_i=\sum_{j=1}^m \log\bigl(c_j^{(u)}[z_j^{(i)}]+\epsilon\bigr).
\]
The final score is a convex combination of the RecJPQ recommender logits, item-level PPS, and sub-ID-level PPS:
\[
\text{logits}_i^{\text{final}}=(1-\alpha-\beta)\text{logits}_i^{\text{rec}}+\alpha \text{PPS}_i^{\text{std}}+\beta \text{sPPS}_i^{\text{std}}.
\]
This extension is intended to capture shared repetition patterns that item-level popularity alone cannot express [2508.05198].

Across these developments, several limitations remain stable. RecJPQ codes are assigned offline and fixed before training; neither the original paper nor URecJPQ learns the discrete assignments dynamically [2312.06165] [2606.23291]. Assignment strategy is materially important: SVD is presented as the safest default in the original sequential setting, Random can be best when stronger regularization helps, and BPR-based discretization can fail badly, as on Gowalla [2312.06165]. The method is also catalogue-scale sensitive: on small datasets such as MovieLens-1M, compression gains can be limited and overhead can dominate, even increasing SASRec checkpoint size in one reported setting [2312.06165].

Inference-side trade-offs are equally explicit. PQTopK remains exhaustive over the candidate set, so latency still scales roughly linearly with $|I|$; its advantage is hardware efficiency and preserved memory compression [2408.09992]. RecJPQPrune is exact, but its worst-case behavior can approach exhaustive scoring when pruning is ineffective, and larger numbers of splits $m$ erode the scoring advantage [2505.00560]. URecJPQ emphasizes memory and checkpoint reductions rather than latency, and it does not report explicit retrieval-throughput benchmarks [2606.23291].

Taken together, these works establish RecJPQ as more than an embedding-compression trick. In its original form it is a JPQ-inspired compositional item layer for training large-catalogue sequential recommenders; in later work it becomes an exact scoring algebra, a dynamic-pruning substrate, a source of sub-ID-level personalization signals, and a basis for user-and-item quantization in multimodal top-$k$ systems [2312.06165].

Source: https://www.emergentmind.com/topics/recjpq