MMLU
Massive Multitask Language Understanding
A benchmark that evaluates LLM knowledge with multiple-choice questions across 57 subjects.
Massive Multitask Language Understanding
A benchmark that evaluates LLM knowledge with multiple-choice questions across 57 subjects.
MMLU (Massive Multitask Language Understanding) is a representative benchmark for evaluating the knowledge and reasoning abilities of LLMs. It consists of approximately 15,000 four-choice multiple-choice questions spanning 57 academic subjects, and includes a range of difficulty levels from elementary school to expert level.
It was published in 2020 by Dan Hendrycks's research team at UC Berkeley. At that time, even GPT-3 fell far behind human experts (89.8%), with an accuracy of 43.9%. It has since been used as a key indicator of LLM progress, and in 2024 GPT-4o achieved 87.2% and Claude 3.5 Sonnet achieved 88.7%.
MMLU consists of four major categories: STEM (mathematics, physics, computer science), humanities (history, philosophy, law), social sciences (economics, psychology, politics), and other (medicine, business). Under a few-shot setting (5-shot is the standard), the model is given examples and then evaluated on whether it can pick the correct answer.
In practice, the MMLU score is a key criterion for choosing an LLM. For legal AI, the detailed law scores are consulted, and for medical AI, the detailed medicine scores. However, since MMLU alone cannot evaluate every capability, it should be judged comprehensively together with HumanEval (coding), MT-Bench (conversation), and others.
from datasets import load_dataset
from openai import OpenAI
import re
# MMLU 데이터셋 로드 (HuggingFace)
dataset = load_dataset("cais/mmlu", "all", split="test")
# 특정 과목 필터링 (예: computer_science)
cs_questions = [q for q in dataset if q["subject"] == "high_school_computer_science"]
client = OpenAI()
def evaluate_mmlu_question(question, choices, answer_idx):
"""MMLU 문제 평가 함수"""
# 5-shot 프롬프트 구성 (실제로는 few-shot 예시 추가)
prompt = f"""Answer the following multiple choice question. Only output A, B, C, or D.
Question: {question}
A) {choices[0]}
B) {choices[1]}
C) {choices[2]}
D) {choices[3]}
Answer:"""
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
max_tokens=1,
temperature=0
)
predicted = response.choices[0].message.content.strip().upper()
correct_answer = ["A", "B", "C", "D"][answer_idx]
return predicted == correct_answer
# 샘플 평가 실행
correct = 0
total = min(50, len(cs_questions)) # 샘플 50문제
for i, q in enumerate(cs_questions[:total]):
is_correct = evaluate_mmlu_question(
q["question"],
q["choices"],
q["answer"]
)
correct += int(is_correct)
if (i + 1) % 10 == 0:
print(f"Progress: {i+1}/{total}, Accuracy: {correct/(i+1)*100:.1f}%")
print(f"\nFinal Accuracy: {correct/total*100:.1f}%")
print(f"Subject: high_school_computer_science")
# lm-evaluation-harness 사용 (더 정확한 평가)
# pip install lm-eval
# lm_eval --model openai --model_args model=gpt-4o-mini --tasks mmlu --batch_size 8
"Our fine-tuned model's MMLU score improved by 12% in the legal domain compared to the base model. The overall score dropped slightly from 72% to 68%, but since performance rose in the target domain, it can be seen as a trade-off."
"MMLU is a benchmark that tests knowledge across 57 subjects. GPT-4 scored 86% and Claude 3 Opus scored 86.8%, approaching the level of human experts. However, MMLU focuses on knowledge rather than reasoning, so coding is evaluated separately with HumanEval and math with GSM8K."
"You shouldn't look at the MMLU score alone. There is criticism that recent models have overfit to MMLU, so harder benchmarks such as MMLU-Pro and GPQA have emerged. Real-world task performance should be evaluated separately with domain-specific test sets."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
MMLU is only a knowledge test. Coding ability, long-context understanding, instruction following, and so on must be evaluated with separate benchmarks.
Check HumanEval (coding), MT-Bench (conversation), TruthfulQA (accuracy), and others together with MMLU. The most important thing is your own evaluation set that fits your actual use cases.