transact-tf

An unofficial implementation of "TransAct: Transformer-based Realtime User Action Model for Recommendation at Pinterest" in Tensorflow

https://github.com/awadalaa/transact

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: acm.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.3%) to scientific vocabulary

Keywords

deep-learning machine-learning sequence-modeling tensorflow transformers user-embeddings
Last synced: 6 months ago · JSON representation ·

Repository

An unofficial implementation of "TransAct: Transformer-based Realtime User Action Model for Recommendation at Pinterest" in Tensorflow

Basic Info
  • Host: GitHub
  • Owner: awadalaa
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 164 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 4
Topics
deep-learning machine-learning sequence-modeling tensorflow transformers user-embeddings
Created over 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme Contributing License Code of conduct Citation Codeowners

README.md

TransAct Twitter

PyPI Run Tests Upload Python Package Code style: black GitHub Super-Linter

GitHub License GitHub stars GitHub followers Twitter Follow

This is NOT the official implementation by the authors of this model architecture. You can find the official pytorch implementation here. This repo is a Tensorflow implementation of TransAct: Transformer-based Realtime User Action Model for Recommendation at Pinterest by Xia, Xue, et al. TransAct is the ranking architecture used by Pinterest's Homefeed to personalize and extract users' short-term preferences from their realtime activities. The paper was presented at KDD 2023.

Installation

PyPI

New user registration on PyPI is temporarily suspended due to malicious attacks. Once admins enable, will add. Until then, skip ahead to the docker step.

Run the following to install:

sh pip install transact-tf

Docker

To install the package using Docker run the following:

sh docker pull ghcr.io/awadalaa/transact:release

Developing transact

To install transact, along with tools you need to develop and test, run the following in your virtualenv:

```sh git clone https://github.com/awadalaa/transact.git

or clone your own fork

cd transact pip install -e . ```

To run rank and shape tests run any of the following:

py python -m transact.test_transact pytest transact --verbose

Usage

```python import tensorflow as tf from transact import TensorflowTransAct, TransActConfig

numactions = 5 actionvocab = list(range(0, numactions)) fullseqlen = 10 testbatchsize = 8 actionembdim = 32 itemembdim = 32 timewindowms = 1000 * 60 * 60 * 1 # 1 hr latestn_emb = 10

Generate random tensors in TensorFlow as input

actiontypeseq = tf.random.uniform(shape=(testbatchsize, fullseqlen), minval=0, maxval=numactions, dtype=tf.int32) itemembeddingseq = tf.random.uniform(shape=(testbatchsize, fullseqlen, itemembdim), dtype=tf.float32) actiontimeseq = tf.random.uniform(shape=(testbatchsize, fullseqlen), minval=0, maxval=numactions, dtype=tf.int32) requesttime = tf.random.uniform(shape=(testbatchsize,), minval=500000, maxval=1000000, dtype=tf.int32) itemembedding = tf.random.uniform(shape=(testbatchsize, itemembdim), dtype=tf.float32) inputfeatures = ( actiontypeseq, itemembeddingseq, actiontimeseq, requesttime, item_embedding, )

Initialize the transact module

transactconfig = TransActConfig( actionvocab=actionvocab, actionembdim=actionembdim, itemembdim=itemembdim, timewindowms=timewindowms, latestnemb=latestnemb, seqlen=fullseqlen, ) model = TensorflowTransAct(transact_config)

userembedding = model(*inputfeatures)

```

Run with Docker

You can also run the example script with Docker.

```sh git clone https://github.com/awadalaa/transact.git cd transact

docker run -it --rm \ --mount type=bind,source="$(pwd)"/example,target=/usr/src/transact/dockerexample \ ghcr.io/awadalaa/transact:release \ python dockerexample/docker_example.py ```

Want to Contribute 🙋‍♂️?

Awesome! If you want to contribute to this project, you're always welcome! See Contributing Guidelines. You can also take a look at open issues for getting more information about current or upcoming tasks.

Want to discuss? 💬

Have any questions, doubts or want to present your opinions, views? You're always welcome. You can start discussions.

Citation

bibtex @article{xia2023transact, title={TransAct: Transformer-based Realtime User Action Model for Recommendation at Pinterest}, 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}, journal={arXiv preprint arXiv:2306.00248}, year={2023} }

License

``` Copyright 2023 Alaa Awad

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```

Owner

  • Name: Alaa
  • Login: awadalaa
  • Kind: user
  • Location: Brooklyn, NY
  • Company: @etsy

Software Engineer at Etsy

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Awad"
  given-names: "Alaa"
  orcid: "https://orcid.org/0000-0000-0000-0000"
title: "transact"
version: 0.1.0
doi: 10.5281/zenodo.1234
date-released: 2023-11-25
url: "https://github.com/awadalaa/transact"

GitHub Events

Total
  • Watch event: 2
Last Year
  • Watch event: 2

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 16 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
pypi.org: transact-tf

An implementation of TransAct: Transformer-based Realtime User Action Model for Recommendation

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 16 Last month
Rankings
Dependent packages count: 10.1%
Average: 38.4%
Dependent repos count: 66.7%
Maintainers (1)
Last synced: 7 months ago

Dependencies

.github/workflows/linter.yml actions
  • actions/checkout v4 composite
  • github/super-linter v5 composite
.github/workflows/python-publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/tests.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
docker/Dockerfile docker
  • python 3.7 build
setup.py pypi
  • tensorflow >=2.9
.github/workflows/container-publish.yml actions
  • actions/checkout v4 composite