Users as Time-Weighted Optimization Problems: Implicit Preference Layers for Irregular Histories

Most sequential recommenders summarize a user's history with a learned average. Attention layers, recurrent cells and time-decay kernels all assign each past interaction a weight and blend the corresponding item vectors. That blend has a blind spot. Because attention weights are normalized to sum to one, a user who clicked once yesterday after six silent months produces a summary just as confident as one who clicked fifty times yesterday. Real preference drift needs the opposite behavior. Many recent signals should overwrite the old profile. A single recent signal after a long gap should only nudge it. The model should know how unsure it is in both cases.

We propose to represent the user's current taste as the solution of a small optimization problem that is re-solved at every query time. The problem fits a preference vector to the user's own history. Each past interaction is weighted by a learned function of the wall-clock time since it happened, and the vector is pulled toward a long-term profile with a strength that also depends on elapsed time. The fit is strongly convex, so we can train the time-weighting functions and item embeddings end to end. We do this by implicit differentiation, which means differentiating the condition "the gradient is zero at the solution" rather than backpropagating through solver iterations. The curvature matrix needed for that gradient is also, read as a Laplace approximation, the posterior precision of the user's taste. Uncertainty that grows with the time gap therefore comes from the same linear solve, with no second network.

Core Claim

Formulating the user representation as an interval-weighted regularized fit, rather than a normalized weighted average, does three things at once. First, it counts evidence: how many interactions are recent, and how consistent they are, decides how far the estimate moves from the long-term profile. Second, it learns how fast to forget, per gap length and item, so the user's "variation budget" (the total amount of preference change, which a fixed discount must assume) need not be known in advance. Third, it gives an interval-aware uncertainty estimate for free. The concrete inner problem at query time $t$ is

$$u^*(t) = \arg\min_u \sum_{i} w_\phi(t - t_i, v_i)\, \ell(u; v_i) + \frac{\lambda_\phi(t - t_{\text{last}})}{2}\,\lVert u - \bar u \rVert^2 .$$

Here $v_i$ is the embedding of the item consumed at time $t_i$, and $\ell$ is a logistic pairwise loss of the user vector $u$ against sampled negatives. The weight network $w_\phi$ maps the gap and the item to a nonnegative weight and may be non-monotone in the gap, so it can express repeat cycles. The anchor strength $\lambda_\phi > 0$ depends on the time since the last interaction. $\bar u$ is a slowly learned long-term user embedding. Training gradients follow from the implicit function theorem, $\partial u^*/\partial \theta = -H^{-1}\,\partial^2 F/\partial u\,\partial\theta$, where $F$ is the objective above, $\theta$ collects $\phi$, the item embeddings and $\bar u$, and $H$ is the Hessian of $F$ in $u$. With embedding size around 64, $H$ is a small positive-definite matrix per user, solved by batched Cholesky factorization. The same $H^{-1}$ serves as the covariance of $u^*(t)$.

The formulation contains familiar models as special cases. With squared loss and $w = e^{-\kappa \Delta t}$ it reduces to exponentially decayed ridge regression, which is the recommender analogue of the discount used by NS-DPO. Replacing the solve with a normalized weighted mean recovers time-aware attention.

Relation to Prior Work

Our motivation comes from the preference-drift literature. Right Now, Wrong Then shows that static preference fitting fails under drift and fixes it with exponential sample weights $\gamma^{T-t_i-1}$. The authors acknowledge that choosing $\gamma$ requires the unknown variation budget, and they work on discrete time indices. We keep the idea of reweighting but learn the weights as a function of continuous gaps, and we add an anchor whose strength adapts to the gap.

The interval-neglect literature supplies our competitors. Self-modulating attention reweights history through a point-process intensity. ReCODE integrates a neural ODE over gaps to score repeat intent and shows that fixed parametric decays miss binge-then-return patterns. This finding constrains our design: $w_\phi$ must not be forced to be monotone. GDERec evolves a graph through a neural ODE. E-NSDE attaches an evidential head and enforces, through a monotone network, that uncertainty grows with the gap. Everything in this group is an explicit forward map trained by ordinary backpropagation, and none of these methods has an evidence-counting mechanism. Our uncertainty grows with the gap for a structural reason: as old weights decay, $H$ loses mass and its inverse grows. It is not imposed as a constraint.

TiCoSeRec argues for the opposite remedy. It makes sequences artificially uniform by inserting and masking items. We address the same instability by letting the gap set regularization strength while leaving the raw sequence untouched. This is a direct test of the tension between that paper and the ODE line.

The method itself is reused from three sources. Differentiable Convex Optimization Layers gives the general recipe for differentiating optimality conditions. Data Poisoning Attacks on Factorization-Based Collaborative Filtering shows that optimality-condition gradients of collaborative-filtering fits are tractable, though only on static rating matrices and for attack rather than modeling. Margossian's review explains why differentiating at the solution avoids storing solver trajectories. Stable Preference Optimization also frames preference learning as a two-level problem, but it replaces the inner problem with a single-level surrogate and has no notion of time. We keep the inner problem exact.

Research Program

We will build the layer in PyTorch. A batched Newton solver runs the forward pass to tolerance $10^{-6}$, and an implicit backward pass solves one $d\times d$ system per user. A shared feature encoder sits on top and produces candidate scores $u^*(t)\cdot v$. Strong convexity holds because $\lambda_\phi>0$ is enforced through a softplus with a floor, which also bounds the conditioning of $H$. This addresses the ill-conditioning concern raised for implicit layers.

