Package: transact-tf
TransActThis is NOT the official implementation by the authors of this model architecture. You can find the official pytorchimplementation here. This repo is aTensorflowimplementation ofTransAct: Transformer-based Realtime User Action Model for
Recommendation at Pinterestby Xia, Xue, et al.TransActis 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.InstallationPyPINew 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:pipinstalltransact-tfDockerTo install the package using Docker run the following:dockerpullghcr.io/awadalaa/transact:releaseDeveloping transactTo installtransact, along with tools you need to develop and test, run the following in your virtualenv:gitclonehttps://github.com/awadalaa/transact.git# or clone your own forkcdtransact
pipinstall-e.To run rank and shape tests run any of the following:python-mtransact.test_transactpytesttransact--verboseUsageimporttensorflowastffromtransactimportTensorflowTransAct,TransActConfignum_actions=5action_vocab=list(range(0,num_actions))full_seq_len=10test_batch_size=8action_emb_dim=32item_emb_dim=32time_window_ms=1000*60*60*1# 1 hrlatest_n_emb=10# Generate random tensors in TensorFlow as inputaction_type_seq=tf.random.uniform(shape=(test_batch_size,full_seq_len),minval=0,maxval=num_actions,dtype=tf.int32)item_embedding_seq=tf.random.uniform(shape=(test_batch_size,full_seq_len,item_emb_dim),dtype=tf.float32)action_time_seq=tf.random.uniform(shape=(test_batch_size,full_seq_len),minval=0,maxval=num_actions,dtype=tf.int32)request_time=tf.random.uniform(shape=(test_batch_size,),minval=500000,maxval=1000000,dtype=tf.int32)item_embedding=tf.random.uniform(shape=(test_batch_size,item_emb_dim),dtype=tf.float32)input_features=(action_type_seq,item_embedding_seq,action_time_seq,request_time,item_embedding,)# Initialize the transact moduletransact_config=TransActConfig(action_vocab=action_vocab,action_emb_dim=action_emb_dim,item_emb_dim=item_emb_dim,time_window_ms=time_window_ms,latest_n_emb=latest_n_emb,seq_len=full_seq_len,)model=TensorflowTransAct(transact_config)user_embedding=model(*input_features)Run with DockerYou can also run the example script with Docker.gitclonehttps://github.com/awadalaa/transact.gitcdtransact

dockerrun-it--rm\--mounttype=bind,source="$(pwd)"/example,target=/usr/src/transact/docker_example\ghcr.io/awadalaa/transact:release\pythondocker_example/docker_example.pyWant to Contribute 🙋‍♂️?Awesome! If you want to contribute to this project, you're always welcome! SeeContributing Guidelines. You can also take a look atopen issuesfor 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 canstart discussions.Citation@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}}LicenseCopyright 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.