{
  "id": 367280,
  "title": "41th Place Solution",
  "url": "/competitions/AI4Code/writeups/dl-41th-place-solution",
  "author_name": "",
  "post_date": "2022-11-20T05:55:28.317Z",
  "votes": 17,
  "comment_count": 1,
  "views": 0,
  "content": "<p><strong>41th Place Solution</strong></p>\n<p>First, thanks Kaggle and the competition hosts for a challenging competition Google AI4Code – Understand Code in Python Notebooks: Predict the  relationship between code and comments. This summarizes the effort of our  team and it was a great experience working with my teammates! This is a  writeup of our collective team effort.</p>\n<h1><strong>Overview</strong></h1>\n<p>Based on Khôi's initial idea, we modify a little bit to get more global context information. We sample 45 cells with shorter code cell's length (10 tokens). If the notebook has less than 45 cells, we dynamically adjust the max length of code cell based on the number of code cell.</p>\n<p>Ensemble from 2 training setting (our setting and Khoi Nguyen setting - 20 code cell with 23 tokens each) also give us a boost on CV and LB. (we don't remember the exact number).</p>\n<ul>\n<li><strong>Model</strong>: Weighted Average of some Point-wise models such as: Distilbert-base-uncased, Deberta-v3-base and Codebert-base</li>\n<li><strong>Data</strong>: All training competition data, no external data. Cross Validation Split: 90/10</li>\n<li><strong>Hardware</strong>: Two A6000-48GB. The largest model training for 3-4 days, the lighting model like distilbert is 1-2 days.</li>\n</ul>\n<p>Some of the results on local CV are detailed in the photos below:</p>\n<p><strong>Initial experimental</strong><br>\nInitial experimentals didn't beat Khoi's baseline:<br>\n<a href=\"https://postimg.cc/DSSp3ZXN\" target=\"_blank\"><img src=\"https://i.postimg.cc/bwT7bSNq/inital-exp1-fix.png\" alt=\"inital-exp1-fix.png\"></a></p>\n<p>Dynamic tokenizer based on number of code cells and FGM training help boost score on both Local CV and LB:</p>\n<p><a href=\"https://postimg.cc/JyJTt2Kc\" target=\"_blank\"><img src=\"https://i.postimg.cc/ZqsXskdg/inital-exp2-fix.png\" alt=\"inital-exp2-fix.png\"></a></p>\n<p><strong>Final &amp; best experimental</strong><br>\nThe best model on both Local CV and LB is Deberta-v3-base.<br>\n<a href=\"https://postimg.cc/JsHxdFwV\" target=\"_blank\"><img src=\"https://i.postimg.cc/P527NG2x/final-exp-fix.png\" alt=\"final-exp-fix.png\"></a></p>\n<p><strong>Inference code:</strong> <a href=\"https://www.kaggle.com/code/dunglt/inference-pct-rank-model?scriptVersionId=101081766\" target=\"_blank\">Inference Ensemble Final Submission</a></p>\n<h1><strong>What worked</strong></h1>\n<h2>[High Impact] Idea</h2>\n<ul>\n<li>Dynamic tokenizer based on number of code cells: Local + 0.007 and LB + 0.005</li>\n<li>Local tokenizer to boost training speed</li>\n</ul>\n<h2>[Medium Impact] Idea</h2>\n<ul>\n<li>MLM pretrained (15% probability random mask token) on all data except 1000 val example: Local and LB + 0.002 (not boost much and much time to pretrained)</li>\n<li>FGM training: Boost Local and CV + 0.002 but 2x time training.</li>\n</ul>\n<h1><strong>What didn’t work</strong></h1>\n<ul>\n<li>Larger model: Deberta-v3-large, Deberta-v3-xlarge</li>\n<li>AWP/Fast AWP training: not boost score on local CV and LB</li>\n<li>EMA training</li>\n<li>Custom head: <ul>\n<li>mean/max pooling</li>\n<li>concat mean-max pooling</li>\n<li>concat last 4 layers</li>\n<li>Attention pooling</li>\n<li>LSTM/ Bi-LSTM</li></ul></li>\n</ul>\n<h2>Additional context (idea not have time to try):</h2>\n<p>We really want to test the ideas in the papers below, but we really don't have enough time and computational resources.</p>\n<ul>\n<li>Deep Attentive Ranking Networks for Learning to Order Sentences - <a href=\"https://arxiv.org/abs/2001.00056\" target=\"_blank\">paper</a>                </li>\n<li>Efficient Relational Sentence Ordering Network    - <a href=\"https://ieeexplore.ieee.org/document/9444816\" target=\"_blank\">paper</a>                             </li>\n<li>Neural Sentence Ordering Based on Constraint Graphs - <a href=\"https://arxiv.org/abs/2101.11178\" target=\"_blank\">paper</a></li>\n<li>Is Everything in Order? A Simple Way to Order Sentences - <a href=\"https://arxiv.org/pdf/2104.07064v2.pdf\" target=\"_blank\">paper</a>                        </li>\n<li>Sentence Ordering and Coherence Modeling using Recurrent Neural Networks - <a href=\"https://arxiv.org/abs/1611.02654\" target=\"_blank\">paper</a>    </li>\n<li>Knowledge Distillation (KD)</li>\n<li>Augmentation technique: Mixup, Random mask</li>\n</ul>\n<h1>Thanks and Acknowledgements:</h1>\n<p>We want to thanks the Kaggle staff team &amp; Competition Host for coordinating this great competition! <br>\nThanks for sharing the solution from all the teams, especially the top teams, we really learned a lot from their solutions.</p>\n<p>Finally, thanks for the hard work of my teammates <a href=\"https://www.kaggle.com/dunglt\" target=\"_blank\">@dunglt</a> </p>\n<h1>Team Members:</h1>\n<ul>\n<li>Khanh Vu Duy <a href=\"https://www.kaggle.com/duykhanh99\" target=\"_blank\">KhanhVD</a>    </li>\n<li>Dung Le <a href=\"https://www.kaggle.com/dunglt\" target=\"_blank\">Dzung</a>    </li>\n</ul>",
  "messages": [
    {
      "id": "2036713",
      "postDate": "11/20/2022 05:29:37",
      "content": "<p><strong>41th Place Solution</strong></p>\n<p>First, thanks Kaggle and the competition hosts for a challenging competition Google AI4Code – Understand Code in Python Notebooks: Predict the  relationship between code and comments. This summarizes the effort of our  team and it was a great experience working with my teammates! This is a  writeup of our collective team effort.</p>\n<h1><strong>Overview</strong></h1>\n<p>Based on Khôi's initial idea, we modify a little bit to get more global context information. We sample 45 cells with shorter code cell's length (10 tokens). If the notebook has less than 45 cells, we dynamically adjust the max length of code cell based on the number of code cell.</p>\n<p>Ensemble from 2 training setting (our setting and Khoi Nguyen setting - 20 code cell with 23 tokens each) also give us a boost on CV and LB. (we don't remember the exact number).</p>\n<ul>\n<li><strong>Model</strong>: Weighted Average of some Point-wise models such as: Distilbert-base-uncased, Deberta-v3-base and Codebert-base</li>\n<li><strong>Data</strong>: All training competition data, no external data. Cross Validation Split: 90/10</li>\n<li><strong>Hardware</strong>: Two A6000-48GB. The largest model training for 3-4 days, the lighting model like distilbert is 1-2 days.</li>\n</ul>\n<p>Some of the results on local CV are detailed in the photos below:</p>\n<p><strong>Initial experimental</strong><br>\nInitial experimentals didn't beat Khoi's baseline:<br>\n<a href=\"https://postimg.cc/DSSp3ZXN\" target=\"_blank\"><img src=\"https://i.postimg.cc/bwT7bSNq/inital-exp1-fix.png\" alt=\"inital-exp1-fix.png\"></a></p>\n<p>Dynamic tokenizer based on number of code cells and FGM training help boost score on both Local CV and LB:</p>\n<p><a href=\"https://postimg.cc/JyJTt2Kc\" target=\"_blank\"><img src=\"https://i.postimg.cc/ZqsXskdg/inital-exp2-fix.png\" alt=\"inital-exp2-fix.png\"></a></p>\n<p><strong>Final &amp; best experimental</strong><br>\nThe best model on both Local CV and LB is Deberta-v3-base.<br>\n<a href=\"https://postimg.cc/JsHxdFwV\" target=\"_blank\"><img src=\"https://i.postimg.cc/P527NG2x/final-exp-fix.png\" alt=\"final-exp-fix.png\"></a></p>\n<p><strong>Inference code:</strong> <a href=\"https://www.kaggle.com/code/dunglt/inference-pct-rank-model?scriptVersionId=101081766\" target=\"_blank\">Inference Ensemble Final Submission</a></p>\n<h1><strong>What worked</strong></h1>\n<h2>[High Impact] Idea</h2>\n<ul>\n<li>Dynamic tokenizer based on number of code cells: Local + 0.007 and LB + 0.005</li>\n<li>Local tokenizer to boost training speed</li>\n</ul>\n<h2>[Medium Impact] Idea</h2>\n<ul>\n<li>MLM pretrained (15% probability random mask token) on all data except 1000 val example: Local and LB + 0.002 (not boost much and much time to pretrained)</li>\n<li>FGM training: Boost Local and CV + 0.002 but 2x time training.</li>\n</ul>\n<h1><strong>What didn’t work</strong></h1>\n<ul>\n<li>Larger model: Deberta-v3-large, Deberta-v3-xlarge</li>\n<li>AWP/Fast AWP training: not boost score on local CV and LB</li>\n<li>EMA training</li>\n<li>Custom head: <ul>\n<li>mean/max pooling</li>\n<li>concat mean-max pooling</li>\n<li>concat last 4 layers</li>\n<li>Attention pooling</li>\n<li>LSTM/ Bi-LSTM</li></ul></li>\n</ul>\n<h2>Additional context (idea not have time to try):</h2>\n<p>We really want to test the ideas in the papers below, but we really don't have enough time and computational resources.</p>\n<ul>\n<li>Deep Attentive Ranking Networks for Learning to Order Sentences - <a href=\"https://arxiv.org/abs/2001.00056\" target=\"_blank\">paper</a>                </li>\n<li>Efficient Relational Sentence Ordering Network    - <a href=\"https://ieeexplore.ieee.org/document/9444816\" target=\"_blank\">paper</a>                             </li>\n<li>Neural Sentence Ordering Based on Constraint Graphs - <a href=\"https://arxiv.org/abs/2101.11178\" target=\"_blank\">paper</a></li>\n<li>Is Everything in Order? A Simple Way to Order Sentences - <a href=\"https://arxiv.org/pdf/2104.07064v2.pdf\" target=\"_blank\">paper</a>                        </li>\n<li>Sentence Ordering and Coherence Modeling using Recurrent Neural Networks - <a href=\"https://arxiv.org/abs/1611.02654\" target=\"_blank\">paper</a>    </li>\n<li>Knowledge Distillation (KD)</li>\n<li>Augmentation technique: Mixup, Random mask</li>\n</ul>\n<h1>Thanks and Acknowledgements:</h1>\n<p>We want to thanks the Kaggle staff team &amp; Competition Host for coordinating this great competition! <br>\nThanks for sharing the solution from all the teams, especially the top teams, we really learned a lot from their solutions.</p>\n<p>Finally, thanks for the hard work of my teammates <a href=\"https://www.kaggle.com/dunglt\" target=\"_blank\">@dunglt</a> </p>\n<h1>Team Members:</h1>\n<ul>\n<li>Khanh Vu Duy <a href=\"https://www.kaggle.com/duykhanh99\" target=\"_blank\">KhanhVD</a>    </li>\n<li>Dung Le <a href=\"https://www.kaggle.com/dunglt\" target=\"_blank\">Dzung</a>    </li>\n</ul>",
      "rawMarkdown": "**41th Place Solution**\n\nFirst, thanks Kaggle and the competition hosts for a challenging competition Google AI4Code – Understand Code in Python Notebooks: Predict the  relationship between code and comments. This summarizes the effort of our  team and it was a great experience working with my teammates! This is a  writeup of our collective team effort.\n\n# **Overview**\n\nBased on Khôi's initial idea, we modify a little bit to get more global context information. We sample 45 cells with shorter code cell's length (10 tokens). If the notebook has less than 45 cells, we dynamically adjust the max length of code cell based on the number of code cell.\n\nEnsemble from 2 training setting (our setting and Khoi Nguyen setting - 20 code cell with 23 tokens each) also give us a boost on CV and LB. (we don't remember the exact number).\n\n- **Model**: Weighted Average of some Point-wise models such as: Distilbert-base-uncased, Deberta-v3-base and Codebert-base\n- **Data**: All training competition data, no external data. Cross Validation Split: 90/10\n- **Hardware**: Two A6000-48GB. The largest model training for 3-4 days, the lighting model like distilbert is 1-2 days.\n\nSome of the results on local CV are detailed in the photos below:\n\n**Initial experimental**\nInitial experimentals didn't beat Khoi's baseline:\n[![inital-exp1-fix.png](https://i.postimg.cc/bwT7bSNq/inital-exp1-fix.png)](https://postimg.cc/DSSp3ZXN)\n\nDynamic tokenizer based on number of code cells and FGM training help boost score on both Local CV and LB:\n\n[![inital-exp2-fix.png](https://i.postimg.cc/ZqsXskdg/inital-exp2-fix.png)](https://postimg.cc/JyJTt2Kc)\n\n**Final & best experimental**\nThe best model on both Local CV and LB is Deberta-v3-base.\n[![final-exp-fix.png](https://i.postimg.cc/P527NG2x/final-exp-fix.png)](https://postimg.cc/JsHxdFwV)\n\n**Inference code:** [Inference Ensemble Final Submission](https://www.kaggle.com/code/dunglt/inference-pct-rank-model?scriptVersionId=101081766)\n\n# **What worked**\n## [High Impact] Idea\n- Dynamic tokenizer based on number of code cells: Local + 0.007 and LB + 0.005\n- Local tokenizer to boost training speed\n## [Medium Impact] Idea\n- MLM pretrained (15% probability random mask token) on all data except 1000 val example: Local and LB + 0.002 (not boost much and much time to pretrained)\n- FGM training: Boost Local and CV + 0.002 but 2x time training.\n\n# **What didn’t work**\n- Larger model: Deberta-v3-large, Deberta-v3-xlarge\n- AWP/Fast AWP training: not boost score on local CV and LB\n- EMA training\n- Custom head: \n - mean/max pooling\n - concat mean-max pooling\n - concat last 4 layers\n - Attention pooling\n - LSTM/ Bi-LSTM\n\n## Additional context (idea not have time to try):\n\nWe really want to test the ideas in the papers below, but we really don't have enough time and computational resources.\n\n- Deep Attentive Ranking Networks for Learning to Order Sentences - [paper](https://arxiv.org/abs/2001.00056)\t\t\t\t\n- Efficient Relational Sentence Ordering Network\t- [paper](https://ieeexplore.ieee.org/document/9444816)\t\t\t\t\t\t\t\t\n- Neural Sentence Ordering Based on Constraint Graphs - [paper](https://arxiv.org/abs/2101.11178)\n- Is Everything in Order? A Simple Way to Order Sentences - [paper](https://arxiv.org/pdf/2104.07064v2.pdf)\t\t\t\t\t\t\n- Sentence Ordering and Coherence Modeling using Recurrent Neural Networks - [paper](https://arxiv.org/abs/1611.02654)\t\n- Knowledge Distillation (KD)\n- Augmentation technique: Mixup, Random mask\n\n# Thanks and Acknowledgements:\n\nWe want to thanks the Kaggle staff team & Competition Host for coordinating this great competition! \nThanks for sharing the solution from all the teams, especially the top teams, we really learned a lot from their solutions.\n\nFinally, thanks for the hard work of my teammates @dunglt \n\n# Team Members:\t\t\t\n - Khanh Vu Duy [KhanhVD](https://www.kaggle.com/duykhanh99)\t\n - Dung Le [Dzung](https://www.kaggle.com/dunglt)",
      "votes": null
    },
    {
      "id": "2038055",
      "postDate": "11/21/2022 06:49:35",
      "content": "<p>Awesome keep it running </p>",
      "rawMarkdown": "Awesome keep it running",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2038055,
      "author_name": "freakmind",
      "author_url": "",
      "post_date": "11/21/2022 06:49:35",
      "content": "<p>Awesome keep it running </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2036713": "**41th Place Solution**\n\nFirst, thanks Kaggle and the competition hosts for a challenging competition Google AI4Code – Understand Code in Python Notebooks: Predict the  relationship between code and comments. This summarizes the effort of our  team and it was a great experience working with my teammates! This is a  writeup of our collective team effort.\n\n# **Overview**\n\nBased on Khôi's initial idea, we modify a little bit to get more global context information. We sample 45 cells with shorter code cell's length (10 tokens). If the notebook has less than 45 cells, we dynamically adjust the max length of code cell based on the number of code cell.\n\nEnsemble from 2 training setting (our setting and Khoi Nguyen setting - 20 code cell with 23 tokens each) also give us a boost on CV and LB. (we don't remember the exact number).\n\n- **Model**: Weighted Average of some Point-wise models such as: Distilbert-base-uncased, Deberta-v3-base and Codebert-base\n- **Data**: All training competition data, no external data. Cross Validation Split: 90/10\n- **Hardware**: Two A6000-48GB. The largest model training for 3-4 days, the lighting model like distilbert is 1-2 days.\n\nSome of the results on local CV are detailed in the photos below:\n\n**Initial experimental**\nInitial experimentals didn't beat Khoi's baseline:\n[![inital-exp1-fix.png](https://i.postimg.cc/bwT7bSNq/inital-exp1-fix.png)](https://postimg.cc/DSSp3ZXN)\n\nDynamic tokenizer based on number of code cells and FGM training help boost score on both Local CV and LB:\n\n[![inital-exp2-fix.png](https://i.postimg.cc/ZqsXskdg/inital-exp2-fix.png)](https://postimg.cc/JyJTt2Kc)\n\n**Final & best experimental**\nThe best model on both Local CV and LB is Deberta-v3-base.\n[![final-exp-fix.png](https://i.postimg.cc/P527NG2x/final-exp-fix.png)](https://postimg.cc/JsHxdFwV)\n\n**Inference code:** [Inference Ensemble Final Submission](https://www.kaggle.com/code/dunglt/inference-pct-rank-model?scriptVersionId=101081766)\n\n# **What worked**\n## [High Impact] Idea\n- Dynamic tokenizer based on number of code cells: Local + 0.007 and LB + 0.005\n- Local tokenizer to boost training speed\n## [Medium Impact] Idea\n- MLM pretrained (15% probability random mask token) on all data except 1000 val example: Local and LB + 0.002 (not boost much and much time to pretrained)\n- FGM training: Boost Local and CV + 0.002 but 2x time training.\n\n# **What didn’t work**\n- Larger model: Deberta-v3-large, Deberta-v3-xlarge\n- AWP/Fast AWP training: not boost score on local CV and LB\n- EMA training\n- Custom head: \n - mean/max pooling\n - concat mean-max pooling\n - concat last 4 layers\n - Attention pooling\n - LSTM/ Bi-LSTM\n\n## Additional context (idea not have time to try):\n\nWe really want to test the ideas in the papers below, but we really don't have enough time and computational resources.\n\n- Deep Attentive Ranking Networks for Learning to Order Sentences - [paper](https://arxiv.org/abs/2001.00056)\t\t\t\t\n- Efficient Relational Sentence Ordering Network\t- [paper](https://ieeexplore.ieee.org/document/9444816)\t\t\t\t\t\t\t\t\n- Neural Sentence Ordering Based on Constraint Graphs - [paper](https://arxiv.org/abs/2101.11178)\n- Is Everything in Order? A Simple Way to Order Sentences - [paper](https://arxiv.org/pdf/2104.07064v2.pdf)\t\t\t\t\t\t\n- Sentence Ordering and Coherence Modeling using Recurrent Neural Networks - [paper](https://arxiv.org/abs/1611.02654)\t\n- Knowledge Distillation (KD)\n- Augmentation technique: Mixup, Random mask\n\n# Thanks and Acknowledgements:\n\nWe want to thanks the Kaggle staff team & Competition Host for coordinating this great competition! \nThanks for sharing the solution from all the teams, especially the top teams, we really learned a lot from their solutions.\n\nFinally, thanks for the hard work of my teammates @dunglt \n\n# Team Members:\t\t\t\n - Khanh Vu Duy [KhanhVD](https://www.kaggle.com/duykhanh99)\t\n - Dung Le [Dzung](https://www.kaggle.com/dunglt)",
    "2038055": "Awesome keep it running"
  },
  "source": "existing_discussion",
  "complete": true,
  "competition_id": 35887,
  "competition_slug": "AI4Code",
  "team_id": 8611091,
  "solution_url": "/competitions/AI4Code/writeups/dl-41th-place-solution"
}