From bb16cd53e0c307642dbb1bbdc411cf4ad70245cc Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Wed, 18 Dec 2024 16:20:28 +0000 Subject: [PATCH] Fixed scorer docs --- .../src/content/docs/guides/scorers.mdx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/evalite-docs/src/content/docs/guides/scorers.mdx b/apps/evalite-docs/src/content/docs/guides/scorers.mdx index 3eda6b1..f77390f 100644 --- a/apps/evalite-docs/src/content/docs/guides/scorers.mdx +++ b/apps/evalite-docs/src/content/docs/guides/scorers.mdx @@ -16,14 +16,14 @@ import { createScorer } from "evalite"; const containsParis = createScorer({ name: "Contains Paris", description: "Checks if the output contains the word 'Paris'.", - score: (output) => { + score: ({ output }) => { return output.includes("Paris") ? 1 : 0; }, }); evalite("My Eval", { data: async () => { - return [{ input: "Hello", output: "Hello World!" }]; + return [{ input: "Hello" }]; }, task: async (input) => { return input + " World!"; @@ -34,6 +34,25 @@ evalite("My Eval", { The `name` and `description` of the scorer will be displayed in the Evalite UI. +### Score Properties + +The `score` function receives three properties on the object passed: + +```ts +import { createScorer } from "evalite"; + +const containsParis = createScorer({ + name: "Contains Paris", + description: "Checks if the output contains the word 'Paris'.", + score: ({ input, output, expected }) => { + // input comes from `data` + // expected also comes from `data` + // output is the output of `task` + return output.includes("Paris") ? 1 : 0; + }, +}); +``` + ## Type Arguments In TypeScript, `createScorer` takes two type arguments, the input and output type: