Memory-Based Collaborative Filtering for Recommendation Service

CK CK 3788 
Created at  
202 0 0

Memory-Based Collaborative Filtering (CF) makes recommendations from patterns of agreement across many users, without using any item content features. It is “memory-based” because it operates directly on the stored user–item interaction matrix at prediction time, computing similarities on demand rather than learning a compact parametric model.

There are two complementary formulations:

  • User-based CF — find users with taste similar to the target user, then recommend what those neighbors liked.
  • Item-based CF — recommend items that are frequently co-consumed with items the target user already likes. This is the classic “customers who bought X also bought Y” approach popularized by Amazon.

Memory-Based Collaborative Filtering for Recommendation Service


 

How It Works (The Math)

Let R be the user–item rating (or interaction) matrix, where r_{u,i} is user u’s rating of item i.

User-based prediction

First compute similarity between users. Pearson correlation over their co-rated items I_{uv}:

sim(u, v) = Σ_{i ∈ I_{uv}} (r_{u,i} − r̄_u)(r_{v,i} − r̄_v) / ( √Σ (r_{u,i} − r̄_u)² · √Σ (r_{v,i} − r̄_v)² )

Then predict the target rating as a similarity-weighted, mean-centered average over the neighborhood N(u):

r̂_{u,i} = r̄_u + ( Σ_{v ∈ N(u)} sim(u,v) · (r_{v,i} − r̄_v) ) / ( Σ_{v ∈ N(u)} |sim(u,v)| )

Item-based prediction

Compute item–item similarity, commonly adjusted cosine (centered on user means to remove rating bias):

sim(i, j) = Σ_{u ∈ U_{ij}} (r_{u,i} − r̄_u)(r_{u,j} − r̄_u) / ( √Σ (r_{u,i} − r̄_u)² · √Σ (r_{u,j} − r̄_u)² )

Predict from the items the user has already rated:

r̂_{u,i} = ( Σ_{j ∈ rated(u)} sim(i,j) · r_{u,j} ) / ( Σ_{j ∈ rated(u)} |sim(i,j)| )

Item-based CF is usually preferred in production because item–item similarities are more stable over time than user–user similarities and can be precomputed offline.



 

Requirements

  • A user–item interaction matrix with sufficient density. Memory-based CF degrades sharply on extreme sparsity.
  • A similarity computation and storage layer. For item-based CF this is a precomputed item–item similarity matrix (often top-N neighbors per item to bound size).
  • Overlap in co-rated items/users, otherwise similarities are undefined or unreliable.
  • No item features required — this is the defining advantage over content-based methods.
  • Strategies for sparsity and scale: neighborhood size limits, significance weighting, and shrinkage to damp similarities estimated from few co-ratings.



 

Simplified Architecture

Memory-Based Collaborative Filtering for Recommendation Service

 


 

Reference Architecture

Memory-Based Collaborative Filtering for Recommendation Service



 

Reference Architecture (with Technology Stack)

The same flow on concrete tooling — Kafka for events, Spark for the nightly similarity job, and Redis (or Cassandra) for the precomputed item–item neighbor store.

Memory-Based Collaborative Filtering for Recommendation Service



 

Signals & Features

Memory-based CF consumes only interaction signals: explicit ratings, or implicit signals such as clicks, purchases, watches, add-to-cart, and dwell. Implicit feedback is treated as positive-only with confidence weighting. No item or user metadata is required, which is both the method’s strength (no feature engineering) and its limitation (it cannot reason about why items are similar).



 

Training & Serving Considerations

There is no parametric “training” in the gradient-descent sense. The expensive step is computing the similarity matrix, which is O(n²) in the naïve case over n items or users — the principal scalability bottleneck. Production systems mitigate this with sampling, locality-sensitive hashing (LSH), sparse co-occurrence counting, and top-N truncation. Item-based similarities are precomputed in nightly/periodic batch jobs; serving is then a fast sparse lookup and weighted sum.



 

Evaluation

Rating-prediction variants are scored with RMSE (Root Mean Square Error) / MAE (Mean Absolute Error); top-N recommendation is evaluated with precision@k, recall@k, MAP (Mean Average Precision), and NDCG (Normalized Discounted Cumulative Gain). Watch coverage and cold-item exposure closely, since memory-based CF systematically underexposes new and long-tail items (the popularity bias and cold-start problem).



 

Strengths & Weaknesses

Strengths: simple, intuitive, and explainable (“because you liked X”); requires no item features; item-based variant precomputes well and serves fast.

Weaknesses: scales poorly on huge user/item sets due to O(n²) similarity computation; sensitive to sparsity — few co-ratings make similarities unreliable; suffers cold-start for new users and new items (no interactions, no neighbors); prone to popularity bias that buries the long tail.



 

When to Use It

Memory-based CF is a strong baseline for small-to-medium catalogs with reasonable interaction density, for e-commerce “related items” modules (item-based CF), and as an interpretable benchmark to beat before investing in matrix factorization or deep models. On web-scale, sparse data it is typically superseded by model-based CF and deep retrieval, though item-based co-occurrence still appears as one signal inside larger hybrid systems.

Tags Cold Start Problem Collaborative Filtering Data Sparsity Item-Based CF Machine Learning Memory-Based CF Popularity Bias Recommendation Architecture Recommendation System Similarity Computation User-Based CF Facebook X
Comments 0
Similar posts
  1. Content-Based Filtering for Recommendation Service (aka User-based Model)
    194
  2. Model-Based CF: Matrix Factorization for Recommendation Service
    186
  3. Common Recommendation Service Architecture
    539
  4. Hybrid Methods for Recommendation Service
    222
  5. Neural Collaborative Filtering (NCF) for Recommendation Service
    250
  6. Sequence Models (RNN / Transformer) for Recommendation Service widely used at OTT and e-Commerce
    254
  7. Two-Tower Model for Recommendation Service having a Very Large Catalog
    271
  8. Wide & Deep / DeepFM for Recommendation Service (aka Ranking Service)
    265
  9. Harnessing the Power of Random Forest Algorithm in Python
    660
  10. Mastering Model Persistence: Saving and Loading Trained Machine Learning Models in Python
    1,166
  11. YouTube's Recommendation System
    269
  12. Reinforcement Learning–Based Methods for CTR Improvement based on Recommendation System
    273
  13. Understanding and Implementing K-Nearest Neighbors (KNN) Algorithm in Python
    636
  14. Forecasting the Weather with PyTorch: A Beginner's Guide to Temperature Prediction
    1,445
  15. Getting Started with PyTorch: A Beginner's Guide to Building Your First Neural Network
    801
  16. Mastering AI: A Beginner's Guide to Python Programming and Beyond
    1,041
  17. Forecasting with Linear Regression and KNN Regression in Python
    929
  18. Vector Databases: From Embeddings to Application
    323
  19. Machine Learning Models for Ad Detection from a Video Stream
    195
  20. FAISS Already Does ANN... So Why Do Top Teams Still Pay for SageMaker?
    314
  21. TikTok's Recommendation System - Monolith
    302
  22. Milvus & FAISS: Decoding Their ML Synergy
    286
  23. PyTorch example to Forcast Stock Price based on 10 days Dataset
    654
  24. Predicting Buyer Preferences with PyTorch: A Deep Learning Approach
    1,234
  25. Mastering Ad Budget Throttling: Static, PID, and ML Strategies
    325
  26. Ad Impression Forecasting (aka Ad Inventory Forecasting): Architecting for Scale, Speed, and Accuracy
    335
  27. AI-Powered Ad Fraud Detection: Architectural Strategies
    337
  28. Brand Safety: AI-Driven Content Moderation on AWS
    739
  29. Building a MCP server in PHP
    639
  30. Building a Video Content Recommendation System with Amazon SageMaker
    527
  1. Nine Types of Testing while we develop APIs
    519
  2. Apache Kafka - a distributed, fault-tolerant, high-throughput streaming platform
    618
  3. Comprehensive Software Development Flow : How Companies Ship Code To Production
    2,334
  4. DeepSeek v3 offers of ChatGPT's performance at 1/10 the price!
    639
  5. Difference between CPU and GPU - Why GPU is faster than CPU?
    809
  6. gRPC - Open-source Universal RPC Framework developed by Google
    770
  7. Exploring the Depths of Data Transfer: sendfile vs. kTLS
    1,328
  8. How Netflix Ensures Smooth Streaming with Open Connect CDN
    2,135
  9. Public DNS (Domain Name Service) based on IPv4, IPv6 widely used
    1,247
  10. All Engineering Software Development How can you prioritize software design trade-offs when developing a new product?
    1,346
  11. MR(Mixed Reality) Game Programming based on Unity 3D
    1,372
  12. Temporal Programming Model - Robust, Long-Running, Fault-Tolerant Applications as WorkFlows
    362
  13. Cadence Programming Model - A Distributed, Fault-Tolerant, Stateful Workflow Orchestration Framework
    301
  14. Multi-AZ Kafka Architecture
    157
  15. Large-Scale Concurrency Control: Solving the DB Bottleneck from a Flood of “Likes”
    276
  16. Stateful Databases: A Deep Dive with Cassandra & TiDB
    198
  17. Why Kubernetes? Core Features and Microservice Orchestration Strategies
    578
  18. Quiz : Twice counter
    701
  19. Kubernetes, aka K8s, is an open-source container orchestration platform
    542
  20. Architecting for Resilience: AWS High Availability Components Including API Gateway
    144
  21. Is AWS API Gateway Disaster-Proof? DR, Benefits, and Multi-AZ Architecture Explained
    146
  22. FNC(Photo/Video File Name Changer) v1.1 Release - Date Time Bug Fix & Retry Function Added
    709
  23. Smart TV Cycling Apps – TV for Fitness
    813
  24. The public could reduce server cost, and enhance performance for global service distribution
    10,744
  25. Cloud gaming coming to Samsung Smart TVs
    561
  26. Kids App – Kids Learn While Parents Control on Samsung Smart TV
    764
  27. Fitness Hub presents your personal trainer, Fitness VOD on Samsung Smart TV
    521
  28. Word counting source program based on MapReduce framework
    692
  29. The leaders who created Smart TV
    820
  30. FNC(Photo/Video File Name Changer) v1.02 release - The file created date time information is available for those cameras providing incorrect EXIF data
    978
Recently updated
  1. Google OAuth Token Expiration: Causes and Solutions
    31
  2. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    57
  3. Why SPF and DKIM Are Essential for Linux Email Servers?
    51
  4. How do I create animated background for Google Meet?
    23,224
  5. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    273
  6. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    104
  7. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    170
  8. Array of arguments passed to script in PHP
    99
  9. Invalid Auction Storms in Ad Tech
    107
  10. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    208
  11. The Two Clocks of Ad Server Architecture
    78
  12. Frequency Cap Architecture Overview
    527
  13. Collecting Proof-of-Play from 100,000 Screens
    153
  14. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    303
  15. What is RedisVL?
    116
  16. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    247
  17. TPU & GPU Cluster Management Tools
    258
  18. The Concept of Scaffolding in AI Agents
    245
  19. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    598
  20. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    268
  21. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    354
  22. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    207
  23. Machine Learning: Training vs. Ranking
    230
  24. The Continuous Learning Machine: Designing a Loop That Actually Turns
    228
  25. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    203
  26. Designing a Data Curation System Around a Vector Database
    230
  27. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    263
  28. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    674
  29. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    201
  30. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    233