{"id":21888615,"url":"https://github.com/swisscom/ai-research-mamo-framework","last_synced_at":"2025-04-15T10:20:17.116Z","repository":{"id":66688639,"uuid":"276602117","full_name":"swisscom/ai-research-mamo-framework","owner":"swisscom","description":"A Model Agnostic Multi-Objective Framework for Deep Learning models","archived":false,"fork":false,"pushed_at":"2020-07-20T15:18:59.000Z","size":99,"stargazers_count":31,"open_issues_count":0,"forks_count":10,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-15T10:20:02.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swisscom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-02T09:16:59.000Z","updated_at":"2024-10-08T06:48:06.000Z","dependencies_parsed_at":"2023-03-11T00:14:07.293Z","dependency_job_id":null,"html_url":"https://github.com/swisscom/ai-research-mamo-framework","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fai-research-mamo-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fai-research-mamo-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fai-research-mamo-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisscom%2Fai-research-mamo-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swisscom","download_url":"https://codeload.github.com/swisscom/ai-research-mamo-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249048785,"owners_count":21204311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T11:16:11.884Z","updated_at":"2025-04-15T10:20:17.106Z","avatar_url":"https://github.com/swisscom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MAMO Framework\n\n\u003e A Model Agnostic Multi-Objective Framework for Deep Learning models\n\n\n[![Build Status](http://img.shields.io/travis/badges/badgerbadgerbadger.svg?style=flat-square)](https://travis-ci.org/badges/badgerbadgerbadger)\n\nThis framework will enable users to easily create, train, test and deploy deep learning models with a focus on multi-objective. The framework is easy to use and understand. It is developed in \"Lego fashion\", meaning that we already supply out of the box models, loss function, metrics which can be easily used to build and train models, but also we leave full flexibility to the user to define their own models, losses, metrics only by implementing abstract classes.  \n\n\n\n\n---\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Features](#features)\n- [Architecture](#architecture)\n- [Tests](#tests)\n- [Team](#team)\n\n\n\n---\n\n## Example\n\nThis example is based on the [Multi-Gradient Descent for Multi-Objective Recommender Systems](https://arxiv.org/abs/2001.00846)(arXiv) paper.\n\n```python\nimport torch\nimport numpy as np\nimport os\n\nfrom dataloader.ae_data_handler import AEDataHandler\nfrom models.multi_VAE import MultiVAE\nfrom loss.vae_loss import VAELoss\nfrom metric.recall_at_k import RecallAtK\nfrom metric.revenue_at_k import RevenueAtK\nfrom trainer import Trainer\n\nimport argparse\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--data_dir\", default=\"/home/user/working_dir/data/\", help=\"the path to the directory where the data is stored\")\nparser.add_argument(\"--models_dir\", default=\"/home/user/working_dir/models\", help=\"the path to the directory where to save the models, it must be empty\")\nargs = parser.parse_args()\n\n# get the arguments\ndir_path = args.data_dir\nsave_to_path = args.models_dir\n\n# set up logging\nimport logging\nimport sys\nlogging.basicConfig(stream=sys.stdout, level=logging.INFO)\nlogger = logging.getLogger(\"main\")\nlogger.setLevel(logging.INFO)\n\n# set cuda if available\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n\ntrain_data_path = os.path.join(\n    dir_path, \"movielens_small_training.npy\")\nvalidation_input_data_path = os.path.join(\n    dir_path, \"movielens_small_validation_input.npy\")\nvalidation_output_data_path = os.path.join(\n    dir_path, \"movielens_small_validation_test.npy\")\ntest_input_data_path = os.path.join(\n    dir_path, \"movielens_small_test_input.npy\")\ntest_output_data_path = os.path.join(\n    dir_path, \"movielens_small_test_test.npy\")\nproducts_data_path = os.path.join(\n    dir_path, \"movielens_products_data.npy\")\n\ndata_handler = AEDataHandler(\n    \"MovieLensSmall\", train_data_path, validation_input_data_path,\n    validation_output_data_path, test_input_data_path,\n    test_output_data_path)\n\ninput_dim = data_handler.get_input_dim()\noutput_dim = data_handler.get_output_dim()\n\nproducts_data_np = np.load(products_data_path)\nproducts_data_torch = torch.tensor(\n    products_data_np, dtype=torch.float32).to(device)\n\n# create model\nmodel = MultiVAE(params=\"yaml_files/params_multi_VAE_training.yaml\")\n\ncorrectness_loss = VAELoss()\nrevenue_loss = VAELoss(weighted_vector=products_data_torch)\nlosses = [correctness_loss, revenue_loss]\n\nrecallAtK = RecallAtK(k=10)\nrevenueAtK = RevenueAtK(k=10, revenue=products_data_np)\nvalidation_metrics = [recallAtK, revenueAtK]\n\ntrainer = Trainer(data_handler, model, losses, validation_metrics, save_to_path)\ntrainer.train()\nprint(trainer.pareto_manager._pareto_front)\n```\n\n### Downloading datasets\nWe provide two already preprocessed, ready to use datasets, and can be downloaded from the following links:\n1. [MovieLens dataset with prices](https://drive.google.com/open?id=15KwO7tk9S4M5raro2ndkYswFLh7MpPkt).\n2. [Amazon movies dataset with prices](https://drive.google.com/open?id=1O1XfAFxKAvUTXGTk6WQDO5H0OP9y5xuI).\n\nPlease, download and unzip the MovieLens dataset before continuing with the next steps.\n\n### Running the example script\nIf all the steps are finished and all the requirements are satisfied, the script can be run with the following command:\n```\npython run_example.py --data_dir bar --models_dir foo\n```\nWhere `--data_dir` is the path to the directory where the data downloaded in the previous step is uncompressed and stored, and `--models_dir` is the path to the directory where the framework will save the models belonging to the Pareto front and it must be empty directory.\n\n\n---\n\n## Installation\n\nThe MAMO framework is compatible with: Python 3.6+. PyTorch 1.2.0+.\n\n### Clone\n\n- Clone this repo using `https://git.swisscom.com/scm/dilrec/moframework.git`\n\n### Dependencies\n\nThe dependencies needs to be satisfied in order to be able to use the MAMO Framework. There are several ways to install them.\n\n\u003e 1. Using pip and the requirements.txt configuration file provided\n\n```shell\n$ pip install -r requirements.txt\n```\n\n\u003e 2. Downloading a [Nvidia PyTorch](https://ngc.nvidia.com/catalog/containers/nvidia:pytorch) Docker image, and run everything inside a Docker container. (preferred)\n\n```shell\n$ docker pull nvcr.io/nvidia/pytorch:18.12.1-py3\n```\n\n---\n\n## Features\n- Train models on multi-objectives.\n- Flexibility for users to define their own model.\n- Compatible with PyTorch models.\n- Automatic model saving.\n- YAML config files for model/data hyperparameters.\n\n---\n\n\n\n## Architecture\nOur architecture is shown on the following diagram:\n\n\u003ca href=\"https://ibb.co/B4GjCZf\"\u003e\u003cimg src=\"https://i.ibb.co/Q8knKNJ/MOMA-class-diagram.png\" alt=\"MOMA-class-diagram\" border=\"0\"\u003e\u003c/a\u003e\n\n\n---\n\n## Tests\nThe tests are written using [pytest](https://docs.pytest.org/en/stable/index.html). It needs to be installed if you want to run the tests.\n\nIn order to run our tests, you have to be in the `tests` directory and run them with `pytest`:\n```\ncd tests\npytest\n```\n\n\n---\n\n## Team\n\nCode written by the recommenders@swisscom, including:\n\n[Kirtan Padh](https://github.com/kirtanp)\n\n[Milena Filipovic](https://github.com/MilenaFilipovic)\n\n[Nelson Antunes](https://github.com/Nelsi11120)\n\n[Loic Nguyen](https://github.com/coiL10)\n\n[Blagoj Mitrevski](https://github.com/blagojce95)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisscom%2Fai-research-mamo-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswisscom%2Fai-research-mamo-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisscom%2Fai-research-mamo-framework/lists"}