Search-based Interest Model (SIM) is a system for predicting user behavior given sequences of previous interactions.
To train your model using mixed or TF32 precision with Tensor Cores or using FP32, perform the following steps using the default parameters of the SIM model on the Amazon Reviews dataset. For the specifics concerning training and inference, refer to the Advanced section.
-
Clone the repository.
git clone https://github.com/NVIDIA/DeepLearningExamples cd DeepLearningExamples/TensorFlow2/Recommendation/SIM -
Build the SIM Tensorflow2 container.
docker build -t sim_tf2 . -
Start an interactive session in the NGC container to run preprocessing, training, or inference (Amazon Books dataset can be mounted if it has already been downloaded, otherwise, refer to point 4). The SIM TensorFlow2 container can be launched with:
docker run --runtime=nvidia -it --rm --ipc=host --security-opt seccomp=unconfined -v ${AMAZON_DATASET_PATH}:${RAW_DATASET_PATH} sim_tf2 bash -
(Optional) Download Amazon Books dataset:
scripts/download_amazon_books_2014.sh export RAW_DATASET_PATH=/data/amazon_books_2014 -
Start preprocessing.
For details of the required file format and certain preprocessing parameters refer to BYO dataset.
python preprocessing/sim_preprocessing.py \ --amazon_dataset_path ${RAW_DATASET_PATH} \ --output_path ${PARQUET_PATH} python preprocessing/parquet_to_tfrecord.py \ --amazon_dataset_path ${PARQUET_PATH} \ --tfrecord_output_dir ${TF_RECORD_PATH} -
Start training (
${GPU}is an arbitrary number of GPUs to be used).mpiexec --allow-run-as-root --bind-to socket -np ${GPU} python main.py \ --dataset_dir ${TF_RECORD_PATH} \ --mode train \ --model_type sim \ --embedding_dim 16 \ --drop_remainder \ --optimizer adam \ --lr 0.01 \ --epochs 3 \ --global_batch_size 131072 \ --amp -
Start inference.
mpiexec --allow-run-as-root --bind-to socket -np ${GPU} python main.py \ --dataset_dir ${TF_RECORD_PATH} \ --mode inference \ --model_type sim \ --embedding_dim 16 \ --global_batch_size 131072 \ --amp
For the explanation of output logs, refer to Log format section.
Now that you have your model trained and evaluated, you can choose to compare your training results with our Training accuracy results. You can also choose to benchmark your performance to Training performance benchmark, or Inference performance benchmark. Following the steps in these sections will ensure that you achieve the same accuracy and performance results as stated in the Results section.