メインコンテンツへスキップ
weave / Evaluation スコアラーのセットとデータセットを含む評価を構成します。 evaluation.evaluate(model) を呼び出すと、データセットの各行がモデルに渡され、 データセットの列名が model.predict の引数名に対応付けられます。 その後、すべてのスコアラーが呼び出され、結果が weave に保存されます。 Example
// 例をデータセットに収集する
const dataset = new weave.Dataset({
  id: 'my-dataset',
  rows: [
    { question: 'What is the capital of France?', expected: 'Paris' },
    { question: 'Who wrote "To Kill a Mockingbird"?', expected: 'Harper Lee' },
    { question: 'What is the square root of 64?', expected: '8' },
  ],
});

// カスタムスコアリング関数を定義する
const scoringFunction = weave.op(function isEqual({ modelOutput, datasetRow }) {
  return modelOutput == datasetRow.expected;
});

// 評価する関数を定義する
const model = weave.op(async function alwaysParisModel({ question }) {
  return 'Paris';
});

// 評価を開始する
const evaluation = new weave.Evaluation({
  id: 'my-evaluation',
  dataset: dataset,
  scorers: [scoringFunction],
});

const results = await evaluation.evaluate({ model });

型パラメーター

名前
Rextends DatasetRow
Eextends DatasetRow
MM

階層

目次

コンストラクタ

プロパティ

アクセサ

メソッド

コンストラクタ

コンストラクター

new Evaluation<R, E, M>(parameters): Evaluation<R, E, M>

型パラメーター

名前
Rextends DatasetRow
Eextends DatasetRow
MM

パラメータ

名前
parametersEvaluationParameters<R, E, M>

戻り値

Evaluation<R, E, M>

オーバーライド

WeaveObject.constructor

定義元

evaluation.ts:148

プロパティ

__savedRef

Optional __savedRef: ObjectRef | Promise<ObjectRef>

継承元

WeaveObject.__savedRef

定義場所

weaveObject.ts:73

アクセサ

description

get description(): undefined | string

戻り値

undefined | string

継承元

WeaveObject.description

定義元

weaveObject.ts:100

name

get name(): string

戻り値

string

継承元

WeaveObject.name

定義元

weaveObject.ts:96

メソッド

evaluate

evaluate(«destructured»): Promise<Record<string, any>>

パラメータ

名前デフォルト値
«destructured»Objectundefined
› maxConcurrency?number5
› modelWeaveCallable<(…args: [{ datasetRow: R }]) => Promise<M>>undefined
› nTrials?number1

戻り値

Promise<Record<string, any>>

定義場所

evaluation.ts:163

predictAndScore

predictAndScore(«destructured»): Promise<{ model_latency: number = modelLatency; model_output: any = modelOutput; model_success: boolean = !modelError; scores: { [key: string]: any; } }>

パラメータ

名前
«destructured»Object
› columnMapping?ColumnMapping<R, E>
› exampleR
› modelWeaveCallable<(…args: [{ datasetRow: E }]) => Promise<M>>

戻り値

Promise<{ model_latency: number = modelLatency; model_output: any = modelOutput; model_success: boolean = !modelError; scores: { [key: string]: any; } }>

定義場所

evaluation.ts:231

saveAttrs

saveAttrs(): Object

戻り値

Object

継承元

WeaveObject.saveAttrs

定義元

weaveObject.ts:77