Neural collaborative filtering

Also known as: NCF

On this page 7

Neural collaborative filtering (NCF) is a recommendation framework that models the interaction between a user and an item with a neural network instead of the fixed dot product used in classic matrix factorization. In recommender systems, it learns user and item embeddings from past behavior, usually implicit feedback such as clicks or purchases, and predicts how likely a user is to engage with each item.

NCF was introduced in 2017 and became one of the most cited bridges between collaborative filtering and deep learning. Its best-known form, NeuMF, combines a generalized matrix factorization branch with a multilayer perceptron, and its later re-evaluation has made it an important lesson in how recommendation models should be benchmarked.

How neural collaborative filtering works

NCF maps each user ID and each item ID to a dense embedding vector and passes these vectors through learned layers that output an interaction score between 0 and 1. The model is trained so that observed user-item pairs receive high scores and unobserved pairs receive low scores.

Because implicit feedback contains only positive signals, training relies on negative sampling: for each observed interaction, a few items the user has not interacted with, typically four negatives per positive, are sampled and treated as negatives. The loss is binary cross-entropy, which turns recommendation into a pointwise classification problem.

The original framework defines three model variants, which differ in how embeddings are combined.

VariantHow embeddings interactStrength
GMFElement-wise product followed by a weighted output layerGeneralizes matrix factorization with learned weights
MLPConcatenation followed by several hidden layersCan, in principle, learn non-linear interactions
NeuMFFuses the GMF and MLP branches before the outputCombines linear and non-linear signals
The three NCF model variants

In NeuMF, the two branches keep separate embeddings, and their final hidden vectors are concatenated into one prediction layer. The original authors reported that pretraining both branches separately before joint training improved results.

Key design choices and hyperparameters

NCF performance depends heavily on embedding size, the number of negative samples and the depth of the MLP tower. A common MLP design uses a tower structure in which each hidden layer has half the width of the previous one.

SettingCommon rangeEffect
Embedding dimension8 to 64Larger sizes capture more detail but risk overfitting
Negatives per positive1 to 10More negatives sharpen ranking at higher training cost
MLP hidden layers1 to 4Deeper towers add capacity with diminishing returns
Learning rate0.0001 to 0.005Too high destabilizes embedding training
RegularizationL2 or dropoutControls overfitting on sparse users
Typical NCF settings and their effects

The standard evaluation protocol is leave-one-out: the latest interaction of each user is held out, and the model ranks it against a sample of non-interacted items using hit ratio and NDCG at 10. This protocol has itself become controversial, as described below.

NCF compared with matrix factorization and later models

The central claim of NCF was that a learned interaction function should outperform the dot product. A widely discussed 2020 re-examination showed that a carefully tuned dot-product model matches or beats the MLP-based variant, and that an MLP has difficulty learning even a simple dot product from data.

ApproachInteraction functionPractical servingCurrent standing
Matrix factorizationDot productFast nearest-neighbor retrievalStrong, well-understood baseline
NeuMFGMF plus MLP fusionRequires scoring each candidateHistorical reference point
Two-tower modelDot product of deep encodersFast nearest-neighbor retrievalIndustry standard for retrieval
DeepFM and Wide & DeepFeature crosses plus deep layersUsed in ranking stagesCommon for CTR prediction
LightGCNGraph propagation then dot productFast nearest-neighbor retrievalStrong academic baseline
NCF relative to neighboring approaches

The serving difference matters. A dot-product score supports maximum inner product search, so millions of items can be searched in milliseconds. An MLP score does not, so NCF is suitable mainly for re-ranking a short candidate list produced by another model in a multi-stage ranking pipeline.

When neural collaborative filtering is useful

NCF remains useful as a teaching model and a benchmark, and it can serve in production when the candidate set is small and only interaction IDs are available. Its weakness is that the basic form uses no side features, so content, context and time must be added through extensions.

SituationSuggested choiceReason
Learning deep recommendersNCF or NeuMFClear structure and well-known datasets
Retrieval from millions of itemsTwo-tower or matrix factorizationSupports approximate nearest-neighbor search
Rich user and item featuresDeepFM or a feature-based rankerNCF ignores side information by default
Strong order effectsSequential models such as SASRecNCF treats interactions as unordered
Re-ranking a few hundred candidatesNeuMF is workablePer-candidate scoring cost is acceptable
Choosing NCF or an alternative

Limitations and evaluation pitfalls

The most important lesson from NCF concerns evaluation practice, not architecture. Many reported gains disappeared when baselines were tuned properly or when full ranking replaced sampled ranking.

  • Weak baselines: comparing against untuned matrix factorization exaggerates the benefit of the neural model.
  • Sampled metrics: ranking against 100 random negatives can reorder models compared with ranking the full catalog.
  • Cold start problem: like all ID-based collaborative filtering, NCF cannot represent new users or items without interactions.
  • Popularity bias: uniform negative sampling tends to favor popular items unless sampling or loss is adjusted.

In simple terms

Neural collaborative filtering is a way for a service to guess what you will like based on what you and people similar to you have done before. Each person and each product gets a short list of numbers that describes its taste or character.

Older methods compare those lists with one fixed formula. NCF instead lets a small neural network learn the comparison. The idea was influential, but later tests showed that the simple formula, used carefully, often works just as well.

A practical example

An online bookstore with about 200,000 active customers and 50,000 titles wants better suggestions on its home page. It has purchase and click histories but little structured book metadata, which makes ID-based collaborative filtering a natural fit.

The data team first builds a tuned matrix factorization model to retrieve 500 candidates per customer. It then trains a NeuMF model with 32-dimensional embeddings and four negative samples per purchase to re-rank those candidates, and it evaluates both models with full-catalog ranking metrics on the most recent week of purchases.

The re-ranking stage adds a modest gain in recall at 10 over the tuned baseline, smaller than early research papers suggested but stable across weeks. The team keeps the two-stage design and treats the tuned factorization model as the benchmark every future model must beat.