# AIMO-2: Bronze Medal Solution 

Bronze Medal Solution (141st) for "AI Mathematical Olympiad - Progress Prize 2
Solve national-level math challenges using artificial intelligence models".
[https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2](https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2)
I would like to express my heartfelt gratitude to Kaggle and the competition Hosts AI|MO for organizing this challenging competition. Congratulations to all the prize and medal winners in this competition. I am glad to win the Bronze medal with a rank of 141st.
This Competition with very high prize moneys  generated lot of excitement.
The participants came forward to share notebooks, ideas  and discussion topics. I am glad to take part  in a competition involving Olympiad level math problems. I  learnt a lot through watching videos of organizers, reading articles and papers, discussions and code posted by participants. I am also currently teaching a subject on LLM which helped me a lot in preparing for this competition.
For my solution for the AIMO-Progress Prize Competition, I started with public notebooks and improvised upon them.  I also used my experience in participating in previous edition of AIMO. I used  open source deepseek-r1-distill-qwen-7b-awq LLM and combined it with prompt engineering, time management and  voting mechanisms to get stable and reasonably good performance.
Prompt Engineering: The prompting  not only guides the model to generate the correct responses but also restricts the model from hallucinating and overthinking. The final prompt is
"
You are an expert trained for Mathematics  Olympiad-level problem solving. Solve the  problem using a rigorous, step-by-step approach. You must give correct final answer.  After solving, review your solution carefully. Avoid overthinking and Hallucination. Analyse the solution to correct any errors or overlooked cases.  Put your Correct final answer within \boxed{}, after taking modulo 1000.
"
Even though this prompting could not achieve higher scores on public LB, it was consistent and stable in generating the solutions.
The prompt uses chain-of-thought approach
Stresses on Correctness of the  response.
Review the answer to find errors and fix them
Instructs the model to avoid overthinking and hallucination
I also improved the time management function to utilize the time efficiently:
*cutoff_time = start_time + (4 * 60 + 45) * 60 # approx 4 hours 45 minutes
cutoff_times = [int(x) for x in np.linspace(cutoff_time, start_time + 15 * 60, 50 + 1)] #start the cutoff times after 15 minutes. *
Also, as the notebook relies on voting of solutions generated, used uniform random number generator in the range of 0-1000  to be returned if model could not find the solution or ran out of time.  This is  to reduce probability of same number being repeated resulting in selection of default values for solutions.
if time.time() > cutoff_time:
random.randint(0, 1000)*
The final Leaderboard score = 24
Runnng time of notebook : Approx 5 hours with Accelerator GPU L4 x4
References:
Simon Frieder, Sam Bealing, Arsenii Nikolaiev, Geoff C. Smith, Kevin Buzzard, Timothy Gowers, Peter J. Liu, Po-Shen Loh, Lester Mackey, Leonardo de Moura, Dan Roberts, D. Sculley, Terence Tao, David Balduzzi, Simon Coyle, Alex Gerko, Ryan Holbrook, Addison Howard, and XTX Markets. AI Mathematical Olympiad - Progress Prize 2.
[https://kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2](https://kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2)
, 2024. Kaggle.
[https://www.kaggle.com/code/itahiro/deepseek-r1-distill-qwen-7b](https://www.kaggle.com/code/itahiro/deepseek-r1-distill-qwen-7b)
( Public high scoring notebook)
[https://www.kaggle.com/code/richolson/ai-math-olympiad-qwen2-5-72b](https://www.kaggle.com/code/richolson/ai-math-olympiad-qwen2-5-72b)
( showing how to submit)
[https://www.kaggle.com/code/abdullahmeda/load-72b-awq-model-using-vllm-on-l4-x4](https://www.kaggle.com/code/abdullahmeda/load-72b-awq-model-using-vllm-on-l4-x4)
[https://www.kaggle.com/code/huikang/qwen2-5-math-1-5b-instruct](https://www.kaggle.com/code/huikang/qwen2-5-math-1-5b-instruct)
6 AI Overthinking: How LLMs Fall into Analysis Paralysis:
[https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2/discussion/569781](https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2/discussion/569781)
AIMO Progress Prize 2: Repeatability of Solutions,
[https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2/discussion/568192](https://www.kaggle.com/competitions/ai-mathematical-olympiad-progress-prize-2/discussion/568192)
8 About the DeepSeek 7b Model used in the solution notebook.
[https://huggingface.co/casperhansen/deepseek-r1-distill-qwen-7b-awq](https://huggingface.co/casperhansen/deepseek-r1-distill-qwen-7b-awq)
Introduction to Large Language Models by Tanmoy Chakraborty, Wiley Publishers
[https://www.wileyindia.com/introduction-to-large-language-models.html](https://www.wileyindia.com/introduction-to-large-language-models.html)
Gemma Cookbook,
[https://github.com/google-gemini/gemma-cookbook](https://github.com/google-gemini/gemma-cookbook)