> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-hivemind-launch.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 모니터 설정

> 프로덕션 트래픽을 별도 개입 없이 점수화해 추세와 문제를 파악합니다

모니터는 LLM 기반 평가자를 사용해 프로덕션 트래픽을 별도 개입 없이 점수화하고, LLM 애플리케이션의 추세와 문제를 파악할 수 있게 해줍니다. 예를 들어 애플리케이션의 응답을 정확성이나 유용성 측면에서 모니터링할 수 있고, 사용자 입력을 모니터링해 사용자가 에이전트에 무엇을 묻는지의 추세를 파악할 수도 있습니다. 모니터는 모든 점수화 결과를 Weave 데이터베이스에 자동으로 저장하므로, 과거 추세와 패턴을 분석할 수 있습니다.

애플리케이션의 입력과 출력에서 텍스트, 이미지, 오디오를 모니터링할 수 있습니다.

모니터를 사용하기 위해 애플리케이션 코드를 변경할 필요는 없습니다. W\&B Weave UI에서 설정하세요.

점수에 따라 애플리케이션의 동작에 적극적으로 개입해야 한다면, 대신 [guardrails](/ko/weave/guides/evaluation/guardrails)을 사용하세요.

<div id="how-to-create-a-monitor-in-weave">
  ## Weave에서 모니터를 생성하는 방법
</div>

Weave에서 모니터를 생성하려면 다음 단계를 따르세요.

