{
  "id": 551449,
  "title": "(Almost) Zero-Shot Solution - Private 64h",
  "content": "<p>I sincerely thank the Kaggle team and competition hosts for providing this valuable opportunity. Through this competition, I explored the latest advancements in large language models (LLMs) and deepened my understanding of zero-shot inference techniques.</p>\n<p>A key feature of my solution is its low computational cost for training. Training light-weight adapter modules takes only a few minutes, with the majority of computational resources allocated to inference.<br>\nAlthough the solution ultimately proved less competitive than fine-tuned approaches, I would like to highlight the potential of zero-shot inference. I hope this document inspires participants with limited computational resources to explore similar approaches.</p>\n<h2>Pipeline</h2>\n<p>The system consists of three main components, as illustrated in Fig.1:</p>\n<ol>\n<li><strong>Text Generation</strong>: This module generates zero-shot inferences to create a semantic alignment between queries (e.g., problem statements and student answers) and misconceptions.</li>\n<li><strong>Retriever</strong>: Retriever: A lightweight retrieval system that uses pre-computed embeddings from a General Text Embedding (GTE) model, combined with shallow MLP adapters to efficiently handle large-scale text representations.</li>\n<li><strong>Reranker</strong>: A reranking system based on <code>Qwen2.5-72B-Instruct-AWQ</code>, equipped with logit processors guiding to output specific choice tokens.</li>\n</ol>\n<p>Details of each component are explained in the following sections.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2Fa140b9d748aade03b5bda478668627fe%2Feedi-architecture.png?generation=1734073366567506&amp;alt=media\" alt=\"\"></p>\n<p><strong>Fig.1: System Architecture</strong></p>\n<h2>The CV Split</h2>\n<h3>Addressing the Challenge of Unseen Misconceptions</h3>\n<p>One of the key challenges of this competition was the fact that 38% of the misconceptions in the test set were not present in the training dataset [1]. This design aligns with the competition's goal to develop models that can generalize to unseen misconceptions:</p>\n<blockquote>\n  <p>\"The goal is to create a model that not only aligns with known misconceptions but also generalizes to new, emerging misconceptions.\"</p>\n</blockquote>\n<p>To address this challenge, I implemented a custom cross-validation (CV) split that simulates the real-world training and test conditions. The dataset was divided into two subsets:</p>\n<ul>\n<li><code>inner-test</code>: 20% of the misconceptions (and their corresponding question-answer pairs) were randomly selected.</li>\n<li><code>inner-train</code>: The remaining pairs that did not overlap with the selected misconceptions.</li>\n</ul>\n<p>After excluding samples without misconception labels, the <code>inner-test</code> set contained <code>1,719</code> question-answer pairs, while the <code>inner-train</code> set contained <code>2,651</code> pairs. This new split significantly improved the correlation between CV and LB scores.</p>\n<h2>Text Feature Generation</h2>\n<p>This approach is similar to publicly shared ones[2], but the public approach were limited to the <code>query</code> domain. In contrast, my goal was to build models capable of aligning two distinct domains -- <code>query</code> and <code>misconception</code>. To achieve this, I applied zero-shot inference to <strong>both domains</strong> as follows:</p>\n<ol>\n<li>Infer candidate misconceptions from queries by leveraging fields such as <code>SubjectName</code>, <code>ConstructName</code>, <code>QuestionText</code>, <code>AnswerText</code>, and <code>CorrectAnswerText</code>.</li>\n<li>Rephrase misconceptions into concise and standardized descriptions that incorporate richer context and information.</li>\n</ol>\n<p>I used <code>Qwen2.5-32B-Instruct-GPTQ-INT4</code> as the text generation model to implement this approach. The specific prompts used for text generation are detailed in Appendix A1.</p>\n<h2>Retriever Module</h2>\n<p>I hypothesized that the text features already encapsulate specific details of both domains (query and misconception). Therefore, pre-computed embeddings from a general text embedding model, combined with lightweight MLP adapters, are sufficient to build high-quality retrieval models.</p>\n<p>For this purpose, I used gte-Qwen2-7B-Instruct to generate the pre-computed embeddings, which were subsequently fed into 2-3 layer MLPs for classification.</p>\n<p>Training was conducted in a manner similar to few-shot text classification (Fig.2), utilizing only in-batch negative samples to train a classifier for 2,587 misconceptions.</p>\n<p>Pre-computing the embeddings significantly reduces computational costs by eliminating repeated forward passes through the large embedding model. This optimization allows 5-fold models to be trained in just a few minutes.</p>\n<p>Details of the training parameters are provided in Appendix A2.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2Fd59836d45da7a0230f36c6f8c69e6f00%2Feedi-train-retriever.png?generation=1734073392563757&amp;alt=media\" alt=\"\"></p>\n<p><strong>Fig.2: Training Scheme of MLP Adapters</strong>: Fig.2 illustrates the MLP adapter training scheme, where blue squares denote positive pairs, white squares denote negative pairs, and gray squares represent masked regions excluded from loss calculation.</p>\n<h2>Reranker Module</h2>\n<p>The reranker module complements the retriever by incorporating cross-document features. While the retriever module processes only single-document features, the reranker refines the results by evaluating the top-25 documents retrieved and selecting the top-K most relevant ones using an LLM.</p>\n<p>The inference scheme follows approaches discussed in public discussions [3-5], with key differences outlined below:</p>\n<ol>\n<li><strong>Token Probability</strong>: The vLLM model generates <code>logprobs</code> for up to the top 20 candidate tokens, providing more accurate probability estimates for each candidate.</li>\n<li><strong>Sub-token Awareness</strong>: Since this approach does not involve fine-tuning, sub-tokens require careful handling during guided generation. For example, Qwen models often produce outputs like <code>id=a&lt;|im_end|&gt;</code>, which are split into <code>[id, =a, &lt;|im_end|&gt;]</code>. To ensure accurate token guidance, the reranker targets <code>=a</code> instead of <code>a</code>.</li>\n</ol>\n<p>I adopted the <code>Qwen2.5-72B-Instruct-AWQ</code> model for reranker. On the test dataset, inference for the reranker module takes approximately 2 hours, which balances computational efficiency and performance. Details about the specific prompts used are provided in Appendix A3.</p>\n<h2>Post Process</h2>\n<h3>Addressing Label Distribution Bias</h3>\n<p>The competition labels are divided into two groups: the <strong>62% that appear in the training data</strong> and the <strong>38% that do not</strong> [1]. I refer to these groups as <em>seen</em> and <em>unseen</em>, respectively.</p>\n<p>Early results suggested that the test set contained a higher proportion of unseen labels compared to seen labels, with an estimated ratio of 3:7 in the inner-test set. Given the observed correlation between CV scores and public leaderboard scores, I hypothesized that the public test set would exhibit a similar ratio.</p>\n<p>To address this bias, I applied an affine transformation to the similarity scores as follows:</p>\n<p>$$<br>\n\\mathrm{similarity}(q_i, d_j) = \\begin{cases}<br>\nw \\times s(d_j) + b &amp; \\text{if } d_j \\in \\mathrm{unseen} \\\\<br>\ns(d_j) &amp; \\text{otherwise}<br>\n\\end{cases}<br>\n$$</p>\n<p>For the <code>inner-test</code> set, the optimal parameters were (<code>w=1.247</code> and <code>b=1.772e-04</code>).</p>\n<h2>Simple Ablation</h2>\n<table>\n<thead>\n<tr>\n<th>+MLP adapter</th>\n<th>+increase unseen prob</th>\n<th>+reranker</th>\n<th>+ensemble</th>\n<th>Recall@25-seen</th>\n<th>Recall@25-unseen</th>\n<th>Recall@25</th>\n<th>CV-seen</th>\n<th>CV-unseen</th>\n<th>CV</th>\n<th>Public LB</th>\n<th>Private LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td></td>\n<td></td>\n<td></td>\n<td></td>\n<td></td>\n<td></td>\n<td>0.754</td>\n<td></td>\n<td></td>\n<td>0.299</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td></td>\n<td></td>\n<td></td>\n<td>0.907</td>\n<td>0.859</td>\n<td>0.873</td>\n<td>0.411</td>\n<td>0.388</td>\n<td>0.395</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td>✔️</td>\n<td></td>\n<td></td>\n<td>0.864</td>\n<td>0.900</td>\n<td>0.890</td>\n<td>0.184</td>\n<td>0.518</td>\n<td>0.418</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td>✔️</td>\n<td>✔️</td>\n<td></td>\n<td>0.831</td>\n<td>0.895</td>\n<td>0.876</td>\n<td>0.427</td>\n<td>0.557</td>\n<td>0.518</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td>✔️</td>\n<td>✔️</td>\n<td>✔️</td>\n<td>0.831</td>\n<td>0.895</td>\n<td>0.876</td>\n<td>0.362</td>\n<td>0.611</td>\n<td>0.537</td>\n<td>0.559</td>\n<td>0.495</td>\n</tr>\n</tbody>\n</table>\n<h2>Reference</h2>\n<ol>\n<li><a href=\"https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/537295\" target=\"_blank\">CV vs LB Score</a></li>\n<li><a href=\"https://www.kaggle.com/code/ubamba98/eedi-zero-shot-w-llm-feature-lb-0-180\" target=\"_blank\">[Eedi] Zero-shot w/ LLM feature (LB: 0.180)</a></li>\n<li><a href=\"https://www.kaggle.com/code/takanashihumbert/eedi-qwen-2-5-32b-awq-two-time-retrieval\" target=\"_blank\">Eedi Qwen-2.5 32B AWQ two-time retrieval</a></li>\n<li><a href=\"https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/546978\" target=\"_blank\">Logits Processors</a></li>\n<li><a href=\"https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/550223\" target=\"_blank\">Qwen2.5-72B &amp; Llama 3.3-70B on 2xT4(questionable performance)</a></li>\n</ol>\n<h2>Appendix</h2>\n<h3>A1. Text Generation Prompts</h3>\n<h4>a. The Student's Misconception Inference</h4>\n<pre><code>The following shows a math problem given in elementary school  the student\n\n**Subject**: {}\n\n**Construct**: {}\n\n**Question**: {}\n\n**Correct Answer**: {}\n\n**The Student\n</code></pre>\n<h4>b. Rephrase Misconception</h4>\n<pre><code>The following passage  an interpretation given by a teacher regarding a student\n\n**Misconception**: {}\n</code></pre>\n<h3>A2. MLP Adapter's Training Parameters</h3>\n<ul>\n<li>num_epochs=75</li>\n<li>label_smoothing=0.0</li>\n<li>lr=5e-4</li>\n<li>optimizer=\"adamw\"</li>\n<li>in_batch_sampling=True</li>\n<li>train_batch_size=256</li>\n<li>hidden_dim=256</li>\n</ul>\n<h3>A3. Reranking Prompt</h3>\n<pre><code>Evaluate the student's misconception and rank the candidates  likelihood.\nAmong the candidates,   is the most likely to be the student's misconception?\nYou should only output the most relevant candidate ID number and  other characters are allowed.\n\nOutput :\nid=(the most relevant candidate ID number)\n\n\n\n\n\n\n\n\n\n\n\n\n{}\n</code></pre>\n<p>Example:</p>\n<pre><code>Evaluate  student's misconception  rank  candidates  likelihood.\nAmong  candidates, which one   most likely  be  student's misconception?\nYou should only output  most relevant candidate ID   no other  are allowed.\n\nOutput Format:\n=( most relevant candidate ID )\n\n**Subject**: Multiplying Terms\n\n**Construct**: Multiply algebraic terms,  both are linear versions  different letters (e.g. a x b)\n\n**Question**: Simplify,  possible:\n\\[\n a \\  b\n\\]\n\n**Correct Answer**: \\(  a b \\)\n\n**Student's Incorrect Answer**: Does  simplify\n\n**Candidates**:\n(=a) Multiplies coefficients  letters separately  writes  an addition\n(=b) Does  realise  two letters together,  a   letter together, are multiplying\n(=c) Does  understand how  multiply algebraic terms\n(=d) Believes you add  terms together when multiplying like terms.\n(=e) Does  recognise  distributive \n(=f) Adds  multiplies when multiplying algebraic terms\n(=g) Thinks two variables next  each other represent addition\n(=h) Does  realise multiplying a variable  itself results  a power   variable\n(=i) Confuses collecting like terms  multiplication\n(=j) Thinks multiplying a variable  a    same  raising  variable   power   \n(=k) Does  correctly apply  commutative   multiplication\n(=l) Does  understand when like terms can be collected\n(=m) Multiplies all terms together when simplifying an expression\n(=n) When squaring a variable, believes they also need  square  coefficient\n(=o) Believes they can ignore  coefficient when expanding double brackets\n(=p) Does  understand  concept  inverse operations  algebra\n(=q) Thinks  we can remove a division symbol  just   variables next  each other\n(=r) Does  include brackets when attempting  multiply an expression\n(=s) Thinks any  values multiplied together can be denoted  a squared symbol\n(=t) Thinks two letters next  each other  a division\n(=u) Adds rather than multiplies when asked  a product\n(=v) Does  know  meaning    \n(=w) Only multiplies  numerical terms when expanding a bracket\n(=x) Does  correctly apply  distributive   multiplication\n(=y) Mixes up squaring  multiplying  \n(=z) Thinks you apply one inverse operation  one term   other inverse operation   other term\n</code></pre>",
  "comments": [
    {
      "id": 3072793,
      "author_name": "Rudi Özgen",
      "author_url": "",
      "post_date": "2024-12-15T16:32:35.830000",
      "content": "<p>Thanks for being a source of inspiration.</p>",
      "votes": -1,
      "replies": []
    },
    {
      "id": 3073310,
      "author_name": "xianZ_waikato",
      "author_url": "",
      "post_date": "2024-12-16T10:24:58.960000",
      "content": "<p>Impression on Text Generation part, thanks for share~</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3072876,
      "author_name": "MrSimple",
      "author_url": "",
      "post_date": "2024-12-15T17:56:01.633000",
      "content": "<p>Thanks for being a source of inspiration.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3071106,
      "author_name": "Digital-Munchikin",
      "author_url": "",
      "post_date": "2024-12-13T10:47:22.743000",
      "content": "<p>thank you for sharing yout work! wonderful write-up as well, I can surely learn a lot from it.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3071055,
      "author_name": "Octavi Grau",
      "author_url": "",
      "post_date": "2024-12-13T09:33:25.400000",
      "content": "<p>Congrats for the solution and for an excellent write-up <a href=\"https://www.kaggle.com/tatamikenn\" target=\"_blank\">@tatamikenn</a> !</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3071033,
      "author_name": "Vladimir Demidov",
      "author_url": "",
      "post_date": "2024-12-13T09:02:27.380000",
      "content": "<p>What a professional, well-structured, literate write-up! Regarding the <code>Reranker Module</code>, I saw in the public notebooks a fixed value for the top 25 documents retrieved (performed by <code>NearestNeighbors</code>). Is its value tunable, or is it determined by other constraints?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 3071100,
          "author_name": "",
          "author_url": "",
          "post_date": "2024-12-13T10:37:29.023000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "comment_count": 7,
  "messages": [
    {
      "id": 3070922,
      "postDate": "2024-12-13T07:03:55.273Z",
      "content": "<p>I sincerely thank the Kaggle team and competition hosts for providing this valuable opportunity. Through this competition, I explored the latest advancements in large language models (LLMs) and deepened my understanding of zero-shot inference techniques.</p>\n<p>A key feature of my solution is its low computational cost for training. Training light-weight adapter modules takes only a few minutes, with the majority of computational resources allocated to inference.<br>\nAlthough the solution ultimately proved less competitive than fine-tuned approaches, I would like to highlight the potential of zero-shot inference. I hope this document inspires participants with limited computational resources to explore similar approaches.</p>\n<h2>Pipeline</h2>\n<p>The system consists of three main components, as illustrated in Fig.1:</p>\n<ol>\n<li><strong>Text Generation</strong>: This module generates zero-shot inferences to create a semantic alignment between queries (e.g., problem statements and student answers) and misconceptions.</li>\n<li><strong>Retriever</strong>: Retriever: A lightweight retrieval system that uses pre-computed embeddings from a General Text Embedding (GTE) model, combined with shallow MLP adapters to efficiently handle large-scale text representations.</li>\n<li><strong>Reranker</strong>: A reranking system based on <code>Qwen2.5-72B-Instruct-AWQ</code>, equipped with logit processors guiding to output specific choice tokens.</li>\n</ol>\n<p>Details of each component are explained in the following sections.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2Fa140b9d748aade03b5bda478668627fe%2Feedi-architecture.png?generation=1734073366567506&amp;alt=media\" alt=\"\"></p>\n<p><strong>Fig.1: System Architecture</strong></p>\n<h2>The CV Split</h2>\n<h3>Addressing the Challenge of Unseen Misconceptions</h3>\n<p>One of the key challenges of this competition was the fact that 38% of the misconceptions in the test set were not present in the training dataset [1]. This design aligns with the competition's goal to develop models that can generalize to unseen misconceptions:</p>\n<blockquote>\n  <p>\"The goal is to create a model that not only aligns with known misconceptions but also generalizes to new, emerging misconceptions.\"</p>\n</blockquote>\n<p>To address this challenge, I implemented a custom cross-validation (CV) split that simulates the real-world training and test conditions. The dataset was divided into two subsets:</p>\n<ul>\n<li><code>inner-test</code>: 20% of the misconceptions (and their corresponding question-answer pairs) were randomly selected.</li>\n<li><code>inner-train</code>: The remaining pairs that did not overlap with the selected misconceptions.</li>\n</ul>\n<p>After excluding samples without misconception labels, the <code>inner-test</code> set contained <code>1,719</code> question-answer pairs, while the <code>inner-train</code> set contained <code>2,651</code> pairs. This new split significantly improved the correlation between CV and LB scores.</p>\n<h2>Text Feature Generation</h2>\n<p>This approach is similar to publicly shared ones[2], but the public approach were limited to the <code>query</code> domain. In contrast, my goal was to build models capable of aligning two distinct domains -- <code>query</code> and <code>misconception</code>. To achieve this, I applied zero-shot inference to <strong>both domains</strong> as follows:</p>\n<ol>\n<li>Infer candidate misconceptions from queries by leveraging fields such as <code>SubjectName</code>, <code>ConstructName</code>, <code>QuestionText</code>, <code>AnswerText</code>, and <code>CorrectAnswerText</code>.</li>\n<li>Rephrase misconceptions into concise and standardized descriptions that incorporate richer context and information.</li>\n</ol>\n<p>I used <code>Qwen2.5-32B-Instruct-GPTQ-INT4</code> as the text generation model to implement this approach. The specific prompts used for text generation are detailed in Appendix A1.</p>\n<h2>Retriever Module</h2>\n<p>I hypothesized that the text features already encapsulate specific details of both domains (query and misconception). Therefore, pre-computed embeddings from a general text embedding model, combined with lightweight MLP adapters, are sufficient to build high-quality retrieval models.</p>\n<p>For this purpose, I used gte-Qwen2-7B-Instruct to generate the pre-computed embeddings, which were subsequently fed into 2-3 layer MLPs for classification.</p>\n<p>Training was conducted in a manner similar to few-shot text classification (Fig.2), utilizing only in-batch negative samples to train a classifier for 2,587 misconceptions.</p>\n<p>Pre-computing the embeddings significantly reduces computational costs by eliminating repeated forward passes through the large embedding model. This optimization allows 5-fold models to be trained in just a few minutes.</p>\n<p>Details of the training parameters are provided in Appendix A2.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2Fd59836d45da7a0230f36c6f8c69e6f00%2Feedi-train-retriever.png?generation=1734073392563757&amp;alt=media\" alt=\"\"></p>\n<p><strong>Fig.2: Training Scheme of MLP Adapters</strong>: Fig.2 illustrates the MLP adapter training scheme, where blue squares denote positive pairs, white squares denote negative pairs, and gray squares represent masked regions excluded from loss calculation.</p>\n<h2>Reranker Module</h2>\n<p>The reranker module complements the retriever by incorporating cross-document features. While the retriever module processes only single-document features, the reranker refines the results by evaluating the top-25 documents retrieved and selecting the top-K most relevant ones using an LLM.</p>\n<p>The inference scheme follows approaches discussed in public discussions [3-5], with key differences outlined below:</p>\n<ol>\n<li><strong>Token Probability</strong>: The vLLM model generates <code>logprobs</code> for up to the top 20 candidate tokens, providing more accurate probability estimates for each candidate.</li>\n<li><strong>Sub-token Awareness</strong>: Since this approach does not involve fine-tuning, sub-tokens require careful handling during guided generation. For example, Qwen models often produce outputs like <code>id=a&lt;|im_end|&gt;</code>, which are split into <code>[id, =a, &lt;|im_end|&gt;]</code>. To ensure accurate token guidance, the reranker targets <code>=a</code> instead of <code>a</code>.</li>\n</ol>\n<p>I adopted the <code>Qwen2.5-72B-Instruct-AWQ</code> model for reranker. On the test dataset, inference for the reranker module takes approximately 2 hours, which balances computational efficiency and performance. Details about the specific prompts used are provided in Appendix A3.</p>\n<h2>Post Process</h2>\n<h3>Addressing Label Distribution Bias</h3>\n<p>The competition labels are divided into two groups: the <strong>62% that appear in the training data</strong> and the <strong>38% that do not</strong> [1]. I refer to these groups as <em>seen</em> and <em>unseen</em>, respectively.</p>\n<p>Early results suggested that the test set contained a higher proportion of unseen labels compared to seen labels, with an estimated ratio of 3:7 in the inner-test set. Given the observed correlation between CV scores and public leaderboard scores, I hypothesized that the public test set would exhibit a similar ratio.</p>\n<p>To address this bias, I applied an affine transformation to the similarity scores as follows:</p>\n<p>$$<br>\n\\mathrm{similarity}(q_i, d_j) = \\begin{cases}<br>\nw \\times s(d_j) + b &amp; \\text{if } d_j \\in \\mathrm{unseen} \\\\<br>\ns(d_j) &amp; \\text{otherwise}<br>\n\\end{cases}<br>\n$$</p>\n<p>For the <code>inner-test</code> set, the optimal parameters were (<code>w=1.247</code> and <code>b=1.772e-04</code>).</p>\n<h2>Simple Ablation</h2>\n<table>\n<thead>\n<tr>\n<th>+MLP adapter</th>\n<th>+increase unseen prob</th>\n<th>+reranker</th>\n<th>+ensemble</th>\n<th>Recall@25-seen</th>\n<th>Recall@25-unseen</th>\n<th>Recall@25</th>\n<th>CV-seen</th>\n<th>CV-unseen</th>\n<th>CV</th>\n<th>Public LB</th>\n<th>Private LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td></td>\n<td></td>\n<td></td>\n<td></td>\n<td></td>\n<td></td>\n<td>0.754</td>\n<td></td>\n<td></td>\n<td>0.299</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td></td>\n<td></td>\n<td></td>\n<td>0.907</td>\n<td>0.859</td>\n<td>0.873</td>\n<td>0.411</td>\n<td>0.388</td>\n<td>0.395</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td>✔️</td>\n<td></td>\n<td></td>\n<td>0.864</td>\n<td>0.900</td>\n<td>0.890</td>\n<td>0.184</td>\n<td>0.518</td>\n<td>0.418</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td>✔️</td>\n<td>✔️</td>\n<td></td>\n<td>0.831</td>\n<td>0.895</td>\n<td>0.876</td>\n<td>0.427</td>\n<td>0.557</td>\n<td>0.518</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>✔️</td>\n<td>✔️</td>\n<td>✔️</td>\n<td>✔️</td>\n<td>0.831</td>\n<td>0.895</td>\n<td>0.876</td>\n<td>0.362</td>\n<td>0.611</td>\n<td>0.537</td>\n<td>0.559</td>\n<td>0.495</td>\n</tr>\n</tbody>\n</table>\n<h2>Reference</h2>\n<ol>\n<li><a href=\"https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/537295\" target=\"_blank\">CV vs LB Score</a></li>\n<li><a href=\"https://www.kaggle.com/code/ubamba98/eedi-zero-shot-w-llm-feature-lb-0-180\" target=\"_blank\">[Eedi] Zero-shot w/ LLM feature (LB: 0.180)</a></li>\n<li><a href=\"https://www.kaggle.com/code/takanashihumbert/eedi-qwen-2-5-32b-awq-two-time-retrieval\" target=\"_blank\">Eedi Qwen-2.5 32B AWQ two-time retrieval</a></li>\n<li><a href=\"https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/546978\" target=\"_blank\">Logits Processors</a></li>\n<li><a href=\"https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/550223\" target=\"_blank\">Qwen2.5-72B &amp; Llama 3.3-70B on 2xT4(questionable performance)</a></li>\n</ol>\n<h2>Appendix</h2>\n<h3>A1. Text Generation Prompts</h3>\n<h4>a. The Student's Misconception Inference</h4>\n<pre><code>The following shows a math problem given in elementary school  the student\n\n**Subject**: {}\n\n**Construct**: {}\n\n**Question**: {}\n\n**Correct Answer**: {}\n\n**The Student\n</code></pre>\n<h4>b. Rephrase Misconception</h4>\n<pre><code>The following passage  an interpretation given by a teacher regarding a student\n\n**Misconception**: {}\n</code></pre>\n<h3>A2. MLP Adapter's Training Parameters</h3>\n<ul>\n<li>num_epochs=75</li>\n<li>label_smoothing=0.0</li>\n<li>lr=5e-4</li>\n<li>optimizer=\"adamw\"</li>\n<li>in_batch_sampling=True</li>\n<li>train_batch_size=256</li>\n<li>hidden_dim=256</li>\n</ul>\n<h3>A3. Reranking Prompt</h3>\n<pre><code>Evaluate the student's misconception and rank the candidates  likelihood.\nAmong the candidates,   is the most likely to be the student's misconception?\nYou should only output the most relevant candidate ID number and  other characters are allowed.\n\nOutput :\nid=(the most relevant candidate ID number)\n\n\n\n\n\n\n\n\n\n\n\n\n{}\n</code></pre>\n<p>Example:</p>\n<pre><code>Evaluate  student's misconception  rank  candidates  likelihood.\nAmong  candidates, which one   most likely  be  student's misconception?\nYou should only output  most relevant candidate ID   no other  are allowed.\n\nOutput Format:\n=( most relevant candidate ID )\n\n**Subject**: Multiplying Terms\n\n**Construct**: Multiply algebraic terms,  both are linear versions  different letters (e.g. a x b)\n\n**Question**: Simplify,  possible:\n\\[\n a \\  b\n\\]\n\n**Correct Answer**: \\(  a b \\)\n\n**Student's Incorrect Answer**: Does  simplify\n\n**Candidates**:\n(=a) Multiplies coefficients  letters separately  writes  an addition\n(=b) Does  realise  two letters together,  a   letter together, are multiplying\n(=c) Does  understand how  multiply algebraic terms\n(=d) Believes you add  terms together when multiplying like terms.\n(=e) Does  recognise  distributive \n(=f) Adds  multiplies when multiplying algebraic terms\n(=g) Thinks two variables next  each other represent addition\n(=h) Does  realise multiplying a variable  itself results  a power   variable\n(=i) Confuses collecting like terms  multiplication\n(=j) Thinks multiplying a variable  a    same  raising  variable   power   \n(=k) Does  correctly apply  commutative   multiplication\n(=l) Does  understand when like terms can be collected\n(=m) Multiplies all terms together when simplifying an expression\n(=n) When squaring a variable, believes they also need  square  coefficient\n(=o) Believes they can ignore  coefficient when expanding double brackets\n(=p) Does  understand  concept  inverse operations  algebra\n(=q) Thinks  we can remove a division symbol  just   variables next  each other\n(=r) Does  include brackets when attempting  multiply an expression\n(=s) Thinks any  values multiplied together can be denoted  a squared symbol\n(=t) Thinks two letters next  each other  a division\n(=u) Adds rather than multiplies when asked  a product\n(=v) Does  know  meaning    \n(=w) Only multiplies  numerical terms when expanding a bracket\n(=x) Does  correctly apply  distributive   multiplication\n(=y) Mixes up squaring  multiplying  \n(=z) Thinks you apply one inverse operation  one term   other inverse operation   other term\n</code></pre>",
      "rawMarkdown": "I sincerely thank the Kaggle team and competition hosts for providing this valuable opportunity. Through this competition, I explored the latest advancements in large language models (LLMs) and deepened my understanding of zero-shot inference techniques.\n\nA key feature of my solution is its low computational cost for training. Training light-weight adapter modules takes only a few minutes, with the majority of computational resources allocated to inference.\nAlthough the solution ultimately proved less competitive than fine-tuned approaches, I would like to highlight the potential of zero-shot inference. I hope this document inspires participants with limited computational resources to explore similar approaches.\n\n## Pipeline\n\nThe system consists of three main components, as illustrated in Fig.1:\n\n1. **Text Generation**: This module generates zero-shot inferences to create a semantic alignment between queries (e.g., problem statements and student answers) and misconceptions.\n1. **Retriever**: Retriever: A lightweight retrieval system that uses pre-computed embeddings from a General Text Embedding (GTE) model, combined with shallow MLP adapters to efficiently handle large-scale text representations.\n1. **Reranker**: A reranking system based on `Qwen2.5-72B-Instruct-AWQ`, equipped with logit processors guiding to output specific choice tokens.\n\nDetails of each component are explained in the following sections.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2Fa140b9d748aade03b5bda478668627fe%2Feedi-architecture.png?generation=1734073366567506&alt=media)\n\n**Fig.1: System Architecture**\n\n## The CV Split\n\n### Addressing the Challenge of Unseen Misconceptions\n\nOne of the key challenges of this competition was the fact that 38% of the misconceptions in the test set were not present in the training dataset [1]. This design aligns with the competition's goal to develop models that can generalize to unseen misconceptions:\n\n> \"The goal is to create a model that not only aligns with known misconceptions but also generalizes to new, emerging misconceptions.\"\n\nTo address this challenge, I implemented a custom cross-validation (CV) split that simulates the real-world training and test conditions. The dataset was divided into two subsets:\n\n* `inner-test`: 20% of the misconceptions (and their corresponding question-answer pairs) were randomly selected.\n* `inner-train`: The remaining pairs that did not overlap with the selected misconceptions.\n\nAfter excluding samples without misconception labels, the `inner-test` set contained `1,719` question-answer pairs, while the `inner-train` set contained `2,651` pairs. This new split significantly improved the correlation between CV and LB scores.\n\n## Text Feature Generation\n\nThis approach is similar to publicly shared ones[2], but the public approach were limited to the `query` domain. In contrast, my goal was to build models capable of aligning two distinct domains -- `query` and `misconception`. To achieve this, I applied zero-shot inference to **both domains** as follows:\n\n1. Infer candidate misconceptions from queries by leveraging fields such as `SubjectName`, `ConstructName`, `QuestionText`, `AnswerText`, and `CorrectAnswerText`.\n2. Rephrase misconceptions into concise and standardized descriptions that incorporate richer context and information.\n\nI used `Qwen2.5-32B-Instruct-GPTQ-INT4` as the text generation model to implement this approach. The specific prompts used for text generation are detailed in Appendix A1.\n\n## Retriever Module\n\nI hypothesized that the text features already encapsulate specific details of both domains (query and misconception). Therefore, pre-computed embeddings from a general text embedding model, combined with lightweight MLP adapters, are sufficient to build high-quality retrieval models.\n\nFor this purpose, I used gte-Qwen2-7B-Instruct to generate the pre-computed embeddings, which were subsequently fed into 2-3 layer MLPs for classification.\n\nTraining was conducted in a manner similar to few-shot text classification (Fig.2), utilizing only in-batch negative samples to train a classifier for 2,587 misconceptions.\n\nPre-computing the embeddings significantly reduces computational costs by eliminating repeated forward passes through the large embedding model. This optimization allows 5-fold models to be trained in just a few minutes.\n\nDetails of the training parameters are provided in Appendix A2.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2Fd59836d45da7a0230f36c6f8c69e6f00%2Feedi-train-retriever.png?generation=1734073392563757&alt=media)\n\n**Fig.2: Training Scheme of MLP Adapters**: Fig.2 illustrates the MLP adapter training scheme, where blue squares denote positive pairs, white squares denote negative pairs, and gray squares represent masked regions excluded from loss calculation.\n\n## Reranker Module\n\nThe reranker module complements the retriever by incorporating cross-document features. While the retriever module processes only single-document features, the reranker refines the results by evaluating the top-25 documents retrieved and selecting the top-K most relevant ones using an LLM.\n\nThe inference scheme follows approaches discussed in public discussions [3-5], with key differences outlined below:\n\n1. **Token Probability**: The vLLM model generates `logprobs` for up to the top 20 candidate tokens, providing more accurate probability estimates for each candidate.\n2. **Sub-token Awareness**: Since this approach does not involve fine-tuning, sub-tokens require careful handling during guided generation. For example, Qwen models often produce outputs like `id=a<|im_end|>`, which are split into `[id, =a, <|im_end|>]`. To ensure accurate token guidance, the reranker targets `=a` instead of `a`.\n\nI adopted the `Qwen2.5-72B-Instruct-AWQ` model for reranker. On the test dataset, inference for the reranker module takes approximately 2 hours, which balances computational efficiency and performance. Details about the specific prompts used are provided in Appendix A3.\n\n## Post Process\n\n### Addressing Label Distribution Bias\n\nThe competition labels are divided into two groups: the **62% that appear in the training data** and the **38% that do not** [1]. I refer to these groups as *seen* and *unseen*, respectively.\n\nEarly results suggested that the test set contained a higher proportion of unseen labels compared to seen labels, with an estimated ratio of 3:7 in the inner-test set. Given the observed correlation between CV scores and public leaderboard scores, I hypothesized that the public test set would exhibit a similar ratio.\n\nTo address this bias, I applied an affine transformation to the similarity scores as follows:\n\n$$\n\\mathrm{similarity}(q_i, d_j) = \\begin{cases}\nw \\times s(d_j) + b & \\text{if } d_j \\in \\mathrm{unseen} \\\\\\\\\ns(d_j) & \\text{otherwise}\n\\end{cases}\n$$\n\nFor the `inner-test` set, the optimal parameters were (`w=1.247` and `b=1.772e-04`).\n\n## Simple Ablation\n\n| +MLP adapter | +increase unseen prob | +reranker | +ensemble | Recall@25-seen | Recall@25-unseen | Recall@25 | CV-seen | CV-unseen | CV   | Public LB | Private LB |\n|-------------|-----------------------|-----------|----------|----------------|-------------------|-----------|---------|-----------|-------|-----------|------------|\n|             |                       |           |          ||| 0.754    |     |                   | 0.299    |         |           |       |           |            |\n| ✔️          |                       |           |          | 0.907          | 0.859             | 0.873     | 0.411   | 0.388     | 0.395 |           |            |\n| ✔️          | ✔️                    |           |          | 0.864          | 0.900             | 0.890     | 0.184   | 0.518     | 0.418 |           |            |\n| ✔️          | ✔️                    | ✔️        |          | 0.831          | 0.895             | 0.876     | 0.427   | 0.557     | 0.518 |           |            |\n| ✔️          | ✔️                    | ✔️        | ✔️       | 0.831          | 0.895             | 0.876     | 0.362   | 0.611     | 0.537 | 0.559     | 0.495      |\n\n## Reference\n\n1. [CV vs LB Score](https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/537295)\n2. [[Eedi] Zero-shot w/ LLM feature (LB: 0.180)](https://www.kaggle.com/code/ubamba98/eedi-zero-shot-w-llm-feature-lb-0-180)\n3. [Eedi Qwen-2.5 32B AWQ two-time retrieval](https://www.kaggle.com/code/takanashihumbert/eedi-qwen-2-5-32b-awq-two-time-retrieval)\n4. [Logits Processors](https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/546978)\n5. [Qwen2.5-72B & Llama 3.3-70B on 2xT4(questionable performance)](https://www.kaggle.com/competitions/eedi-mining-misconceptions-in-mathematics/discussion/550223)\n\n## Appendix\n\n### A1. Text Generation Prompts\n\n#### a. The Student's Misconception Inference\n\n```\nThe following shows a math problem given in elementary school and the student's response. Your task is to identify objective facts about the mental model formed in the student's mind. Explain the student's thinking behind this response, based on objective facts. Use terms commonly used in U.K. elementary school curricula. Keep your explanation concise, upto 6-7 English sentences.\n\n**Subject**: {}\n\n**Construct**: {}\n\n**Question**: {}\n\n**Correct Answer**: {}\n\n**The Student's Answer**: {}\n```\n\n#### b. Rephrase Misconception\n\n```\nThe following passage is an interpretation given by a teacher regarding a student's incorrect answer in a math problem at a U.K. elementary school. Rephrase this passage using language that aligns with the U.K. elementary school math curriculum. Also, provide examples of typical incorrect answers that fall under this category. Keep your explanation as objective and concise as possible, upto 6-7 English sentences. The output should be written in English sentence.\n\n**Misconception**: {}\n```\n\n### A2. MLP Adapter's Training Parameters\n\n- num_epochs=75\n- label_smoothing=0.0\n- lr=5e-4\n- optimizer=\"adamw\"\n- in_batch_sampling=True\n- train_batch_size=256\n- hidden_dim=256\n\n### A3. Reranking Prompt\n\n```\nEvaluate the student's misconception and rank the candidates by likelihood.\nAmong the candidates, which one is the most likely to be the student's misconception?\nYou should only output the most relevant candidate ID number and no other characters are allowed.\n\nOutput Format:\nid=(the most relevant candidate ID number)\n\n**Subject**: {}\n\n**Construct**: {}\n\n**Question**: {}\n\n**Correct Answer**: {}\n\n**Student's Incorrect Answer**: {}\n\n**Candidates**:\n{}\n```\n\nExample:\n\n```\nEvaluate the student's misconception and rank the candidates by likelihood.\nAmong the candidates, which one is the most likely to be the student's misconception?\nYou should only output the most relevant candidate ID number and no other characters are allowed.\n\nOutput Format:\nid=(the most relevant candidate ID number)\n\n**Subject**: Multiplying Terms\n\n**Construct**: Multiply algebraic terms, where both are linear versions of different letters (e.g. 4a x 2b)\n\n**Question**: Simplify, if possible:\n\\[\n6 a \\times 4 b\n\\]\n\n**Correct Answer**: \\( 24 a b \\)\n\n**Student's Incorrect Answer**: Does not simplify\n\n**Candidates**:\n(id=a) Multiplies coefficients and letters separately and writes as an addition\n(id=b) Does not realise that two letters together, or a number and letter together, are multiplying\n(id=c) Does not understand how to multiply algebraic terms\n(id=d) Believes you add the terms together when multiplying like terms.\n(id=e) Does not recognise the distributive property\n(id=f) Adds instead of multiplies when multiplying algebraic terms\n(id=g) Thinks two variables next to each other represent addition\n(id=h) Does not realise multiplying a variable by itself results in a power of that variable\n(id=i) Confuses collecting like terms with multiplication\n(id=j) Thinks multiplying a variable by a number is the same as raising that variable to the power of that number\n(id=k) Does not correctly apply the commutative property of multiplication\n(id=l) Does not understand when like terms can be collected\n(id=m) Multiplies all terms together when simplifying an expression\n(id=n) When squaring a variable, believes they also need to square the coefficient\n(id=o) Believes they can ignore the coefficient when expanding double brackets\n(id=p) Does not understand the concept of inverse operations in algebra\n(id=q) Thinks that we can remove a division symbol and just write the variables next to each other\n(id=r) Does not include brackets when attempting to multiply an expression\n(id=s) Thinks any 2 values multiplied together can be denoted with a squared symbol\n(id=t) Thinks two letters next to each other is a division\n(id=u) Adds rather than multiplies when asked for a product\n(id=v) Does not know the meaning of the word \"product\"\n(id=w) Only multiplies the numerical terms when expanding a bracket\n(id=x) Does not correctly apply the distributive property of multiplication\n(id=y) Mixes up squaring and multiplying by 4\n(id=z) Thinks you apply one inverse operation to one term and the other inverse operation to the other term\n```",
      "votes": 40
    },
    {
      "id": 3072793,
      "postDate": "2024-12-15T16:32:35.830Z",
      "content": "<p>Thanks for being a source of inspiration.</p>",
      "rawMarkdown": "Thanks for being a source of inspiration.",
      "votes": -1
    },
    {
      "id": 3073310,
      "postDate": "2024-12-16T10:24:58.960Z",
      "content": "<p>Impression on Text Generation part, thanks for share~</p>",
      "rawMarkdown": "Impression on Text Generation part, thanks for share~"
    },
    {
      "id": 3072876,
      "postDate": "2024-12-15T17:56:01.633Z",
      "content": "<p>Thanks for being a source of inspiration.</p>",
      "rawMarkdown": "Thanks for being a source of inspiration.\n\n\n"
    },
    {
      "id": 3071106,
      "postDate": "2024-12-13T10:47:22.743Z",
      "content": "<p>thank you for sharing yout work! wonderful write-up as well, I can surely learn a lot from it.</p>",
      "rawMarkdown": "thank you for sharing yout work! wonderful write-up as well, I can surely learn a lot from it."
    },
    {
      "id": 3071055,
      "postDate": "2024-12-13T09:33:25.400Z",
      "content": "<p>Congrats for the solution and for an excellent write-up <a href=\"https://www.kaggle.com/tatamikenn\" target=\"_blank\">@tatamikenn</a> !</p>",
      "rawMarkdown": "Congrats for the solution and for an excellent write-up @tatamikenn !"
    },
    {
      "id": 3071033,
      "postDate": "2024-12-13T09:02:27.380Z",
      "content": "<p>What a professional, well-structured, literate write-up! Regarding the <code>Reranker Module</code>, I saw in the public notebooks a fixed value for the top 25 documents retrieved (performed by <code>NearestNeighbors</code>). Is its value tunable, or is it determined by other constraints?</p>",
      "rawMarkdown": "What a professional, well-structured, literate write-up! Regarding the `Reranker Module`, I saw in the public notebooks a fixed value for the top 25 documents retrieved (performed by `NearestNeighbors`). Is its value tunable, or is it determined by other constraints?",
      "replies": [
        {
          "id": 3071100,
          "postDate": "2024-12-13T10:37:29.023Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-20T03:45:09Z",
  "competition_id": 82695,
  "competition_slug": "eedi-mining-misconceptions-in-mathematics",
  "team_id": 12711680,
  "solution_url": "/competitions/eedi-mining-misconceptions-in-mathematics/writeups/bilzard-almost-zero-shot-solution-private-64h"
}