Git Product home page Git Product logo

max-recommender's Introduction

Build Status Website Status

IBM Developer Model Asset Exchange: MAX Recommender

This repository contains code to instantiate and deploy a recommender model. This model can be trained on a dataset containing users, items, ratings, and timestamps and make personalized item recommendations for a given user. Once trained, the input to the model is a user IDs and the output is a list of recommended item IDs sorted by probability in descending order. For demo purposes this model has been trained on a subset of the MovieTweetings Dataset, containing 457 users with their IDs mapped from 0 to 457 for convenience.

The model is based on the Neural Collaborative Filtering model. The model files are hosted on IBM Cloud Object Storage. The code in this repository deploys the model as a web service in a Docker container. This repository was developed as part of the IBM Developer Model Asset Exchange and the public API is powered by IBM Cloud.

Model Metadata

Domain Application Industry Framework Training Data Input Data Format
Information Retrieval Recommendations Commerce TensorFlow MovieTweetings CSV

References

Licenses

Component License Link
This repository Apache 2.0 LICENSE
Model Weights Apache 2.0 LICENSE
Model Code (3rd party) MIT Microsoft Recommender Systems GitHub Repo

Pre-requisites:

  • docker: The Docker command-line interface. Follow the installation instructions for your system.
  • The minimum recommended resources for this model is 4GB Memory and 2 CPUs.

Steps

  1. Deploy from Quay
  2. Deploy on Kubernetes
  3. Deploy on Red Hat OpenShift
  4. Run Locally

Deploy from Quay

To run the docker image, which automatically starts the model serving API, run:

$ docker run -it -p 5000:5000 quay.io/codait/max-recommender

This will pull a pre-built image from the Quay.io container registry (or use an existing image if already cached locally) and run it. If you'd rather checkout and build the model locally you can follow the run locally steps below.

Deploy on Kubernetes

You can also deploy the model on Kubernetes using the latest docker image on Quay.

On your Kubernetes cluster, run the following commands:

$ kubectl apply -f https://github.com/IBM/MAX-Recommender/raw/master/max-recommender.yaml

The model will be available internally at port 5000, but can also be accessed externally through the NodePort.

A more elaborate tutorial on how to deploy this MAX model to production on IBM Cloud can be found here.

Deploy on Red Hat OpenShift:

Follow the instructions for the OpenShift web console or the OpenShift Container Platform CLI in this tutorial and specify quay.io/codait/max-recommender as the image name.

Run Locally

  1. Build the Model
  2. Deploy the Model
  3. Use the Model
  4. Development
  5. Cleanup

1. Build the Model

Clone this repository locally. In a terminal, run the following command:

$ git clone https://github.com/IBM/MAX-Recommender.git

Change directory into the repository base folder:

$ cd MAX-Recommender

To build the docker image locally, run:

$ docker build -t max-recommender .

All required model assets will be downloaded during the build process. Note that currently this docker image is CPU only (we will add support for GPU images later).

2. Deploy the Model

To run the docker image, which automatically starts the model serving API, run:

$ docker run -it -p 5000:5000 max-recommender

3. Use the Model

The API server automatically generates an interactive Swagger documentation page. Go to http://localhost:5000 to load it. From there you can explore the API and also create test requests.

User the model/predict endpoint to retrieve recommendations for a user ID. The number of predictions returned can be specified with num_results, by default the model returns 5 predictions.

SWAGGER UI SCREENSHOT

You can also test it on the command line, for example:

$ curl -X POST "http://localhost:5000/model/predict?user_id=1&num_results=5" -H "accept: application/json"

You should see a JSON response like that below:

{
  "status": "ok",
  "predictions": [
      {
      "user": "1",
      "item": "1454468",
      "prediction": 0.995230495929718
    },
    {
      "user": "1",
      "item": "1300854",
      "prediction": 0.9938176274299622
    },
    {
      "user": "1",
      "item": "77413",
      "prediction": 0.9930911064147949
    },
    {
      "user": "1",
      "item": "1731141",
      "prediction": 0.9929673671722412
    },
    {
      "user": "1",
      "item": "363226",
      "prediction": 0.9914621710777283
    }
  ]
}

4. Development

To run the Flask API app in debug mode, edit config.py to set DEBUG = True under the application settings. You will then need to rebuild the docker image (see step 1).

5. Cleanup

To stop the Docker container, type CTRL + C in your terminal.

max-recommender's People

Contributors

bdwyer2 avatar dependabot[bot] avatar djalova avatar imgbotapp avatar kmh4321 avatar stevemar avatar xuhdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

max-recommender's Issues

Update WML API to v4

Can this repository be upgraded to work with the new WML API? I tried training it but run into auth errors

ImportError: No module named max_training_framework.wml_setup; Training

When following the README instructions for training under the Run the Setup Script (step 3), I run the command python setup_max_model_training.py max-recommender-training-config.yaml and receive an error
Traceback (most recent call last): File "setup_max_model_training.py", line 21, in <module> from max_training_framework.wml_setup import do_setup ImportError: No module named max_training_framework.wml_setup
I did not find this setup file in the repository either

Clarify that the model needs to be trained to be meaningful

The Docker image is immediately deployable. But the document does not make it clear that user should have trained the model first, and otherwise the immediately deployable model isn't really useful. This can be confusing for some users who are not familar with recommender systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.