The analysis has three parts. First, we will characterize what $w_\phi$ and $\lambda_\phi$ learn on each dataset: whether forgetting is monotone, whether repeat cycles appear on music data, and how anchor strength scales with silence. Second, we will test whether Hessian-based uncertainty is calibrated. Third, we will measure where the evidence-counting property matters, by stratifying users by the number of interactions in the window before the query and by the length of the last gap. Our prediction is concrete. Gains over normalized attention should concentrate in the "few recent interactions after a long gap" stratum and vanish for dense, uniformly spaced users. E-NSDE notes that interval signals collapse in exactly that dense regime.

Baselines

The naive reference is a static sequential model with no time input: SASRec, plus matrix factorization on music data. It establishes how much any interval modeling buys. We will run it with the same embedding size, the same negative sampling and the same chronological leave-last-out split.

The time-decay baseline is our own layer with $w_\phi$ fixed to $e^{-\kappa \Delta t}$ and a constant $\lambda$, with $\kappa$ and $\lambda$ tuned by grid search. This is the NS-DPO-style discount transplanted to recommendation. Beating it shows that learning the forgetting function matters. To count as a win, our model must lead on validation data under an equal tuning budget.

The strongest existing methods are E-NSDE and self-modulating attention, plus ReCODE on repeat-heavy data. Reported numbers give the bars. On MovieLens-100K, E-NSDE reports Precision@5 of 0.4711, against 0.4149 for BERT4Rec (E-NSDE). On Tmall, self-modulating SASRec reports HR@10 of 0.51347, against 0.50433 for SASRec (Self-modulating attention). On MMTD, ReCODE with matrix factorization reports Recall@50 of 25.20%, against 18.68% for plain matrix factorization (ReCODE). GDERec reports only an average relative gain of 6.5% Recall@5 over its baselines. For Koubei there is no reported result found on Lacuna, and for Amazon Beauty, Sports and Home, TiCoSeRec reports only relative gains of 5–18% in NDCG@10 and Hit@10. We will rerun all of these from public code on our splits with matched hyperparameter search budgets (equal trial counts) and matched GPU hours. Beating them means a statistically significant improvement over three or more seeds on our reruns, and at least parity with the published figures where the protocols match.

The key ablation isolates the solve. We keep $w_\phi$, $\lambda_\phi$ and $\bar u$ identical but replace $u^*$ with the normalized weighted mean of item vectors blended with $\bar u$. We also add a second variant using unnormalized attention with a learned gap-dependent gate. If either variant matches the full model, the optimization structure is not what earns the gain.

Why not just…?

Why not just use an exponential time-decay weight? A fixed decay assumes a known forgetting rate, and NS-DPO itself flags that this requires the unknown variation budget (Right Now, Wrong Then). ReCODE shows monotone kernels miss repeat cycles. Our decay baseline is an exact special case of our layer, so the comparison isolates the learned weighting. If it ties on all datasets, we will report that learned forgetting adds nothing at these scales.

Why not just use time-aware attention, normalized or gated? This is the real threat. A softmax cannot distinguish one recent click from fifty, but an unnormalized gate could approximate evidence counting. The solve-versus-mean ablation, examined on the sparse-recent stratum, settles it. If the gated variant matches the full model there, we drop the claim that the optimization layer is necessary and keep only the uncertainty result.

Why not just unroll a few Newton steps instead of implicit differentiation? With $d\approx 64$ and short histories, unrolling five Newton steps is affordable, and memory concerns from Gao's survey may not bite. We do not claim implicit differentiation is what improves accuracy. We will report accuracy, memory and wall-clock time for both, expecting equal accuracy and lower memory for implicit differentiation on long histories such as ML-1M. The contribution is the formulation, and implicit differentiation is its efficient training path.

Why not just augment sequences to be uniform, as TiCoSeRec does? Augmentation inserts synthetic items and deletes real ones, which distorts refractory and repeat patterns. We will run TiCoSeRec on Amazon Beauty, Sports and Home, and also on MMTD, where we expect it to hurt repeat prediction. We can also combine it with our layer to test whether the two are complementary.

Proposed Experiments

The main benchmarks are MovieLens-100K and 1M, Amazon Beauty, Sports and Home, Tmall, and MMTD with Nowplaying-RS. Metrics are Precision@5, HR@10, NDCG@10 and Recall@50, matching each cited paper's protocol where possible.

The first decisive check is the stratified analysis described above. A win concentrated in sparse-recent, long-gap users, with parity among dense users, supports evidence counting. A uniform win, or none, refutes it.

The second check is uncertainty. We bin test queries by the trace of $H^{-1}$ and compare expected calibration error and error–uncertainty rank correlation against E-NSDE's epistemic estimate. We will also use the uncertainty to weight exploration in a replay simulation, mirroring E-NSDE's weighted ranking loss.

The third check is controlled drift. On MovieLens-1M we inject synthetic genre switches at known change points, with gradual and abrupt variants that mirror the flip scenarios used for NS-DPO. We then test whether $\lambda_\phi$ and $w_\phi$ recover faster forgetting after abrupt switches without being told the variation budget, compared with tuned fixed-decay models. Recovery speed is measured in interactions needed to regain pre-switch accuracy.