{
  "id": 324094,
  "title": "4th place solution",
  "url": "/competitions/h-and-m-personalized-fashion-recommendations/writeups/hongwei-zhang-4th-place-solution",
  "author_name": "",
  "post_date": "2022-05-10T09:13:34.490Z",
  "votes": 65,
  "comment_count": 12,
  "views": 0,
  "content": "<p>Thanks to H&amp;M and Kaggle Team&nbsp;for organizing such a great recommendation competition.<br>\nThanks <a href=\"https://www.kaggle.com/paweljankiewicz\" target=\"_blank\">@paweljankiewicz</a>, <a href=\"https://www.kaggle.com/titericz\" target=\"_blank\">@titericz</a>, <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> and many Kagglers for their great discussions and notebooks.<br>\nI hope to get a solo gold metal this time, so I decided to do this competition by myself in the beginning.</p>\n<h1>Overview</h1>\n<p>I followed the same pipeline as <a href=\"https://www.kaggle.com/paweljankiewicz\" target=\"_blank\">@paweljankiewicz</a> suggested in <a href=\"kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/307288\" target=\"_blank\">Addressing common questions and what the competition is really about</a> . First, generate candidates using different recall models for each customers. Second, build a ranking model that ranks the candidates within customer.<br>\n<a href=\"https://postimg.cc/PNQsRDhB\" target=\"_blank\"><img src=\"https://i.postimg.cc/CMWhdC2L/arch.png\" alt=\"arch.png\"></a></p>\n<h1>CV setup</h1>\n<p>I mainly followed <a href=\"https://www.kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/308919\" target=\"_blank\">How To Setup Local CV</a>, I created 5 folds and used 3 folds as training data. I also tried more training data, but it didn’t increase the local CV and LB.</p>\n<h1>Recall model</h1>\n<p>I developed 4 recall models in total.</p>\n<ul>\n<li>Item2item CF: the relationship between the pair of items (the user who bought Y, also bought Z).</li>\n<li>repurchase: latest 20 purchased products by each customers.</li>\n<li>popular: popular ranking in last week.</li>\n<li>Two Tower MMoE: I mainly focused on improving the performance of this model. Because it can generate candidates of arbitrary length for all users, and the user/item embeddings (similarity) can also be used as an important feature for ranking model.</li>\n</ul>\n<p>I used a gating network to make sure that the user tower can learn well by using different experts for recent active customers and non active customers.<br>\n<a href=\"https://postimg.cc/phyh6v5S\" target=\"_blank\"><img src=\"https://i.postimg.cc/j54HCdxR/user-tower.png\" alt=\"user-tower.png\"></a><br>\n<a href=\"https://postimg.cc/crGCQwh2\" target=\"_blank\"><img src=\"https://i.postimg.cc/RVNtxTHS/item-tower.png\" alt=\"item-tower.png\"></a><br>\n<a href=\"https://postimg.cc/kRQnjYsZ\" target=\"_blank\"><img src=\"https://i.postimg.cc/wMP7jSm6/loss.png\" alt=\"loss.png\"></a></p>\n<h1>Ranking model</h1>\n<p>I mainly used lightgbm with lambda-rank objective. I also implement DCN model described in <a href=\"https://arxiv.org/abs/2008.13535\" target=\"_blank\">https://arxiv.org/abs/2008.13535</a>. But I didn’t have enough time to tune it. The score of lightgbm is much better.</p>\n<h1>Cold-start users</h1>\n<p>Two Tower MMoE can also generate candidates using user demographic features for customers without purchase log.</p>\n<h1>Cold-start items</h1>\n<p>Besides product meta features, I also extracted the following features from text and image.</p>\n<ul>\n<li>Text: Extract TF-IDF features from product description, cluster products using SVD + K-means. Then use cluster id as feature.</li>\n<li>Image: Extract image vectors using pre-trained tf_efficientnet_b3_ns backbone, cluster products using PCA + K-means.  Then use cluster id as feature.</li>\n</ul>\n<h1>Submission</h1>\n<p>best local CV is 0.039, LB is 0.0349.<br>\nMy final submission combined my previous submissions by<br>\n<a href=\"https://www.kaggle.com/code/titericz/h-m-ensembling-how-to\" target=\"_blank\">h-m-ensembling-how-to</a></p>\n<h1>to be updated</h1>",
  "messages": [
    {
      "id": "1783066",
      "postDate": "05/10/2022 05:11:23",
      "content": "<p>Thanks to H&amp;M and Kaggle Team&nbsp;for organizing such a great recommendation competition.<br>\nThanks <a href=\"https://www.kaggle.com/paweljankiewicz\" target=\"_blank\">@paweljankiewicz</a>, <a href=\"https://www.kaggle.com/titericz\" target=\"_blank\">@titericz</a>, <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> and many Kagglers for their great discussions and notebooks.<br>\nI hope to get a solo gold metal this time, so I decided to do this competition by myself in the beginning.</p>\n<h1>Overview</h1>\n<p>I followed the same pipeline as <a href=\"https://www.kaggle.com/paweljankiewicz\" target=\"_blank\">@paweljankiewicz</a> suggested in <a href=\"kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/307288\" target=\"_blank\">Addressing common questions and what the competition is really about</a> . First, generate candidates using different recall models for each customers. Second, build a ranking model that ranks the candidates within customer.<br>\n<a href=\"https://postimg.cc/PNQsRDhB\" target=\"_blank\"><img src=\"https://i.postimg.cc/CMWhdC2L/arch.png\" alt=\"arch.png\"></a></p>\n<h1>CV setup</h1>\n<p>I mainly followed <a href=\"https://www.kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/308919\" target=\"_blank\">How To Setup Local CV</a>, I created 5 folds and used 3 folds as training data. I also tried more training data, but it didn’t increase the local CV and LB.</p>\n<h1>Recall model</h1>\n<p>I developed 4 recall models in total.</p>\n<ul>\n<li>Item2item CF: the relationship between the pair of items (the user who bought Y, also bought Z).</li>\n<li>repurchase: latest 20 purchased products by each customers.</li>\n<li>popular: popular ranking in last week.</li>\n<li>Two Tower MMoE: I mainly focused on improving the performance of this model. Because it can generate candidates of arbitrary length for all users, and the user/item embeddings (similarity) can also be used as an important feature for ranking model.</li>\n</ul>\n<p>I used a gating network to make sure that the user tower can learn well by using different experts for recent active customers and non active customers.<br>\n<a href=\"https://postimg.cc/phyh6v5S\" target=\"_blank\"><img src=\"https://i.postimg.cc/j54HCdxR/user-tower.png\" alt=\"user-tower.png\"></a><br>\n<a href=\"https://postimg.cc/crGCQwh2\" target=\"_blank\"><img src=\"https://i.postimg.cc/RVNtxTHS/item-tower.png\" alt=\"item-tower.png\"></a><br>\n<a href=\"https://postimg.cc/kRQnjYsZ\" target=\"_blank\"><img src=\"https://i.postimg.cc/wMP7jSm6/loss.png\" alt=\"loss.png\"></a></p>\n<h1>Ranking model</h1>\n<p>I mainly used lightgbm with lambda-rank objective. I also implement DCN model described in <a href=\"https://arxiv.org/abs/2008.13535\" target=\"_blank\">https://arxiv.org/abs/2008.13535</a>. But I didn’t have enough time to tune it. The score of lightgbm is much better.</p>\n<h1>Cold-start users</h1>\n<p>Two Tower MMoE can also generate candidates using user demographic features for customers without purchase log.</p>\n<h1>Cold-start items</h1>\n<p>Besides product meta features, I also extracted the following features from text and image.</p>\n<ul>\n<li>Text: Extract TF-IDF features from product description, cluster products using SVD + K-means. Then use cluster id as feature.</li>\n<li>Image: Extract image vectors using pre-trained tf_efficientnet_b3_ns backbone, cluster products using PCA + K-means.  Then use cluster id as feature.</li>\n</ul>\n<h1>Submission</h1>\n<p>best local CV is 0.039, LB is 0.0349.<br>\nMy final submission combined my previous submissions by<br>\n<a href=\"https://www.kaggle.com/code/titericz/h-m-ensembling-how-to\" target=\"_blank\">h-m-ensembling-how-to</a></p>\n<h1>to be updated</h1>",
      "rawMarkdown": "Thanks to H&M and Kaggle Team for organizing such a great recommendation competition.\nThanks @paweljankiewicz, @titericz, @cdeotte and many Kagglers for their great discussions and notebooks.\nI hope to get a solo gold metal this time, so I decided to do this competition by myself in the beginning.\n\n# Overview\nI followed the same pipeline as @paweljankiewicz suggested in [Addressing common questions and what the competition is really about](kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/307288) . First, generate candidates using different recall models for each customers. Second, build a ranking model that ranks the candidates within customer.\n[![arch.png](https://i.postimg.cc/CMWhdC2L/arch.png)](https://postimg.cc/PNQsRDhB)\n\n# CV setup\nI mainly followed [How To Setup Local CV](https://www.kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/308919), I created 5 folds and used 3 folds as training data. I also tried more training data, but it didn’t increase the local CV and LB.\n\n# Recall model\nI developed 4 recall models in total.\n* Item2item CF: the relationship between the pair of items (the user who bought Y, also bought Z).\n* repurchase: latest 20 purchased products by each customers.\n* popular: popular ranking in last week.\n* Two Tower MMoE: I mainly focused on improving the performance of this model. Because it can generate candidates of arbitrary length for all users, and the user/item embeddings (similarity) can also be used as an important feature for ranking model.\n\nI used a gating network to make sure that the user tower can learn well by using different experts for recent active customers and non active customers.\n[![user-tower.png](https://i.postimg.cc/j54HCdxR/user-tower.png)](https://postimg.cc/phyh6v5S)\n[![item-tower.png](https://i.postimg.cc/RVNtxTHS/item-tower.png)](https://postimg.cc/crGCQwh2)\n[![loss.png](https://i.postimg.cc/wMP7jSm6/loss.png)](https://postimg.cc/kRQnjYsZ)\n\n# Ranking model\nI mainly used lightgbm with lambda-rank objective. I also implement DCN model described in https://arxiv.org/abs/2008.13535. But I didn’t have enough time to tune it. The score of lightgbm is much better.\n\n# Cold-start users\nTwo Tower MMoE can also generate candidates using user demographic features for customers without purchase log.\n\n# Cold-start items\nBesides product meta features, I also extracted the following features from text and image.\n* Text: Extract TF-IDF features from product description, cluster products using SVD + K-means. Then use cluster id as feature.\n* Image: Extract image vectors using pre-trained tf_efficientnet_b3_ns backbone, cluster products using PCA + K-means.  Then use cluster id as feature.\n\n# Submission\nbest local CV is 0.039, LB is 0.0349.\nMy final submission combined my previous submissions by\n[h-m-ensembling-how-to](https://www.kaggle.com/code/titericz/h-m-ensembling-how-to)\n\n# to be updated",
      "votes": null
    },
    {
      "id": "1783072",
      "postDate": "05/10/2022 05:20:04",
      "content": "<p>Congratulations to my former colleague for winning solo gold and taking a big step forward on the path to becoming a GM!</p>",
      "rawMarkdown": "Congratulations to my former colleague for winning solo gold and taking a big step forward on the path to becoming a GM!",
      "votes": null
    },
    {
      "id": "1783116",
      "postDate": "05/10/2022 06:18:05",
      "content": "<p>Congratulations! Great work!</p>",
      "rawMarkdown": "Congratulations! Great work!",
      "votes": null
    },
    {
      "id": "1783140",
      "postDate": "05/10/2022 06:43:14",
      "content": "<p>Congratulations！</p>",
      "rawMarkdown": "Congratulations！",
      "votes": null
    },
    {
      "id": "1783239",
      "postDate": "05/10/2022 08:07:49",
      "content": "<p>Amazing! Congratulations!</p>",
      "rawMarkdown": "Amazing! Congratulations!",
      "votes": null
    },
    {
      "id": "1783380",
      "postDate": "05/10/2022 10:55:48",
      "content": "<p>Thanks a lot for sharing this with us! Great explanation!</p>",
      "rawMarkdown": "Thanks a lot for sharing this with us! Great explanation!",
      "votes": null
    },
    {
      "id": "1783383",
      "postDate": "05/10/2022 11:00:20",
      "content": "<p>Congrats!Two Tower MMoE recall should have much fun</p>",
      "rawMarkdown": "Congrats!Two Tower MMoE recall should have much fun",
      "votes": null
    },
    {
      "id": "1783427",
      "postDate": "05/10/2022 11:50:26",
      "content": "<p>Thanks! But honestly it is really challenge to train a NN model with so many cold users.</p>",
      "rawMarkdown": "Thanks! But honestly it is really challenge to train a NN model with so many cold users.",
      "votes": null
    },
    {
      "id": "1783460",
      "postDate": "05/10/2022 12:17:13",
      "content": "<p>Congrats! your tow tower MMoE model is very interesting.  to get greater user representation your gated NN learn from users' profile to control the \"importance\" between user static profile and user history behavior sequence.  btw，how is LB or oof score of this mmoe model?</p>",
      "rawMarkdown": "Congrats! your tow tower MMoE model is very interesting.  to get greater user representation your gated NN learn from users' profile to control the \"importance\" between user static profile and user history behavior sequence.  btw，how is LB or oof score of this mmoe model?",
      "votes": null
    },
    {
      "id": "1783487",
      "postDate": "05/10/2022 12:32:44",
      "content": "<p><a href=\"https://www.kaggle.com/biubiug\" target=\"_blank\">@biubiug</a> </p>\n<blockquote>\n  <p>how is LB or oof score of this mmoe model?</p>\n</blockquote>\n<p>I didn't submit it. Actually I mainly focused on improving the recall of this model instead of mAP. I only calculated mAP@12 local as a reference, it is around 0.025 for last week.</p>",
      "rawMarkdown": "biubiug \n\n> how is LB or oof score of this mmoe model?\n\nI didn't submit it. Actually I mainly focused on improving the recall of this model instead of mAP. I only calculated mAP@12 local as a reference, it is around 0.025 for last week.",
      "votes": null
    },
    {
      "id": "1785485",
      "postDate": "05/12/2022 06:14:42",
      "content": "<p><a href=\"https://www.kaggle.com/hongweizhang\" target=\"_blank\">@hongweizhang</a> congratulations! and thanks for the detailed write up :)</p>",
      "rawMarkdown": "hongweizhang congratulations! and thanks for the detailed write up :)",
      "votes": null
    },
    {
      "id": "1785693",
      "postDate": "05/12/2022 10:23:04",
      "content": "<p>Thanks a lot for sharing! Great explanation</p>",
      "rawMarkdown": "Thanks a lot for sharing! Great explanation",
      "votes": null
    },
    {
      "id": "1794544",
      "postDate": "05/18/2022 23:15:48",
      "content": "<p><a href=\"https://www.kaggle.com/hongweizhang\" target=\"_blank\">@hongweizhang</a> Hi, the design of MMoE tower is very interesting. Can you give more details? What's the input of the gate? How to get time embedding? Is it one feature you designed?</p>",
      "rawMarkdown": "hongweizhang Hi, the design of MMoE tower is very interesting. Can you give more details? What's the input of the gate? How to get time embedding? Is it one feature you designed?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1783072,
      "author_name": "haqishen",
      "author_url": "",
      "post_date": "05/10/2022 05:20:04",
      "content": "<p>Congratulations to my former colleague for winning solo gold and taking a big step forward on the path to becoming a GM!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1783116,
      "author_name": "alexkim2",
      "author_url": "",
      "post_date": "05/10/2022 06:18:05",
      "content": "<p>Congratulations! Great work!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1783140,
      "author_name": "xuxiaodong",
      "author_url": "",
      "post_date": "05/10/2022 06:43:14",
      "content": "<p>Congratulations！</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1783239,
      "author_name": "pakersmuch",
      "author_url": "",
      "post_date": "05/10/2022 08:07:49",
      "content": "<p>Amazing! Congratulations!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1783380,
      "author_name": "loicge",
      "author_url": "",
      "post_date": "05/10/2022 10:55:48",
      "content": "<p>Thanks a lot for sharing this with us! Great explanation!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1783383,
      "author_name": "senkin13",
      "author_url": "",
      "post_date": "05/10/2022 11:00:20",
      "content": "<p>Congrats!Two Tower MMoE recall should have much fun</p>",
      "votes": null,
      "replies": [
        {
          "id": 1783427,
          "author_name": "hongweizhang",
          "author_url": "",
          "post_date": "05/10/2022 11:50:26",
          "content": "<p>Thanks! But honestly it is really challenge to train a NN model with so many cold users.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1783460,
      "author_name": "biubiug",
      "author_url": "",
      "post_date": "05/10/2022 12:17:13",
      "content": "<p>Congrats! your tow tower MMoE model is very interesting.  to get greater user representation your gated NN learn from users' profile to control the \"importance\" between user static profile and user history behavior sequence.  btw，how is LB or oof score of this mmoe model?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1783487,
          "author_name": "hongweizhang",
          "author_url": "",
          "post_date": "05/10/2022 12:32:44",
          "content": "<p><a href=\"https://www.kaggle.com/biubiug\" target=\"_blank\">@biubiug</a> </p>\n<blockquote>\n  <p>how is LB or oof score of this mmoe model?</p>\n</blockquote>\n<p>I didn't submit it. Actually I mainly focused on improving the recall of this model instead of mAP. I only calculated mAP@12 local as a reference, it is around 0.025 for last week.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1785485,
      "author_name": "lachlangillian",
      "author_url": "",
      "post_date": "05/12/2022 06:14:42",
      "content": "<p><a href=\"https://www.kaggle.com/hongweizhang\" target=\"_blank\">@hongweizhang</a> congratulations! and thanks for the detailed write up :)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1785693,
      "author_name": "abhishekwani",
      "author_url": "",
      "post_date": "05/12/2022 10:23:04",
      "content": "<p>Thanks a lot for sharing! Great explanation</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1794544,
      "author_name": "laimc01",
      "author_url": "",
      "post_date": "05/18/2022 23:15:48",
      "content": "<p><a href=\"https://www.kaggle.com/hongweizhang\" target=\"_blank\">@hongweizhang</a> Hi, the design of MMoE tower is very interesting. Can you give more details? What's the input of the gate? How to get time embedding? Is it one feature you designed?</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1783066": "Thanks to H&M and Kaggle Team for organizing such a great recommendation competition.\nThanks @paweljankiewicz, @titericz, @cdeotte and many Kagglers for their great discussions and notebooks.\nI hope to get a solo gold metal this time, so I decided to do this competition by myself in the beginning.\n\n# Overview\nI followed the same pipeline as @paweljankiewicz suggested in [Addressing common questions and what the competition is really about](kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/307288) . First, generate candidates using different recall models for each customers. Second, build a ranking model that ranks the candidates within customer.\n[![arch.png](https://i.postimg.cc/CMWhdC2L/arch.png)](https://postimg.cc/PNQsRDhB)\n\n# CV setup\nI mainly followed [How To Setup Local CV](https://www.kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/308919), I created 5 folds and used 3 folds as training data. I also tried more training data, but it didn’t increase the local CV and LB.\n\n# Recall model\nI developed 4 recall models in total.\n* Item2item CF: the relationship between the pair of items (the user who bought Y, also bought Z).\n* repurchase: latest 20 purchased products by each customers.\n* popular: popular ranking in last week.\n* Two Tower MMoE: I mainly focused on improving the performance of this model. Because it can generate candidates of arbitrary length for all users, and the user/item embeddings (similarity) can also be used as an important feature for ranking model.\n\nI used a gating network to make sure that the user tower can learn well by using different experts for recent active customers and non active customers.\n[![user-tower.png](https://i.postimg.cc/j54HCdxR/user-tower.png)](https://postimg.cc/phyh6v5S)\n[![item-tower.png](https://i.postimg.cc/RVNtxTHS/item-tower.png)](https://postimg.cc/crGCQwh2)\n[![loss.png](https://i.postimg.cc/wMP7jSm6/loss.png)](https://postimg.cc/kRQnjYsZ)\n\n# Ranking model\nI mainly used lightgbm with lambda-rank objective. I also implement DCN model described in https://arxiv.org/abs/2008.13535. But I didn’t have enough time to tune it. The score of lightgbm is much better.\n\n# Cold-start users\nTwo Tower MMoE can also generate candidates using user demographic features for customers without purchase log.\n\n# Cold-start items\nBesides product meta features, I also extracted the following features from text and image.\n* Text: Extract TF-IDF features from product description, cluster products using SVD + K-means. Then use cluster id as feature.\n* Image: Extract image vectors using pre-trained tf_efficientnet_b3_ns backbone, cluster products using PCA + K-means.  Then use cluster id as feature.\n\n# Submission\nbest local CV is 0.039, LB is 0.0349.\nMy final submission combined my previous submissions by\n[h-m-ensembling-how-to](https://www.kaggle.com/code/titericz/h-m-ensembling-how-to)\n\n# to be updated",
    "1783072": "Congratulations to my former colleague for winning solo gold and taking a big step forward on the path to becoming a GM!",
    "1783116": "Congratulations! Great work!",
    "1783140": "Congratulations！",
    "1783239": "Amazing! Congratulations!",
    "1783380": "Thanks a lot for sharing this with us! Great explanation!",
    "1783383": "Congrats!Two Tower MMoE recall should have much fun",
    "1783427": "Thanks! But honestly it is really challenge to train a NN model with so many cold users.",
    "1783460": "Congrats! your tow tower MMoE model is very interesting.  to get greater user representation your gated NN learn from users' profile to control the \"importance\" between user static profile and user history behavior sequence.  btw，how is LB or oof score of this mmoe model?",
    "1783487": "biubiug \n\n> how is LB or oof score of this mmoe model?\n\nI didn't submit it. Actually I mainly focused on improving the recall of this model instead of mAP. I only calculated mAP@12 local as a reference, it is around 0.025 for last week.",
    "1785485": "hongweizhang congratulations! and thanks for the detailed write up :)",
    "1785693": "Thanks a lot for sharing! Great explanation",
    "1794544": "hongweizhang Hi, the design of MMoE tower is very interesting. Can you give more details? What's the input of the gate? How to get time embedding? Is it one feature you designed?"
  },
  "source": "meta"
}