> ## 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.

# フィードバックを収集してアノテーションを使用する

> UI と SDK を使用して LLM アプリケーションのフィードバックを収集・分析します

LLM アプリケーションを評価するには、フィードバックを収集・分析するためのツールが必要です。W\&B Weave には統合されたフィードバックシステムが用意されており、UI から直接、または SDK を使用してプログラムから Call にフィードバックを提供できます。Weave は絵文字によるリアクション、テキストコメント、構造化データなど、複数のフィードバックタイプをサポートしているため、チームで次のようなことを行えます。

* パフォーマンスのモニタリング用に評価データセットを構築する。
* LLM が生成するコンテンツの問題を特定して解決する。
* ファインチューニングなどの高度なタスクに使用するサンプルを収集する。

このガイドは、Weave で LLM アプリケーションを扱う開発者とレビュアーを対象としています。UI と SDK の両方での Weave のフィードバック機能の使い方、フィードバックをクエリして管理する方法、詳細な評価に人によるアノテーションを使用する方法について説明します。

* [UI でフィードバックを提供する](#provide-feedback-in-the-ui)
* [SDK を使用してフィードバックを提供する](#provide-feedback-through-the-sdk)
* [人によるアノテーションを追加する](#add-human-annotations)

<h2 id="provide-feedback-in-the-ui">
  UI でフィードバックを提供する
</h2>

以下のセクションでは、Weights & Biases の UI でフィードバックを提供する方法を説明します。フィードバックは、Call details パネルから、またはフィードバックアイコンを使用して提供できます。

<h3 id="use-the-call-details-panel">
  Call details パネルを使用する
</h3>

1. Weave プロジェクトのサイドバーで、**Traces** にアクセスします。
2. フィードバックを追加する Call の行を探します。
3. リンクになっている トレース名をクリックして、トレース ツリーと Call details パネルを開きます。
4. Call details のタブバーで **Feedback** を選択します。
5. フィードバックを追加、表示、または削除します。
   * *アイコンを使用してフィードバックを追加および表示します。* アイコンは Call details のフィードバックビューの右上にあります。
   * *Call details のフィードバック表でフィードバックを表示および削除します。* フィードバックを削除するには、対象のフィードバック行の右端の列にあるゴミ箱アイコンをクリックします。

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/feedback_tab.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=50b49b6e6e2614b182b1a33775754175" alt="Call details の Feedback タブ" width="1266" height="548" data-path="products/wandb/weave/_media/feedback_tab.png" />
</Frame>

<h3 id="use-the-feedback-icons">
  フィードバックアイコンを使用する
</h3>

Traces の表と個々の Call details パネルの両方にあるアイコンを使用して、リアクションの追加や削除、メモの追加を行えます。

* *Traces の表*: **Traces** の表の該当する行の **Feedback** 列にあります。
* *Call details パネル*: 各 Call details パネルの右上にあります。

リアクションを追加するには:

1. 絵文字アイコンをクリックします。
2. 高評価または低評価を追加するか、**+** アイコンをクリックしてその他の絵文字を選択します。

リアクションを削除するには:

1. 削除する絵文字リアクションにマウスカーソルを合わせます。
2. リアクションをクリックして削除します。

> [Call details パネルの **Feedback** 列](#use-the-call-details-panel)からフィードバックを削除することもできます。

コメントを追加するには:

1. コメントの吹き出しアイコンをクリックします。
2. テキストボックスにメモを入力します。フィードバックのメモは最大 1024 文字です。
3. **Enter** キーを押してメモを保存します。メモは複数追加できます。

<Warning>
  フィードバックのメモは最大 1024 文字です。この制限を超えるメモは Weave によって作成されません。
</Warning>

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/feedback_calls.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=ab4006b5d636f9e87db1edc7a80fd1ab" alt="Feedback 列を含む Call のグリッド" width="3056" height="1589" data-path="products/wandb/weave/_media/feedback_calls.png" />
</Frame>

<h2 id="provide-feedback-through-the-sdk">
  SDK を使用してフィードバックを提供する
</h2>

UI で手動でフィードバックを入力する代わりに、フィードバックの収集を自動化したい場合や、評価パイプラインに統合したい場合は、SDK を使用します。

フィードバックに関する SDK の使用例は、UI の Call details パネルにある **Use** タブで確認できます。

Weave Python SDK を使用すると、Call に対するフィードバックをプログラムから[追加](/ja/products/wandb/weave/reference/python-sdk/trace/feedback#method-add)、[削除](/ja/products/wandb/weave/reference/python-sdk/trace/feedback#method-purge)、[クエリ](/ja/products/wandb/weave/reference/python-sdk/trace/weave_client#method-get_feedback)できます。TypeScript SDK はフィードバック機能をサポートしていません。

<h3 id="query-a-projects-feedback">
  project のフィードバックをクエリする
</h3>

SDK を使用して、Weave プロジェクトのフィードバックをクエリできます。SDK では、次のフィードバッククエリ操作がサポートされています。

* `client.get_feedback()`: project 内のすべてのフィードバックを返します。
* `client.get_feedback("[FEEDBACK-UUID]")`: `[FEEDBACK-UUID]` で指定した特定のフィードバックオブジェクトをコレクションとして返します。
* `client.get_feedback(reaction="[REACTION-TYPE]")`: 特定のリアクションタイプに該当するすべてのフィードバックオブジェクトを返します。

`client.get_feedback()` では、各フィードバックオブジェクトについて次の詳細情報も取得できます。

* `id`: フィードバックオブジェクトの ID。
* `created_at`: フィードバックオブジェクトの作成日時。
* `feedback_type`: フィードバックのタイプ (リアクション、メモ、カスタム) 。
* `payload`: フィードバックのペイロード。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    import weave
    client = weave.init('intro-example')

    # project 内のすべてのフィードバックを取得する
    all_feedback = client.get_feedback()

    # ID を指定して特定のフィードバックオブジェクトを取得する。
    # API はコレクションを返しますが、含まれる項目は最大 1 つです。
    one_feedback = client.get_feedback("[FEEDBACK-UUID]")[0]

    # 特定のリアクションを持つすべてのフィードバックオブジェクトを検索する。offset と limit も指定できます。
    thumbs_up = client.get_feedback(reaction="👍", limit=10)

    # 取得後、個々のフィードバックオブジェクトの詳細を確認する。
    for f in client.get_feedback():
        print(f.id)
        print(f.created_at)
        print(f.feedback_type)
        print(f.payload)
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    この機能は TypeScript ではまだ利用できません。
    ```
  </Tab>
</Tabs>

<h3 id="add-feedback-to-a-call">
  Call にフィードバックを追加する
</h3>

Call の UUID を使用して、Call にフィードバックを追加できます。UUID を使用して特定の Call を取得するには、[Call の実行中または実行後に UUID を取得](#retrieve-the-call-uuid)してください。SDK では、Call にフィードバックを追加するための次の操作がサポートされています。

* `call.feedback.add_reaction("[REACTION-TYPE]")`: 👍 など、サポートされる `[REACTION-TYPE]` の値 (絵文字) のいずれかを追加します。
* `call.feedback.add_note("[NOTE]")`: メモを追加します。
* `call.feedback.add("[LABEL]", [OBJECT])`: `[LABEL]` で指定したカスタムフィードバック `[OBJECT]` を追加します。

<Warning>
  フィードバックのメモの最大文字数は 1024 文字です。この制限を超えるメモは Weave によって作成されません。
</Warning>

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    import weave
    client = weave.init('intro-example')

    call = client.get_call("[CALL-UUID]")

    # 絵文字のリアクションを追加
    call.feedback.add_reaction("👍")

    # メモを追加
    call.feedback.add_note("this is a note")

    # カスタムのキーと値のペアを追加
    # 最初の引数は、ユーザー定義の「タイプ」を表す string です。
    # フィードバックは JSON シリアル化可能で、シリアル化後のサイズが 1 KB 未満である必要があります。
    call.feedback.add("correctness", { "value": 5 })
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    This feature is not available in TypeScript yet.
    ```
  </Tab>
</Tabs>

<h4 id="retrieve-the-call-uuid">
  Call の UUID を取得する
</h4>

Call の直後にフィードバックを追加する必要がある場合は、Call の実行中または実行後に Call の UUID をプログラムから取得できます。

<h5 id="during-call-execution">
  Call の実行中
</h5>

Call の実行中に UUID を取得するには、現在の Call を取得し、その ID を返します。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}

    import weave
    weave.init("uuid")

    @weave.op()
    def simple_operation(input_value):
        # 簡単な操作を実行します
        output = f"Processed {input_value}"
        # 現在の Call ID を取得します
        current_call = weave.require_current_call()
        call_id = current_call.id
        return output, call_id
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    この機能は TypeScript ではまだ利用できません。
    ```
  </Tab>
</Tabs>

<h5 id="after-call-execution">
  Call の実行後
</h5>

または、`call()` メソッドを使用して操作を実行し、Call の実行後に ID を取得することもできます。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    import weave
    weave.init("uuid")

    @weave.op()
    def simple_operation(input_value):
        return f"Processed {input_value}"

    # 操作を実行し、結果と Call ID を取得します
    result, call = simple_operation.call("example input")
    call_id = call.id
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    This feature is not available in TypeScript yet.
    ```
  </Tab>
</Tabs>

<h3 id="delete-feedback-from-a-call">
  Call からフィードバックを削除する
</h3>

UUID を指定すると、特定の Call からフィードバックを削除できます。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    call.feedback.purge("[FEEDBACK-UUID]")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    この機能は TypeScript ではまだ利用できません。
    ```
  </Tab>
</Tabs>

<h2 id="add-human-annotations">
  人によるアノテーションを追加する
</h2>

人によるアノテーションを使用すると、Call に対して人がレビューした判断を構造化された形式で取得できます。これにより、レビュー担当者は独自の基準に基づいてモデル出力をスコア付けできます。

人によるアノテーションは Weights & Biases UI でサポートされています。この機能では、カスタムフィールドを作成し、人が入力したデータをフィードバックとしてトレースに追加できます。人によるアノテーションを行うには、まず [UI](#create-a-human-annotation-scorer-in-the-ui) または [API](#create-a-human-annotation-scorer-using-the-api) を使用して Human Annotation スコアラーを作成する必要があります。作成後は、[UI でスコアラーを使用してアノテーションを行ったり](#use-the-human-annotation-scorer-in-the-ui)、[API を使用してアノテーションスコアラーを変更したり](#modify-a-human-annotation-scorer-using-the-api)できます。

<h3 id="create-a-human-annotation-scorer-in-the-ui">
  UI で Human Annotation スコアラーを作成する
</h3>

UI で Human Annotation スコアラーを作成するには、次の手順に従います。

1. プロジェクトのサイドバーで、**Assets** にアクセスします。
2. Assets のナビゲーションパネルで、**Scorers** をクリックします。
3. **Scorers** パネルのヘッダーで、**New scorer** をクリックします。
4. **Create Scorer** モーダルダイアログで、次の項目を設定します。
   * `Scorer type`：`Human annotation` を選択
   * `Name`
   * `Description`
   * `Type`：収集するフィードバックのタイプ (`boolean`、`integer` など) を指定します。
5. **Create scorer** をクリックします。これで、作成したスコアラーを使用してアノテーションを付けられるようになります。

次の例では、LLM が読み込んだドキュメントの種類をアノテーターが選択します。スコア設定の `Type` は、想定されるドキュメントタイプを列挙した `enum` です。

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/human-annotation-scorer-form.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=7d38f47385bd21b407caf5a959b1a7e9" alt="Create Scorer モーダルダイアログ" width="3342" height="1862" data-path="products/wandb/weave/_media/human-annotation-scorer-form.png" />
</Frame>

<h3 id="use-the-human-annotation-scorer-in-the-ui">
  UI で 人によるアノテーション スコアラーを使用する
</h3>

人によるアノテーション スコアラーを作成すると、トレース ページで使用できるようになります。

スコアラーを使用するには、次の手順を実行します。

1. プロジェクトのサイドバーで **Traces** にアクセスします。

2. 人によるアノテーションを追加する Call の行を探します。

3. リンクになっているトレース名をクリックして、トレース ツリーと Call details パネルを開きます。

4. Call details のタブバーの右上にある **Show feedback** ボタンをクリックします。

   <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/marker-icon.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=aafc9db6195967a8ec0acfe214fd5044" alt="Call ヘッダーのマーカー アイコン" width="306" height="84" data-path="products/wandb/weave/_media/marker-icon.png" />

   使用可能な 人によるアノテーション スコアラーが **Annotate** パネルに表示されます。

   <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/full-feedback-sidebar.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=ba9ef22e7d49bd57e0a087b7dcbd05f0" alt="人によるアノテーション スコアラーのフィードバック パネル" width="3342" height="1862" data-path="products/wandb/weave/_media/full-feedback-sidebar.png" />

5. アノテーションを入力します。

6. **Save** をクリックします。

7. Call details パネルのタブバーで **Feedback** タブをクリックして、Feedback の表を表示します。新しいアノテーションが表に表示されます。アノテーションは、メインの Traces の表の **Annotations** 列でも確認できます。

   > 最新の情報を表示するには、Traces の表を更新してください。

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/feedback-in-the-table.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=6118c46e60c28bc3117179d9d44b49fa" alt="Traces の表に表示された 人によるアノテーション スコアラーのフィードバック" width="3342" height="1569" data-path="products/wandb/weave/_media/feedback-in-the-table.png" />
</Frame>

<h3 id="create-a-human-annotation-scorer-using-the-api">
  API を使用して Human Annotation スコアラーを作成する
</h3>

Human Annotation スコアラーは API から作成することもできます。スコアラーはそれぞれ独立したオブジェクトであり、個別に作成・更新します。Human Annotation スコアラーをプログラムで作成するには、次の手順を実行します。

1. `weave.flow.annotation_spec` から `AnnotationSpec` クラスをインポートします。
2. `weave` の `publish` メソッドを使用してスコアラーを作成します。

次の例では、2 つのスコアラーを作成します。1 つ目のスコアラー `Temperature` は、LLM Call の体感温度をスコアリングします。2 つ目のスコアラー `Tone` は、LLM の応答のトーンをスコアリングします。各スコアラーは、対応するオブジェクト ID (`temperature-scorer` と `tone-scorer`) を指定して `save` を使用します。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    import weave
    from weave.flow.annotation_spec import AnnotationSpec

    client = weave.init("feedback-example")

    spec1 = AnnotationSpec(
      name="Temperature",
      description="The perceived temperature of the llm call",
      field_schema={
        "type": "number",
        "minimum": -1,
        "maximum": 1,
      }
    )
    spec2 = AnnotationSpec(
      name="Tone",
      description="The tone of the llm response",
      field_schema={
        "type": "string",
        "enum": ["Aggressive", "Neutral", "Polite", "N/A"],
      },
    )
    weave.publish(spec1, "temperature-scorer")
    weave.publish(spec2, "tone-scorer")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    この機能は TypeScript ではまだ利用できません。
    ```
  </Tab>
</Tabs>

<h3 id="modify-a-human-annotation-scorer-using-the-api">
  API を使用して Human Annotation スコアラーを変更する
</h3>

[API を使用した Human Annotation スコアラーの作成](#create-a-human-annotation-scorer-using-the-api)の例をもとに、次の例では `publish` で元のオブジェクト ID (`temperature-scorer`) を指定して、`Temperature` スコアラーの新しいバージョンを作成します。その結果、オブジェクトが更新され、すべてのバージョンの履歴が保持されます。

> Human Annotation スコアラーのオブジェクト履歴は、**Human annotations** の **Scorers** タブで確認できます。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    import weave
    from weave.flow.annotation_spec import AnnotationSpec

    client = weave.init("feedback-example")

    # スコアラーの新しいバージョンを作成する
    spec1 = AnnotationSpec(
      name="Temperature",
      description="The perceived temperature of the llm call",
      field_schema={
        "type": "integer",  # <<- タイプを integer に変更する
        "minimum": -1,
        "maximum": 1,
      }
    )
    weave.publish(spec1, "temperature-scorer")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```plaintext theme={"system"}
    この機能は TypeScript ではまだ利用できません。
    ```
  </Tab>
</Tabs>

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/weave/_media/human-annotation-scorer-history.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=98b79764fd87597de1bde43f086def64" alt="Human Annotation スコアラーの履歴" width="2574" height="1434" data-path="products/wandb/weave/_media/human-annotation-scorer-history.png" />
</Frame>

<h3 id="use-a-human-annotation-scorer-using-the-api">
  API で Human Annotation スコアラーを使用する
</h3>

フィードバック API では、特別な形式で構成した名前と `annotation_ref` フィールドを指定することで、Human Annotation スコアラーを使用できます。`annotation_spec_ref` は、UI で該当するタブを選択するか、`AnnotationSpec` の作成時に取得できます。

<Tabs>
  <Tab title="Python">
    ```python lines theme={"system"}
    import weave

    client = weave.init("feedback-example")

    call = client.get_call("[CALL-ID]")
    annotation_spec = weave.ref("[ANNOTATION-SPEC-REF-URI]")

    call.feedback.add(
      feedback_type="wandb.annotation." + annotation_spec.name,
      payload={"value": 1},
      annotation_ref=annotation_spec.uri(),
    )
    ```
  </Tab>
</Tabs>


## Related topics

- [Call の更新と削除](/ja/products/wandb/weave/guides/tracking/update-call.md)
