Have you seen our custom evaluation wrappers? They are
a great way to quickly create your own evaluation class.
If you want to write your own evaluation class, you can do so by extending the BaseEvaluator
class.You can extend the BaseEvaluator class. See this example You need to implement the following methods:
@propertydef _model(self): # Which model was used for this evaluation pass@propertydef name(self): return "UpperCamelCaseName"@propertydef display_name(self): return "Evaluation Display Name"@propertydef metric_ids(self) -> List[str]: return [MetricType.PASSED.value]@propertydef default_function_arguments(self): return {}@propertydef required_args(self): # expects an array of strings from ["query", "context", "response", "expected_response", "text"] pass@propertydef examples(self): passdef is_failure(self) -> Optional[bool]: passdef _evaluate(self, **kwargs) -> EvalResult: pass
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Athina","colors":{"primary":"#1976D2","light":"#419BF4","dark":"#1976D2"},"favicon":"/logo/light.svg","logo":{"light":"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/logo/light.svg","dark":"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/logo/dark.svg"},"api":{"mdx":{"server":null,"auth":{"method":"key","name":"athina-api-key"}}},"navbar":{"links":[{"label":"AI Hub","href":"https://hub.athina.ai"},{"label":"Website","href":"https://athina.ai"}],"primary":{"type":"button","label":"Sign-up","href":"https://app.athina.ai/"}},"footer":{"socials":{"twitter":"https://twitter.com/AthinaAI","linkedin":"https://linkedin.com/company/athina-ai"}},"integrations":{"ga4":{"measurementId":"G-KZVC5R2GB1"}},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"athinaai","hasAudioNarration":false,"actualSubdomain":"athinaai","customDomains":["docs.athina.ai"],"gitSource":{"type":"github","owner":"athina-ai","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6a21e615bd0a90f91cb442e4","collectionId":"b894bf83-39f4-42e1-9517-d1cffb901672","schemaVersion":"v2"},"feedback":{"thumbs":false},"entitlements":{},"buildId":"6a21e615bd0a90f91cb442e4:success","clientVersion":"0.0.4043","searchFilterCounts":[{"language":"default","tag":"Documentation","count":166},{"language":"default","tag":"Docs","count":79},{"language":"default","tag":"API / SDK Reference","count":54},{"language":"default","tag":"Evals","count":52},{"language":"default","tag":"Datasets","count":37},{"language":"default","tag":"Guides","count":23},{"language":"default","tag":"Logging","count":21},{"language":"default","tag":"Preset Evals","count":15},{"language":"default","tag":"Prompts","count":14},{"language":"default","tag":"Logging LLM Inferences","count":13}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/evals/custom-evals/create-your-own-eval","slug":"/api-reference/evals/custom-evals/create-your-own-eval","pageMetadata":{"title":"Write your own LLM Eval class","sidebarTitle":"Create Your Own Eval","description":null,"href":"/api-reference/evals/custom-evals/create-your-own-eval"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(Tip,{children:_jsxs(_components.p,{children:[`Have you seen our `,_jsx(_components.a,{href:`/evals/custom-evals`,children:`custom evaluation`}),` wrappers? They are\na great way to quickly create your own evaluation class.`]})}),`\n`,_jsxs(_components.p,{children:[`If you want to write your own evaluation class, you can do so by extending the `,_jsx(_components.code,{children:`BaseEvaluator`}),`\nclass.`]}),`\n`,_jsxs(_components.p,{children:[`You can extend the `,_jsx(_components.code,{children:`BaseEvaluator`}),` class. See this `,_jsx(_components.a,{href:`https://github.com/athina-ai/athina-evals/blob/main/athina/evals/base_evaluator.py`,children:`example `})]}),`\n`,_jsx(_components.p,{children:`You need to implement the following methods:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`38`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`38`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` _model`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # Which model was used for this evaluation`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` pass`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"UpperCamelCaseName\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` display_name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Evaluation Display Name\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` metric_ids`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> List[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [MetricType.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`PASSED`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.value]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` default_function_arguments`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {}`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` required_args`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # expects an array of strings from [\"query\", \"context\", \"response\", \"expected_response\", \"text\"]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` pass`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`@`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`property`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` examples`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` pass`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` is_failure`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> Optional[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`bool`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` pass`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` _evaluate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`self`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`**`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`kwargs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> EvalResult:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` pass`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`]})})}),`\n`,_jsxs(Tip,{children:[_jsx(_components.p,{children:_jsx(_components.strong,{children:`Contribute !`})}),_jsxs(_components.p,{children:[`If you write an evaluator that could be useful for others, please consider raising a PR at `,_jsx(_components.a,{href:`https://github.com/athina-ai/athina-evals`,children:`https://github.com/athina-ai/athina-evals`}),`.`]})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Write your own LLM Eval class","sidebarTitle":"Create Your Own Eval","description":null,"href":"/api-reference/evals/custom-evals/create-your-own-eval"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"subdomain":"athinaai","siteName":"Athina","title":"Write your own LLM Eval class - Athina","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"originalFileLocation":"api-reference/evals/custom-evals/create-your-own-eval.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Athina\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/_generated/favicon/apple-touch-icon.png?v=3\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/_generated/favicon/favicon-32x32.png?v=3\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/_generated/favicon/favicon-16x16.png?v=3\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/_generated/favicon/favicon.ico?v=3\">\u003cmeta data-mint-head property=\"og:title\" content=\"Write your own LLM Eval class - Athina\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Athina\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://athinaai.mintlify.app/_mintlify/api/og/v2?division=Custom+Evals\u0026amp;title=Write+your+own+LLM+Eval+class\u0026amp;theme=999050368802f5d9cfbe8395\u0026amp;signature=5df527bfd03d15b6f543859ad7bb38fa7e7e523d5f5f0503f8221bebedc1135b\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Write your own LLM Eval class - Athina\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://athinaai.mintlify.app/_mintlify/api/og/v2?division=Custom+Evals\u0026amp;title=Write+your+own+LLM+Eval+class\u0026amp;theme=999050368802f5d9cfbe8395\u0026amp;signature=5df527bfd03d15b6f543859ad7bb38fa7e7e523d5f5f0503f8221bebedc1135b\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/_generated/favicon/browserconfig.xml?v=3\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Athina\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1976D2\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/evals/custom-evals/create-your-own-eval.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.athina.ai/#organization\",\"name\":\"Athina\",\"url\":\"https://docs.athina.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintlify.s3.us-west-1.amazonaws.com/athinaai/logo/light.svg\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.athina.ai#website\",\"name\":\"Athina\",\"url\":\"https://docs.athina.ai\",\"publisher\":{\"@id\":\"https://docs.athina.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval#webpage\",\"url\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval\",\"name\":\"Write your own LLM Eval class\",\"isPartOf\":{\"@id\":\"https://docs.athina.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Evals\",\"item\":\"https://docs.athina.ai/api-reference/evals/running-evals/run-single-eval\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Custom Evals\",\"item\":\"https://docs.athina.ai/api-reference/evals/custom-evals/api-call\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Write your own LLM Eval class\",\"item\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval#article\",\"headline\":\"Write your own LLM Eval class\",\"name\":\"Write your own LLM Eval class\",\"url\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval\",\"mainEntityOfPage\":{\"@id\":\"https://docs.athina.ai/api-reference/evals/custom-evals/create-your-own-eval#webpage\"},\"publisher\":{\"@id\":\"https://docs.athina.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.athina.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Athina\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Athina","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open","tabs":[{"tab":"Docs","pages":[{"title":"Docs","href":"/overview"}]},{"tab":"API / SDK Reference","groups":[{"group":"Logging","pages":[{"title":"Logging","sidebarTitle":"Overview","icon":"hand-wave","href":"/api-reference/logging/overview"},{"title":"Logging Attributes","sidebarTitle":"Logging Attributes","api":"POST https://log.athina.ai/api/v2/log/inference","href":"/api-reference/logging/logging-attributes"},{"group":"Logging LLM Inferences","icon":"code","pages":[{"title":"Log via API Request","api":"POST https://log.athina.ai/api/v2/log/inference","href":"/api-reference/logging/log-via-api-request"},{"title":"Log via Python SDK","icon":"code","href":"/api-reference/logging/log-via-python-sdk"},{"title":"Log via TypeScript SDK","icon":"code","href":"/api-reference/logging/log-via-typescript-sdk"},{"title":"Langchain","icon":"code","href":"/api-reference/logging/langchain"},{"title":"🚅 LiteLLM","sidebarTitle":"LiteLLM","icon":"code","href":"/api-reference/logging/lite-llm"},{"title":"OpenAI Chat Completion","sidebarTitle":"OpenAI Chat (1.x)","icon":"code","href":"/api-reference/logging/openai-chat-1x"},{"title":"OpenAI Chat Completion","sidebarTitle":"OpenAI Chat (0.x)","icon":"code","href":"/api-reference/logging/openai-chat-0x"},{"title":"OpenAI Assistant","icon":"code","href":"/api-reference/logging/openai-assistant"},{"title":"Tracing","icon":"code","href":"/api-reference/logging/tracing"},{"title":"Tracing via API","icon":"code","href":"/api-reference/logging/tracing-via-api"},{"title":"Tracing using Python decorators","icon":"code","href":"/api-reference/logging/tracing-using-python-decorators"},{"title":"Tracing for Langchain (Python)","sidebarTitle":"Tracing for Langchain","icon":"code","href":"/api-reference/logging/tracing-for-langchain"},{"title":"Supported Models","icon":"cube","href":"/api-reference/logging/supported-models"}]},{"group":"Updating Logs","icon":"pencil","pages":[{"title":"Update Logs By ID","icon":"code","href":"/api-reference/logging/updates/update-logs-by-id"},{"title":"Update Logs By External Reference ID","icon":"code","href":"/api-reference/logging/updates/update-logs-by-external-reference-id"}]}]},{"group":"Datasets","pages":[{"title":"List All Datasets","icon":"code","href":"/api-reference/datasets/list"},{"title":"Create a Dataset","icon":"code","href":"/api-reference/datasets/create-dataset"},{"title":"Add Rows to Dataset","icon":"code","href":"/api-reference/datasets/add-rows-to-dataset"},{"title":"Get Dataset","icon":"code","href":"/api-reference/datasets/get-dataset"},{"title":"Delete Dataset","icon":"code","href":"/api-reference/datasets/delete-dataset"},{"title":"Update Cells in a Dataset","icon":"code","href":"/api-reference/datasets/update-cell-via-api"}]},{"group":"Evals","pages":[{"group":"Running Evals via SDK","icon":"bolt-lightning","pages":[{"title":"Running Evals","sidebarTitle":"Python: Run a single eval","icon":"code","href":"/api-reference/evals/running-evals/run-single-eval"},{"title":"Running a suite of evals","sidebarTitle":"Python: Run evals on a dataset","icon":"code","href":"/api-reference/evals/running-evals/run-eval-suite"}]},{"group":"Loading Data for Evals","icon":"file-import","pages":[{"title":"Loading data for Evals","icon":"code","href":"/api-reference/evals/loading-data/loading-data-for-eval"},{"title":"Loading data via Llama-Index","icon":"code","href":"/api-reference/evals/loading-data/loading-data-via-llama-index"}]},{"group":"Preset Evals","icon":"grid","pages":[{"title":"Preset Evals","sidebarTitle":"Overview","icon":"grid","href":"/api-reference/evals/preset-evals/overview"},{"group":"RAG Evals","icon":"files","pages":[{"title":"Context Sufficiency","icon":"code","href":"/api-reference/evals/preset-evals/rag/context-sufficiency"},{"title":"Response Faithfulness","icon":"code","href":"/api-reference/evals/preset-evals/rag/response-faithfulness"},{"title":"Answer Completeness","icon":"code","href":"/api-reference/evals/preset-evals/rag/answer-completeness"},{"title":"Groundedness","icon":"code","href":"/api-reference/evals/preset-evals/rag/groundedness"},{"title":"RAGAS","icon":"ruler-triangle","href":"/api-reference/evals/preset-evals/rag/ragas"}]},{"group":"Safety","icon":"shield","pages":[{"title":"PII Detection","icon":"shield","href":"/api-reference/evals/preset-evals/safety/pii-detection"},{"title":"Prompt Injection","icon":"shield","href":"/api-reference/evals/preset-evals/safety/prompt-injection"},{"title":"OpenAI Content Moderation","icon":"shield","href":"/api-reference/evals/preset-evals/safety/open-ai-content-moderation"},{"title":"Guardrails","icon":"shield","href":"/api-reference/evals/preset-evals/guardrails"}]},{"title":"JSON Evals","icon":"brackets-curly","href":"/api-reference/evals/preset-evals/json-evals"},{"title":"Summarization QA","icon":"code","href":"/api-reference/evals/preset-evals/summarization-qa"},{"sidebarTitle":"Function Evals","title":"Function Based Evaluators","icon":"code","href":"/api-reference/evals/preset-evals/function-evals"},{"title":"Grounded Evals","href":"/api-reference/evals/preset-evals/grounded-evals"},{"title":"Conversation Evals","sidebarTitle":"Conversation Evaluators","href":"/api-reference/evals/preset-evals/conversation-evals"}]},{"group":"Custom Evals","pages":[{"title":"API Call","href":"/api-reference/evals/custom-evals/api-call"},{"sidebarTitle":"LLM-as-a-Judge (Custom Prompt Eval)","title":"LLM-as-a-Judge (Custom Prompt Eval)","href":"/api-reference/evals/custom-evals/custom-prompt"},{"title":"Pairwise Evaluation","href":"/api-reference/evals/custom-evals/pairwise-evaluation"},{"sidebarTitle":"Custom Code Eval","title":"Evaluation with Custom Python Code","href":"/api-reference/evals/custom-evals/custom-code-eval"},{"title":"Custom Grading Criteria","description":null,"href":"/api-reference/evals/custom-evals/grading-criteria"},{"title":"Write your own LLM Eval class","sidebarTitle":"Create Your Own Eval","href":"/api-reference/evals/custom-evals/create-your-own-eval"}]}]},{"group":"GraphQL API","pages":[{"title":"Overview","icon":"hand-wave","description":null,"href":"/api-reference/graphql-api/overview"},{"title":"Getting Started","icon":"rocket","href":"/api-reference/graphql-api/getting-started"},{"title":"Sample GraphQL Queries","icon":"code","href":"/api-reference/graphql-api/sample-queries"},{"title":"Query the Graph API using cURL or Python","sidebarTitle":"Curl and Python Examples","href":"/api-reference/graphql-api/curl-python-examples"}]},{"group":"Deprecated","pages":[{"title":"OpenAI Completions","sidebarTitle":"OpenAI Completion 0.x","href":"/api-reference/logging/misc/openai-completion-0x"},{"title":"OpenAI Completions","sidebarTitle":"OpenAI Completion 1.x","href":"/api-reference/logging/misc/openai-completion-1x"}]}]},{"tab":"Guides","pages":[{"title":"Guides","href":"/guides/overview"}]},{"tab":"FAQs","pages":[{"title":"FAQs","href":"/faqs/data-policy"}]}]},{"anchor":"Open-Source Evals","href":"https://github.com/athina-ai/athina-evals","icon":"github"},{"anchor":"Blog","href":"https://blog.athina.ai/","icon":"book"},{"anchor":"Email us","href":"mailto:hello@athina.ai","icon":"envelope"},{"anchor":"Book a call","href":"https://cal.com/shiv-athina/30min","icon":"calendar"}]},"basePath":"","title":"Write your own LLM Eval class - Athina","buildId":"dpl_G9nrg4qeJSZtah1Ziwbc2n6WkLch","deploymentId":"dpl_G9nrg4qeJSZtah1Ziwbc2n6WkLch","dynamics":[],"chunks":[]}