RecomNext

Logic & algorithms

Recommendation logics and algorithm deep dives.

05 - Logic types & algorithms

Related: ML models · Worked examples

Search algorithms are omitted from this pack.

Matrix

LogicIntentRequired inputsDefault algorithmAlso available
user-to-itemPersonalized “for you”userIdweighted-historyelsa-cf, realm-sequential
item-to-itemRelated to one productitemIdco-occurrenceelsa-cf
items-to-itemsRelated to a set (cart)itemIds[]multi-seed-co-occurrencemulti-seed-hybrid
similar-productsContent/vector similarityitemIdvector-similaritybeeformer-multimodal
recently-viewedRecency of viewsuserIdrecency-

1. user-to-itemweighted-history (default)

Idea

Rank items the user already engaged with by weighted interaction strength, then fill with popular items if needed.

Score

total_weight(item) = Σ event.weight × type_multiplier(type)
window = last 30 days
type_multiplier: purchase=4, rating=3, cart=2, else 1

Over-fetch count × 4. If still short, append 7-day popular items (by count) with score 0.5 when no personal weight.

Flow

Tweaks

  • Scenario filter/boosters/constraints as usual.
  • Event quality & identity merge dominate accuracy.
  • Type multipliers are code constants (not Admin fields).

2. item-to-itemco-occurrence (default)

Idea

“Users who interacted with seed also interacted with …”

Score

co_count = number of user co-interactions between seed and candidate in 30 days (self-join on user_id).

Fallback: same category catalog items with score 0.5.

Flow

Example

If 40 users touched both seed S and item R in 30d, R scores 40 (before boosters).

Tweaks

  • Needs enough overlapping users; sparse catalogs rely on category fallback.
  • Pass userId to enable purchase cap.

3. items-to-itemsmulti-seed-co-occurrence (default)

Idea

Aggregate co-occurrence across multiple seeds (cart). Candidates matching a seed category get a ×2 category boost (legacy hardcoded).

Score (simplified)

base = aggregated co_count across seeds
score = base × (2 if category matches any seed else 1)

Fallback: same-category catalog fill.

Tweaks

  • Prefer this for classic cart rails.
  • For vector+co fusion, switch algorithm to multi-seed-hybrid.

4. items-to-itemsmulti-seed-hybrid

Idea

Fuse collaborative (multi-seed co-occurrence) and vector (Qdrant) ranked lists with RRF, with strategies:

StrategyBehavior
rrfPer-seed fan-out + RRF fuse
centroidAverage seed vectors → one Qdrant query (good when cart is homogeneous)
adaptiveHomogeneity ratio unique(seed categories)/seedCount; ≤0.5 → centroid, else RRF fan-out

RRF contribution per list:

score(id) += 1 / (rrfK + rank_index + 1)

Typical rrfK ≈ 60 (configurable). Missing legs degrade gracefully (union of available lists).

Key hybridSettings

KnobRole
enabledIf false → fall back to multi-seed-co-occurrence
strategyrrf / centroid / adaptive
rrfK, coTopK, vectorTopKFusion / fan-out sizes
minCoSupportMin distinct seeds that must support a candidate
categoryBoostMultiplier for category match (hybrid path)
qdrantSettingsVector engine tuning (threshold, ef, …)

V1 fusion mode is RRF (weighted fusion reserved).


5. similar-productsvector-similarity (default)

Idea

Nearest neighbors of the seed’s embedding in Qdrant.

Score

Qdrant similarity score (higher = closer). Settings from tenant defaults + scenario qdrantSettings:

KnobRole
score_thresholdDrop weak neighbors
hnsw_efSearch quality vs latency
filter_categoriesRestrict neighbor categories
quantization_rescore / oversamplingQuantized index behavior

Flow

Tweaks

  • Embedding template / reindex quality dominates.
  • Raise threshold → fewer but “stronger” neighbors; may trigger minItems auto-relax.

6. recently-viewedrecency

Idea

Items the user viewed in 30d, ordered by most recent view time.

Notes

  • Uses type = 'view' only for ordering source.
  • Still runs through scenario post-process when a scenario is attached.

7. ML algorithms (summary - details in ch.06)

AlgorithmLogicsOnline scoring
elsa-cfuser-to-item, item-to-itemDot product of user↔item or item↔item factors; fallback to weighted-history / co-occurrence if factors missing
realm-sequentialuser-to-itemSession/sequence-aware next-item from GRU factors; fallback weighted-history
beeformer-multimodalsimilar-productsNN in Qdrant using beeFormer embeddings

Choosing logic for a placement

Driffle PDP similar rail uses similar-products + scenario pdp-similar-products (vector path).