Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time


Cornac is a comparative framework for multimodal recommender systems. It focuses on making it convenient to work with models leveraging auxiliary data (e.g., item descriptive text and image, social network, etc). Cornac enables fast experiments and straightforward implementations of new models. It is highly compatible with existing machine learning libraries (e.g., TensorFlow, PyTorch).

Quick Links

Website | Documentation | Tutorials | Examples | Models | Datasets | Paper | Preferred.AI

.github/workflows/python-package.yml CircleCI AppVeyor Codecov Docs
Release PyPI Conda Conda Recipe Downloads
Python Conda Platforms License


Currently, we are supporting Python 3. There are several ways to install Cornac:

  • From PyPI (you may need a C++ compiler):

    pip3 install cornac
  • From Anaconda:

    conda install cornac -c conda-forge
  • From the GitHub source (for latest updates):

    pip3 install Cython
    git clone
    cd cornac
    python3 install


Additional dependencies required by models are listed here.

Some algorithm implementations use OpenMP to support multi-threading. For Mac OS users, in order to run those algorithms efficiently, you might need to install gcc from Homebrew to have an OpenMP compiler:

brew install gcc | brew link gcc

Getting started: your first Cornac experiment

Flow of an Experiment in Cornac

import cornac
from cornac.eval_methods import RatioSplit
from cornac.models import MF, PMF, BPR
from cornac.metrics import MAE, RMSE, Precision, Recall, NDCG, AUC, MAP

# load the built-in MovieLens 100K and split the data based on ratio
ml_100k = cornac.datasets.movielens.load_feedback()
rs = RatioSplit(data=ml_100k, test_size=0.2, rating_threshold=4.0, seed=123)

