하나의 평가자에서 여러 점수 반환 방법

하나의 평가자에서 여러 점수 반환 방법

커스텀 평가자 또는 요약 평가자가 여러 메트릭을 반환하는 것이 유용할 때가 있어요. 예를 들어 LLM 판사가 생성하는 메트릭이 여러 개라면, 여러 LLM 호출을 하는 대신 여러 메트릭을 생성하는 단일 LLM 호출을 만들어 시간과 비용을 절약할 수 있어요.

Python SDK로 여러 점수를 반환하려면 다음 형태의 dict/객체 목록을 반환하면 됩니다:

[
    # 'key' is the metric name
    # 'score' is the value of a numerical metric
    {"key": string, "score": number},
    # 'value' is the value of a categorical metric
    {"key": string, "value": string},
    ... # You may log as many as you wish
]

JS/TS SDK로 이렇게 하려면 'results' 키가 있는 객체를 반환한 다음 위 형태의 목록을 반환합니다

{results: [{ key: string, score: number }, ...]};

이 dict 각각은 feedback 필드의 일부 또는 전부를 포함할 수 있습니다. 자세한 내용은 연결된 문서를 확인하세요.

예제:

  • Python: langsmith>=0.2.0 필요
  • TypeScript: 다중 점수 지원은 [email protected] 이상에서 사용 가능

출처: 문서

본문

def multiple_scores(outputs: dict, reference_outputs: dict) -> list[dict]:
    # Replace with real evaluation logic.
    precision = 0.8
    recall = 0.9
    f1 = 0.85
    return [
        {"key": "precision", "score": precision},
        {"key": "recall", "score": recall},
        {"key": "f1", "score": f1},
    ]
import type { Run, Example } from "langsmith/schemas";

function multipleScores(rootRun: Run, example: Example) {
  // Your evaluation logic here
  return {
      results: [
          { key: "precision", score: 0.8 },
          { key: "recall", score: 0.9 },
          { key: "f1", score: 0.85 },
      ],
  };
}

결과 실험의 행은 각 점수를 표시합니다.

관련 자료

더 알아보기