# 13th Place Solution 

Thank you Kaggle  and The Learning Agency Lab  for hosting this competition.
Although we are disappointed 😢 to loose gold by one rank, we are grateful for the opportunity to learn and grow.
Summary
Our highest scoring private LB submission was -
(a) Knowledge Distillation
Qwen2.5-Math-7B-Instruct was used to solve the question in order to reach the final correct answer. The base model itself was used as it seemed quite capable and also to not overfit the Public LB. This reasoning was used to train the Embedding model for the next step
(b) Candidate Generation
Qwen2.5-14B-Instruct was finetuned with the reasoning text from step 1. Training code was adapted from
[@sayoulala](https://www.kaggle.com/sayoulala)
’s github repo. This retriever was used to obtain the top 100 misconceptions
(c) 1st Listwise Reranking
The top 100 misconceptions from step 2 are stuffed into the prompt and sent to a finetuned Qwen2.5-32B-Instruct along with the Subject, Construct, Question, Correct Answer and the Incorrect Answer. The model generates just 1 token (the letter id) associated with the correct misconception. However, the logprobs were calculated to obtain the top 25 misconception ids rather than just 1
(d) 2nd Listwise Reranking
The top 25 misconceptions from stage 3 are now reranked in the same manner using a finetuned Qwen2.5-72B-Instruct
All the above combined gives private 0.561 and public 0.578.
Data
CV - 4 fold based on groupkfold by misconception id.
Training Embedding Model
FlagEmbedding (adapted from
[@sayoulala](https://www.kaggle.com/sayoulala)
’s github repo)
Used SFR fine-tuned embedding model predictions to get hard negatives. Public LB score for this model was 0.45x which is less than public kernel, however this worked better when combined with reranker.
Reasoning for the correct answer generated by Qwen 2.5 Math 7b instruct was part of the input as well. (Private 0.433 , Public 0.486)
Training Multiple Choice Reranker
72B
LLaMa-Factory was utilized to finetune all 72B models using LoRA in a distributed setting.  All models were trained and sharded with the DeepSpeed ZeRO-3 protocol to ensure the weights, gradients, and optimizer states could all fit within the available VRAM.
32B
Trained using Hugging Face SFT Trainer
Inference
Qwen 2.5 Math 7b uses vllm in fp16
Qwen 2.5 14b uses bnb to fit on a single gpu - we used both GPUs to speed up inference.
Qwen 2.5 32b and 72b are run in fp16 one layer at a time - we used both GPUs to speed up inference.
Total submission time: 500 minutes (8.3 hrs)
Failed ideas
Ensembling 72b models
Inserting step-by-step solution into context window of reranker
Various ways to generate synthetic data
32B Embedding model - was part of final selection but not the best submission. (Private 0.453, Public 0.470)
AWQ Qwen14B embedding model - but it requires vllm >= 0.6.4 for inference on Kaggle.
Synthetic Data - One of the models with synthetic data was part of 3 selected submissions.
Lastly, Huge Thank you to my fabulous  team mates 🌟
[@nbroad](https://www.kaggle.com/nbroad)
, 🌟
[@abdullahmeda](https://www.kaggle.com/abdullahmeda)
and 🌟
[@benbla](https://www.kaggle.com/benbla)
for your hard work and collaboration on this competition !!