diff --git a/examples/usecases/ecommerce-session-based-next-item-prediction-for-fashion.ipynb b/examples/usecases/ecommerce-session-based-next-item-prediction-for-fashion.ipynb index b93907c239..45066f1171 100644 --- a/examples/usecases/ecommerce-session-based-next-item-prediction-for-fashion.ipynb +++ b/examples/usecases/ecommerce-session-based-next-item-prediction-for-fashion.ipynb @@ -104,12 +104,12 @@ "text": [ "/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!\n", " warnings.warn(\"urllib3 ({}) or chardet ({}) doesn't match a supported \"\n", - "2022-11-23 19:40:59.948016: I tensorflow/core/platform/cpu_feature_guard.cc:194] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE3 SSE4.1 SSE4.2 AVX\n", - "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n", - "2022-11-23 19:41:02.322167: I tensorflow/core/common_runtime/gpu/gpu_process_state.cc:222] Using CUDA malloc Async allocator for GPU: 0\n", - "2022-11-23 19:41:02.322315: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 16254 MB memory: -> device: 0, name: Quadro GV100, pci bus id: 0000:15:00.0, compute capability: 7.0\n", "/usr/local/lib/python3.8/dist-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n" + " from .autonotebook import tqdm as notebook_tqdm\n", + "2022-12-14 18:31:08.508511: I tensorflow/core/platform/cpu_feature_guard.cc:194] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE3 SSE4.1 SSE4.2 AVX\n", + "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n", + "2022-12-14 18:31:09.698802: I tensorflow/core/common_runtime/gpu/gpu_process_state.cc:222] Using CUDA malloc Async allocator for GPU: 0\n", + "2022-12-14 18:31:09.698899: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 16254 MB memory: -> device: 0, name: Quadro GV100, pci bus id: 0000:15:00.0, compute capability: 7.0\n" ] } ], @@ -260,123 +260,123 @@ " \n", " \n", " 0\n", - " 8130\n", - " 3106\n", - " 2020-03-10 21:15:13.940\n", - " -1\n", - " -1\n", - " 394\n", - " -1\n", - " 588\n", + " 24094\n", + " 142\n", + " 2021-01-07 15:20:55.857\n", + " 793\n", + " 605\n", + " 798\n", + " 378\n", " -1\n", - " 123\n", + " 559\n", + " 549\n", " ...\n", " 706\n", " 861\n", - " -1\n", - " 10\n", - " 885\n", + " 521\n", + " 745\n", + " 740\n", " 75\n", " 544\n", - " 1583874913940\n", - " 69\n", - " 27556\n", + " 1610032855857\n", + " 372\n", + " 15000\n", " \n", " \n", " 1\n", - " 8133\n", - " 22243\n", - " 2020-12-17 22:41:32.759\n", + " 24094\n", + " 15986\n", + " 2021-01-07 15:21:23.399\n", " 793\n", " 605\n", - " 170\n", + " 798\n", " 378\n", " -1\n", " 559\n", - " 842\n", + " 549\n", " ...\n", " 706\n", " 861\n", - " -1\n", - " 383\n", - " 592\n", + " 521\n", + " 14\n", + " 805\n", " 75\n", " 544\n", - " 1608244892759\n", - " 351\n", - " 24900\n", + " 1610032883399\n", + " 372\n", + " 15000\n", " \n", " \n", " 2\n", - " 8133\n", - " 2021\n", - " 2020-12-17 22:41:38.078\n", + " 24094\n", + " 27843\n", + " 2021-01-07 15:21:38.885\n", " 793\n", " 605\n", - " 170\n", + " 798\n", " 378\n", " -1\n", " 559\n", - " 842\n", + " 218\n", " ...\n", " 706\n", - " 861\n", - " -1\n", - " 373\n", - " 592\n", + " 599\n", + " 521\n", + " 745\n", + " 805\n", " 75\n", " 544\n", - " 1608244898078\n", - " 351\n", - " 24900\n", + " 1610032898885\n", + " 372\n", + " 15000\n", " \n", " \n", " 3\n", - " 8133\n", - " 2021\n", - " 2020-12-17 22:41:55.567\n", + " 24094\n", + " 14493\n", + " 2021-01-07 15:21:41.367\n", " 793\n", " 605\n", - " 170\n", + " 2\n", " 378\n", " -1\n", " 559\n", - " 842\n", + " 549\n", " ...\n", - " 706\n", + " 462\n", " 861\n", - " -1\n", - " 373\n", - " 592\n", - " 75\n", + " 521\n", + " 702\n", + " 538\n", + " 748\n", " 544\n", - " 1608244915567\n", - " 351\n", - " 24900\n", + " 1610032901367\n", + " 372\n", + " 15000\n", " \n", " \n", " 4\n", - " 8133\n", - " 2021\n", - " 2020-12-17 22:42:35.599\n", + " 24094\n", + " 14493\n", + " 2021-01-07 15:21:42.928\n", " 793\n", " 605\n", - " 170\n", + " 2\n", " 378\n", " -1\n", " 559\n", - " 842\n", + " 549\n", " ...\n", - " 706\n", + " 462\n", " 861\n", - " -1\n", - " 373\n", - " 592\n", - " 75\n", + " 521\n", + " 702\n", + " 538\n", + " 748\n", " 544\n", - " 1608244955599\n", - " 351\n", - " 24900\n", + " 1610032902928\n", + " 372\n", + " 15000\n", " \n", " \n", "\n", @@ -385,25 +385,25 @@ ], "text/plain": [ " session_id item_id date f_3 f_5 f_7 f_17 f_24 \\\n", - "0 8130 3106 2020-03-10 21:15:13.940 -1 -1 394 -1 588 \n", - "1 8133 22243 2020-12-17 22:41:32.759 793 605 170 378 -1 \n", - "2 8133 2021 2020-12-17 22:41:38.078 793 605 170 378 -1 \n", - "3 8133 2021 2020-12-17 22:41:55.567 793 605 170 378 -1 \n", - "4 8133 2021 2020-12-17 22:42:35.599 793 605 170 378 -1 \n", + "0 24094 142 2021-01-07 15:20:55.857 793 605 798 378 -1 \n", + "1 24094 15986 2021-01-07 15:21:23.399 793 605 798 378 -1 \n", + "2 24094 27843 2021-01-07 15:21:38.885 793 605 798 378 -1 \n", + "3 24094 14493 2021-01-07 15:21:41.367 793 605 2 378 -1 \n", + "4 24094 14493 2021-01-07 15:21:42.928 793 605 2 378 -1 \n", "\n", " f_45 f_47 ... f_61 f_63 f_65 f_68 f_69 f_72 f_73 timestamp \\\n", - "0 -1 123 ... 706 861 -1 10 885 75 544 1583874913940 \n", - "1 559 842 ... 706 861 -1 383 592 75 544 1608244892759 \n", - "2 559 842 ... 706 861 -1 373 592 75 544 1608244898078 \n", - "3 559 842 ... 706 861 -1 373 592 75 544 1608244915567 \n", - "4 559 842 ... 706 861 -1 373 592 75 544 1608244955599 \n", + "0 559 549 ... 706 861 521 745 740 75 544 1610032855857 \n", + "1 559 549 ... 706 861 521 14 805 75 544 1610032883399 \n", + "2 559 218 ... 706 599 521 745 805 75 544 1610032898885 \n", + "3 559 549 ... 462 861 521 702 538 748 544 1610032901367 \n", + "4 559 549 ... 462 861 521 702 538 748 544 1610032902928 \n", "\n", " day purchase_id \n", - "0 69 27556 \n", - "1 351 24900 \n", - "2 351 24900 \n", - "3 351 24900 \n", - "4 351 24900 \n", + "0 372 15000 \n", + "1 372 15000 \n", + "2 372 15000 \n", + "3 372 15000 \n", + "4 372 15000 \n", "\n", "[5 rows x 24 columns]" ] @@ -457,8 +457,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 118 µs, sys: 43 µs, total: 161 µs\n", - "Wall time: 122 µs\n" + "CPU times: user 97 µs, sys: 35 µs, total: 132 µs\n", + "Wall time: 135 µs\n" ] } ], @@ -467,7 +467,7 @@ "item_features_names = ['f_' + str(col) for col in [47, 68]]\n", "cat_features = [['item_id', 'purchase_id']] + item_features_names >> nvt.ops.Categorify(start_index=1)\n", "\n", - "features = ['session_id', 'timestamp', 'date'] + cat_features" + "features = ['session_id', 'timestamp'] + cat_features" ] }, { @@ -484,7 +484,7 @@ "The NVTabular `GroupBy` op enables the transformation. \n", "\n", "First, we define how the different columns should be aggregates:\n", - "- Keep the first occurrence of `date`\n", + "- Keep the first occurrence of `timestamp`\n", "- Keep the last item and concatenate all items to a list (results are 2 features)\n", "- Keep the first occurrence of `purchase_id` (purchase_id should be the same for all rows of one session)" ] @@ -497,7 +497,7 @@ "outputs": [], "source": [ "to_aggregate = {}\n", - "to_aggregate['date'] = [\"first\"]\n", + "to_aggregate['timestamp'] = [\"first\"]\n", "to_aggregate['item_id'] = [\"last\", \"list\"]\n", "to_aggregate['purchase_id'] = [\"first\"] " ] @@ -530,7 +530,7 @@ { "data": { "text/plain": [ - "{'date': ['first'],\n", + "{'timestamp': ['first'],\n", " 'item_id': ['last', 'list'],\n", " 'purchase_id': ['first'],\n", " 'f_47': ['list'],\n", @@ -551,7 +551,7 @@ "id": "caead45e", "metadata": {}, "source": [ - "We want to sort the dataframe by `date` and groupby the columns by `session_id`." + "We want to sort the dataframe by `timestamp` and groupby the columns by `session_id`." ] }, { @@ -563,7 +563,7 @@ "source": [ "groupby_features = features >> nvt.ops.Groupby(\n", " groupby_cols=[\"session_id\"], \n", - " sort_cols=[\"date\"],\n", + " sort_cols=[\"timestamp\"],\n", " aggs= to_aggregate,\n", " name_sep=\"_\")" ] @@ -600,7 +600,7 @@ " )\n", ")\n", "\n", - "other_features = groupby_features['session_id', 'date_first']\n", + "other_features = groupby_features['session_id', 'timestamp_first']\n", "\n", "groupby_features = item_last + item_list + feature_list + other_features + groupby_features['purchase_id_first']" ] @@ -623,7 +623,7 @@ "outputs": [], "source": [ "list_features = [name+'_list' for name in item_features_names] + ['item_id_list']\n", - "nonlist_features = ['session_id', 'date_first', 'item_id_last', 'purchase_id_first']" + "nonlist_features = ['session_id', 'timestamp_first', 'item_id_last', 'purchase_id_first']" ] }, { @@ -720,7 +720,7 @@ " os.path.join(DATA_FOLDER, \"train/*.parquet\")\n", " )\n", ")\n", - "df = df.sort_values('date_first').reset_index(drop=True)\n", + "df = df.sort_values('timestamp_first').reset_index(drop=True)\n", "df.to_parquet(os.path.join(DATA_FOLDER, \"train_sorted.parquet\"))" ] }, @@ -760,7 +760,7 @@ " \n", " \n", " session_id\n", - " date_first\n", + " timestamp_first\n", " item_id_last\n", " purchase_id_first\n", " f_47_list_seq\n", @@ -772,7 +772,7 @@ " \n", " 0\n", " 3747794\n", - " 2020-01-01 00:00:01.359\n", + " 1577836801359\n", " 7920\n", " 13757\n", " [3, 6, 14]\n", @@ -782,7 +782,7 @@ " \n", " 1\n", " 3458777\n", - " 2020-01-01 00:00:21.440\n", + " 1577836821440\n", " 11594\n", " 17900\n", " [2, 2, 2]\n", @@ -792,7 +792,7 @@ " \n", " 2\n", " 4350716\n", - " 2020-01-01 00:00:48.505\n", + " 1577836848505\n", " 5192\n", " 14217\n", " [14]\n", @@ -802,7 +802,7 @@ " \n", " 3\n", " 2579761\n", - " 2020-01-01 00:06:37.801\n", + " 1577837197801\n", " 9675\n", " 12251\n", " [9, 8, 9]\n", @@ -812,7 +812,7 @@ " \n", " 4\n", " 2048031\n", - " 2020-01-01 00:08:19.297\n", + " 1577837299297\n", " 14877\n", " 12751\n", " [2, 6, 2]\n", @@ -824,19 +824,19 @@ "" ], "text/plain": [ - " session_id date_first item_id_last purchase_id_first \\\n", - "0 3747794 2020-01-01 00:00:01.359 7920 13757 \n", - "1 3458777 2020-01-01 00:00:21.440 11594 17900 \n", - "2 4350716 2020-01-01 00:00:48.505 5192 14217 \n", - "3 2579761 2020-01-01 00:06:37.801 9675 12251 \n", - "4 2048031 2020-01-01 00:08:19.297 14877 12751 \n", + " session_id timestamp_first item_id_last purchase_id_first f_47_list_seq \\\n", + "0 3747794 1577836801359 7920 13757 [3, 6, 14] \n", + "1 3458777 1577836821440 11594 17900 [2, 2, 2] \n", + "2 4350716 1577836848505 5192 14217 [14] \n", + "3 2579761 1577837197801 9675 12251 [9, 8, 9] \n", + "4 2048031 1577837299297 14877 12751 [2, 6, 2] \n", "\n", - " f_47_list_seq f_68_list_seq item_id_list_seq \n", - "0 [3, 6, 14] [2, 10, 8] [538, 4177, 7920] \n", - "1 [2, 2, 2] [10, 45, 7] [14809, 7840, 11594] \n", - "2 [14] [9] [5192] \n", - "3 [9, 8, 9] [15, 4, 4] [19431, 16369, 9675] \n", - "4 [2, 6, 2] [6, 2, 10] [779, 15326, 14877] " + " f_68_list_seq item_id_list_seq \n", + "0 [2, 10, 8] [538, 4177, 7920] \n", + "1 [10, 45, 7] [14809, 7840, 11594] \n", + "2 [9] [5192] \n", + "3 [15, 4, 4] [19431, 16369, 9675] \n", + "4 [6, 2, 10] [779, 15326, 14877] " ] }, "execution_count": 16, @@ -918,7 +918,7 @@ "source": [ "#### Hyperparameters\n", "\n", - "We use the following hyperparameters, we found during experimentations." + "We use the following hyperparameters that we found during experimentations." ] }, { @@ -1176,13 +1176,13 @@ "output_type": "stream", "text": [ "Epoch 1/3\n", - "900/900 [==============================] - 193s 204ms/step - loss: 7.9515 - recall_at_100: 0.3355 - mrr_at_100: 0.0685 - ndcg_at_100: 0.1182 - map_at_100: 0.0685 - precision_at_100: 0.0034 - regularization_loss: 0.0000e+00 - loss_batch: 7.9502 - val_loss: 7.8314 - val_recall_at_100: 0.5061 - val_mrr_at_100: 0.1206 - val_ndcg_at_100: 0.1948 - val_map_at_100: 0.1206 - val_precision_at_100: 0.0051 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.6789\n", + "900/900 [==============================] - 172s 181ms/step - loss: 7.9477 - recall_at_100: 0.3383 - mrr_at_100: 0.0690 - ndcg_at_100: 0.1192 - map_at_100: 0.0690 - precision_at_100: 0.0034 - regularization_loss: 0.0000e+00 - loss_batch: 7.9465 - val_loss: 7.8318 - val_recall_at_100: 0.5073 - val_mrr_at_100: 0.1207 - val_ndcg_at_100: 0.1950 - val_map_at_100: 0.1207 - val_precision_at_100: 0.0051 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.6509\n", "Epoch 2/3\n", - "900/900 [==============================] - 163s 179ms/step - loss: 7.4533 - recall_at_100: 0.4877 - mrr_at_100: 0.1219 - ndcg_at_100: 0.1921 - map_at_100: 0.1219 - precision_at_100: 0.0049 - regularization_loss: 0.0000e+00 - loss_batch: 7.4520 - val_loss: 7.8223 - val_recall_at_100: 0.5003 - val_mrr_at_100: 0.1263 - val_ndcg_at_100: 0.1985 - val_map_at_100: 0.1263 - val_precision_at_100: 0.0050 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.6835\n", + "900/900 [==============================] - 161s 177ms/step - loss: 7.4508 - recall_at_100: 0.4886 - mrr_at_100: 0.1221 - ndcg_at_100: 0.1925 - map_at_100: 0.1221 - precision_at_100: 0.0049 - regularization_loss: 0.0000e+00 - loss_batch: 7.4495 - val_loss: 7.8267 - val_recall_at_100: 0.5003 - val_mrr_at_100: 0.1250 - val_ndcg_at_100: 0.1973 - val_map_at_100: 0.1250 - val_precision_at_100: 0.0050 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.6584\n", "Epoch 3/3\n", - "900/900 [==============================] - 162s 179ms/step - loss: 7.3036 - recall_at_100: 0.5498 - mrr_at_100: 0.1468 - ndcg_at_100: 0.2246 - map_at_100: 0.1468 - precision_at_100: 0.0055 - regularization_loss: 0.0000e+00 - loss_batch: 7.3014 - val_loss: 7.8592 - val_recall_at_100: 0.4952 - val_mrr_at_100: 0.1279 - val_ndcg_at_100: 0.1988 - val_map_at_100: 0.1279 - val_precision_at_100: 0.0050 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.7491\n", - "CPU times: user 6min 28s, sys: 4min 3s, total: 10min 31s\n", - "Wall time: 8min 41s\n" + "900/900 [==============================] - 160s 176ms/step - loss: 7.3057 - recall_at_100: 0.5503 - mrr_at_100: 0.1466 - ndcg_at_100: 0.2246 - map_at_100: 0.1466 - precision_at_100: 0.0055 - regularization_loss: 0.0000e+00 - loss_batch: 7.3038 - val_loss: 7.8918 - val_recall_at_100: 0.4900 - val_mrr_at_100: 0.1227 - val_ndcg_at_100: 0.1932 - val_map_at_100: 0.1227 - val_precision_at_100: 0.0049 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.7488\n", + "CPU times: user 6min 14s, sys: 3min 59s, total: 10min 14s\n", + "Wall time: 8min 15s\n" ] } ], @@ -1213,13 +1213,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "78/78 [==============================] - 13s 158ms/step - loss: 7.8592 - recall_at_100: 0.4953 - mrr_at_100: 0.1269 - ndcg_at_100: 0.1980 - map_at_100: 0.1269 - precision_at_100: 0.0050 - regularization_loss: 0.0000e+00 - loss_batch: 7.8569\n" + "78/78 [==============================] - 13s 157ms/step - loss: 7.8918 - recall_at_100: 0.4901 - mrr_at_100: 0.1223 - ndcg_at_100: 0.1929 - map_at_100: 0.1223 - precision_at_100: 0.0049 - regularization_loss: 0.0000e+00 - loss_batch: 7.8888\n" ] }, { "data": { "text/plain": [ - "0.1279435157775879" + "0.12273602932691574" ] }, "execution_count": 30, @@ -1249,7 +1249,7 @@ { "data": { "text/plain": [ - "86" + "133" ] }, "execution_count": 31, @@ -1302,7 +1302,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 32, "id": "9275b012", "metadata": { "tags": [] @@ -1345,7 +1345,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 33, "id": "33820698-9303-44bc-8798-b74e753e6a8c", "metadata": {}, "outputs": [], @@ -1369,7 +1369,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "id": "fcd660b5", "metadata": {}, "outputs": [], @@ -1391,7 +1391,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "id": "deea812a", "metadata": {}, "outputs": [], @@ -1422,7 +1422,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 36, "id": "921df537-5577-46f4-a656-c2c420483751", "metadata": {}, "outputs": [], @@ -1432,7 +1432,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 37, "id": "7fa8d645", "metadata": {}, "outputs": [], @@ -1454,7 +1454,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 38, "id": "17e9c24e", "metadata": {}, "outputs": [], @@ -1473,7 +1473,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 39, "id": "7673905c", "metadata": {}, "outputs": [], @@ -1503,7 +1503,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 40, "id": "7dfa4858-d87c-43db-a6fa-c02a55e83941", "metadata": {}, "outputs": [ @@ -1511,7 +1511,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "2022-11-18 14:58:36.833089: I tensorflow/stream_executor/cuda/cuda_dnn.cc:424] Loaded cuDNN version 8500\n" + "2022-12-14 18:39:55.579998: I tensorflow/stream_executor/cuda/cuda_dnn.cc:424] Loaded cuDNN version 8500\n" ] }, { @@ -1537,11 +1537,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "900/900 [==============================] - 177s 186ms/step - loss: 7.9902 - recall_at_100: 0.3257 - mrr_at_100: 0.0710 - ndcg_at_100: 0.1184 - map_at_100: 0.0710 - precision_at_100: 0.0033 - regularization_loss: 0.0170 - loss_batch: 7.9890 - val_loss: 7.8630 - val_recall_at_100: 0.5017 - val_mrr_at_100: 0.1217 - val_ndcg_at_100: 0.1945 - val_map_at_100: 0.1217 - val_precision_at_100: 0.0050 - val_regularization_loss: 0.0223 - val_loss_batch: 7.6872\n", + "900/900 [==============================] - 177s 186ms/step - loss: 7.9891 - recall_at_100: 0.3269 - mrr_at_100: 0.0705 - ndcg_at_100: 0.1183 - map_at_100: 0.0705 - precision_at_100: 0.0033 - regularization_loss: 0.0175 - loss_batch: 7.9880 - val_loss: 7.8680 - val_recall_at_100: 0.5002 - val_mrr_at_100: 0.1195 - val_ndcg_at_100: 0.1924 - val_map_at_100: 0.1195 - val_precision_at_100: 0.0050 - val_regularization_loss: 0.0226 - val_loss_batch: 7.6988\n", "Epoch 2/3\n", - "900/900 [==============================] - 165s 182ms/step - loss: 7.4587 - recall_at_100: 0.4763 - mrr_at_100: 0.1215 - ndcg_at_100: 0.1895 - map_at_100: 0.1215 - precision_at_100: 0.0048 - regularization_loss: 0.0192 - loss_batch: 7.4572 - val_loss: 7.8587 - val_recall_at_100: 0.4947 - val_mrr_at_100: 0.1330 - val_ndcg_at_100: 0.2026 - val_map_at_100: 0.1330 - val_precision_at_100: 0.0049 - val_regularization_loss: 0.0200 - val_loss_batch: 7.6938\n", + "900/900 [==============================] - 165s 182ms/step - loss: 7.4564 - recall_at_100: 0.4776 - mrr_at_100: 0.1221 - ndcg_at_100: 0.1903 - map_at_100: 0.1221 - precision_at_100: 0.0048 - regularization_loss: 0.0195 - loss_batch: 7.4549 - val_loss: 7.8788 - val_recall_at_100: 0.4914 - val_mrr_at_100: 0.1292 - val_ndcg_at_100: 0.1990 - val_map_at_100: 0.1292 - val_precision_at_100: 0.0049 - val_regularization_loss: 0.0204 - val_loss_batch: 7.6964\n", "Epoch 3/3\n", - "900/900 [==============================] - 167s 184ms/step - loss: 7.2690 - recall_at_100: 0.5503 - mrr_at_100: 0.1487 - ndcg_at_100: 0.2261 - map_at_100: 0.1487 - precision_at_100: 0.0055 - regularization_loss: 0.0197 - loss_batch: 7.2667 - val_loss: 7.9709 - val_recall_at_100: 0.4830 - val_mrr_at_100: 0.1289 - val_ndcg_at_100: 0.1971 - val_map_at_100: 0.1289 - val_precision_at_100: 0.0048 - val_regularization_loss: 0.0189 - val_loss_batch: 7.8040\n" + "900/900 [==============================] - 165s 182ms/step - loss: 7.2698 - recall_at_100: 0.5502 - mrr_at_100: 0.1489 - ndcg_at_100: 0.2264 - map_at_100: 0.1489 - precision_at_100: 0.0055 - regularization_loss: 0.0204 - loss_batch: 7.2677 - val_loss: 7.9789 - val_recall_at_100: 0.4848 - val_mrr_at_100: 0.1253 - val_ndcg_at_100: 0.1943 - val_map_at_100: 0.1253 - val_precision_at_100: 0.0048 - val_regularization_loss: 0.0200 - val_loss_batch: 7.7853\n" ] } ], @@ -1563,7 +1563,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 41, "id": "2676f668", "metadata": {}, "outputs": [ @@ -1571,16 +1571,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "78/78 [==============================] - 13s 164ms/step - loss: 7.9709 - recall_at_100: 0.4813 - mrr_at_100: 0.1286 - ndcg_at_100: 0.1964 - map_at_100: 0.1286 - precision_at_100: 0.0048 - regularization_loss: 0.0189 - loss_batch: 7.9674\n" + "78/78 [==============================] - 12s 154ms/step - loss: 7.9789 - recall_at_100: 0.4841 - mrr_at_100: 0.1246 - ndcg_at_100: 0.1937 - map_at_100: 0.1246 - precision_at_100: 0.0048 - regularization_loss: 0.0200 - loss_batch: 7.9748\n" ] }, { "data": { "text/plain": [ - "0.12894360721111298" + "0.12525714933872223" ] }, - "execution_count": 40, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1592,10 +1592,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "id": "ba44d4ae-38ba-420d-9d25-3c58490f4883", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "89887" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "del model_bi_lstm\n", "gc.collect()" @@ -1625,7 +1636,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 43, "id": "699cc21e-56d1-4ea5-a028-fd82becc5c79", "metadata": {}, "outputs": [], @@ -1635,7 +1646,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 44, "id": "19d1d918-fc3b-45f0-aee0-876b30897bcd", "metadata": {}, "outputs": [], @@ -1673,17 +1684,26 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 45, "id": "6d523493-2fa0-4fbb-bc1c-52a522532f62", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.8/dist-packages/merlin/schema/tags.py:148: UserWarning: Compound tags like Tags.ITEM_ID have been deprecated and will be removed in a future version. Please use the atomic versions of these tags, like [, ].\n", + " warnings.warn(\n" + ] + } + ], "source": [ "batch = mm.sample_batch(train, batch_size=128, include_targets=False, to_ragged=True)" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 46, "id": "b4a65115-560f-4509-8a24-8b57a8071339", "metadata": {}, "outputs": [ @@ -1693,7 +1713,7 @@ "TensorShape([128, None, 288])" ] }, - "execution_count": 44, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1704,7 +1724,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 47, "id": "75fc5a5c-dca6-47f4-94f2-28ac139df902", "metadata": {}, "outputs": [ @@ -1714,7 +1734,7 @@ "TensorShape([128, 256])" ] }, - "execution_count": 45, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -1749,7 +1769,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 48, "id": "01b8243b-22de-4c68-a277-76216bad0346", "metadata": {}, "outputs": [], @@ -1764,7 +1784,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 49, "id": "cdef6ac0-011f-42ac-bd70-0b4bcced6576", "metadata": {}, "outputs": [], @@ -1791,24 +1811,17 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 50, "id": "33f62939-b2af-498c-8885-44712923811a", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2022-11-22 20:18:02.023558: I tensorflow/stream_executor/cuda/cuda_dnn.cc:424] Loaded cuDNN version 8500\n" - ] - }, { "data": { "text/plain": [ "TensorShape([128, 256])" ] }, - "execution_count": 49, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } @@ -1827,7 +1840,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 51, "id": "c2ac9fc9-4e11-413b-ac0f-f18a60fca428", "metadata": {}, "outputs": [], @@ -1849,7 +1862,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 52, "id": "bc42a786-17fb-4321-97c9-493f1ecdb958", "metadata": {}, "outputs": [ @@ -1859,7 +1872,7 @@ "TensorShape([128, 512])" ] }, - "execution_count": 51, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -1870,7 +1883,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 53, "id": "a4d076c5-a7da-46f0-bebd-4ea9165c1a53", "metadata": {}, "outputs": [], @@ -1885,7 +1898,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 54, "id": "48c793fe-8bed-452b-bc50-c2f9df67d906", "metadata": {}, "outputs": [], @@ -1899,7 +1912,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 55, "id": "afbc3f18-a792-47ab-9fa9-10306ad43203", "metadata": {}, "outputs": [], @@ -1917,7 +1930,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 56, "id": "5b2be155-a8ed-4a7b-bed4-6a9e7663d58d", "metadata": {}, "outputs": [], @@ -1939,7 +1952,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 57, "id": "43f5a3a0-6218-4162-ad8b-319d0581602a", "metadata": {}, "outputs": [ @@ -1948,14 +1961,14 @@ "output_type": "stream", "text": [ "Epoch 1/3\n", - "WARNING:tensorflow:Gradients do not exist for variables ['model_1/mask_emb:0', 'transformer/layer_._0/rel_attn/r_s_bias:0', 'transformer/layer_._0/rel_attn/seg_embed:0', 'transformer/layer_._1/rel_attn/r_s_bias:0', 'transformer/layer_._1/rel_attn/seg_embed:0'] when minimizing the loss. If you're using `model.compile()`, did you forget to provide a `loss`argument?\n" + "WARNING:tensorflow:Gradients do not exist for variables ['model_2/mask_emb:0', 'transformer/layer_._0/rel_attn/r_s_bias:0', 'transformer/layer_._0/rel_attn/seg_embed:0', 'transformer/layer_._1/rel_attn/r_s_bias:0', 'transformer/layer_._1/rel_attn/seg_embed:0'] when minimizing the loss. If you're using `model.compile()`, did you forget to provide a `loss`argument?\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/indexed_slices.py:444: UserWarning: Converting sparse IndexedSlices(IndexedSlices(indices=Tensor(\"gradient_tape/model_1/parallel_block_3/sequential_block_5/xl_net_block/prepare_transformer_inputs_4/RaggedToTensor/boolean_mask_1/GatherV2:0\", shape=(None,), dtype=int32), values=Tensor(\"gradient_tape/model_1/parallel_block_3/sequential_block_5/xl_net_block/prepare_transformer_inputs_4/RaggedToTensor/boolean_mask/GatherV2:0\", shape=(None, 256), dtype=float32), dense_shape=Tensor(\"gradient_tape/model_1/parallel_block_3/sequential_block_5/xl_net_block/prepare_transformer_inputs_4/RaggedToTensor/Shape:0\", shape=(2,), dtype=int32))) to a dense Tensor of unknown shape. This may consume a large amount of memory.\n", + "/usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/indexed_slices.py:444: UserWarning: Converting sparse IndexedSlices(IndexedSlices(indices=Tensor(\"gradient_tape/model_2/parallel_block_6/sequential_block_7/xl_net_block/prepare_transformer_inputs_4/RaggedToTensor/boolean_mask_1/GatherV2:0\", shape=(None,), dtype=int32), values=Tensor(\"gradient_tape/model_2/parallel_block_6/sequential_block_7/xl_net_block/prepare_transformer_inputs_4/RaggedToTensor/boolean_mask/GatherV2:0\", shape=(None, 256), dtype=float32), dense_shape=Tensor(\"gradient_tape/model_2/parallel_block_6/sequential_block_7/xl_net_block/prepare_transformer_inputs_4/RaggedToTensor/Shape:0\", shape=(2,), dtype=int32))) to a dense Tensor of unknown shape. This may consume a large amount of memory.\n", " warnings.warn(\n" ] }, @@ -1963,21 +1976,21 @@ "name": "stdout", "output_type": "stream", "text": [ - "WARNING:tensorflow:Gradients do not exist for variables ['model_1/mask_emb:0', 'transformer/layer_._0/rel_attn/r_s_bias:0', 'transformer/layer_._0/rel_attn/seg_embed:0', 'transformer/layer_._1/rel_attn/r_s_bias:0', 'transformer/layer_._1/rel_attn/seg_embed:0'] when minimizing the loss. If you're using `model.compile()`, did you forget to provide a `loss`argument?\n", - "900/900 [==============================] - 195s 204ms/step - loss: 8.1952 - recall_at_100: 0.2791 - mrr_at_100: 0.0532 - ndcg_at_100: 0.0947 - map_at_100: 0.0532 - precision_at_100: 0.0028 - regularization_loss: 0.0000e+00 - loss_batch: 8.1939 - val_loss: 8.0644 - val_recall_at_100: 0.4416 - val_mrr_at_100: 0.1056 - val_ndcg_at_100: 0.1695 - val_map_at_100: 0.1056 - val_precision_at_100: 0.0044 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.8888\n", + "WARNING:tensorflow:Gradients do not exist for variables ['model_2/mask_emb:0', 'transformer/layer_._0/rel_attn/r_s_bias:0', 'transformer/layer_._0/rel_attn/seg_embed:0', 'transformer/layer_._1/rel_attn/r_s_bias:0', 'transformer/layer_._1/rel_attn/seg_embed:0'] when minimizing the loss. If you're using `model.compile()`, did you forget to provide a `loss`argument?\n", + "900/900 [==============================] - 188s 200ms/step - loss: 8.2095 - recall_at_100: 0.2764 - mrr_at_100: 0.0520 - ndcg_at_100: 0.0932 - map_at_100: 0.0520 - precision_at_100: 0.0028 - regularization_loss: 0.0000e+00 - loss_batch: 8.2083 - val_loss: 8.0752 - val_recall_at_100: 0.4398 - val_mrr_at_100: 0.1011 - val_ndcg_at_100: 0.1656 - val_map_at_100: 0.1011 - val_precision_at_100: 0.0044 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.8628\n", "Epoch 2/3\n", - "900/900 [==============================] - 179s 197ms/step - loss: 7.6537 - recall_at_100: 0.4164 - mrr_at_100: 0.1019 - ndcg_at_100: 0.1617 - map_at_100: 0.1019 - precision_at_100: 0.0042 - regularization_loss: 0.0000e+00 - loss_batch: 7.6524 - val_loss: 8.0413 - val_recall_at_100: 0.4529 - val_mrr_at_100: 0.1153 - val_ndcg_at_100: 0.1803 - val_map_at_100: 0.1153 - val_precision_at_100: 0.0045 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.8238\n", + "900/900 [==============================] - 178s 196ms/step - loss: 7.6697 - recall_at_100: 0.4114 - mrr_at_100: 0.0995 - ndcg_at_100: 0.1588 - map_at_100: 0.0995 - precision_at_100: 0.0041 - regularization_loss: 0.0000e+00 - loss_batch: 7.6682 - val_loss: 8.0399 - val_recall_at_100: 0.4532 - val_mrr_at_100: 0.1148 - val_ndcg_at_100: 0.1799 - val_map_at_100: 0.1148 - val_precision_at_100: 0.0045 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.8145\n", "Epoch 3/3\n", - "900/900 [==============================] - 179s 197ms/step - loss: 7.4630 - recall_at_100: 0.4873 - mrr_at_100: 0.1273 - ndcg_at_100: 0.1963 - map_at_100: 0.1273 - precision_at_100: 0.0049 - regularization_loss: 0.0000e+00 - loss_batch: 7.4609 - val_loss: 8.1287 - val_recall_at_100: 0.4509 - val_mrr_at_100: 0.1180 - val_ndcg_at_100: 0.1820 - val_map_at_100: 0.1180 - val_precision_at_100: 0.0045 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.9060\n" + "900/900 [==============================] - 178s 196ms/step - loss: 7.4710 - recall_at_100: 0.4847 - mrr_at_100: 0.1263 - ndcg_at_100: 0.1949 - map_at_100: 0.1263 - precision_at_100: 0.0048 - regularization_loss: 0.0000e+00 - loss_batch: 7.4690 - val_loss: 8.1183 - val_recall_at_100: 0.4502 - val_mrr_at_100: 0.1155 - val_ndcg_at_100: 0.1799 - val_map_at_100: 0.1155 - val_precision_at_100: 0.0045 - val_regularization_loss: 0.0000e+00 - val_loss_batch: 7.9078\n" ] }, { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 56, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -1999,7 +2012,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 58, "id": "0847c456-c401-4284-94fe-eb888b2f0e0c", "metadata": {}, "outputs": [ @@ -2007,16 +2020,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "78/78 [==============================] - 13s 165ms/step - loss: 8.1287 - recall_at_100: 0.4515 - mrr_at_100: 0.1172 - ndcg_at_100: 0.1815 - map_at_100: 0.1172 - precision_at_100: 0.0045 - regularization_loss: 0.0000e+00 - loss_batch: 8.1239\n" + "78/78 [==============================] - 13s 167ms/step - loss: 8.1183 - recall_at_100: 0.4508 - mrr_at_100: 0.1146 - ndcg_at_100: 0.1792 - map_at_100: 0.1146 - precision_at_100: 0.0045 - regularization_loss: 0.0000e+00 - loss_batch: 8.1138\n" ] }, { "data": { "text/plain": [ - "0.1180129125714302" + "0.11548776179552078" ] }, - "execution_count": 57, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -2028,10 +2041,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 59, "id": "c7dae36f-6a77-4984-8d47-d6eb7f647f22", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "134" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "del model_transformer\n", "gc.collect()"