- 新项目要快速拉起一个可对比的基线:ALS/BPR/NCF 这些实现和评估工具都在,省掉自己写 train/test split 和离线指标;换别的就得从论文或零散 repo 拼
- 做算法选型评审:同一套数据加载和评估口径下横向跑多个模型,比各模型各自 repo 的指标更有可比性
- 教学或团队内训:notebook 按数据准备→建模→评估→调参→上线分节,能直接当教材走一遍
- 需要 Spark 侧的大规模召回/排序实验:装了 [spark] extra 后能复用同一套工具函数,不用另起一套代码
recommenders
recommenders-teamMIT活跃维护 有专家点评微软出品的推荐系统实践库,提供从数据准备、模型训练到部署上线的完整示例和最佳实践,帮算法工程师快速搭建推荐与排序模型。
Best Practices on Recommendation Systems
专家点评
上手难度:进阶更新于 2026-11-11推荐系统从 notebook 到上线的参考实现集合,用来替代自己从零搭一套算法基线
适用场景
踩坑
- 只 pip install recommenders 跑不了 GPU 和 Spark 模型,得按模型选 [gpu]/[spark] extra;装之前先确认目标 notebook 属于哪类,否则会在 import 阶段才发现缺依赖
- notebook 不是装完包就能开:要先 clone 仓库、注册 ipykernel 内核,Linux/WSL 还得先有 gcc,纯 pip 安装的用户会卡在这一步
- issue 里 OOM 类问题(NCFDataset、RBM affinity matrix)被反复提出,跑这些模型时对内存的预期要留余量;具体阈值 README 没写,得自己按数据规模试
同类对比
要的是生产级推荐服务框架而不是参考实现,看 TensorFlow Recommenders 或 TorchRec;只要单机快速验证一两个经典协同过滤,implicit 更轻。
uv venv ~/.venvs/recommenders --python 3.11
source ~/.venvs/recommenders/bin/activate
uv pip install recommenders核心包可在 CPU 上运行全部 CPU notebook;GPU 模型需安装 [gpu] extra,Spark 模型需 [spark] extra;README 未给出具体显存或 GPU 型号要求。
项目说明
由 README 自动翻译提炼微软开源的推荐系统最佳实践库,用 Jupyter notebook 演示从数据准备到上线的完整流程
微软出品的推荐系统实践库,提供从数据准备、模型训练到部署上线的完整示例和最佳实践,帮算法工程师快速搭建推荐与排序模型。
核心能力
- 用 Jupyter notebook 演示数据准备、建模、评估、调参与上线五个环节
- 内置 ALS、xDeepFM、BPR、BiVAE、Caser 等经典与深度学习算法实现
- 提供数据加载、训练测试集划分、离线指标评估等通用工具函数
- 通过 gpu、spark、dev、all、experimental 等 extras 按需安装依赖
- 附带 Azure 上模型运营化的示例流程
容易踩的坑
GPU 和 Spark 模型需额外安装 [gpu]、[spark] 等 extras,只装核心包跑不了;Linux/WSL 上需先装 gcc;示例 notebook 需先克隆仓库并注册 ipykernel 内核才能运行。
- 1.2.1Recommenders 1.2.1最新正式版2024-12-24 · 2024-12-24 07:39 UTC
New algorithms or improvements
- SAR sparse multiplication modification due to a breaking change in scipy by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2083
- Remove LightFM from core package in #2122 #2144
- Modified 2 files to update newsrec model by @sumana-2705 in https://github.com/recommenders-team/recommenders/pull/2125
New utilities or improvements
- Flattening matrix so dataframe can be built correctly by @gramhagen in https://github.com/recommenders-team/recommenders/pull/2084
- Added r-precision by @daviddavo in https://github.com/recommenders-team/recommenders/pull/2086
- Fix breaking change in sklearn in log_loss by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2106
- Fix and improve ImplicitCF by @daviddavo in #2117 #2164
- Changing Function Name to reflect new Tensorflow interface. by @siyerp in https://github.com/recommenders-team/recommenders/pull/2143
- Deprecated use of dict in SeriesGroupBy.agg by @daviddavo in https://github.com/recommenders-team/recommenders/pull/2114
- Revert and fix python evaluation by @daviddavo in https://github.com/recommenders-team/recommenders/pull/2119
- Updated function signatures to comply with new tensorflow requirements by @siyerp in https://github.com/recommenders-team/recommenders/pull/2146
- Update MIND dataset utilities by @miguelgfierro in #2145 #2155 #2160
New notebooks or improvements
- Update jupyter dep to accomodate Colab by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2108
- Update cornac_bivae_deep_dive.ipynb: fix typos by @martin0258 in https://github.com/recommenders-team/recommenders/pull/2104
- Correct variable used in pickle dump in
mind_utils.ipynbby @ubergonmx in https://github.com/recommenders-team/recommenders/pull/2158
Other features
- Fix issues with numpy by @daviddavo in #2113 #2120
- Update setup instructions #2080 #2181
- Added ideas and guidelines for new contributors by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2103
- Set scipy <= 1.13.1 by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2127
- Added free course on Recommendation systems by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2135
- Add reference to scenarios to README.md by @anargyri in https://github.com/recommenders-team/recommenders/pull/2093
- Documentation improvement and typos #2102 #2109 #2096 #2130
- Updated Issue Template with "Willingness to Contribute" Section for issue #2032 by @sumana-2705 in https://github.com/recommenders-team/recommenders/pull/2123
- Moved pymanopt tests to experimental test group #2138 by @daviddavo in https://github.com/recommenders-team/recommenders/pull/2139
- Migrate AML SDK from v1 to v2 by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2134
- Update dev container by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2157
- Improve GitHub actions #2159 #2190 #2197
- Update service principal role to AzureML Compute Operator for improved security by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2169
- Update the code of conduct by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2177
- Use managed identity with OpenID Connect for Azure login by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2182
- Merge multiple Dockerfiles into a single one by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2167
- Install sbt for sarplus tests by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2192
New Contributors
- @martin0258 made their first contribution in https://github.com/recommenders-team/recommenders/pull/2104
- @Kingston257 made their first contribution in https://github.com/recommenders-team/recommenders/pull/2109
- @sumana-2705 mad
- 1.2.0Recommenders 1.2.02024-05-01 · 2024-05-01 13:41 UTC
查看更新说明
New algorithms or improvements
- Implemented Spark item to item recommenders by @ChuyangKe in https://github.com/recommenders-team/recommenders/pull/1809
- Correct packaging commands in SARPlus workflow by @simonzhaoms in https://github.com/recommenders-team/recommenders/pull/1860
- New URL of Glove from Huggingface by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1949
- Bug in Deeprec tests and adding more tests by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1957
- Make early_stopping a callable in LightGBM by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1967
- Update Hybrid algo classification to align with Recommenders book and Aggarwal by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2050
- Fixed bug when reading dataset with timestamp for sasrec model by @gazon1 in https://github.com/recommenders-team/recommenders/pull/2052
- Catch import error separately for SUMModel by @SimonYansenZhao in https://github.com/recommenders-team/recommenders/pull/2077
- Fixed error in fastai in nightly by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/2068
New utilities or improvements
- Optimized Python splitters by @ChuyangKe in https://github.com/recommenders-team/recommenders/pull/1802
- Replace append with pd.concat by @gro1m in https://github.com/recommenders-team/recommenders/pull/1811
- Python generalized ndcg by @ChuyangKe in https://github.com/recommenders-team/recommenders/pull/1812
- Simplify eval args by @AdityaSoni19031997 in https://github.com/recommenders-team/recommenders/pull/1828
- CVE-2007-4559 Patch by @TrellixVulnTeam in https://github.com/recommenders-team/recommenders/pull/1835
- New notebook executor #1865 #2048 #2031
- Restricting cornac to 1.15.1 for issue with 1.15.4 by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1934
- Refactor ranking metric
mapto be the same as Spark's by @loomlike in https://github.com/recommenders-team/recommenders/pull/2004 - Correct MIND user behavior history construction by @thaiminhpv in https://github.com/recommenders-team/recommenders/pull/2054
- Merged two concats into one by @daviddavo in https://github.com/recommenders-team/recommenders/pull/2075
New notebooks or improvements
- Minor change in lightgcn_deep_dive.ipynb by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1814
- Removed unused import by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1824
- Benchmark movielens in https://github.com/recommenders-team/recommenders/pull/1831 #1846
- Fix error Wide and Deep by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1854
- Update xDeepFM notebook and fix test error by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1850
- Rerun and clean dataprep notebooks by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1873
- typo fixes wrt notebook by @AdityaSoni19031997 in https://github.com/recommenders-team/recommenders/pull/1836
- Update multinomial_vae.py by @kone807 in https://github.com/recommenders-team/recommenders/pull/1916
- Review CPU notebooks in quick start with Python 3.9 by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1944
- Rerun and clean notebooks https://github.com/recommenders-team/recommenders/pull/1947 #1950
- Update DKN notebook by @miguelgfierro in https://github.com/recommenders-team/recommenders/pull/1959
Other features
- Explicitly list references in the pull request template by @simonzhaoms in https://github.com/recommenders-team/recommenders/pull/1798
- Improve README.md in https://github.com/recommenders-team/recommenders/pull/1805 #1827 #1906 #1871 #1912 #2058 #2053
- Improve SETUP in https://github.com/recommenders-team/recommenders/pull/1920 #1926 #1923
- Miguel/remove ado by @miguelgf
- 1.1.1Recommenders 1.1.12022-07-20 · 2022-07-20 05:58 UTC
查看更新说明
New algorithms or improvements
- Reduce iterations of W&D to reduce the integration tests time in https://github.com/microsoft/recommenders/pull/1698
- Implementation of most frequent recommendation in https://github.com/microsoft/recommenders/pull/1666
- Implement time_now for sarplus in #1719 #1721
- Add a fast failure in SAR+ if the similarity metric is not within the options in https://github.com/microsoft/recommenders/pull/1743
- SAR item similarity dtype correction in https://github.com/microsoft/recommenders/pull/1751
- Simplify SAR test data loading functions in https://github.com/microsoft/recommenders/pull/1752
- Reformat SAR+ SQL queries in https://github.com/microsoft/recommenders/pull/1772
- Add new item similarity metrics for SAR in https://github.com/microsoft/recommenders/pull/1754
New utilities or improvements
- Rewrite get_top_k_items() to improve runtime in https://github.com/microsoft/recommenders/pull/1748
- Optimized Spark recall_at_k time performance in https://github.com/microsoft/recommenders/pull/1796
New notebooks or improvements
- Fix missing import in FastAI notebook https://github.com/microsoft/recommenders/pull/1708
- Review NCF notebook in #1703 #1712
- Review LigthFM notebook and add test in https://github.com/microsoft/recommenders/pull/1706
- Review BPR notebook in https://github.com/microsoft/recommenders/pull/1704
- Review LightGCN notebook in https://github.com/microsoft/recommenders/pull/1714
- Review DKN notebook in https://github.com/microsoft/recommenders/pull/1722
- Review SAR notebook #1738 #1768
Other features
- Enable distributed tests with AzureML #1696 #1717 #1729 #1733 #1739 #1747 #1732 #1755 #1763 #1771 #1773 #1775 #1787 #1788 #1794
- Added tests for Python 3.8 and 3.9 in https://github.com/microsoft/recommenders/pull/1756
- Image of contributors in https://github.com/microsoft/recommenders/pull/1692
- Update README.md in #1709 #1711 #1767
- Error in codeowners file in https://github.com/microsoft/recommenders/pull/1699
- Add test to check if CuDNN is enabled in https://github.com/microsoft/recommenders/pull/1715
- Update docker image reference to internal registry in https://github.com/microsoft/recommenders/pull/1727
- Fixed a link error in data_transform.ipynb in https://github.com/microsoft/recommenders/pull/1736
- Added tests for ranking function get_top_k_items() in https://github.com/microsoft/recommenders/pull/1757
- Fix memory error in CPU nightly workflow in https://github.com/microsoft/recommenders/pull/1759
- Update test infrastructure explanation #1776 #1777
- Added time performance tests in https://github.com/microsoft/recommenders/pull/1765
- Add path filter to avoid triggering unit tests when we change a markdown in https://github.com/microsoft/recommenders/pull/1791
Full Changelog: https://github.com/microsoft/recommenders/compare/1.1.0...1.1.1
- 1.1.0Recommenders 1.1.02022-04-01 · 2022-04-01 09:25 UTC
查看更新说明
New algorithms or improvements
- SASRec and SSEPT in Tensorflow 2.x in https://github.com/microsoft/recommenders/pull/1530 #1621 #1678
- RBM Code Cleanup, model save and other additions in #1599 #1618 #1622
- Overwrite older test file in NCF deep dive to avoid bug in https://github.com/microsoft/recommenders/pull/1674
- SAR+ improvement and bug fixes #1636 #1644 #1680 #1671
- NCF improvement and bug fixes in #1612
- Remove drop_duplicates() from SAR method fix #1464 in https://github.com/microsoft/recommenders/pull/1588
- SAR literal fix in https://github.com/microsoft/recommenders/pull/1663
New utilities or improvements
- Update lightfm_utils.py in https://github.com/microsoft/recommenders/pull/1624
- Change formats of user_ids and item_ids arg. in LigthFM in https://github.com/microsoft/recommenders/pull/1651
- Fix randomness issue in spark_stratified_split() in https://github.com/microsoft/recommenders/pull/1654
- Clarification for jaccard and lift similarity measures in https://github.com/microsoft/recommenders/pull/1668
- Use numpy divide in explained variance in https://github.com/microsoft/recommenders/pull/1691
- Change MovieLens URL from HTTP to HTTPS in https://github.com/microsoft/recommenders/pull/1677
- Remove casting of user and item IDs in Spark evaluation in https://github.com/microsoft/recommenders/pull/1686
- Persist intermediate data to avoid non-determinism caused by Spark lazy random evaluation in https://github.com/microsoft/recommenders/pull/1676 #1652
New notebooks or improvements
- Fix notebook build failure on Spark 3.2 in https://github.com/microsoft/recommenders/pull/1608
- Remove early stopping round from LightGBM example notebook in https://github.com/microsoft/recommenders/pull/1620
Other features
- Enable Python 3.8 and 3.9 in https://github.com/microsoft/recommenders/pull/1626 #1617
- Upgrade Python from 3.6 to 3.7 in ADO tests pipeline in https://github.com/microsoft/recommenders/pull/1627
- Increase time out for GPU nightly tests in https://github.com/microsoft/recommenders/pull/1623
- Lower LightGBM test AUC base value in https://github.com/microsoft/recommenders/pull/1619
- Change timeouts for tests #1625 #1661 #1684
- Scenario gaming in https://github.com/microsoft/recommenders/pull/1637
- Limiting tests: reducing the time of the news recommendation GPU notebooks in https://github.com/microsoft/recommenders/pull/1656
- Remove pydocumentdb in install_requires in https://github.com/microsoft/recommenders/pull/1629
- Change and improve dependencies #1630 #1653
- Fix Spark tuning test in https://github.com/microsoft/recommenders/pull/1635
- Typos in markdown files and other files #1639 #1589 #1646 #1647 #1688
- Update Dockerfile in https://github.com/microsoft/recommenders/pull/1645
- Improve documentation #1648 #1669 #1682 #1690 #1672
- Codecov Fix in https://github.com/microsoft/recommenders/pull/1665
- Set Spark env variables in nightly test in https://github.com/microsoft/recommenders/pull/1655 #1659
Full Changelog: https://github.com/microsoft/recommenders/compare/1.0.0...1.1.0
- 1.0.0Recommenders 1.0.02022-01-13 · 2022-01-13 20:18 UTC
查看更新说明
Backwards incompatible changes
- TensorFlow upgrade to 2.6.1 / 2.7 #1574 , #1565 , #1540
New algorithms or improvements
- Improve algos visibility #1542
- LightGBM test improvement #1531
- Fix Surprise and Python 3.7 #1540
- TF-IDF runtime enhancement changes #1571
- Add Spark 3.x support for SARplus #1566
New utilities or improvements
- Upgrade to Spark v3 #1555 , #1549 , #1543
- Move scikit-surprise and pymanopt from setup.py #1602
- Issue with pymanopt #1606
New notebooks or improvements
- Fix bugs in RBM notebooks #1581
- Remove explicit mapping of ratings to integers from RBM notebooks #1585
Other features
- Fix nightly workflows #1576 , #1548
- Stabilize more flaky tests #1558
- Miscellaneous Pipeline Fixes #1545
- Optimize Notebook Unit Tests #1538
- Development status change to production/stable #1579
- Update dependencies #1569, #1570
- Fix Databricks installation script #1531
- Adding codespace deployment #1521
- Improve GitHub tests #1518, #1578, #1590, #1592
- Flake8 Fixes #1552 , #1550
- Improvement in documentation #1591, #1598, #1594, #1603
- Update release pipeline #1596
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
What's New (April, 2025)
We reached 20,000 stars!!
We are happy to announce that we have reached 20,000 stars on GitHub! Thank you for your support and contributions to the Recommenders project. We are excited to continue building and improving this project with your help.
Check out the release Recommenders 1.2.1!
We fixed a lot of bugs due to dependencies, improved security, reviewed the notebooks and the libraries.
Introduction
Recommenders objective is to assist researchers, developers and enthusiasts in prototyping, experimenting with and bringing to production a range of classic and state-of-the-art recommendation systems.
Recommenders is a project under the Linux Foundation of AI and Data.
This repository contains examples and best practices for building recommendation systems, provided as Jupyter notebooks. The examples detail our learnings on five key tasks:
- Prepare Data: Preparing and loading data for each recommendation algorithm.
- Model: Building models using various classical and deep learning recommendation algorithms such as Alternating Least Squares (ALS) or eXtreme Deep Factorization Machines (xDeepFM).
- Evaluate: Evaluating algorithms with offline metrics.
- Model Select and Optimize: Tuning and optimizing hyperparameters for recommendation models.
- Operationalize: Operationalizing models in a production environment on Azure.
Several utilities are provided in recommenders to support common tasks such as loading datasets in the format expected by different algorithms, evaluating model outputs, and splitting training/test data. Implementations of several state-of-the-art algorithms are included for self-study and customization in your own applications. See the Recommenders documentation.
For a more detailed overview of the repository, please see the documents on the wiki page.
For some of the practical scenarios where recommendation systems have been applied, see scenarios.
Getting Started
We recommend uv for environment management (10-100x faster than conda/pip), and VS Code for development. To install the recommenders package and run an example notebook on Linux/WSL:
# 1. Install gcc if it is not installed already. On Ubuntu, this could done by using the command
# sudo apt install gcc
# 2. Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 3. Create and activate a new virtual environment
uv venv ~/.venvs/recommenders --python 3.11
source ~/.venvs/recommenders/bin/activate
# 4. Install the core recommenders package. It can run all the CPU notebooks.
uv pip install recommenders
# 5. Create a Jupyter kernel
uv pip install ipykernel
python -m ipykernel install --user --name recommenders --display-name "Python (recommenders)"
# 6. Clone this repo within VSCode or using command line:
git clone https://github.com/recommenders-team/recommenders.git
# 7. Within VSCode:
# a. Open a notebook, e.g., examples/00_quick_start/sar_movielens.ipynb;
# b. Select Jupyter kernel "Python (recommenders)";
# c. Run the notebook.
For more information about setup on other platforms (e.g., Windows and macOS) and different configurations (e.g., GPU, Spark and experimental features), see the Setup Guide.
In addition to the core package, several extras are also provided, including:
[gpu]: Needed for running GPU models.[spark]: Needed for running Spark models.[dev]: Needed for development for the repo.[all]:[gpu]|[spark]|[dev][experimental]: Models that are not thoroughly tested and/or may require additional steps in installation.
Algorithms
The table below lists the recommendation algorithms currently available in the repository. Notebooks are linked under the Example column as Quick start, showcasing an easy to run example of the algorithm, or as Deep dive, explaining in detail the math and implementation of the algorithm.
| Algorithm | Type | Description | Example |
|---|---|---|---|
| Alternating Least Squares (ALS) | Collaborative Filtering | Matrix factorization algorithm for explicit or implicit feedback in large datasets, optimized for scalability and distributed computing capability. It works in the PySpark environment. | Quick start / Deep dive |
| Attentive Asynchronous Singular Value Decomposition (A2SVD)* | Collaborative Filtering | Sequential-based algorithm that aims to capture both long and short-term user preferences using attention mechanism. It works in the CPU/GPU environment. | Quick start |
| Cornac/Bayesian Personalized Ranking (BPR) | Collaborative Filtering | Matrix factorization algorithm for predicting item ranking with implicit feedback. It works in the CPU environment. | Deep dive |
| Cornac/Bilateral Variational Autoencoder (BiVAE) | Collaborative Filtering | Generative model for dyadic data (e.g., user-item interactions). It works in the CPU/GPU environment. | Deep dive |
| Convolutional Sequence Embedding Recommendation (Caser) | Collaborative Filtering | Algorithm based on convolutions that aim to capture both user’s general preferences and sequential patterns. It works in the CPU/GPU environment. | Quick start |
| Deep Knowledge-Aware Network (DKN)* | Content-Based Filtering | Deep learning algorithm incorporating a knowledge graph and article embeddings for providing news or article recommendations. It works in the CPU/GPU environment. | Quick start / Deep dive |
| Extreme Deep Factorization Machine (xDeepFM)* | Collaborative Filtering | Deep learning based algorithm for implicit and explicit feedback with user/item features. It works in the CPU/GPU environment. | Quick start |
| Embedding Dot Bias | Collaborative Filtering | General purpose algorithm with embeddings and biases for users and items. It works in the CPU/GPU environment. | Quick start |
| LightFM/Factorization Machine | Collaborative Filtering | Factorization Machine algorithm for both implicit and explicit feedbacks. It works in the CPU environment. | Quick start |
| LightGBM/Gradient Boosting Tree* | Content-Based Filtering | Gradient Boosting Tree algorithm for fast training and low memory usage in content-based problems. It works in the CPU/GPU/PySpark environments. | Quick start in CPU / Deep dive in PySpark |
| LightGCN | Collaborative Filtering | Deep learning algorithm which simplifies the design of GCN for predicting implicit feedback. It works in the CPU/GPU environment. | Deep dive |
| GeoIMC* | Collaborative Filtering | Matrix completion algorithm that takes into account user and item features using Riemannian conjugate gradient optimization and follows a geometric approach. It works in the CPU environment. | Quick start |
| GRU | Collaborative Filtering | Sequential-based algorithm that aims to capture both long and short-term user preferences using recurrent neural networks. It works in the CPU/GPU environment. | Quick start |
| Multinomial VAE | Collaborative Filtering | Generative model for predicting user/item interactions. It works in the CPU/GPU environment. | Deep dive |
| Neural Recommendation with Long- and Short-term User Representations (LSTUR)* | Content-Based Filtering | Neural recommendation algorithm for recommending news articles with long- and short-term user interest modeling. It works in the CPU/GPU environment. | Quick start |
| Neural Recommendation with Attentive Multi-View Learning (NAML)* | Content-Based Filtering | Neural recommendation algorithm for recommending news articles with attentive multi-view learning. It works in the CPU/GPU environment. | Quick start |
| Neural Collaborative Filtering (NCF) | Collaborative Filtering | Deep learning algorithm with enhanced performance for user/item implicit feedback. It works in the CPU/GPU environment. | Quick start / Deep dive |
| Neural Recommendation with Personalized Attention (NPA)* | Content-Based Filtering | Neural recommendation algorithm for recommending news articles with personalized attention network. It works in the CPU/GPU environment. | Quick start |
| Neural Recommendation with Multi-Head Self-Attention (NRMS)* | Content-Based Filtering | Neural recommendation algorithm for recommending news articles with multi-head self-attention. It works in the CPU/GPU environment. | Quick start |
| Next Item Recommendation (NextItNet) | Collaborative Filtering | Algorithm based on dilated convolutions and residual network that aims to capture sequential patterns. It considers both user/item interactions and features. It works in the CPU/GPU environment. | Quick start |
| Restricted Boltzmann Machines (RBM) | Collaborative Filtering | Neural network based algorithm for learning the underlying probability distribution for explicit or implicit user/item feedback. It works in the CPU/GPU environment. | Quick start / Deep dive |
| Riemannian Low-rank Matrix Completion (RLRMC)* | Collaborative Filtering | Matrix factorization algorithm using Riemannian conjugate gradients optimization with small memory consumption to predict user/item interactions. It works in the CPU environment. | Quick start |
| Simple Algorithm for Recommendation (SAR)* | Collaborative Filtering | Similarity-based algorithm for implicit user/item feedback. It works in the CPU environment. | Quick start / Deep dive |
| Self-Attentive Sequential Recommendation (SASRec) | Collaborative Filtering | Transformer based algorithm for sequential recommendation. It works in the CPU/GPU environment. | Quick start |
| Short-term and Long-term Preference Integrated Recommender (SLi-Rec)* | Collaborative Filtering | Sequential-based algorithm that aims to capture both long and short-term user preferences using attention mechanism, a time-aware controller and a content-aware controller. It works in the CPU/GPU environment. | Quick start |
| Multi-Interest-Aware Sequential User Modeling (SUM)* | Collaborative Filtering | An enhanced memory network-based sequential user model which aims to capture users' multiple interests. It works in the CPU/GPU environment. | Quick start |
| Sequential Recommendation Via Personalized Transformer (SSEPT) | Collaborative Filtering | Transformer based algorithm for sequential recommendation with User embedding. It works in the CPU/GPU environment. | Quick start |
| Standard VAE | Collaborative Filtering | Generative Model for predicting user/item interactions. It works in the CPU/GPU environment. | Deep dive |
| Surprise/Singular Value Decomposition (SVD) | Collaborative Filtering | Matrix factorization algorithm for predicting explicit rating feedback in small datasets. It works in the CPU/GPU environment. | Deep dive |
| Term Frequency - Inverse Document Frequency (TF-IDF) | Content-Based Filtering | Simple similarity-based algorithm for content-based recommendations with text datasets. It works in the CPU environment. | Quick start |
| Vowpal Wabbit (VW)* | Content-Based Filtering | Fast online learning algorithms, great for scenarios where user features / context are constantly changing. It uses the CPU for online learning. | Deep dive |
| Wide and Deep | Collaborative Filtering | Deep learning algorithm that can memorize feature interactions and generalize user features. It works in the CPU/GPU environment. | Quick start |
| xLearn/Factorization Machine (FM) & Field-Aware FM (FFM) | Collaborative Filtering | Quick and memory efficient algorithm to predict labels with user/item features. It works in the CPU/GPU environment. | Deep dive |
NOTE: * indicates algorithms invented/contributed by Microsoft.
Independent or incubating algorithms and utilities are candidates for the contrib folder. This will house contributions which may not easily fit into the core repository or need time to refactor or mature the code and add necessary tests.
| Algorithm | Type | Description | Example |
|---|---|---|---|
| SARplus * | Collaborative Filtering | Optimized implementation of SAR for Spark | Quick start |
Algorithm Comparison
We provide a benchmark notebook to illustrate how different algorithms could be evaluated and compared. In this notebook, the MovieLens dataset is split into training/test sets at a 75/25 ratio using a stratified split. A recommendation model is trained using each of the collaborative filtering algorithms below. We utilize empirical parameter values reported in literature here. For ranking metrics we use k=10 (top 10 recommended items). We run the comparison on a machine with 24 CPUs, 30Gb of RAM, and 1 GPU GeForce RTX 5090 GPU with 24Gb of memory. Spark ALS is run in local standalone mode. In this table we show the results on Movielens 100k. For BPR, ratings are binarized with a threshold of 3.5 (ratings ≥ 4 treated as positive implicit feedback) for both training and evaluation.
| Algo | MAP | nDCG@k | Precision@k | Recall@k | RMSE | MAE | R2 | Explained Variance |
|---|---|---|---|---|---|---|---|---|
| ALS | 0.010400 | 0.032800 | 0.038100 | 0.013200 | 0.966732 | 0.752552 | 0.267438 | 0.263534 |
| BiVAE | 0.330000 | 0.471700 | 0.411300 | 0.224300 | N/A | N/A | N/A | N/A |
| BPR | 0.229200 | 0.362300 | 0.285500 | 0.251700 | N/A | N/A | N/A | N/A |
| embdotbias | 0.054900 | 0.119000 | 0.107000 | 0.042300 | 0.992760 | 0.776040 | 0.223344 | 0.223393 |
| LightGCN | 0.277200 | 0.419100 | 0.359900 | 0.197100 | N/A | N/A | N/A | N/A |
| NCF | 0.260300 | 0.393100 | 0.346900 | 0.181900 | N/A | N/A | N/A | N/A |
| SAR | 0.258500 | 0.393800 | 0.340600 | 0.185400 | 1.229103 | 1.035996 | -0.487843 | 0.097283 |
Contributing
This project welcomes contributions and suggestions. Before contributing, please see our contribution guidelines.
This project adheres to this Code of Conduct in order to foster a welcoming and inspiring community for all.
References
- D. Li, J. Lian, L. Zhang, K. Ren, D. Lu, T. Wu, X. Xie, "Recommender Systems: Frontiers and Practices", Springer, Beijing, 2024. Available on this link.
- A. Argyriou, M. González-Fierro, and L. Zhang, "Microsoft Recommenders: Best Practices for Production-Ready Recommendation Systems", WWW 2020: International World Wide Web Conference Taipei, 2020. Available online: https://dl.acm.org/doi/abs/10.1145/3366424.3382692
- S. Graham, J.K. Min, T. Wu, "Microsoft recommenders: tools to accelerate developing recommender systems", RecSys '19: Proceedings of the 13th ACM Conference on Recommender Systems, 2019. Available online: https://dl.acm.org/doi/10.1145/3298689.3346967
- L. Zhang, T. Wu, X. Xie, A. Argyriou, M. González-Fierro and J. Lian, "Building Production-Ready Recommendation System at Scale", ACM SIGKDD Conference on Knowledge Discovery and Data Mining 2019 (KDD 2019), 2019.