> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 모델 비교 및 순위 지정

> 평가 메트릭을 기준으로 여러 모델 버전을 비교하고 순위를 지정합니다

Weave Leaderboards를 사용하면 여러 모델을 다양한 메트릭으로 평가 및 비교하고 정확도, 생성 품질, 지연 시간 또는 맞춤형 평가 로직을 측정할 수 있습니다. 리더보드를 활용하면 모델 성능을 한곳에서 시각화하고, 시간에 따른 변화를 추적하며, 팀 전체가 동일한 벤치마크를 기준으로 삼을 수 있습니다.

이 가이드에서는 팀이 공유 벤치마크를 기준으로 모델 버전을 비교할 수 있도록 리더보드를 생성, 설정, 게시하는 방법을 설명합니다.

리더보드는 다음과 같은 경우에 적합합니다.

* 모델 성능 저하 추적
* 공유 평가 워크플로 조율

> [!NOTE]
>
> 리더보드는 Weights & Biases UI와 Weave Python SDK에서만 생성할 수 있습니다. TypeScript 사용자는 [Weights & Biases UI](#use-the-ui)에서 리더보드를 생성하고 관리할 수 있습니다.

## 리더보드 만들기

리더보드는 [Weights & Biases UI](#use-the-ui)에서 만들거나 [프로그래밍 방식](#use-the-python-sdk)으로 만들 수 있습니다. 필요할 때마다 간단히 비교하려면 UI를 사용하고, 리더보드 생성을 자동화된 평가 워크플로에 통합하려면 Python SDK를 사용하세요.

### UI 사용하기

Weights & Biases UI에서 리더보드를 대화형으로 생성하고 사용자 지정할 수 있습니다. 다음 단계를 따르세요.

1. Weights & Biases UI에서 **Leaders** 섹션으로 이동하세요. 보이지 않으면 **More** → **Leaders**를 클릭하세요.
2. **+ New Leaderboard**를 클릭하세요.
3. **Leaderboard Title** 필드에 리더보드를 잘 나타내는 이름을 입력하세요(예: `summarization-benchmark-v1`).
4. 필요하면 이 리더보드에서 무엇을 비교하는지 설명을 추가하세요.
5. [열을 추가](#add-columns)하여 표시할 평가와 메트릭을 지정하세요.
6. 레이아웃이 완성되면 리더보드를 저장하고 게시하여 다른 사람과 공유하세요.

#### 열 추가

열은 리더보드에서 각 모델에 대해 표시할 내용을 정의합니다. 리더보드의 각 열은 특정 평가의 메트릭을 나타냅니다. 열을 설정하려면 다음 항목을 지정합니다.

* **Evaluation**: 드롭다운에서 평가 run을 선택하세요(미리 생성되어 있어야 합니다).
* **Scorer**: 해당 평가에 사용된 점수화 함수를 선택하세요(예: `jaccard_similarity` 또는 `simple_accuracy`).
* **Metric**: 표시할 summary 메트릭을 선택하세요(예: `mean` 또는 `true_fraction`).

열을 더 추가하려면 **Add Column**을 클릭하세요.

열을 편집하려면 오른쪽의 액션() 메뉴를 클릭하세요. 다음 작업을 할 수 있습니다.

* **Move before or after**. 열 순서를 변경합니다.
* **Duplicate**. 열 정의를 복사합니다.
* **Delete**. 열을 삭제합니다.
* **Sort ascending**. 리더보드의 기본 정렬을 설정합니다(다시 클릭하면 내림차순으로 전환됩니다).

### Python SDK 사용하기

Python SDK를 사용하면 코드에서 리더보드를 정의하고, 게시하고, 조회할 수 있습니다. 이 방식을 사용하면 리더보드를 평가 코드와 함께 버전 관리하고 자동화된 워크플로의 일부로 실행할 수 있습니다.

> [!TIP]
>
> 바로 실행할 수 있는 전체 코드 예시가 필요하신가요? [엔드투엔드 Python 예시](#end-to-end-python-example)를 참조하세요.

리더보드를 생성하고 게시하려면 다음 단계를 따르세요.

1. 테스트 데이터셋을 정의합니다. 기본 제공 [`Dataset`](https://docs.coreweave.com/ko/products/wandb/weave/guides/core-types/datasets)을 사용하거나, 입력과 타깃 목록을 직접 정의할 수 있습니다.

   ```python lines theme={"system"}
   dataset = [
       {"input": "...", "target": "..."},
       ...
   ]
   ```

2. 하나 이상의 [Scorer](https://docs.coreweave.com/ko/products/wandb/weave/guides/evaluation/scorers.md)를 정의합니다.

   ```python lines theme={"system"}
   @weave.op
   def jaccard_similarity(target: str, output: str) -> float:
       ...
   ```

3. [`Evaluation`](https://docs.coreweave.com/ko/products/wandb/weave/guides/core-types/evaluations)을 생성합니다.

   ```python lines theme={"system"}
   evaluation = weave.Evaluation(
       name="My Eval",
       dataset=dataset,
       scorers=[jaccard_similarity],
   )
   ```

4. 평가할 모델을 정의합니다.

   ```python lines theme={"system"}
   @weave.op
   def my_model(input: str) -> str:
       ...
   ```

5. 평가를 실행합니다.

   ```python lines theme={"system"}
    async def run_all():
        await evaluation.evaluate(model_vanilla)
        await evaluation.evaluate(model_humanlike)
        await evaluation.evaluate(model_messy)

   asyncio.run(run_all())
   ```

6. 리더보드를 생성합니다.

   ```python lines theme={"system"}
   spec = leaderboard.Leaderboard(
       name="My Leaderboard",
       description="Evaluating models on X task",
       columns=[
           leaderboard.LeaderboardColumn(
               evaluation_object_ref=get_ref(evaluation).uri(),
               scorer_name="jaccard_similarity",
               summary_metric_path="mean",
           )
       ]
   )
   ```

7. 리더보드를 게시합니다.

   ```python lines theme={"system"}
   weave.publish(spec)
   ```

8. 결과를 조회합니다.

   ```python lines theme={"system"}
   results = leaderboard.get_leaderboard_results(spec, client)
   print(results)
   ```

게시한 리더보드는 Weights & Biases UI의 **Leaders** 탭에서 사용할 수 있으며, 팀원들은 이 탭에서 모델 성능을 확인하고 비교할 수 있습니다.

## 엔드투엔드 Python 예시

다음 예시에서는 Weave Evaluations로 리더보드를 만들고, 맞춤형 메트릭을 사용해 공유 데이터셋에서 세 가지 요약 모델을 비교합니다. 소규모 벤치마크를 만들어 각 모델을 평가하고, [Jaccard 유사도](https://www.learndatasci.com/glossary/jaccard-similarity/)로 각 모델의 점수를 매긴 후, 결과를 Weave 리더보드에 게시합니다.

```python lines theme={"system"}
import weave
from weave.flow import leaderboard
from weave.trace.ref_util import get_ref
import asyncio

client = weave.init("leaderboard-demo")

dataset = [
    {
        "input": "Weave is a tool for building interactive LLM apps. It offers observability, trace inspection, and versioning.",
        "target": "Weave helps developers build and observe LLM applications."
    },
    {
        "input": "The OpenAI GPT-4o model can process text, audio, and vision inputs, making it a multimodal powerhouse.",
        "target": "GPT-4o is a multimodal model for text, audio, and images."
    },
    {
        "input": "The W&B team recently added native support for agents and evaluations in Weave.",
        "target": "W&B added agents and evals to Weave."
    }
]

@weave.op
def jaccard_similarity(target: str, output: str) -> float:
    target_tokens = set(target.lower().split())
    output_tokens = set(output.lower().split())
    intersection = len(target_tokens & output_tokens)
    union = len(target_tokens | output_tokens)
    return intersection / union if union else 0.0

evaluation = weave.Evaluation(
    name="Summarization Quality",
    dataset=dataset,
    scorers=[jaccard_similarity],
)

@weave.op
def model_vanilla(input: str) -> str:
    return input[:50]

@weave.op
def model_humanlike(input: str) -> str:
    if "Weave" in input:
        return "Weave helps developers build and observe LLM applications."
    elif "GPT-4o" in input:
        return "GPT-4o supports text, audio, and vision input."
    else:
        return "W&B added agent support to Weave."

@weave.op
def model_messy(input: str) -> str:
    return "Summarizer summarize models model input text LLMs."

async def run_all():
    await evaluation.evaluate(model_vanilla)
    await evaluation.evaluate(model_humanlike)
    await evaluation.evaluate(model_messy)

asyncio.run(run_all())

spec = leaderboard.Leaderboard(
    name="Summarization Model Comparison",
    description="Evaluate summarizer models using Jaccard similarity on three short samples.",
    columns=[
        leaderboard.LeaderboardColumn(
            evaluation_object_ref=get_ref(evaluation).uri(),
            scorer_name="jaccard_similarity",
            summary_metric_path="mean",
        )
    ]
)

weave.publish(spec)

results = leaderboard.get_leaderboard_results(spec, client)
print(results)
```

### 리더보드 보기 및 해석

스크립트가 리더보드를 게시하면 Weights & Biases UI에서 결과를 확인하고 모델 성능을 나란히 비교할 수 있습니다.

1. Weights & Biases UI에서 **Leaders** 탭으로 이동하세요. 탭이 보이지 않으면 **More**를 클릭한 다음 **Leaders**를 선택하세요.
2. 리더보드 이름(예: `Summarization Model Comparison`)을 클릭하세요.

리더보드 table의 각 행은 하나의 모델(`model_humanlike`, `model_vanilla`, `model_messy`)을 나타냅니다. `mean` 열에는 모델 출력과 참조 요약 간의 평균 Jaccard 유사도가 표시됩니다.

![Weights & Biases UI의 리더보드](https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/leaderboard-example.png?fit=max\&auto=format\&n=3Dv_sw2eg8feUJlx\&q=85\&s=3da07eee6db4c80e3a534776f396a85d)

이 예제의 결과는 다음과 같습니다.

* `model_humanlike`는 약 46%의 일치율로 가장 높은 성능을 보입니다.
* `model_vanilla`(단순히 텍스트를 잘라내는 방식)는 약 21%를 기록합니다.
* 의도적으로 성능을 낮게 만든 `model_messy`는 약 2%에 그칩니다.
