Google 於 2024 年 10 月 31 日(台灣時間 11/1) 正式推出 Gemini 的 Grounding with Google Search 功能,允許 Gemini 模型從 Google 搜尋結果中獲取最新、更精確的資訊,提升回應的準確性和即時性,並有效減少 AI 幻覺(hallucinations)。而 ChatGPT Search 挑在此功能宣布後 1 分鐘後推出(Google 1:00 AM、OpenAI 1:01 AM),較勁意味相當濃厚。
Say hello to Grounding with Google Search, available in the Gemini API + Google AI Studio!
— Logan Kilpatrick (@OfficialLoganK) October 31, 2024
You can now access real time, fresh, up to date information from Google Search when building with Gemini by enabling the Grounding tool.https://t.co/oGVTOKHfM8
當用戶透過 Gemini API 或 Google AI Studio 提交查詢時,系統會運用 Google 搜尋引擎尋找相關的最新資訊,並將這些資訊提供給 Gemini 模型。模型會根據搜尋結果生成更準確、更符合現況的答案,並在回覆中提供資料來源連結和搜尋建議,增加透明度和可信度。
Google 建議開發者在以下情況下使用 Grounding with Google Search
- 需要減少 AI 幻覺的應用: Grounding 技術能有效降低 Gemini 模型產生不實資訊的機率。
- 需要提供最新資訊的應用: 模型能透過 Google 搜尋獲取即時資訊,讓 AI 應用程式更貼近現實。
- 希望能提升透明度和可信度的應用: 提供資料來源連結能提升 AI 應用程式的透明度,並引導使用者點擊連結了解更多資訊,有助於增加發布者的流量。
- 希望能提供更豐富資訊的應用: Grounding 技術能整合 Google 搜尋的豐富資訊,使 Gemini 模型能提供更全面的答案。
如何使用 Grounding with Google Search
目前 Gemini 1.5 全系列的模型皆支援使用 Grounding with Google Search,開發者可以在 Google AI Studio 的「工具」區段,或透過啟用 API 中的 google_search_retrieval 工具來啟動此功能。 Grounding 功能現在已可在 Google AI Studio 中免費測試,但在 API 中則需付費使用,每 1,000 次查詢的費用為 35 美元,免費版 Gemini API 無法調用 Grounding with Google Search 功能(詳見:Gemini API pricing 或 Vertex AI 定價)。

函式庫呼叫程式碼範例
|
|
動態檢索功能:
即使啟用了 Grounding with Google Search,並非每個查詢都需要 grounding,這會造成額外的成本和延遲。因此,Google 提供了 動態檢索(dynamic retrieval) 功能,讓開發者能更精細地控制 grounding 的使用。當開發者請求 grounded 答案時,動態檢索功能會根據提示內容給予一個預測分數(0 到 1 之間的浮點數),分數越高表示越需要 grounding。開發者可以設定一個閾值,只有分數超過閾值的查詢才會使用 grounding(預設閾值為 0.3)。

更詳細的程式碼範例和說明,請參考 Google 官方文件。