# Neural Collaborative Filtering vs Neural Collaborative Filtering

Neural collaborative filtering against its generalised-matrix-factorisation hybrid.

**Neural Collaborative Filtering has 70M more parameters than Neural Collaborative Filtering: 4 layers added, 5 changed.**

Source: https://neurarch.com/diff/ncf-vs-neumf.html

## Sides

| | Neural Collaborative Filtering | Neural Collaborative Filtering |
|---|---|---|
| Layers | 9 | 13 |
| Parameters | 35M | 106M |
| Input | 1 | 1 |
| Output | 1 × 1 | 1 × 1 |
| Forward-passes | yes | yes |
| Est. train cost | $0.053 | $0.076 |
| T4 16GB | fits | fits |
| A100 40GB | fits | fits |
| H100 80GB | fits | fits |

## Deltas (Neural Collaborative Filtering relative to Neural Collaborative Filtering)

- Parameters: +70M (+200%)
- Layers: +4
- Added 4, removed 0, changed 5, unchanged 7

## Layer by layer

| # | Status | Neural Collaborative Filtering | Params | Output | Neural Collaborative Filtering | Params | Output |
|---|---|---|---|---|---|---|---|
| 1 | same | User ID (Input) |  | 1 | User ID (Input) |  | 1 |
| 2 | same | Item ID (Input) |  | 1 | Item ID (Input) |  | 1 |
| 3 | added |  | |  | User MF Emb (Embedding) | 3.2M | 1 × 32 |
| 4 | added |  | |  | User MLP Emb (Embedding) | 6.4M | 1 × 64 |
| 5 | changed (vocabSize) | User Embedding (Embedding) | 3.2M | 1 × 32 | Item MF Emb (Embedding) | 32M | 1 × 32 |
| 6 | changed (embeddingDim) | Item Embedding (Embedding) | 32M | 1 × 32 | Item MLP Emb (Embedding) | 64M | 1 × 64 |
| 7 | added |  | |  | GMF (⊙) (Multiply) |  | 1 × 32 |
| 8 | changed (dim, numInputs, axis) | Concat [u; i] (Concatenate) |  | 1 × 64 | Concat (Concatenate) |  | 1 × 128 |
| 9 | changed (inFeatures) | MLP 1 (Linear) | 4.2K | 1 × 64 | MLP FC 1 (Linear) | 8.3K | 1 × 64 |
| 10-12 | same | 3 unchanged layers | | | | | |
| 13 | added |  | |  | Fuse GMF+MLP (Concatenate) |  | 1 × 64 |
| 14 | changed (inFeatures) | Score Head (Linear) | 33 | 1 × 1 | Predict (Linear) | 65 | 1 × 1 |
| 15 | same | Sigmoid (Sigmoid) |  | 1 × 1 | Sigmoid (Sigmoid) |  | 1 × 1 |
| 16 | same | P(click) (Output) |  | 1 × 1 | P(rating) (Output) |  | 1 × 1 |

## What this is not

- Parameter counts are derived from the graph, not read from a checkpoint. They are exact for a graph that is fully specified and approximate for one that is not.
- Cost and GPU fit are estimates from the graph under one set of assumptions, not measurements of a run.

## Graphs

- Neural Collaborative Filtering: https://neurarch.com/templates/ncf/model.json
- Neural Collaborative Filtering: https://neurarch.com/templates/neumf/model.json
- Check a graph of your own: `POST https://www.neurarch.com/api/v1/plan`
