Versatile End-to-End Recommender System
Alternatives To Librecommender
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Transformers102,873649114 hours ago91June 21, 2022751apache-2.0Python
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Stable Diffusion Webui80,981
5 hours ago1,936agpl-3.0Python
Stable Diffusion web UI
Pytorch67,5231464 hours ago23August 10, 202212,171otherPython
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Real Time Voice Cloning41,693
a month ago129otherPython
Clone a voice in 5 seconds to generate arbitrary speech in real-time
a day ago35May 21, 2022257agpl-3.0Python
YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
Made With Ml33,193
a month ago5May 15, 201911mitJupyter Notebook
Learn how to responsibly develop, deploy and maintain production machine learning applications.
Mockingbird29,18423 days ago9February 28, 2022425otherPython
🚀AI拟声: 5秒内克隆您的声音并生成任意语音内容 Clone a voice in 5 seconds to generate arbitrary speech in real-time
Gfpgan27,65112 months ago11February 15, 2022209otherPython
GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration.
Pytorch Tutorial26,129
2 months ago85mitPython
PyTorch Tutorial for Deep Learning Researchers
Ray25,902801994 hours ago76June 09, 20222,901apache-2.0Python
Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a toolkit of libraries (Ray AIR) for accelerating ML workloads.
Alternatives To Librecommender
Select To Compare

Alternative Project Comparisons


Build CI Codecov pypi Downloads Codacy Badge Code style: black Ruff Documentation Status python versions License


LibRecommender is an easy-to-use recommender system focused on end-to-end recommendation process. It contains a training(libreco) and serving(libserving) module to let users quickly train and deploy different kinds of recommendation models.

The main features are:

  • Implements a number of popular recommendation algorithms such as FM, DIN, LightGCN etc. See full algorithm list.
  • A hybrid recommender system, which allows user to use either collaborative-filtering or content-based features. New features can be added on the fly.
  • Low memory usage, automatically converts categorical and multi-value categorical features to sparse representation.
  • Supports training for both explicit and implicit datasets, as well as negative sampling on implicit data.
  • Provides end-to-end workflow, i.e. data handling / preprocessing -> model training -> evaluate -> save/load -> serving.
  • Supports cold-start prediction and recommendation.
  • Supports dynamic feature and sequence recommendation.
  • Provides unified and friendly API for all algorithms.
  • Easy to retrain model with new users/items from new data.


pure collaborative-filtering example :

import numpy as np
import pandas as pd
from import random_split, DatasetPure
from libreco.algorithms import LightGCN  # pure data, algorithm LightGCN
from libreco.evaluation import evaluate

data = pd.read_csv("examples/sample_data/sample_movielens_rating.dat", sep="::",
                   names=["user", "item", "label", "time"])

# split whole data into three folds for training, evaluating and testing
train_data, eval_data, test_data = random_split(data, multi_ratios=[0.8, 0.1, 0.1])

train_data, data_info = DatasetPure.build_trainset(train_data)
eval_data = DatasetPure.build_evalset(eval_data)
test_data = DatasetPure.build_testset(test_data)
print(data_info)  # n_users: 5894, n_items: 3253, data sparsity: 0.4172 %

