Google 検索によるグラウンディング

Google 検索によるグラウンディングは、Gemini モデルをリアルタイムのウェブ コンテンツに接続し、利用可能なすべての言語で機能します。これにより、Gemini はより正確な回答を提供して、ナレッジ カットオフ以降の検証可能な情報源を引用することができます。

グラウンディングは、次のことができるアプリケーションの構築に役立ちます。

  • 事実の正確性を高める: 回答を実世界の情報に基づいて生成することで、モデルのハルシネーションを減らします。
  • リアルタイムの情報にアクセスする: 最近の出来事やトピックに関する質問に答えます。
  • 引用を提供する: モデルの主張の出典を示すことで、ユーザーの信頼を築きます。

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input="Who won the euro 2024?",
    tools=[{"type": "google_search"}]
)

print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    model: "gemini-3.6-flash",
    input: "Who won the euro 2024?",
    tools: [{ type: "google_search" }]
});

console.log(interaction.output_text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.6-flash",
    "input": "Who won the euro 2024?",
    "tools": [{"type": "google_search"}]
  }'

Google 検索によるグラウンディングの仕組み

google_search ツールを有効にすると、モデルは情報の検索、処理、引用のワークフロー全体を自動的に処理します。

grounding-overview

  1. ユーザー プロンプト: アプリケーションは、google_search ツールを有効にして、ユーザーのプロンプトを Gemini API に送信します。
  2. プロンプトの分析: モデルがプロンプトを分析し、Google 検索で回答を改善できるかどうかを判断します。
  3. Google 検索: 必要に応じて、モデルは 1 つ以上の検索クエリを自動的に生成して実行します。
  4. 検索結果の処理: モデルが検索結果を処理し、情報を合成して回答を作成します。
  5. グラウンディングされたレスポンス: API は、検索結果に基づいてグラウンディングされた、最終的なユーザー フレンドリーなレスポンスを返します。このレスポンスには、引用を含むインライン annotations を含むモデルのテキスト回答、検索クエリと検索候補を含む google_search_call ステップと google_search_result ステップが含まれます。

グラウンディング レスポンスについて

レスポンスが正常にグラウンディングされると、モデルのテキスト出力には、テキスト コンテンツ ブロックに直接インライン annotations が含まれます。これらのアノテーションは、回答の一部をそのソースにリンクする引用情報を提供します。

{
  "steps": [
    {
      "type": "thought",
      "summary": [
        {
          "type": "text",
          "text": "The user is asking for the winner of Euro 2024. I need to search for the result of the Euro 2024 final."
        }
      ],
      "signature": "CoMDAXLI2nynRYojJIy6B1Jh9os2crpWLfB0..."
    },
    {
      "type": "google_search_call",
      "arguments": {
        "queries": ["UEFA Euro 2024 winner"]
      }
    },
    {
      "type": "google_search_result",
      "call_id": "search_001",
      "result": [
        {
          "search_suggestions": "<!-- HTML and CSS for the search widget -->"
        }
      ]
    },
    {
      "type": "model_output",
      "content": [
        {
          "type": "text",
          "text": "Spain won Euro 2024, defeating England 2-1 in the final. This victory marks Spain's record fourth European Championship title.",
          "annotations": [
            {
              "type": "url_citation",
              "url": "https://www.aljazeera.com/sports/euro-2024-final",