# Cornac: a comparative framework for multimodal recommender research

> Cornac is an Apache-2.0 Python library for recommender research, built around a single Experiment object that runs several models over the same split with the same metrics so the comparison is meaningful, with a large catalogue of collaborative filtering, deep learning and multimodal models and a JMLR paper behind it. It suits a researcher or student running controlled comparisons, and it is the wrong dependency for a production recommendation service that needs one tuned model.

**PreferredAI/cornac** — A Comparative Framework for Multimodal Recommender Systems

- Repository: https://github.com/PreferredAI/cornac
- Website: https://cornac.preferred.ai
- Stars: 1,063 · Forks: 175
- Language: Python
- License: Apache-2.0
- Published: 2026-10-19 · Updated: 2026-10-19 · Language: en
- Canonical page: https://hysenlabs.com/projects/preferredai-cornac

## The comparison is the API, not the model list

Cornac is described as a comparative framework for multimodal recommender systems, and the emphasis in the README is on convenience, fast experiments, straightforward implementations of new models, and compatibility with existing machine learning libraries such as TensorFlow and PyTorch. The design follows from that word comparative. Most recommender code fails to compare models fairly, because each model is wired up with its own split, its own metric loop and its own seed handling. Cornac's Experiment object takes an evaluation method, a list of models and a list of metrics, and runs the whole matrix, which is why the output table in the README has a uniform set of columns per model rather than three separate runs printed one after another.

## The first experiment in the README is short enough to run as-is

The getting started section loads the built-in MovieLens 100K, splits it with RatioSplit at a test_size of 0.2, a rating_threshold of 4.0 and a seed of 123, then compares three models.

```python
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

ml_100k = cornac.datasets.movielens.load_feedback()
rs = RatioSplit(data=ml_100k, test_size=0.2, rating_threshold=4.0, seed=123)

mf = MF(k=10, max_iter=25, learning_rate=0.01, lambda_reg=0.02, use_bias=True, seed=123)
pmf = PMF(k=10, max_iter=100, learning_rate=0.001, lambda_reg=0.001, seed=123)
bpr = BPR(k=10, max_iter=200, learning_rate=0.001, lambda_reg=0.01, seed=123)
models = [mf, pmf, bpr]

metrics = [MAE(), RMSE(), Precision(k=10), Recall(k=10), NDCG(k=10), AUC(), MAP()]

cornac.Experiment(eval_method=rs, models=models, metrics=metrics, user_based=True).run()
```

The result table that follows is instructive beyond the numbers, because the BPR row shows N/A for MAE and RMSE. BPR is a pairwise ranking method with no rating prediction, so the framework honestly reports that two of the metrics do not apply rather than silently computing something meaningless. The table also breaks out training and test time per model, so you can see the cost of each method as well as its accuracy.

## Install options, and the optional dependencies that bite

Three install routes are documented, with PyPI the recommended one.

```bash
pip3 install cornac
```

Conda is the alternative, and the GitHub source route is for the latest updates.

```bash
conda install cornac -c conda-forge
pip3 install git+https://github.com/PreferredAI/cornac.git
```

The core dependencies in pyproject.toml are numpy above version 2.0, scipy, tqdm and powerlaw, and the package requires Python 3.10 or later, with classifiers for 3.10 through 3.14. The README then warns that additional dependencies required by individual models are listed separately, which is the thing to read before picking a model. It also notes that some algorithm implementations use OpenMP for multi-threading, and that Mac OS users may need gcc from Homebrew, linked, to run those algorithms efficiently.

```bash
brew install gcc && brew link gcc
```

The setup.py shows why that matters, with a flag that is turned on only if a working libomp is found, and an environment variable that lets you point the build at a custom libomp.

## Serving a model is a Flask app, and the compose file shows the shape

For serving, the README describes a simple standalone web service built on Flask, described as very handy for testing or creating a demo application. You save the trained model, then point the app at it.

```bash
$ MODEL_PATH='save_dir/BPR' \
  MODEL_CLASS='cornac.models.BPR' \
  flask --app cornac.serving.app run --host localhost --port 8080
```

The recommendation endpoint takes a user id and a count, and returns a JSON object with the item ids and a record of the query parameters, so the response echoes back what it did. The docker-compose.yml in the repository root shows the containerised version, using the image ghcr.io/preferredai/cornac-server:latest, mounting a save directory and a named volume for serving data, and setting the same MODEL_PATH and MODEL_CLASS environment variables, with the host port 8080 mapped to the container port 5000. The README notes you can also use a WSGI server for production deployment rather than the Flask development server.

