関数呼び出しをチューニングする

関数呼び出しを使用すると、データベース、顧客管理システム、ドキュメント リポジトリなどのリアルタイムの情報やサービスとやり取りできる Gemini ベースのアプリケーションとエージェントを作成できます。これにより、関連性の高いコンテキストに沿った回答を提供するアプリケーションの能力が向上します。

教師ありファインチューニングでは、独自のチューニング データセットを使用して、アプリケーションの関数呼び出しベースのレスポンスの全体的な精度を向上させることができます。

チューニング用データセットの形式

ファインチューニング データセットの fileUri は、Cloud Storage バケット内のファイルの URI にすることも、一般公開されている HTTP または HTTPS URL にすることもできます。

汎用形式の例については、Gemini のデータセットの例をご覧ください。

以降のセクションでは、関数呼び出しのチューニング ジョブの作成に使用する関数呼び出しデータセットの例を示します。

テキストを生成するための関数呼び出しのチューニング

以下は、関数呼び出しをチューニングして単一のテキスト レスポンスを生成するためのデータセットの例です。

{
  "system_instruction": {
    "role": "system",
    "parts": [
      {
        "text": "You are an assistant that helps users find the best product for them."
      }
    ]
  },
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Do you have the White Pixel 8 Pro 128GB in stock in the US?"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "functionCall": {
            "name": "get_product_sku",
            "args": {
              "product_name": "Pixel 8 Pro 128GB"
            }
          }
        }
      ]
    }
  ],
  "tools": [
    {
      "functionDeclarations": [
        {
          "name": "get_product_sku",
          "description": "Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "product_name": {
                "type": "STRING",
                "description": "Product name",
                "enum": [
                  "Pixel 8 Pro 128GB",
                  "Pixel 8 Pro 256GB",
                  "Pixel 8 Pro 512GB",
                  "Pixel 8 Pro 1TB"
                ]
              }
            }
          }
        },
        {
          "name": "get_store_location",
          "description": "Get the location of the closest store",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "location": {
                "type": "STRING",
                "description": "Location"
              }
            }
          }
        }
      ]
    }
  ]
}

チャット セッションをサポートするための関数呼び出しのチューニング

以下は、関数呼び出しをチューニングしてチャット セッションをサポートするためのデータセットの例です。

{
  "system_instruction": {
    "role": "system",
    "parts": [
      {
        "text": "You are an assistant that helps users find the best product for them."
      }
    ]
  },
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Do you have the Porcelain Pixel 8 Pro 128GB in stock in the US?"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "functionCall": {
            "name": "get_product_sku",
            "args": {
              "product_name": "Pixel 8 Pro 128GB"
            }
          }
        }
      ]
    },
    {
      "parts": [
        {
          "functionResponse": {
            "name": "get_product_sku",
            "response": {
              "output": "True"
            }
          }
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "text": "Yes, we have the Porcelain Pixel 8 Pro 128GB in stock in the US."
        }
      ]
    }
  ],
  "tools": [
    {
      "functionDeclarations": [
        {
          "name": "get_product_sku",
          "description": "Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "product_name": {
                "type": "STRING",
                "description": "Product name",
                "enum": [
                  "Pixel 8 Pro 128GB",
                  "Pixel 8 Pro 256GB",
                  "Pixel 8 Pro 512GB",
                  "Pixel 8 Pro 1TB"
                ]
              }
            }
          }
        },
        {
          "name": "get_store_location",
          "description": "Get the location of the closest store",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "location": {
                "type": "STRING",
                "description": "Location"
              }
            }
          }
        }
      ]
    }
  ]
}

並列関数呼び出しのチューニング

以下は、並列関数呼び出しのチューニング用のデータセットの例です。

{
  "system_instruction": {
    "role": "system",
    "parts": [
      {
        "text": "You are an assistant that helps users find the best product for them."
      }
    ]
  },
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Where is the closest Google Store to Mountain View, CA that has Pixel 8 Pro 128GB in stock?"
        }
      ]
    },
    {
      "role": "model",
      "parts": [
        {
          "functionCall": {
            "name": "get_product_sku",
            "args": {
              "product_name": "Pixel 8 Pro 128GB"
            }
          }
        },
        {
          "functionCall": {
            "name": "get_store_location",
            "args": {
              "location": "Mountain View, CA"
            }
          }
        }
      ]
    }
  ],
  "tools": [
    {
      "functionDeclarations": [
        {
          "name": "get_product_sku",
          "description": "Get the available inventory for a Google products, e.g: Pixel phones, Pixel Watches, Google Home etc",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "product_name": {
                "type": "STRING",
                "description": "Product name",
                "enum": [
                  "Pixel 8 Pro 128GB",
                  "Pixel 8 Pro 256GB",
                  "Pixel 8 Pro 512GB",
                  "Pixel 8 Pro 1TB"
                ]
              }
            }
          }
        },
        {
          "name": "get_store_location",
          "description": "Get the location of the closest store",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "location": {
                "type": "STRING",
                "description": "Location"
              }
            }
          }
        }
      ]
    }
  ]
}

次のステップ