LangSmith는 categorical 및 numerical metrics를 모두 지원하며, custom evaluator를 작성할 때 둘 중 하나를 반환할 수 있습니다. evaluator 결과가 numerical metric으로 기록되려면 다음과 같이 반환되어야 합니다:
  • (Python만 해당) int, float, 또는 bool
  • {"key": "metric_name", "score": int | float | bool} 형식의 dict
evaluator 결과가 categorical metric으로 기록되려면 다음과 같이 반환되어야 합니다:
  • (Python만 해당) str
  • {"key": "metric_name", "value": str | int | float | bool} 형식의 dict
다음은 몇 가지 예시입니다:
  • Python: langsmith>=0.2.0 필요
  • TypeScript: 여러 score 지원은 [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"}

관련 항목


Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I