# initialize models, here we are comparing: Biased MF, PMF, and BPR
models = [
    MF(k=10, max_iter=25, learning_rate=0.01, lambda_reg=0.02, use_bias=True, seed=123),
    PMF(k=10, max_iter=100, learning_rate=0.001, lambda_reg=0.001, seed=123),
    BPR(k=10, max_iter=200, learning_rate=0.001, lambda_reg=0.01, seed=123),

# define metrics to evaluate the models
metrics = [MAE(), RMSE(), Precision(k=10), Recall(k=10), NDCG(k=10), AUC(), MAP()]

# put it together in an experiment, voilà!
cornac.Experiment(eval_method=rs, models=models, metrics=metrics, user_based=True).run()


MAE RMSE AUC MAP NDCG@10 Precision@10 Recall@10 Train (s) Test (s)
MF 0.7430 0.8998 0.7445 0.0407 0.0479 0.0437 0.0352 0.13 1.57
PMF 0.7534 0.9138 0.7744 0.0491 0.0617 0.0533 0.0479 2.18 1.64
BPR N/A N/A 0.8695 0.0753 0.0975 0.0727 0.0891 3.74 1.49

For more details, please take a look at our examples as well as tutorials. For learning purposes, this list of tutorials on recommender systems will be more organized and comprehensive.


The recommender models supported by Cornac are listed below. Why don't you join us to lengthen the list?

Year Model and paper Additional dependencies Examples
2021 Bilateral Variational Autoencoder for Collaborative Filtering (BiVAECF), paper requirements.txt PreferredAI/bi-vae
Causal Inference for Visual Debiasing in Visually-Aware Recommendation (CausalRec), paper requirements.txt
Explainable Recommendation with Comparative Constraints on Product Aspects (ComparER), paper N/A PreferredAI/ComparER
2020 Adversarial Training Towards Robust Multimedia Recommender System (AMR), paper requirements.txt
2019 Embarrassingly Shallow Autoencoders for Sparse Data (EASEᴿ), paper N/A
2018 Collaborative Context Poisson Factorization (C2PF), paper N/A
Multi-Task Explainable Recommendation (MTER), paper N/A
Neural Attention Rating Regression with Review-level Explanations (NARRE), paper requirements.txt
Probabilistic Collaborative Representation Learning (PCRL), paper requirements.txt
Variational Autoencoder for Collaborative Filtering (VAECF), paper requirements.txt
2017 Collaborative Variational Autoencoder (CVAE), paper requirements.txt
Conditional Variational Autoencoder for Collaborative Filtering (CVAECF), paper requirements.txt
Generalized Matrix Factorization (GMF), paper requirements.txt
Indexable Bayesian Personalized Ranking (IBPR), paper requirements.txt
Matrix Co-Factorization (MCF), paper N/A
Multi-Layer Perceptron (MLP), paper requirements.txt
Neural Matrix Factorization (NeuMF) / Neural Collaborative Filtering (NCF), paper requirements.txt
Online Indexable Bayesian Personalized Ranking (Online IBPR), paper requirements.txt
Visual Matrix Factorization (VMF), paper requirements.txt
2016 Collaborative Deep Ranking (CDR), paper requirements.txt
Collaborative Ordinal Embedding (COE), paper requirements.txt
Convolutional Matrix Factorization (ConvMF), paper requirements.txt
Spherical K-means (SKM), paper N/A
Visual Bayesian Personalized Ranking (VBPR), paper requirements.txt
2015 Collaborative Deep Learning (CDL), paper requirements.txt
Hierarchical Poisson Factorization (HPF), paper N/A
2014 Explicit Factor Model (EFM), paper N/A
Social Bayesian Personalized Ranking (SBPR), paper N/A
2013 Hidden Factors and Hidden Topics (HFT), paper N/A
2012 Weighted Bayesian Personalized Ranking (WBPR), paper N/A
2011 Collaborative Topic Regression (CTR), paper N/A
Earlier Baseline Only, paper N/A
Bayesian Personalized Ranking (BPR), paper N/A
Factorization Machines (FM), paper Linux only
Global Average (GlobalAvg), paper N/A
Item K-Nearest-Neighbors (ItemKNN), paper N/A
Matrix Factorization (MF), paper N/A,
Maximum Margin Matrix Factorization (MMMF), paper N/A
Most Popular (MostPop), paper N/A
Non-negative Matrix Factorization (NMF), paper N/A
Probabilistic Matrix Factorization (PMF), paper N/A
Singular Value Decomposition (SVD), paper N/A
Social Recommendation using PMF (SoRec), paper N/A
User K-Nearest-Neighbors (UserKNN), paper N/A
Weighted Matrix Factorization (WMF), paper requirements.txt


Your contributions at any level of the library are welcome. If you intend to contribute, please:

  • Fork the Cornac repository to your own account.
  • Make changes and create pull requests.

You can also post bug reports and feature requests in GitHub issues.


If you use Cornac in a scientific publication, we would appreciate citations to the following papers:

  • Cornac: A Comparative Framework for Multimodal Recommender Systems, Salah et al., Journal of Machine Learning Research, 21(95):1–5, 2020.

      title={Cornac: A Comparative Framework for Multimodal Recommender Systems},
      author={Salah, Aghiles and Truong, Quoc-Tuan and Lauw, Hady W},
      journal={Journal of Machine Learning Research},
  • Exploring Cross-Modality Utilization in Recommender Systems, Truong et al., IEEE Internet Computing, 25(4):50–57, 2021.

      title={Exploring Cross-Modality Utilization in Recommender Systems},
      author={Truong, Quoc-Tuan and Salah, Aghiles and Tran, Thanh-Binh and Guo, Jingyao and Lauw, Hady W},
      journal={IEEE Internet Computing},
  • Multi-Modal Recommender Systems: Hands-On Exploration, Truong et al., ACM Conference on Recommender Systems, 2021.

      title={Multi-modal recommender systems: Hands-on exploration},
      author={Truong, Quoc-Tuan and Salah, Aghiles and Lauw, Hady},
      booktitle={Fifteenth ACM Conference on Recommender Systems},


Apache License 2.0