{ "cells": [ { "cell_type": "markdown", "id": "97a673be", "metadata": {}, "source": [ "# IRT modeling\n", "\n", "MathArena benchmark measures the performance of different LLMs on a variety of mathematical problems.\n", "\n", "We use the [results](https://matharena.ai/?view=detailed&comp=usamo--usamo_2026) from USAMO 2026, which is a math competition for high school students in the United States.\n", "\n", "There are **6 models**, **6 problems**, each problem is scored on a **scale of 0 to 7** and each model has **4 attempts** at each problem.\n", "\n", "Let's try to fit an IRT model to this data." ] }, { "cell_type": "markdown", "id": "03d8a0bd", "metadata": {}, "source": [ "IRT model assumes that each LLM $m$ has a latent ability $\\theta_m$ and each question has a difficulty $b_q$ and discrimination $a_q$. The probability of LLM $i$ solving problem $j$ is given by the logistic function:\n", "$$P(X_{mq} = 1) = \\frac{1}{1 + e^{-a_q(\\theta_m - b_q)}}$$\n", "\n", "Where $X_{mq}$ is the binary outcome of whether LLM $m$ solved problem $q$ (1 if solved, 0 if not).\n", "\n", "Well... our outcome is not binary, but as a first approximation we can treat the score as binomial rv with $n=7$ trials and $p$ being the probability of solving each point of the problem." ] }, { "cell_type": "code", "execution_count": 1, "id": "a22a5535", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import pymc as pm\n", "import arviz as az\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "id": "7c631000", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
modelproblemrunscore
0GPT-5.4117
1GPT-5.4127
2GPT-5.4137
3GPT-5.4147
4GPT-5.4217
\n", "
" ], "text/plain": [ " model problem run score\n", "0 GPT-5.4 1 1 7\n", "1 GPT-5.4 1 2 7\n", "2 GPT-5.4 1 3 7\n", "3 GPT-5.4 1 4 7\n", "4 GPT-5.4 2 1 7" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(\"models_scores.csv\")\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 8, "id": "5cf04682", "metadata": {}, "outputs": [], "source": [ "model_idx, model_labels = pd.factorize(df[\"model\"])\n", "problem_idx, problem_labels = pd.factorize(df[\"problem\"])" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.8" } }, "nbformat": 4, "nbformat_minor": 5 }