{"id":39904759,"url":"https://github.com/awadalaa/transact","last_synced_at":"2026-01-18T15:33:36.940Z","repository":{"id":209246153,"uuid":"723568811","full_name":"awadalaa/transact","owner":"awadalaa","description":"An unofficial implementation of \"TransAct: Transformer-based Realtime User Action Model for Recommendation at Pinterest\"  in Tensorflow","archived":false,"fork":false,"pushed_at":"2023-12-23T01:02:42.000Z","size":168,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-05T09:17:54.548Z","etag":null,"topics":["deep-learning","machine-learning","sequence-modeling","tensorflow","transformers","user-embeddings"],"latest_commit_sha":null,"homepage":"","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/awadalaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-26T04:29:14.000Z","updated_at":"2025-04-11T21:57:04.000Z","dependencies_parsed_at":"2025-04-13T15:12:44.019Z","dependency_job_id":"e244f3d3-a615-490b-b385-4bf3066d5f24","html_url":"https://github.com/awadalaa/transact","commit_stats":null,"previous_names":["awadalaa/transact"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/awadalaa/transact","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awadalaa%2Ftransact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awadalaa%2Ftransact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awadalaa%2Ftransact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awadalaa%2Ftransact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awadalaa","download_url":"https://codeload.github.com/awadalaa/transact/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awadalaa%2Ftransact/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28539257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T14:59:57.589Z","status":"ssl_error","status_checked_at":"2026-01-18T14:59:46.540Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["deep-learning","machine-learning","sequence-modeling","tensorflow","transformers","user-embeddings"],"created_at":"2026-01-18T15:33:36.298Z","updated_at":"2026-01-18T15:33:36.931Z","avatar_url":"https://github.com/awadalaa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TransAct [![Twitter](https://img.shields.io/twitter/url?style=social\u0026url=https%3A%2F%2Fgithub.com%2Fawadalaa%2Ftransact)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2Fawadalaa%2Ftransact)\n\n![PyPI](https://img.shields.io/pypi/v/transact-tf)\n[![Run Tests](https://github.com/awadalaa/transact/actions/workflows/tests.yml/badge.svg)](https://github.com/awadalaa/transact/actions/workflows/tests.yml)\n[![Upload Python Package](https://github.com/awadalaa/transact/actions/workflows/python-publish.yml/badge.svg)](https://github.com/awadalaa/transact/actions/workflows/python-publish.yml)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![GitHub Super-Linter](https://github.com/awadalaa/transact/actions/workflows/linter.yml/badge.svg)](https://github.com/marketplace/actions/super-linter)\n\n\n![GitHub License](https://img.shields.io/github/license/awadalaa/transact)\n[![GitHub stars](https://img.shields.io/github/stars/awadalaa/transact?style=social)](https://github.com/awadalaa/transact/stargazers)\n[![GitHub followers](https://img.shields.io/github/followers/awadalaa?label=Follow\u0026style=social)](https://github.com/awadalaa)\n[![Twitter Follow](https://img.shields.io/twitter/follow/awadalaa?style=social)](https://twitter.com/intent/follow?screen_name=awadalaa)\n\nThis is NOT the official implementation by the authors of this model architecture. You can find the official pytorch [implementation here](https://github.com/pinterest/transformer_user_action). This repo is a **Tensorflow** implementation of [TransAct: Transformer-based Realtime User Action Model for\nRecommendation at Pinterest](https://dl.acm.org/doi/10.1145/3580305.3599918) by Xia, Xue, et al. **TransAct** is the ranking architecture \nused by Pinterest's Homefeed to personalize and extract users' short-term preferences from their realtime activities. The paper was presented at KDD 2023.\n\n![](https://github.com/awadalaa/transact/blob/main/media/architecture.png)\n\n## Installation\n\n### PyPI\n\nNew user registration on PyPI is temporarily suspended due to malicious attacks. Once admins enable, will add. Until then, skip ahead to the docker step.\n\nRun the following to install:\n\n```sh\npip install transact-tf\n```\n\n### Docker\n\nTo install the package using Docker run the following:\n\n```sh\ndocker pull ghcr.io/awadalaa/transact:release\n```\n\n## Developing transact\n\nTo install `transact`, along with tools you need to develop and test, run the following in your virtualenv:\n\n```sh\ngit clone https://github.com/awadalaa/transact.git\n# or clone your own fork\n\ncd transact\npip install -e .\n```\n\nTo run rank and shape tests run any of the following:\n\n```py\npython -m transact.test_transact\npytest transact --verbose\n```\n\n## Usage\n\n```python\nimport tensorflow as tf\nfrom transact import TensorflowTransAct, TransActConfig\n\nnum_actions = 5\naction_vocab = list(range(0, num_actions))\nfull_seq_len = 10\ntest_batch_size = 8\naction_emb_dim = 32\nitem_emb_dim = 32\ntime_window_ms = 1000 * 60 * 60 * 1  # 1 hr\nlatest_n_emb = 10\n\n# Generate random tensors in TensorFlow as input\naction_type_seq = tf.random.uniform(shape=(test_batch_size, full_seq_len), minval=0, maxval=num_actions, dtype=tf.int32)\nitem_embedding_seq = tf.random.uniform(shape=(test_batch_size, full_seq_len, item_emb_dim), dtype=tf.float32)\naction_time_seq = tf.random.uniform(shape=(test_batch_size, full_seq_len), minval=0, maxval=num_actions, dtype=tf.int32)\nrequest_time = tf.random.uniform(shape=(test_batch_size,), minval=500000, maxval=1000000, dtype=tf.int32)\nitem_embedding = tf.random.uniform(shape=(test_batch_size, item_emb_dim), dtype=tf.float32)\ninput_features = (\n    action_type_seq,\n    item_embedding_seq,\n    action_time_seq,\n    request_time,\n    item_embedding,\n)\n\n# Initialize the transact module\ntransact_config = TransActConfig(\n    action_vocab=action_vocab,\n    action_emb_dim=action_emb_dim,\n    item_emb_dim=item_emb_dim,\n    time_window_ms=time_window_ms,\n    latest_n_emb=latest_n_emb,\n    seq_len=full_seq_len,\n)\nmodel = TensorflowTransAct(transact_config)\n\nuser_embedding = model(*input_features)\n\n```\n\n## Run with Docker\n\nYou can also run the example script with Docker.\n\n```sh\ngit clone https://github.com/awadalaa/transact.git\ncd transact\n\ndocker run -it --rm \\\n    --mount type=bind,source=\"$(pwd)\"/example,target=/usr/src/transact/docker_example \\\n    ghcr.io/awadalaa/transact:release \\\n    python docker_example/docker_example.py\n```\n\n## Want to Contribute 🙋‍♂️?\n\nAwesome! If you want to contribute to this project, you're always welcome! See [Contributing Guidelines](CONTRIBUTING.md). You can also take a look at [open issues](https://github.com/awadalaa/transact/issues) for getting more information about current or upcoming tasks.\n\n## Want to discuss? 💬\n\nHave any questions, doubts or want to present your opinions, views? You're always welcome. You can [start discussions](https://github.com/awadalaa/transact/discussions).\n\n## Citation\n\n```bibtex\n@article{xia2023transact,\n  title={TransAct: Transformer-based Realtime User Action Model for Recommendation at Pinterest},\n  author={Xia, Xue and Eksombatchai, Pong and Pancha, Nikil and Badani, Dhruvil Deven and Wang, Po-Wei and Gu, Neng and Joshi, Saurabh Vishwas and Farahpour, Nazanin and Zhang, Zhiyuan and Zhai, Andrew},\n  journal={arXiv preprint arXiv:2306.00248},\n  year={2023}\n}\n```\n\n## License\n\n```\nCopyright 2023 Alaa Awad\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawadalaa%2Ftransact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawadalaa%2Ftransact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawadalaa%2Ftransact/lists"}