1. [W\&B UI](https://wandb.ai/home)를 연 다음 Weave 프로젝트를 엽니다.

2. Weave 사이드 내비게이션에서 **Monitors**를 선택한 다음 **+ New Monitor** 버튼을 선택합니다. 그러면 **Create new monitor** 모달 대화상자가 열립니다.

3. Create new monitor 메뉴에서 다음 필드를 설정합니다.
   * **Name**: 문자 또는 숫자로 시작해야 합니다. 문자, 숫자, 하이픈, 밑줄을 포함할 수 있습니다.
   * **Description** (선택): 모니터의 기능을 설명합니다.
   * **Active monitor** 토글: 모니터를 켜거나 끕니다.
   * **Calls to monitor**:
     * **Operations**: 모니터링할 `@weave.op`를 하나 이상 선택합니다. 사용 가능한 op 목록에 표시되려면 먼저 해당 op를 사용하는 트레이스를 하나 이상 log해야 합니다.
     * **Filter** (선택): 점수화 대상이 되는 call을 좁힙니다(예: `max_tokens` 또는 `top_p` 기준).
     * **Sampling rate**: 점수를 매길 call의 비율입니다(0%\~100%).
       <Tip>
         샘플링 비율이 낮을수록 각 점수화 call에 비용이 발생하므로 전체 비용을 줄일 수 있습니다.
       </Tip>
   * **LLM-as-a-judge 설정**:
     * **Scorer name**: 문자 또는 숫자로 시작해야 합니다. 문자, 숫자, 하이픈, 밑줄을 포함할 수 있습니다.
     * **Score Audio**: 사용 가능한 LLM 모델을 오디오 지원 모델만 표시하도록 필터링하고 Media Scoring JSON Paths 필드를 엽니다.
     * **Score Images**: 사용 가능한 LLM 모델을 이미지 지원 모델만 표시하도록 필터링하고 Media Scoring JSON Paths 필드를 엽니다.
     * **Judge model**: op의 점수를 매길 모델을 선택합니다. 이 메뉴에는 W\&B 계정에서 설정한 상용 LLM 모델과 [Serverless Inference models](/ko/inference/models)이 포함됩니다. 오디오 지원 모델은 이름 옆에 **Audio Input** 레이블이 표시됩니다. 선택한 모델에 대해 다음 설정을 구성합니다.
       * **Configuration name**: 이 모델 설정의 이름입니다.
       * **System prompt**: 평가 모델의 역할과 페르소나를 정의합니다. 예: "You are an impartial AI judge."
       * **Response format**: 평가자가 응답을 출력할 형식입니다(예: `json_object` 또는 일반 `text`).
       * **Scoring prompt**: op의 점수를 매기는 데 사용하는 평가 작업입니다. 점수화 프롬프트에서 op의 [prompt variables](/ko/weave/guides/evaluation/scorers#access-variables-from-your-ops-in-scoring-prompts)를 참조할 수 있습니다. 예: "Evaluate whether `{output}` is accurate based on `{ground_truth}`."
     * **Media Scoring JSON Paths**: 트레이스 데이터에서 미디어를 추출할 JSONPath 표현식(RFC 9535)을 지정합니다. 경로를 지정하지 않으면 사용자 메시지의 점수화 가능한 모든 미디어가 포함됩니다. 이 필드는 **Score Audio** 또는 **Score Images**를 활성화하면 표시됩니다.

4. 모니터 필드 설정을 마쳤으면 **Create monitor**를 클릭합니다. 그러면 모니터가 Weave 프로젝트에 추가됩니다. 코드가 트레이스를 생성하기 시작하면 **Traces** 탭에서 모니터 이름을 선택하고 표시되는 패널의 데이터를 검토해 점수를 확인할 수 있습니다.

또한 Weave UI에서 모니터의 트레이스 데이터를 [비교](/ko/weave/guides/tools/comparison)하고 시각화하거나, Traces 탭의 다운로드 버튼(<Icon icon="download" iconType="regular" />)을 사용해 다양한 형식(예: CSV, JSON)으로 다운로드할 수 있습니다.

Weave는 모든 scorer 결과를 [Call](/ko/weave/guides/tracking/tracing#calls) 객체의 `feedback` 필드에 자동으로 저장합니다.

<div id="example-create-a-truthfulness-monitor">
  ### 예시: 진실성 모니터 만들기
</div>

다음 예시에서는 생성된 문장의 진실성을 평가하는 모니터를 만듭니다.

1. 문장을 생성하는 함수를 정의합니다. 일부 문장은 사실에 부합하고, 일부는 그렇지 않습니다:

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import weave
    import random
    import openai

    weave.init("my-team/my-weave-project")

    client = openai.OpenAI()

    @weave.op()
    def generate_statement(ground_truth: str) -> str:
        if random.random() < 0.5:
            response = client.chat.completions.create(
                model="gpt-4.1",
                messages=[
                    {
                        "role": "user",
                        "content": f"Generate a statement that is incorrect based on this fact: {ground_truth}"
                    }
                ]
            )
            return response.choices[0].message.content
        else:
            return ground_truth

    generate_statement("The Earth revolves around the Sun.")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import * as weave from 'weave';
    import OpenAI from 'openai';

    await weave.init('my-team/my-weave-project');

    const client = new OpenAI();

    const generateStatement = weave.op(async (ground_truth: string): Promise<string> => {
      if (Math.random() < 0.5) {
        const response = await client.chat.completions.create({
          model: 'gpt-4.1',
          messages: [
            {
              role: 'user',
              content: `Generate a statement that is incorrect based on this fact: ${ground_truth}`,
            },
          ],
        });
        return response.choices[0]?.message?.content ?? '';
      }
      return ground_truth;
    });

    await generateStatement("The Earth revolves around the Sun.");
    ```
  </Tab>
</Tabs>

2. 함수를 최소 한 번 실행하여 프로젝트에 트레이스를 로깅합니다. 그러면 W\&B UI에서 해당 op를 모니터링 대상으로 사용할 수 있습니다.

3. W\&B UI에서 Weave 프로젝트를 열고 사이드 내비게이션에서 **Monitors**를 선택합니다. 그런 다음 **New Monitor**를 선택합니다.

4. Create new monitor 메뉴에서 다음 값으로 필드를 설정합니다:
   * **Name**: `truthfulness-monitor`
   * **Description**: `Evaluates the truthfulness of generated statements.`
   * **Active monitor**: **on**으로 설정합니다.
   * **Operations**: `generate_statement`를 선택합니다.
   * **Sampling rate**: 모든 call을 점수화하도록 `100%`로 설정합니다.
   * **Scorer name**: `truthfulness-scorer`
   * **Judge model**: `o3-mini-2025-01-31`
   * **System prompt**: `You are an impartial AI judge. Your task is to evaluate the truthfulness of statements.`
   * **Response format**: `json_object`
   * **Scoring prompt**:
     ```text theme={null}
     Evaluate whether the output statement is accurate based on the input statement.

     This is the input statement: {ground_truth}

     This is the output statement: {output}

     The response should be a JSON object with the following fields:
     - is_true: a boolean stating whether the output statement is true or false based on the input statement.
     - reasoning: your reasoning as to why the statement is true or false.
     ```

5. **Create Monitor**를 클릭합니다. 그러면 모니터가 Weave 프로젝트에 추가됩니다.

6. 스크립트에서 진실성의 정도가 서로 다른 문장을 사용해 함수를 호출하여 스코어링 함수를 테스트합니다:

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    generate_statement("The Earth revolves around the Sun.")
    generate_statement("Water freezes at 0 degrees Celsius.")
    generate_statement("The Great Wall of China was built over several centuries.")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    await generateStatement("The Earth revolves around the Sun.");
    await generateStatement("Water freezes at 0 degrees Celsius.");
    await generateStatement("The Great Wall of China was built over several centuries.");
    ```
  </Tab>
</Tabs>

7. 여러 문장으로 스크립트를 실행한 후 W\&B UI를 열고 **Traces** 탭으로 이동합니다. 아무 **LLMAsAJudgeScorer.score** 트레이스나 선택해 결과를 확인합니다.

<img src="https://mintcdn.com/wb-21fd5541-docs-hivemind-launch/HbhUDAG_r2i2K_Pk/weave/guides/evaluation/img/monitors-4.png?fit=max&auto=format&n=HbhUDAG_r2i2K_Pk&q=85&s=e58dec7afc74856f85a3c31dc2b6efb3" alt="모니터 트레이스" width="3024" height="1428" data-path="weave/guides/evaluation/img/monitors-4.png" />
