This repository provides a minimal TensorFlow 1.12 implementation of Decoupled Temporal Encoding (DTE) for generative recommendation.
DTE contains two temporal components:
- Macro-temporal module: injects temporal context into input item embeddings.
- Micro-sequential module: adds a time-gated order bias to masked self-attention.
This code is intended as a reference implementation / reproducible demo for the paper, based on the KuaiRand 1K setting rather than a full production system.
This code is developed and tested with:
- Framework: TensorFlow 1.12
Note: this project is implemented in TensorFlow 1.x graph mode.
This implementation is deeply optimized for the PPU-ZW810E architecture. Due to specific instruction set and memory hierarchy differences, running this code on standard NVIDIA GPUs or CPUs may result in significantly degraded performance or execution failures.
The demo follows the paper setting:
- decoder-only Transformer backbone
- single decoder block
- 8 attention heads
- embedding size = 64
- MLP tower =
16 -> 8 -> 1 - optimizer = Adam
- learning rate =
1e-4 - batch size =
1024
For the temporal modules:
- learnable decay coefficient
lambda - adaptive fusion MLP:
16 -> 8 -> 4 - user context from average pooling over historical item embeddings
- pairwise time gaps are computed in seconds
- learnable threshold
tau - fixed temperature
gamma = 10
config.pyfeature_maps.pylayers.pydata_loader.pymodel.pytrain.py
Descriptions:
layers.py: macro and micro temporal modulesdata_loader.py: local txt data readermodel.py: model graphtrain.py: training entry
Install dependencies:
pip install tensorflow==1.12.0 numpy
Prepare your local data and training file.
Run:
python train.py
- This is a minimal demo, not a full industrial system.
- Only a subset of user/item side features is retained.
- The code focuses on the two main ideas of the paper:
- macro temporal encoding
- micro time-gated attention bias
If you find this code useful, please cite:
@inproceedings{dte2026,
title={Decoupled Temporal Encoding for Generative Recommendation},
author={Pengfei Jia, Jingjian Wang, Jingmao Li, Ge Zhang, Feng Shi},
year={2026}
}