{"id":29673827,"url":"https://github.com/otto-de/tron","last_synced_at":"2025-07-22T22:08:24.036Z","repository":{"id":179411797,"uuid":"645794645","full_name":"otto-de/TRON","owner":"otto-de","description":"⚡️ Implementation of TRON: Transformer Recommender using Optimized Negative-sampling, accepted at ACM RecSys 2023.","archived":false,"fork":false,"pushed_at":"2025-05-08T18:34:52.000Z","size":2183,"stargazers_count":67,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-08T19:39:54.620Z","etag":null,"topics":["artificial-intelligence","deep-learning","e-commerce","gru4rec","negative-sampling","python","pytorch","pytorch-lightning","recommendation-engine","recommender-system","recsys","sasrec","session-based-recommender-system","transformers"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2307.14906","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otto-de.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,"zenodo":null}},"created_at":"2023-05-26T12:58:39.000Z","updated_at":"2025-05-08T18:34:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"a36c04a4-33ff-4e29-a499-7fe242a74ad4","html_url":"https://github.com/otto-de/TRON","commit_stats":null,"previous_names":["otto-de/tron"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/otto-de/TRON","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2FTRON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2FTRON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2FTRON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2FTRON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otto-de","download_url":"https://codeload.github.com/otto-de/TRON/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2FTRON/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266580862,"owners_count":23951304,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["artificial-intelligence","deep-learning","e-commerce","gru4rec","negative-sampling","python","pytorch","pytorch-lightning","recommendation-engine","recommender-system","recsys","sasrec","session-based-recommender-system","transformers"],"created_at":"2025-07-22T22:08:23.302Z","updated_at":"2025-07-22T22:08:24.028Z","avatar_url":"https://github.com/otto-de.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# TRON: Scalable Session-Based Transformer Recommender using Optimized Negative Sampling\n\n[![GitHub stars](https://img.shields.io/github/stars/otto-de/TRON.svg?style=for-the-badge\u0026color=yellow)](https://github.com/otto-de/TRON)\n[![Test suite](https://img.shields.io/github/actions/workflow/status/otto-de/TRON/test.yml?branch=main\u0026style=for-the-badge)](https://github.com/otto-de/TRON/actions/workflows/test.yml)\n[![Conference](https://img.shields.io/badge/Conference-RecSys%202023-4b44ce?style=for-the-badge)](https://recsys.acm.org/recsys23/)\n[![OTTO jobs](https://img.shields.io/badge/otto-jobs-F00020?style=for-the-badge\u0026logo=otto)](https://www.otto.de/jobs/technology/ueberblick/)\n\n**TRON is a scalable session-based Transformer Recommender using Optimized Negative-sampling. This repository contains the official [PyTorch Lightning](https://github.com/Lightning-AI/lightning) implementation for our paper: [_Scaling Session-Based Transformer Recommendations using Optimized Negative Sampling and Loss Functions_](https://arxiv.org/abs/2307.14906), authored by [Timo Wilm](https://www.linkedin.com/in/timo-wilm/), [Philipp Normann](https://www.linkedin.com/in/pnormann), [Sophie Baumeister](https://www.linkedin.com/in/sophie-baumeister/), and [Paul-Vincent Kobow](https://www.linkedin.com/in/paul-vincent-kobow/).**\n\n\u003cimg src=\".readme/header.png\" width=\"100%\"\u003e\n\n\u003c/div\u003e\n\n## 🎯 Abstract\n\nThis work introduces **TRON**, a scalable session-based **T**ransformer **R**ecommender using **O**ptimized **N**egative-sampling. Motivated by the scalability and performance limitations of prevailing models such as SASRec and GRU4Rec+, TRON integrates top-k negative sampling and listwise loss functions to enhance its recommendation accuracy. Evaluations on relevant large-scale e-commerce datasets show that TRON improves upon the recommendation quality of current methods while maintaining training speeds similar to SASRec. A live A/B test yielded an **18.14%** increase in click-through rate over SASRec, highlighting the potential of TRON in practical settings. For further research, we provide access to our [source code](https://github.com/otto-de/TRON) and an [anonymized dataset](https://github.com/otto-de/recsys-dataset).\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr style=\"vertical-align:top\"\u003e\n    \u003ctd\u003e\u003cimg src=\".readme/recall.svg\" width=\"100%\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\".readme/onex.svg\" width=\"100%\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n    \n  \u003ctr\u003e\n    \u003ctd\u003eOffline evaluation results on our private OTTO dataset used for the online A/B test of our three groups.\u003c/td\u003e\n    \u003ctd\u003eOnline results of our A/B test relative to the SASRec baseline. The error bars indicate the 95% confidence interval.\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## 🌟 RecSys 2023 Research Showcase\n\nBelow is our poster presented at the [17th ACM Conference on Recommender Systems](https://recsys.acm.org/recsys23/) (RecSys 2023), which provides a comprehensive overview of the key concepts, methodologies, and results of our TRON research.\n\n\u003ca href=\".readme/poster.pdf\"\u003e\u003cimg src=\".readme/poster.svg\" width=\"100%\"\u003e\u003c/a\u003e\n\n## 🚀 Quick Start\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/otto-de/TRON.git\n```\n\n2. Install the dependencies:\n\n```bash\npip install pipenv\npipenv install --dev\n```\n\n3. Execute the test scripts:\n\n```bash\npipenv run pytest\n```\n\n4. Install 7zip, gzip, and zip utilities on your system:\n\n```bash\nsudo apt-get install 7zip gzip unzip\n```\n\n5. Prepare a dataset (e.g., yoochoose):\n\n```bash\n./prepare.sh yoochoose\n```\n\n6. Run the main script with a configuration file:\n\n```bash\npipenv run python -m src --config-filename tron/yoochoose\n```\n\n## 🗂️ Repository Structure\n\n```yaml\n.\n├── Pipfile\n├── Pipfile.lock\n├── README.md\n├── configs                # Contains experiment configuration files\n├── doc                    # Contains the paper and related files\n├── prepare.sh             # Script to prepare datasets\n├── src                    # Source code for the models\n└── test                   # Test scripts\n```\n\n## ⚙️ Config File Documentation\n\nThe [config folder](configs/) contains JSON configuration files for all experiments performed in our research. These configurations detail the model's parameters and options.\n\nHere's an explanation of each parameter in the config file:\n\n- `model`: The base model to be used (e.g., \"sasrec\", \"gru4rec\").\n- `dataset`: The dataset to be used for training (e.g., \"yoochoose\", \"otto\", \"diginetica\").\n- `hidden_size`: The size of the hidden layers and item embeddings.\n- `num_layers`: The number of layers in the model.\n- `dropout`: The dropout rate applied to the model's layers.\n- `num_batch_negatives`: The number of negative samples from the batch. Limited by `batch_size` - 1.\n- `num_uniform_negatives`: The number of uniformly sampled negatives.\n- `reject_uniform_session_items`: If true, items from the same session won't be used as uniform negatives. Becomes slow if `num_uniform_negatives` is large.\n- `reject_in_batch_items`: If true, items from the same session won't be used as batch negatives.\n- `sampling_style`: The style of negative sampling to use (e.g., \"eventwise\", \"sessionwise\", \"batchwise\"). Has significant impact on training speed.\n- `loss`: The loss function to use (e.g., \"bce\", \"bpr-max\", \"ssm\").\n- `bpr_penalty`: The penalty factor for BPR-Max loss. Ignored if not using BPR-Max loss.\n- `max_epochs`: The maximum number of training epochs.\n- `batch_size`: The batch size used for training and validation.\n- `max_session_length`: The maximum length of a session. Longer sessions will be truncated.\n- `lr`: The learning rate for the optimizer.\n- `limit_val_batches`: The fraction of validation data to use for the validation step.\n- `accelerator`: The device type to be used for training (e.g., \"gpu\", \"cpu\").\n- `overfit_batches`: The fraction or number of batches of training data to use for overfitting. Set to 0 for no overfitting. See [PyTorch Lightning docs](https://lightning.ai/docs/pytorch/stable/common/trainer.html#overfit-batches) for more details.\n- `share_embeddings`: If true, the embedding weights are shared between the input and output layers.\n- `output_bias`: If true, includes bias in the output layer.\n- `shuffling_style`: The style of shuffling to use for the training dataset (e.g., \"no_shuffling\", \"shuffling_with_replacement\", \"shuffling_without_replacement\").\n- `optimizer`: The optimizer to use for training (e.g., \"adam\", \"adagrad\")\n- `topk_sampling`: If true, top-k negative sampling is enabled.\n- `topk_sampling_k`: If `topk_sampling` is true, this parameter specifies the number of top k negative samples to be used for training.\n\n### Example Config File for TRON on the OTTO Dataset\n\n```json\n{\n    \"model\": \"sasrec\",\n    \"dataset\": \"otto\",\n    \"hidden_size\": 200,\n    \"num_layers\": 2,\n    \"dropout\": 0.05,\n    \"num_batch_negatives\": 127,\n    \"num_uniform_negatives\": 16384,\n    \"reject_uniform_session_items\": false,\n    \"reject_in_batch_items\": true,\n    \"sampling_style\": \"batchwise\",\n    \"topk_sampling\": true,\n    \"topk_sampling_k\": 100,\n    \"loss\": \"ssm\",\n    \"max_epochs\": 10,\n    \"batch_size\": 128,\n    \"max_session_length\": 50,\n    \"lr\": 0.0005,\n    \"limit_val_batches\": 1.0,\n    \"accelerator\": \"gpu\",\n    \"overfit_batches\": 0,\n    \"share_embeddings\": true,\n    \"output_bias\": false,\n    \"shuffling_style\": \"no_shuffling\",\n    \"optimizer\": \"adam\"\n}\n```\n\nFor all config files used in our experiments, refer to the [configs directory](configs/).\n\n## 🙌 Contribution\n\nContributions to TRON are welcome and appreciated. For issues or suggestions for improvements, please open an issue or create a pull request. We believe that open source knowledge sharing is the best way to advance the field of recommender systems.\n\n## 📖 Citing\n\nIf TRON aids your research, please consider citing our work:\n\n```bibtex\n@inproceedings{wilm2023tron,\n  title={Scaling Session-Based Transformer Recommendations using Optimized Negative Sampling and Loss Functions},\n  author={Wilm, Timo and Normann, Philipp and Baumeister, Sophie and Kobow, Paul-Vincent},\n  booktitle={Proceedings of the 17th ACM Conference on Recommender Systems},\n  doi = {10.1145/3604915.3610236},\n  pages={1023--1026},\n  year={2023}\n}\n```\n\n## 📜 License\n\nThis project is [MIT licensed](./LICENSE).\n\n## 📞 Contact\n\nFor any queries or questions, please reach out to us via our LinkedIn profiles:\n\n- [Timo Wilm](https://www.linkedin.com/in/timo-wilm)\n- [Philipp Normann](https://www.linkedin.com/in/pnormann/)\n- [Sophie Baumeister](https://www.linkedin.com/in/sophie-baumeister-9a5a59200/)\n\nFor specific issues related to the codebase or for feature requests, please create a new issue on our [GitHub page](https://github.com/otto-de/TRON/issues).\n\nIf this project aids your research or you find it interesting, we would appreciate it if you could star ⭐ the repository. Thanks for your support!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotto-de%2Ftron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotto-de%2Ftron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotto-de%2Ftron/lists"}