## The model catalogue spans classical and multimodal methods

The examples/ directory is the clearest index of what is implemented. The file names cover biased matrix factorization in biased_mf.py and pmf, neural network models, the C2PF and CDR and CDL neighbourhood-based approaches, convolution and recurrent variants, variational autoencoders including the cvae and cvaecf files for a film dataset, contrastive and diffusion-based generative recommenders in diffgrm_example.py and dmrl, a fast causal recommender in causalrec, and a set of models that clearly need extra data, since the names reference clothing, CiteULike, TAFENG and Netflix datasets, and a beacon and deep item-based and session-based files for transaction logs. There is an ease_movielens.py, an item-to-item collaborative example, and a first_example.py. The point of the catalogue is coverage: the framework lets you hold data, split and metrics constant while the model changes.

## The framework has academic standing and a paper

Cornac is described as one of the frameworks recommended by ACM RecSys 2023 for the evaluation and reproducibility of recommendation algorithms, and the README adds that the BPR implementation in Cornac has been recommended as a trustworthy baseline for RecSys comparison by independent research, with a DOI link to the paper. The project itself published a design paper in the Journal of Machine Learning Research, volume 21, issue 19-805, and the same volume is cited for the JMLR entry in the quick links. The licence is Apache-2.0, with the license field in pyproject.toml pointing at the LICENSE file. The release history shows v3.0.1 on 2026-09-14, v3.0.0 on 2026-08-27 and v2.6.0 on 2026-07-15, so the 3.0 line is recent and the last push was on 2026-09-14.

## Distribution is broad and the build is Cython-based

Cornac is published on PyPI, on conda-forge and through a conda recipe, and the README shows a Dockerfile, a docker-compose.yml and a MANIFEST.in at the repository root, along with a pytest.ini, a setup.cfg, a .coveragerc and a .codecov.yml, so the project runs on multiple continuous integration services including Azure Pipelines for the conda feedstock, GitHub Actions, CircleCI and Read the Docs. The build backend is setuptools with a Cython extension, and the build requirements list Cython at 0.29.21 or above alongside numpy above 2.0 and scipy, which tells you the heavy lifting in some models is compiled rather than pure Python. The optional tests extra pulls in pytest, pytest-xdist, pytest-cov and Flask, and the tutorials/ directory at the root holds notebook-based walkthroughs.

## Conclusion

Cornac fits a researcher or student who needs to compare recommender models on identical data splits with identical metrics, since the Experiment object removes the bookkeeping that makes such comparisons unfair, and the framework has been recommended by ACM RecSys 2023 for evaluation and reproducibility. It is a poor fit for a production service, because the framework is organised around running many models rather than serving one, and the serving app in the documentation is described as handy for testing or a demo. Verify first which extra dependencies your chosen model needs, since the README lists them separately from the core install, and note that the build path uses Cython with OpenMP, so a Mac install may need a Homebrew gcc before the multi-threaded algorithms run efficiently.

## FAQ

### What problem does Cornac solve?

It is a comparative framework for multimodal recommender systems, aimed at making it convenient to work with models that use auxiliary data such as item descriptive text and image, and at enabling fast experiments and straightforward implementations of new models, with high compatibility with TensorFlow and PyTorch.

### How do I install Cornac?

The recommended route is pip3 install cornac from PyPI. Conda users can run conda install cornac -c conda-forge, and the GitHub source route is pip3 install git+https://github.com/PreferredAI/cornac.git for the latest updates. The package requires Python 3.10 or later.

### How do I run a first Cornac experiment?

Load a built-in dataset such as MovieLens 100K, create a RatioSplit with a test_size, rating_threshold and seed, instantiate several models with the same seed, define metrics, and pass all three to cornac.Experiment with eval_method, models, metrics and user_based, then call run on it. The README shows exactly this with MF, PMF and BPR.

### Can I serve a trained Cornac model?

Yes, with the built-in Flask serving app. Save the model with save, then run flask with MODEL_PATH and MODEL_CLASS pointing at the saved directory and the model class, then query the recommend endpoint with a uid and a k parameter.

## Sources

- [License: Apache-2.0](https://github.com/PreferredAI/cornac/blob/master/LICENSE)
- [PreferredAI/cornac on GitHub](https://github.com/PreferredAI/cornac)
- [Project website](https://cornac.preferred.ai)
- [README](https://github.com/PreferredAI/cornac/blob/master/README.md)
- [Releases](https://github.com/PreferredAI/cornac/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/preferredai-cornac