lightgcn = LightGCN(
# monitor metrics on eval data during training
    metrics=["loss", "roc_auc", "precision", "recall", "ndcg"],

# do final evaluation on test data
    metrics=["loss", "roc_auc", "precision", "recall", "ndcg"],

# predict preference of user 2211 to item 110
lightgcn.predict(user=2211, item=110)
# recommend 7 items for user 2211
lightgcn.recommend_user(user=2211, n_rec=7)

# cold-start prediction
lightgcn.predict(user="ccc", item="not item", cold_start="average")
# cold-start recommendation
lightgcn.recommend_user(user="are we good?", n_rec=7, cold_start="popular")

include features example :

import numpy as np
import pandas as pd
from import split_by_ratio_chrono, DatasetFeat
from libreco.algorithms import YouTubeRanking  # feat data, algorithm YouTubeRanking

data = pd.read_csv("examples/sample_data/sample_movielens_merged.csv", sep=",", header=0)
# split into train and test data based on time
train_data, test_data = split_by_ratio_chrono(data, test_size=0.2)

# specify complete columns information
sparse_col = ["sex", "occupation", "genre1", "genre2", "genre3"]
dense_col = ["age"]
user_col = ["sex", "age", "occupation"]
item_col = ["genre1", "genre2", "genre3"]

train_data, data_info = DatasetFeat.build_trainset(
    train_data, user_col, item_col, sparse_col, dense_col
test_data = DatasetFeat.build_testset(test_data)
print(data_info)  # n_users: 5962, n_items: 3226, data sparsity: 0.4185 %

ytb_ranking = YouTubeRanking(
    hidden_units=(128, 64, 32),
    metrics=["loss", "roc_auc", "precision", "recall", "map", "ndcg"],

# predict preference of user 2211 to item 110
ytb_ranking.predict(user=2211, item=110)
# recommend 7 items for user 2211
ytb_ranking.recommend_user(user=2211, n_rec=7)

# cold-start prediction
ytb_ranking.predict(user="ccc", item="not item", cold_start="average")
# cold-start recommendation
ytb_ranking.recommend_user(user="are we good?", n_rec=7, cold_start="popular")

Data Format

JUST normal data format, each line represents a sample. One thing is important, the model assumes that user, item, and label column index are 0, 1, and 2, respectively. You may wish to change the column order if that's not the case. Take for Example, the movielens-1m dataset:


Besides, if you want to use some other meta features (e.g., age, sex, category etc.), you need to tell the model which columns are [sparse_col, dense_col, user_col, item_col], which means all features must be in a same table. See above YouTubeRanking for example.

Also note that your data should not contain missing values.


The tutorials and API documentation are hosted on

The example scripts are under examples/ folder.

Installation & Dependencies

From pypi :  

$ pip install -U LibRecommender

Build from source:

$ git clone
$ cd LibRecommender
$ pip install .

Basic Dependencies for libreco:

  • Python >= 3.6
  • TensorFlow >= 1.15
  • PyTorch >= 1.10
  • Numpy >= 1.19.5
  • Pandas >= 1.0.0
  • Scipy >= 1.2.1
  • scikit-learn >= 0.20.0
  • gensim >= 4.0.0
  • tqdm
  • nmslib (optional, used in approximate similarity searching. See Embedding)
  • DGL (optional, used in GraphSage and PinSage. See Implementation Details)

If you are using Python 3.6, you also need to install dataclasses, which was first introduced in Python 3.7.

LibRecommender has been tested under TensorFlow 1.15, 2.6, 2.10 and 2.12. If you encounter any problem during running, feel free to open an issue.

Known issue: Sometimes one may encounter errors like ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject. In this case try upgrading numpy, and version 1.22.0 or higher is probably a safe option.

The table below shows some compatible version combinations:

Python Numpy TensorFlow OS
3.6 1.19.5 1.15, 2.5 linux, windows, macos
3.7 1.20.3, 1.21.6 1.15, 2.6, 2.10 linux, windows, macos
3.8 1.22.4, 1.23.4 2.6, 2.10, 2.12 linux, windows, macos
3.9 1.22.4, 1.23.4 2.6, 2.10, 2.12 linux, windows, macos
3.10 1.22.4, 1.23.4, 1.24.2 2.10, 2.12 linux, windows, macos
3.11 1.23.4, 1.24.2 2.12 linux, windows, macos

Optional Dependencies for libserving:


One can also use the library in a docker container without installing dependencies, see Docker.


Algorithm Category1 Backend Sequence2 Graph3 Embedding4 Paper
userCF / itemCF pure Cython Item-Based Collaborative Filtering Recommendation Algorithms
SVD pure TensorFlow1 ✔️ Matrix Factorization Techniques for Recommender Systems
SVD++ pure TensorFlow1 ✔️ Factorization Meets the Neighborhood: a Multifaceted Collaborative Filtering Model
ALS pure Cython ✔️ 1. Matrix Completion via Alternating Least Square(ALS)
2. Collaborative Filtering for Implicit Feedback Datasets
3. Applications of the Conjugate Gradient Method for Implicit Feedback Collaborative Filtering
NCF pure TensorFlow1 Neural Collaborative Filtering
BPR pure Cython, TensorFlow1 ✔️ BPR: Bayesian Personalized Ranking from Implicit Feedback
Wide & Deep feat TensorFlow1 Wide & Deep Learning for Recommender Systems
FM feat TensorFlow1 Factorization Machines
DeepFM feat TensorFlow1 DeepFM: A Factorization-Machine based Neural Network for CTR Prediction
YouTubeRetrieval feat TensorFlow1 ✔️ ✔️ Deep Neural Networks for YouTube Recommendations
YouTubeRanking feat TensorFlow1 ✔️ Deep Neural Networks for YouTube Recommendations
AutoInt feat TensorFlow1 AutoInt: Automatic Feature Interaction Learning via Self-Attentive Neural Networks
DIN feat TensorFlow1 ✔️ Deep Interest Network for Click-Through Rate Prediction
Item2Vec pure / ✔️ ✔️ Item2Vec: Neural Item Embedding for Collaborative Filtering
RNN4Rec / GRU4Rec pure TensorFlow1 ✔️ ✔️ Session-based Recommendations with Recurrent Neural Networks
Caser pure TensorFlow1 ✔️ ✔️ Personalized Top-N Sequential Recommendation via Convolutional Sequence Embedding
WaveNet pure TensorFlow1 ✔️ ✔️ WaveNet: A Generative Model for Raw Audio
DeepWalk pure / ✔️ ✔️ DeepWalk: Online Learning of Social Representations
NGCF pure PyTorch ✔️ ✔️ Neural Graph Collaborative Filtering
LightGCN pure PyTorch ✔️ ✔️ LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation
GraphSage feat DGL, PyTorch ✔️ ✔️ Inductive Representation Learning on Large Graphs
PinSage feat DGL, PyTorch ✔️ ✔️ Graph Convolutional Neural Networks for Web-Scale Recommender Systems

[1] Category: pure means collaborative-filtering algorithms which only use behavior data, feat means other side-features can be included.

[2] Sequence: Algorithms that leverage user behavior sequence.

[3] Graph: Algorithms that leverage graph information, including Graph Embedding (GE) and Graph Neural Network (GNN) .

[4] Embedding: Algorithms that can generate final user and item embeddings.

Powered by

JetBrains Logo

Popular Deep Learning Projects
Popular Pytorch Projects
Popular Machine Learning Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Deep Learning
Recommendation System
Recommender System
Collaborative Filtering