發布日期:2025 年 5 月 15 日,上次更新日期:2026 年 5 月 27 日
提供使用者評論的網站 (例如電子商務或旅遊網站) 通常會有大量資訊。使用者可能要花費大量時間篩選評論,才能決定是否購買產品。提供評論摘要可協助使用者瞭解意見回饋,並節省時間。
瞭解 redBus 和 Miravia 如何使用 Summarizer API 提升決策品質和購物體驗。Miravia 在產品頁面和整個網站加入評論摘要後,轉換率有所提升。
| 說明 | 網頁 | 擴充功能 | Chrome 狀態 | Intent |
|---|---|---|---|---|
| MDN | 查看 | 出貨意願 |
摘要產生器 API 可生成不同類型、長度和格式的摘要,例如句子、段落、項目符號清單等。與許多內建 AI API 相同,這項 API 也會使用大型語言模型執行推論。在 Chrome 中,模型為 Gemini Nano。
redBus 可協助顧客決定最佳巴士選項
redBus 是印度最大的巴士供應商,擁有超過 3,000 萬名顧客, 在全國約 10,000 個城市和鄉鎮提供巴士服務。透過資料和意見回饋,redBus 發現使用者產生的評論在協助顧客決定最符合自身需求的路線和巴士方面,扮演著重要角色。redBus 收到大量評論,每則評論都具體指出確切的抵達和出發地點與時間。
為協助顧客大致瞭解特定城市或路線的評價,他們會使用 Summarizer API 呈現相關評論中的重要洞察。
「Summarizer API 能夠從大量評論和使用者搜尋查詢排列組合中,產生高品質摘要。這項用戶端功能可移除技術複雜度,並避免伺服器端替代方案產生的額外業務成本。這對我們來說很重要,因為這個用途是轉換漏斗的一部分。」
— redBus 資深工程經理 Amit Kumar
儲存在 redBus 後端的評論詳細程度,加上使用者搜尋查詢中可能出現的大量排列組合 (包括出發和抵達時間、城市中的特定上車地點,以及不同的巴士營運商等變數),使得我們難以從評論中找出特定洞察資料。如果資料量這麼大,為每項搜尋查詢提供伺服器端摘要的成本會非常高。
為生成有效的摘要,除了顧客評論外,redBus 還會向 Summarizer API 提供下列背景資訊:
//Context to provide a useful summary
const promptContext =
'Summarize the following reviews in 30 words or less.' +
'Focus on key positives and negatives, such as comfort, maintenance,' +
'pricing, and cleanliness. Reviews are separated by {end}.' +
'Give the summary in just one paragraph.';
摘要可協助顧客做出決策,且不會增加業務成本和技術複雜度。此外,redBus 還可根據登入使用者的旅遊偏好設定 (例如座位舒適度或 Wi-Fi 連線狀況),提供個人化的摘要資訊。推論是在用戶端進行,因此這項搜尋和摘要功能只供使用者本人存取。
請參閱簡短的程式碼範例,瞭解如何檢查摘要工具是否可用、提供脈絡資訊,以及根據使用者的搜尋查詢擷取評論。
// The Summarizer API is available
if ('Summarizer' in self) {
try {
const available = await Summarizer.availability();
let summarizer;
if (available === 'unavailable') {
return null;
}
if (available === 'available') {
//model is already available, use immediately
summarizer = await Summarizer.create();
} else {
//trigger model download and wait
summarizer = await Summarizer.create();
}
// Context to provide a useful summary
const promptContext =
'Summarize the following reviews in 30 words or less.' +
'Focus on key positives and negatives, such as comfort, maintenance,' +
'pricing, and cleanliness. Reviews are separated by {end}.' +
'Give the summary in just one paragraph.';
// Retrieve the reviews to be summarized based on user's search query
let reviews = getIndividualBusReviews();
if (reviews) {
const reviewSummary = await summarizer.summarize(reviews, {
context: promptContext
});
}
} catch (e) {
console.error("SUMMARIZER_API_ERROR: ", e);
return null
}
}
以從班加羅爾到曼格洛爾的搜尋為例,摘要工具的輸出內容如下:
<Bus Provider X>通常在舒適度、清潔度和員工服務方面獲得好評。部分使用者遇到的小問題包括延誤、司機行為 (粗魯)、缺乏便利設施 (即時追蹤、毛毯) 和不適感 (座位大小、避震器不良)。
這篇評論符合要求,以簡短段落列出優點和缺點,比 308 則個別評論更容易閱讀。
Miravia 電子商務評論摘要
Miravia 是西班牙首屈一指的電子商務平台,每月活躍使用者人數達數百萬。每當使用者篩選評論 (例如依產品評分),系統就會生成新的摘要。這份摘要會簡要說明顧客意見,並重點列出顧客的疑慮和建議。
「過去,如要瞭解產品評論中的主要優缺點,使用者必須詳閱詳細資料頁面上的大量個別留言。 為協助使用者快速掌握整體顧客情緒,我們推出了 Summarizer API。只要使用者篩選評論 (例如依星級評等或其他條件),這份摘要就會動態更新,快速提供相關買家意見回饋的完整概覽。」
— Miravia 資深軟體工程師 Ziyi Liang
Miravia 的使用者評論摘要功能最初是採用伺服器端 AI 服務。他們發現,執行用戶端 AI 的 Gemini Nano 可提供類似結果,同時降低維護成本。這項優勢對於熱銷產品尤其明顯,因為這類產品的評論會不斷更新。
雖然 Miravia 的實作需要即時擷取和摘要評論,但無論推論是在伺服器或瀏覽器中進行,隨著頻率增加,用戶端 AI 的效率都會顯著提升。他們對整體成效感到滿意。
首先,Miravia 會檢查功能和裝置是否相容。
// Compatibility check for device with built-in AI
export const deviceCheck = async () => {
// Query the browser's AI capabilities
const availability = await Summarizer.availability();
// Case 1: Device doesn't support AI summarization
if (availability === 'unavailable') {
return {
summarizationAvailable: false,
message:
'AI summarization tools are not supported on this device, or the appropriate permissions have not be set.',
};
}
// Case 2: Device supports AI but requires model download
if (availability === 'downloadable') {
// Try to trigger an installation
Summarizer.create();
return {
summarizationAvailable: false,
message: 'Installing in the background. This may take a few minutes...',
};
}
// Case 3: Device supports AI summarization
return {
summarizationAvailable: true,
message: 'Ready for use.',
};
};
Miravia 會彙整可用的評論,評論會加上額外句號,讓輸入內容更連貫。
/**
* Summarizes a list of reviews using Chrome's Built-in AI
* @param {Array<string>} reviewContentList - Array of review texts to summarize
* @returns {Promise<string>} The generated summary text
* @throws {Error} If summarization is not available or fails
*/
export const reviewSummarize = async (reviewContentList) => {
// Validate input
if (!Array.isArray(reviewContentList) || !reviewContentList.length) {
throw new Error('Please provide a non-empty array of reviews to summarize');
}
// Check device compatibility
const { summarizationAvailable, message } = await deviceCheck();
if (summarizationAvailable) {
try {
// Configure and create the summarizer with appropriate parameters
const summarizer = await Summarizer.create({
type: 'tl;dr',
length: 'short',
sharedContext:
'Summarize the given user reviews. Maintain a polite and formal tone.',
});
// Generate the summary from the joined review texts
const summary = await summarizer.summarize(reviewContentList.join('. '));
// Return the generated summary
return summary;
} catch (error) {
// Handle any errors during summarization
throw new Error(`Summarization failed: ${error.message}`);
}
} else {
// If unavailable, throw an error with the message from deviceCheck
throw new Error(
message ||
'AI summarization tools are not supported on this device or browser.'
);
}
};
轉換量增加
自從 Summarizer API 在正式版中推出後,Miravia 發現摘要可帶來以下好處:
- 產品頁面的轉換率提高 12.4%。
- 網站轉換率提升 3.3%。
最佳做法
如果評論輸入內容超過權杖限制,請採取下列因應措施:
- 將較小的樣本 (例如最近 4 則評論) 傳送至 API。這有助於加快生成結果的速度。請參閱擴大用戶端摘要功能規模的指南。
QuotaExceededError提供輸入內容中要求權杖的相關資訊。summarizer物件具有inputQuota屬性,可指出 API 的權杖限制。這樣一來,系統就能即時提供意見回饋,並在輸入內容超出限制時停用功能。
建議採用混合式做法,確保所有使用者都能享有流暢體驗。首次呼叫內建 AI API 時,瀏覽器必須下載模型。
- Miravia 使用伺服器端模型提供初步摘要,同時下載模型。內建模型準備就緒後,網站就會改為在用戶端執行推論。
您應盡量建立友善且具溝通性的介面:
- 導入進度列,顯示模型下載進度,減少回應延遲。
- 請考慮模型下載的透明度。Bright Sites 會通知使用者模型下載事宜,確保資源使用情況公開透明,並徵得同意。這樣使用者就能在繼續操作前接受或拒絕要求。
結論與最佳化建議
redBus 和 Miravia 的這些實際案例,說明 Summarizer API 如何提供簡潔且相關的使用者評論摘要,協助使用者快速做出明智決策。這項 API 可以在用戶端運作,不會增加額外的業務成本,技術複雜度也很低,因此對於需要摘要資訊的類似用途而言,是可行的選擇。所有內建 AI API 都能實現實用的用戶端 AI 用途。
想知道 Summarizer API 如何協助處理其他用途嗎?我們也分享了摘要 API 如何提高文章參與度。
您是否要使用這些 API 建構新項目?歡迎在 X 上的@ChromiumDev 或 LinkedIn 上的 Chromium for Developers 分享。
資源
- 進一步瞭解 Summarizer API。
- 開始使用 Chrome 內建 API。
- 閱讀提示 API 個案研究,瞭解如何協助部落客。
- 請參閱翻譯和語言偵測器個案研究。
- 瞭解 Summarizer API 如何協助 Bright Sites 和 Terra 製作引人入勝的文章摘要
特別銘謝
感謝 Miravia (阿里巴巴集團) 的 Makakhov Andrey 和 Ziyi Liang、redBus 的 Amit Kumar、Swetha Gopalakrishnan、Alexandra Klepper、Thomas Steiner 和 Kenji Baheux 協助撰寫及審查本文。