🔥 DeepEval 4.0 just got released. Read the announcement.
Available Benchmarks

SQuAD

SQuAD (Stanford Question Answering Dataset) is a QA benchmark designed to test a language model's reading comprehension capabilities. It consists of 100K question-answer pairs (including 10K in the validation set), where each answer is a segment of text taken directly from the accompanying reading passage. To learn more about the dataset and its construction, you can read the original SQuAD paper here.

Arguments

There are THREE optional arguments when using the SQuAD benchmark:

  • [Optional] tasks: a list of tasks (SQuADTask enums), which specifies the subject areas for model evaluation. By default, this is set to all tasks. The list of SQuADTask enums can be found here.
  • [Optional] n_shots: the number of examples for few-shot learning. This is set to 5 by default and cannot exceed 5.
  • [Optional] evaluation_model: a string specifying which of OpenAI's GPT models to use for scoring, OR any custom LLM model of type DeepEvalBaseLLM. Defaulted to gpt-5.4.

Usage

The code below assesses a custom mistral_7b model (click here to learn how to use ANY custom LLM) on passages about pharmacy and Normans in SQuAD using 3-shot prompting.

from deepeval.benchmarks import SQuAD
from deepeval.benchmarks.tasks import SQuADTask

# Define benchmark with specific tasks and shots
benchmark = SQuAD(
    tasks=[SQuADTask.PHARMACY, SQuADTask.NORMANS],
    n_shots=3
)

# Replace 'mistral_7b' with your own custom model
benchmark.evaluate(model=mistral_7b)
print(benchmark.overall_score)

The overall_score for this benchmark ranges from 0 to 1, where 1 signifies perfect performance and 0 indicates no correct answers. The model's score, based on LLM-as-a-judge, is calculated by evaluating whether the predicted answer aligns with the expected output based on the passage context.

For example, if the question asks, "How many atoms are present?" and the model predicts "two atoms," the LLM-as-a-judge determines whether this aligns with the expected answer of "2" by assessing semantic equivalence rather than exact text matching.

SQuAD Tasks

The SQuADTask enum classifies the diverse range of categories covered in the SQuAD benchmark.

from deepeval.benchmarks.tasks import SQuADTask

math_qa_tasks = [SQuADTask.PHARMACY]

Below is the comprehensive list of available tasks:

  • PHARMACY
  • NORMANS
  • HUGUENOT
  • DOCTOR_WHO
  • OIL_CRISIS_1973
  • COMPUTATIONAL_COMPLEXITY_THEORY
  • WARSAW
  • AMERICAN_BROADCASTING_COMPANY
  • CHLOROPLAST
  • APOLLO_PROGRAM
  • TEACHER
  • MARTIN_LUTHER
  • ECONOMIC_INEQUALITY
  • YUAN_DYNASTY
  • SCOTTISH_PARLIAMENT
  • ISLAMISM
  • UNITED_METHODIST_CHURCH
  • IMMUNE_SYSTEM
  • NEWCASTLE_UPON_TYNE
  • CTENOPHORA
  • FRESNO_CALIFORNIA
  • STEAM_ENGINE
  • PACKET_SWITCHING
  • FORCE
  • JACKSONVILLE_FLORIDA
  • EUROPEAN_UNION_LAW
  • SUPER_BOWL_50
  • VICTORIA_AND_ALBERT_MUSEUM
  • BLACK_DEATH
  • CONSTRUCTION
  • SKY_UK
  • UNIVERSITY_OF_CHICAGO
  • VICTORIA_AUSTRALIA
  • FRENCH_AND_INDIAN_WAR
  • IMPERIALISM
  • PRIVATE_SCHOOL
  • GEOLOGY
  • HARVARD_UNIVERSITY
  • RHINE
  • PRIME_NUMBER
  • INTERGOVERNMENTAL_PANEL_ON_CLIMATE_CHANGE
  • AMAZON_RAINFOREST
  • KENYA
  • SOUTHERN_CALIFORNIA
  • NIKOLA_TESLA
  • CIVIL_DISOBEDIENCE
  • GENGHIS_KHAN
  • OXYGEN

FAQs

What does the SQuAD benchmark measure?
SQuAD tests a language model's reading comprehension by asking question-answer pairs where each answer is a segment of text taken directly from an accompanying Wikipedia passage. It contains 100K question-answer pairs, including 10K in the validation set. See the benchmarks introduction for how scoring works across benchmarks.
How is SQuAD scored in deepeval?
Unlike most benchmarks, deepeval's SQuAD implementation uses an LLM-as-a-judge to generate a binary score that determines whether the prediction aligns with the expected output given the passage context. This assesses semantic equivalence rather than relying on exact match, so an answer of "two atoms" can still align with an expected "2".
Why does SQuAD require an evaluation_model?
Because scoring is performed by an LLM-as-a-judge, you must supply an evaluation_model. It accepts a string for one of OpenAI's GPT models, or any custom LLM of type DeepEvalBaseLLM, and the judge decides whether a prediction and the expected output align.
What is the default n_shots for SQuAD?
It defaults to 5 and cannot exceed that. Use the n_shots argument to lower it for few-shot prompting.
Which tasks can I evaluate with SQuAD?
You can pass a list of SQuADTask enums to the tasks argument to target specific subject areas such as PHARMACY or NORMANS. By default, all tasks are evaluated.
How do I run SQuAD on a custom LLM?
Define the benchmark, then call evaluate() with your model (for example a custom DeepEvalBaseLLM) and read overall_score, which ranges from 0 to 1. See benchmarking your LLM for details.

On this page