<meta charset="utf-8" /><meta http-equiv="content-security-policy" content=""><meta name="hf:doc:metadata" content="{&quot;local&quot;:&quot;creating-an-evaluationsuite&quot;,&quot;title&quot;:&quot;Creating an EvaluationSuite&quot;}" data-svelte="svelte-1phssyn">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/assets/pages/__layout.svelte-hf-doc-builder.css">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/start-hf-doc-builder.js">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/chunks/vendor-hf-doc-builder.js">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/chunks/paths-hf-doc-builder.js">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/pages/__layout.svelte-hf-doc-builder.js">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/pages/evaluation_suite.mdx-hf-doc-builder.js">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/chunks/IconCopyLink-hf-doc-builder.js">
	<link rel="modulepreload" href="/docs/evaluate/pr_340/en/_app/chunks/CodeBlock-hf-doc-builder.js"> 





<h1 class="relative group"><a id="creating-an-evaluationsuite" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#creating-an-evaluationsuite"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a>
	<span>Creating an EvaluationSuite
	</span></h1>

<p>The <code>EvaluationSuite</code> provides a way to compose any number of (<a href="base_evaluator">evaluator</a>, dataset, metric) tuples to evaluate a model on a collection of several evaluation tasks.</p>
<p>A new <code>EvaluationSuite</code> is made up of <code>SubTask</code> classes, and can be defined by subclassing the <code>EvaluationSuite</code> class. Files can be uploaded to a Space on the Hugging Face Hub or saved locally.</p>
<p>Datasets which require additional preprocessing before being used with an <code>Evaluator</code> can be processed with <code>datasets</code> transformations by setting the <code>preprocessor</code> attribute to a preprocessing function. Keyword arguments for the <code>Evaluator</code> can be passed down through <code>args_for_task</code>.</p>

	<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5   text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
	<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
	Copied</div></button></div>
	<pre><!-- HTML_TAG_START --><span class="hljs-keyword">import</span> evaluate
<span class="hljs-keyword">from</span> evaluate.evaluation_suite <span class="hljs-keyword">import</span> SubTask

<span class="hljs-keyword">class</span> <span class="hljs-title class_">Suite</span>(evaluate.EvaluationSuite):

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, name</span>):
        <span class="hljs-built_in">super</span>().__init__(name)
        self.preprocessor = <span class="hljs-keyword">lambda</span> x: {<span class="hljs-string">&quot;text&quot;</span>: x[<span class="hljs-string">&quot;text&quot;</span>].lower()}
        self.suite = [
            SubTask(
                task_type=<span class="hljs-string">&quot;text-classification&quot;</span>,
                data=<span class="hljs-string">&quot;glue&quot;</span>,
                subset=<span class="hljs-string">&quot;cola&quot;</span>,
                split=<span class="hljs-string">&quot;test[:10]&quot;</span>,
                args_for_task={
                    <span class="hljs-string">&quot;metric&quot;</span>: <span class="hljs-string">&quot;accuracy&quot;</span>,
                    <span class="hljs-string">&quot;input_column&quot;</span>: <span class="hljs-string">&quot;sentence&quot;</span>,
                    <span class="hljs-string">&quot;label_column&quot;</span>: <span class="hljs-string">&quot;label&quot;</span>,
                    <span class="hljs-string">&quot;label_mapping&quot;</span>: {
                        <span class="hljs-string">&quot;LABEL_0&quot;</span>: <span class="hljs-number">0.0</span>,
                        <span class="hljs-string">&quot;LABEL_1&quot;</span>: <span class="hljs-number">1.0</span>
                    }
                }
            )
        ]<!-- HTML_TAG_END --></pre></div>
<p>An <code>EvaluationSuite</code> can be loaded by name from the Hugging Face Hub, or locally by providing a path, and run with <code>.run(model_or_pipeline)</code>.</p>

	<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5   text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
	<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
	Copied</div></button></div>
	<pre><!-- HTML_TAG_START --><span class="hljs-keyword">from</span> evaluate <span class="hljs-keyword">import</span> EvaluationSuite

suite = EvaluationSuite.load(<span class="hljs-string">&#x27;mathemakitten/glue&#x27;</span>)
results = suite.run(<span class="hljs-string">&quot;gpt2&quot;</span>)<!-- HTML_TAG_END --></pre></div>
<p>The evaluation results are printed along with their task names and information about the time it took to obtain predictions through the pipeline.</p>

	<div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5   text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg>
	<div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div>
	Copied</div></button></div>
	<pre><!-- HTML_TAG_START -->{<span class="hljs-string">&#x27;glue/cola&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.0</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">0.9766696180449799</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">10.238876909079256</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.09766696180449798</span>}, <span class="hljs-string">&#x27;glue/sst2&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.5</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">1.1422595420153812</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">8.754577775166744</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.11422595420153811</span>}, <span class="hljs-string">&#x27;glue/qqp&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.6</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">1.3553926559980027</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">7.377935800188323</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.13553926559980026</span>}, <span class="hljs-string">&#x27;glue/mrpc&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.6</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">2.021696529001929</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">4.946340786832532</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.2021696529001929</span>}, <span class="hljs-string">&#x27;glue/mnli&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.2</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">2.0380110969999805</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">4.9067446270142145</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.20380110969999807</span>}, <span class="hljs-string">&#x27;glue/qnli&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.3</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">2.082032073987648</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">4.802999975330509</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.20820320739876477</span>}, <span class="hljs-string">&#x27;glue/rte&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.7</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">2.8592985830036923</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">3.4973612267855576</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.2859298583003692</span>}, <span class="hljs-string">&#x27;glue/wnli&#x27;</span>: {<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.5</span>, <span class="hljs-string">&#x27;total_time_in_seconds&#x27;</span>: <span class="hljs-number">1.5406486629508436</span>, <span class="hljs-string">&#x27;samples_per_second&#x27;</span>: <span class="hljs-number">6.490772517107661</span>, <span class="hljs-string">&#x27;latency_in_seconds&#x27;</span>: <span class="hljs-number">0.15406486629508437</span>}}<!-- HTML_TAG_END --></pre></div>


		<script type="module" data-hydrate="1632dwe">
		import { start } from "/docs/evaluate/pr_340/en/_app/start-hf-doc-builder.js";
		start({
			target: document.querySelector('[data-hydrate="1632dwe"]').parentNode,
			paths: {"base":"/docs/evaluate/pr_340/en","assets":"/docs/evaluate/pr_340/en"},
			session: {},
			route: false,
			spa: false,
			trailing_slash: "never",
			hydrate: {
				status: 200,
				error: null,
				nodes: [
					import("/docs/evaluate/pr_340/en/_app/pages/__layout.svelte-hf-doc-builder.js"),
						import("/docs/evaluate/pr_340/en/_app/pages/evaluation_suite.mdx-hf-doc-builder.js")
				],
				params: {}
			}
		});
	</script>
