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

> W&B の実験管理を使って Cohere モデルをファインチューニングし、トレーニングメトリクスをログしてモデル性能を監視できます。

# Cohere ファインチューニング

W\&B を使うと、Cohere モデルのファインチューニング時のメトリクスと設定をログし、モデルのパフォーマンスを分析して把握したり、結果を同僚と共有したりできます。

この [Cohere のガイド](https://docs.cohere.com/page/convfinqa-finetuning-wandb) には、ファインチューニングの run を開始する方法の完全な例が掲載されています。[Cohere API ドキュメントはこちら](https://docs.cohere.com/reference/createfinetunedmodel#request.body.settings.wandb) で確認できます。

<div id="log-your-cohere-fine-tuning-results">
  ## Cohere ファインチューニングの結果をログする
</div>

W\&B ワークスペースに Cohere ファインチューニングの logging を追加するには、次の手順に従います。

1. W\&B APIキー、W\&B `entity`、`project` 名を指定して `WandbConfig` を作成します。APIキーは [https://wandb.ai/settings](https://wandb.ai/settings) で作成してください。

2. この設定を、モデル名、データセット、ハイパーパラメーターとともに `FinetunedModel` object に渡して、ファインチューニングの run を開始します。

   ```python theme={null}
   from cohere.finetuning import WandbConfig, FinetunedModel

   # W&B の情報を指定して設定を作成します
   wandb_ft_config = WandbConfig(
       api_key="<wandb_api_key>",
       entity="my-entity", # 指定した APIキー に関連付けられた有効な entity である必要があります
       project="cohere-ft",
   )

   ...  # データセットとハイパーパラメーターを設定します

   # Cohere でファインチューニングの run を開始します
   cmd_r_finetune = co.finetuning.create_finetuned_model(
     request=FinetunedModel(
       name="command-r-ft",
       settings=Settings(
         base_model=...
         dataset_id=...
         hyperparameters=...
         wandb=wandb_ft_config  # ここで W&B の設定を渡します
       ),
     ),
   )
   ```

3. 作成した W\&B プロジェクトで、モデルのファインチューニングにおけるトレーニングと検証のメトリクス、およびハイパーパラメーターを確認します。

   <Frame>
     <img src="https://mintcdn.com/wb-21fd5541-css-tab-borders/Zp1Au-vBGBD27x6o/images/integrations/cohere_ft.png?fit=max&auto=format&n=Zp1Au-vBGBD27x6o&q=85&s=5d515122dcede483a6e2acbd9b92210c" alt="Cohere ファインチューニング ダッシュボード" width="2180" height="586" data-path="images/integrations/cohere_ft.png" />
   </Frame>

<div id="organize-runs">
  ## run を整理する
</div>

W\&B の run は自動的に整理され、ジョブのタイプ、ベースモデル、学習率、そのほかの任意のハイパーパラメーターなどの設定パラメーターに基づいて、フィルターや並べ替えを行えます。

さらに、run の名前を変更したり、メモを追加したり、グループ化用のタグを作成したりできます。

<div id="resources">
  ## リソース
</div>

* [Cohere ファインチューニングのサンプル](https://github.com/cohere-ai/notebooks/blob/kkt_ft_cookbooks/notebooks/finetuning/convfinqa_finetuning_wandb.ipynb)
