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

> W&B Artifacts の概要、仕組み、および使用開始方法について説明します。

# Artifacts の概要

export const TryProductLink = ({url}) => <a href={url} target="_blank" rel="noopener noreferrer" className="github-source-link">
    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" xmlns="http://www.w3.org/2000/svg">
      <line x1="4" y1="21" x2="4" y2="14"></line>
      <line x1="4" y1="10" x2="4" y2="3"></line>
      <line x1="12" y1="21" x2="12" y2="12"></line>
      <line x1="12" y1="8" x2="12" y2="3"></line>
      <line x1="20" y1="21" x2="20" y2="16"></line>
      <line x1="20" y1="12" x2="20" y2="3"></line>
      <circle cx="4" cy="12" r="2"></circle>
      <circle cx="12" cy="10" r="2"></circle>
      <circle cx="20" cy="14" r="2"></circle>
    </svg>
    Try in W&amp;B
  </a>;

export const ColabLink = ({url}) => <a href={url} target="_blank" rel="noopener noreferrer" className="colab-link">
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01.21.03zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z" />
    </svg>
    Try in Colab
  </a>;

<CardGroup cols={4}>
  <ColabLink url="https://colab.research.google.com/github/wandb/examples/blob/master/colabs/wandb-artifacts/Pipeline_Versioning_with_W&B_Artifacts.ipynb" />

  <TryProductLink url="https://forge.coreweave.com/wandb/wandb/arttest/artifacts/model/iv3_trained/5334ab69740f9dda4fed/lineage" />
</CardGroup>

W\&B Artifacts を使用すると、[W\&B run](/ja/products/wandb/runs) の入力および出力となるデータをトラッキングし、バージョン管理できます。たとえば、モデル トレーニングの run では、データセットを入力として受け取り、トレーニング済みモデルを出力として生成します。run にはハイパーパラメーター、メタデータ、メトリクスをログできます。さらに、アーティファクトを使用して、モデルのトレーニングに使用したデータセットを入力としてログ、トラッキング、バージョン管理できます。同様に、結果として得られたモデル チェックポイントも、別のアーティファクトを使用して出力として管理できます。

<h2 id="use-cases">
  ユースケース
</h2>

アーティファクトは、ML ワークフロー全体を通じて [run](/ja/products/wandb/runs) の入力および出力として使用できます。データセットやモデル、さらには他のアーティファクトも、処理の入力として使用できます。

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/_media/artifacts_landing_page2.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=473134067fd8e18b8e2cc3988de8b5de" alt="モデルのトレーニング、データ処理、モデル評価における入力と出力を示すアーティファクトのワークフロー図" width="1991" height="503" data-path="products/wandb/_media/artifacts_landing_page2.png" />
</Frame>

| ユースケース | 入力 | 出力 |
| - | - | - |
| モデルのトレーニング | データセット (トレーニングデータと検証データ) | トレーニング済みモデル |
| データセットの前処理 | データセット (生データ) | データセット (前処理済みデータ) |
| モデル評価 | モデル + データセット (テストデータ) | [W\&B 表](/ja/products/wandb/tables) |
| モデルの最適化 | モデル | 最適化済みモデル |

<Note>
  以下のスニペットは、順番に実行することを前提としています。
</Note>

<h2 id="create-an-artifact">
  アーティファクトを作成する
</h2>

4行のコードでアーティファクトを作成します：

1. [W\&B run](/ja/products/wandb/runs) を作成します。
2. [`wandb.Artifact`](/ja/products/wandb/ref/python/experiments/artifact) でアーティファクト オブジェクトを作成します。
3. `wandb.Artifact.add_file()` で、モデルファイルやデータセットなどの1つ以上のファイルをアーティファクト オブジェクトに追加します。
4. `wandb.Run.log_artifact()` でアーティファクトをW\&Bにログします。

例えば、次のコードスニペットは、`dataset.h5` というファイルを `example_artifact` というアーティファクトにログする方法を示しています：

```python theme={"system"}
import wandb

with wandb.init(project="artifacts-example", job_type="add-dataset") as run:
    artifact = wandb.Artifact(name="example_artifact", type="dataset")
    artifact.add_file(local_path="./dataset.h5", name="training_dataset")
    run.log_artifact(artifact)
```

* アーティファクトの `type` は、W\&B プラットフォーム上での表示方法に影響します。`type` を指定しない場合、デフォルトで `unspecified` になります。
* ドロップダウンの各ラベルは、それぞれ異なる `type` パラメーターの値を表しています。上記のコードスニペットでは、アーティファクトの `type` は `dataset` です。

<Note>
  Amazon S3 バケットなどの外部オブジェクトストレージに保存されているファイルやディレクトリへの参照を追加する方法については、[外部ファイルをトラッキングする](/ja/products/wandb/artifacts/track-external-files) ページを参照してください。
</Note>

<h2 id="download-an-artifact">
  アーティファクトをダウンロードする
</h2>

run にアーティファクトを入力としてマークしたい場合は、[`wandb.Run.use_artifact()`](/ja/products/wandb/ref/python/experiments/run#use_artifact) メソッドを使用します。

前のコードスニペットに続いて、次のコード例は、以前に作成した `example_artifact` という名前のアーティファクトの使い方を示しています：

```python theme={"system"}
with wandb.init(project="artifacts-example", job_type="add-dataset") as run:
    artifact = run.use_artifact("training_dataset:latest")  # "my_data" アーティファクトを使用する Run オブジェクトを返します
```

これはアーティファクト オブジェクトを返します。

次に、返されたオブジェクトを使用してアーティファクトのすべてのコンテンツをダウンロードします：

```python theme={"system"}
datadir = artifact.download()  # `my_data` アーティファクト全体をデフォルトのディレクトリにダウンロードします。
```

<Note>
  `root` [パラメーター](/ja/products/wandb/ref/python/experiments/artifact) にカスタムのパスを渡すことで、アーティファクトを特定のディレクトリにダウンロードできます。アーティファクトをダウンロードする代替の方法や追加のパラメーターについては、[アーティファクトのダウンロードと使用](/ja/products/wandb/artifacts/download-and-use-an-artifact) のガイドを参照してください。
</Note>

<h2 id="next-steps">
  次のステップ
</h2>

* アーティファクトの[バージョン管理](/ja/products/wandb/artifacts/create-a-new-artifact-version)と[更新](/ja/products/wandb/artifacts/update-an-artifact)の方法について学びましょう。
* [オートメーション](/ja/products/wandb/automations)を使って、アーティファクトの変更をきっかけにダウンストリームのワークフローをトリガーしたり、Slack チャンネルに通知したりする方法について学びましょう。
* トレーニング済みモデルを格納するスペースである[Registry](/ja/products/registry)について学びましょう。
* [Python SDK](/ja/products/wandb/ref/python/experiments/artifact) と [CLI](/ja/products/wandb/ref/cli/wandb-artifact) のリファレンスガイドもご覧ください。


## Related topics

- [Experiments の概要](/ja/products/wandb/ref/python/experiments.md)
