범주형 vs 수치형 메트릭 반환 방법
범주형 vs 수치형 메트릭 반환 방법
LangSmith는 범주형과 수치형 메트릭을 모두 지원하며, 커스텀 평가자를 작성할 때 둘 중 하나를 반환할 수 있어요.
평가자 결과가 수치형(numerical) 메트릭으로 기록되려면 다음으로 반환해야 합니다:
- (Python만)
int,float, 또는bool {"key": "metric_name", "score": int | float | bool}형태의 dict
평가자 결과가 범주형(categorical) 메트릭으로 기록되려면 다음으로 반환해야 합니다:
- (Python만)
str {"key": "metric_name", "value": str | int | float | bool}형태의 dict
예제는 다음과 같습니다:
- Python:
langsmith>=0.2.0필요 - TypeScript: 다중 점수 지원은
[email protected]이상에서 사용 가능
출처: 문서
본문
def numerical_metric(inputs: dict, outputs: dict, reference_outputs: dict) -> float:
# Evaluation logic...
return 0.8
# Equivalently
# return {"score": 0.8}
# Or
# return {"key": "numerical_metric", "score": 0.8}
def categorical_metric(inputs: dict, outputs: dict, reference_outputs: dict) -> str:
# Evaluation logic...
return "english"
# Equivalently
# return {"key": "categorical_metric", "score": "english"}
# Or
# return {"score": "english"}
import type { Run, Example } from "langsmith/schemas";
function numericalMetric(run: Run, example: Example) {
// Your evaluation logic here
return { key: "numerical_metric", score: 0.8};
}
function categoricalMetric(run: Run, example: Example) {
// Your evaluation logic here
return { key: "categorical_metric", value: "english"};
}
관련 자료
더 알아보기
- 하나의 평가자에서 여러 점수 반환 — 한 번에 여러 메트릭 기록.