本页介绍了如何使用此 API 获取包含搜索结果的搜索摘要。还介绍了搜索摘要中可用的选项。 仅适用于非结构化数据和网站数据。
如需了解如何获取 请参阅获取搜索结果。如需了解如何使用“回答”方法获取搜索摘要,请参阅获取回答和后续问题。
如需了解如何针对医疗数据查询获取生成式 AI 回答,请参阅使用生成式 AI 回答的自然语言查询进行搜索。
准备工作
根据您应用的类型,满足以下要求:
对于非结构化搜索应用:开启高级 LLM 功能。
对于网站搜索应用:开启以下功能:
高级网站索引编制功能。要求 域名验证。
获取搜索摘要
搜索摘要是对最热门的一条或多条搜索结果的简短摘要 。摘要本身取自响应中返回的摘要型回答。因此,要获取摘要 提取的答案。有关详情,请参阅获取 提取式答案(预览版)。
下图显示了使用以下内容查询数据存储区中的 PDF 时的摘要
将 summaryResultCount
设置为 5
。摘要内容可能会因应用配置而异。
搜索摘要可能包含 Markdown 格式的文本。因此,请考虑 使用 Markdown 解析器呈现 Markdown 文本。
要获取搜索摘要,请按以下步骤操作:
提交包含
contentSearchSpec.summarySpec
且指定summaryResultCount
和maxExtractiveAnswerCount
值的搜索请求。如需详细了解如何提交搜索请求,请参阅获取搜索结果。在以下示例中,
summarySpec
表示您想要生成搜索摘要,并且摘要应根据前三条搜索结果生成。"contentSearchSpec": { "summarySpec": { "summaryResultCount": 3 }, "extractiveContentSpec": { "maxExtractiveAnswerCount" : 1} }
summaryResultCount
:用于生成搜索摘要的热门搜索结果的数量。如果返回的结果数少于summaryResultCount
- 系统会根据所有结果生成摘要。maxExtractiveAnswerCount
:为每个搜索结果返回的提取式回答的数量。默认值为 0,最大值为 1。
从搜索响应中获取摘要。返回一个
summary
属性 。以下是搜索响应末尾返回的摘要示例:
"summary": { "summaryText": "BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse. BigQuery supports all data types, works across clouds, and has built-in machine learning and business intelligence, all within a unified platform." }
根据语义块生成摘要
您可以开启 use_semantic_chunks
,以便根据最相关的文档段生成摘要。使用语义数据块生成摘要
Recall 和 检索与使用抽取答案的默认行为进行了比较。
为摘要启用语义分块后,响应会返回 以及摘要所使用的每个分块的内容。
如需使用语义块生成摘要,请按以下步骤操作:
提交包含以下内容的搜索请求:
contentSearchSpec.summarySpec
并指定"use_semantic_chunks": true
。详细了解如何提交搜索查询 请求,请参阅获取搜索结果。下面的
summarySpec
示例表明您想要搜索 使用语义块的摘要、要包含的结果数量,以及 以包含引用。"contentSearchSpec": { "summarySpec": { "useSemanticChunks": SEMANTIC_CHUNK_BOOLEAN, "summaryResultCount": SUMMARY_RESULT_COUNT, "includeCitations": CITATIONS_BOOLEAN, } }
SEMANTIC_CHUNK_BOOLEAN
:一个布尔值,用于指定 是否使用语义块生成搜索摘要。如果设置为true
,使用语义块。SUMMARY_RESULT_COUNT
:排名靠前的结果的数量 生成搜索摘要。最大值为10
。CITATIONS_BOOLEAN
:一个布尔值,用于指定是否 已返回 个引用。如果您在创建 而引用是指数据块否则,引用引用的是 来源文档。如需详细了解分块模式,请参阅解析和分块文档。
从搜索响应中获取摘要。
以下搜索响应示例包含摘要 数据块生成,并包含引用。
references
部分 响应包含生成摘要的区块内容 。响应
{ "results": [ { "id": "123xyz", "document": { "name": "projects/exampleproject/locations/global/collections/default_collection/dataStores/exampledatastore/branches/0/documents/123xyz", "id": "123xyz", "derivedStructData": { "link": "gs://examplebucket/alphabet-investor-pdfs/2004_google_annual_report.pdf" } } } ], "totalSize": 8375, "attributionToken": "abcdefg", "nextPageToken": "hijklmnop", "guidedSearchResult": {}, "summary": { "summaryText": "Google's search technology uses a combination of techniques to determine the importance of a web page independent of a particular search query and to determine the relevance of that page to a particular search query. [1]", "summaryWithMetadata": { "summary": "Google's search technology uses a combination of techniques to determine the importance of a web page independent of a particular search query and to determine the relevance of that page to a particular search query.", "citationMetadata": { "citations": [ { "endIndex": "216", "sources": [ {} ] } ] }, "references": [ { "document": "projects/exampleproject/locations/global/collections/default_collection/dataStores/exampledatastore/branches/0/documents/123xyz", "chunkContents": [ { "content": "Groups contains more than 1 billion messages from Usenet Internet discussion groups dating back to 1981.The\ndiscussions in these groups cover a broad range of discourse and provide a comprehensive look at evolving\nviewpoints, debate and advice on many subjects.The new Google Groups adds in the ability to create your own\ngroups for you and your friends and an improved user interface.Google Mobile.Google Mobile offers people the ability to search and view both the "mobile web,"\nconsisting of pages created specifically for wireless devices, and the entire Google index of more than 8 billion\nweb pages.Google Mobile works on devices that support WAP, WAP 2.0, i-mode or j-sky mobile Internet\nprotocols.In addition, users can access a variety of information using Google SMS by typing a query to the\nGoogle shortcode.Google Mobile is available through many wireless and mobile phone services worldwide.", "pageIdentifier": "17" }, { "content": "Google Labs is our playground for our engineers and for adventurous Google users.On Google\nLabs, we post product prototypes and solicit feedback on how the technology could be used or improved.Current Google Labs examples include:Google Personalized Search—provides customized search results based on an individual user's interests.Froogle Wireless—gives people the ability to search for product information from their mobile phones\nand other wireless devices.Google Maps—enables users to see maps, get directions, and find local businesses and services quickly\nand easily.Google Maps has several unique features, including draggable maps, integrated local search\nfrom Google Local, and keyboard shortcuts.Google Scholar—enables users to search specifically for scholarly literature, including peer-reviewed\npapers, theses, books, preprints, abstracts and technical reports from all broad areas of research.Google\nScholar can be used to find articles from a wide variety of academic publishers, professional societies,\npreprint repositories and universities, as well as scholarly articles available across the web.Google Suggest—guesses what you're typing and offers suggestions in real time.This is similar to\nGoogle's "Did you mean?"feature that offers alternative spellings for your query after you search, except\nthat it works in real time.", "pageIdentifier": "17" }, { "content": "Groups contains more than 1 billion messages from Usenet Internet discussion groups dating back to 1981.The\ndiscussions in these groups cover a broad range of discourse and provide a comprehensive look at evolving\nviewpoints, debate and advice on many subjects.The new Google Groups adds in the ability to create your own\ngroups for you and your friends and an improved user interface.Google Mobile.Google Mobile offers people the ability to search and view both the "mobile web,"\nconsisting of pages created specifically for wireless devices, and the entire Google index of more than 8 billion\nweb pages.Google Mobile works on devices that support WAP, WAP 2.0, i-mode or j-sky mobile Internet\nprotocols.In addition, users can access a variety of information using Google SMS by typing a query to the\nGoogle shortcode.Google Mobile is available through many wireless and mobile phone services worldwide.\n\nGoogle Local.Google Local enables users to find relevant local businesses near a city, postal code, or specific\naddress.This service combines Yellow Page listings with information found on web pages, and plots their\nlocations on interactive maps.Google Print.Google Print brings information online that had previously not been available to web\nsearchers.Under this program, we enable a number of publishers to host their content and show their\npublications at the top of our search results.", "pageIdentifier": "17" }, { "content": "Votes cast by important web pages with high PageRank weigh more heavily and are\nmore influential in deciding the PageRank of pages on the web.Text-Matching Techniques.Our technology employs text-matching techniques that compare search queries\nwith the content of web pages to help determine relevance.Our text-based scoring techniques do far more than\ncount the number of times a search term appears on a web page.For example, our technology determines the\nproximity of individual search terms to each other on a given web page, and prioritizes results that have the\nsearch terms near each other.Many other aspects of a page's content are factored into the equation, as is the\ncontent of pages that link to the page in question.By combining query independent measures such as PageRank\nwith our text-matching techniques, we are able to deliver search results that are relevant to what people are\ntrying to find.\n\nAdvertising Technology\nOur advertising program serves millions of relevant, targeted ads each day based on search terms people\n\nenter or content they view on the web.The key elements of our advertising technology include:\n\nGoogle AdWords Auction System.We use the Google AdWords auction system to enable advertisers to\nautomatically deliver relevant, targeted advertising.", "pageIdentifier": "21" }, { "content": "Votes cast by important web pages with high PageRank weigh more heavily and are\nmore influential in deciding the PageRank of pages on the web.Text-Matching Techniques.Our technology employs text-matching techniques that compare search queries\nwith the content of web pages to help determine relevance.Our text-based scoring techniques do far more than\ncount the number of times a search term appears on a web page.For example, our technology determines the\nproximity of individual search terms to each other on a given web page, and prioritizes results that have the\nsearch terms near each other.Many other aspects of a page's content are factored into the equation, as is the\ncontent of pages that link to the page in question.By combining query independent measures such as PageRank\nwith our text-matching techniques, we are able to deliver search results that are relevant to what people are\ntrying to find.\n\nAdvertising Technology\nOur advertising program serves millions of relevant, targeted ads each day based on search terms people\n\nenter or content they view on the web.The key elements of our advertising technology include:", "pageIdentifier": "21" }, { "content": "Google Maps—enables users to see maps, get directions, and find local businesses and services quickly\nand easily.Google Maps has several unique features, including draggable maps, integrated local search\nfrom Google Local, and keyboard shortcuts.Google Scholar—enables users to search specifically for scholarly literature, including peer-reviewed\npapers, theses, books, preprints, abstracts and technical reports from all broad areas of research.Google\nScholar can be used to find articles from a wide variety of academic publishers, professional societies,\npreprint repositories and universities, as well as scholarly articles available across the web.Google Suggest—guesses what you're typing and offers suggestions in real time.This is similar to\nGoogle's "Did you mean?"feature that offers alternative spellings for your query after you search, except\nthat it works in real time.Google Video—includes thousands of programs that play on our TVs every day.Google Video enables\nyou to search a growing archive of televised content—everything from sports to dinosaur\ndocumentaries to news shows.\n\n6", "pageIdentifier": "17" }, { "content": "Every search query we process involves the automated\nexecution of an auction, resulting in our advertising system often processing hundreds of millions of auctions per\nday.To determine whether an ad is relevant to a particular query, this system weighs an advertiser's willingness\nto pay for prominence in the ad listings (the CPC) and interest from users in the ad as measured by the click\nthrough rate and other factors.If an ad does not attract user clicks, it moves to a less prominent position on the\npage, even if the advertiser offers to pay a high amount.This prevents advertisers with irrelevant ads from\n"squatting" in top positions to gain exposure.Conversely, more relevant, well-targeted ads that are clicked on\nfrequently move up in ranking, with no need for advertisers to increase their bids.Because we are paid only\nwhen users click on ads, the AdWords ranking system aligns our interests equally with those of our advertisers\nand our users.The more relevant and useful the ad, the better for our users, for our advertisers and for us.\n\nThe AdWords auction system also incorporates our AdWords discounter, which automatically lowers the\namount advertisers actually pay to the minimum needed to maintain their ad position.", "pageIdentifier": "21" }, { "content": "Web Search Technology\nOur web search technology uses a combination of techniques to determine the importance of a web page\nindependent of a particular search query and to determine the relevance of that page to a particular search\nquery.We do not explain how we do ranking in great detail because some people try to manipulate our search\nresults for their own gain, rather than in an attempt to provide high-quality information to users.\n\nRanking Technology.One element of our technology for ranking web pages is called PageRank.While we\ndeveloped much of our ranking technology after Google was formed, PageRank was developed at Stanford\nUniversity with the involvement of our founders, and was therefore published as research.Most of our current\nranking technology is protected as trade-secret.PageRank is a query-independent technique for determining the\nimportance of web pages by looking at the link structure of the web.PageRank treats a link from web page A to\nweb page B as a "vote" by page A in favor of page B.The PageRank of a page is the sum of the PageRank of the\npages that link to it.The PageRank of a web page also depends on the importance (or PageRank) of the other\nweb pages casting the votes.", "pageIdentifier": "21" }, { "content": "The Company recognizes as revenue the fees charged advertisers each time a user clicks on one of the text\nbased ads that are displayed next to the search results on Google web sites.Effective January 1, 2004, the\nCompany offered a single pricing structure to all of its advertisers based on the AdWords cost per click model.\n\nGoogle AdSense is the program through which the Company distributes its advertisers' text-based ads for\ndisplay on the web sites of the Google Network members.In accordance with Emerging Issues Task Force\n("EITF") Issue No. 99 19, Reporting Revenue Gross as a Principal Versus Net as an Agent, the Company recognizes\nas revenues the fees it receives from its advertisers.This revenue is reported gross primarily because the\nCompany is the primary obligor to its advertisers.\n\nThe Company generates fees from search services through a variety of contractual arrangements, which\ninclude per-query search fees and search service hosting fees.Revenues from set up and support fees and search\nservice hosting fees are recognized on a straight-line basis over the term of the contract, which is the expected\nperiod during which these services will be provided.The Company's policy is to recognize revenues from per\nquery search fees in the period queries are made and results are delivered.\n\nThe Company provides search services pursuant to certain AdSense agreements.", "pageIdentifier": "85" }, { "content": "On Google Print pages, we provide links to book sellers that may\noffer the full versions of these publications for sale, and we show content-targeted ads that are served through\nthe Google AdSense program.Google Desktop Search.Google Desktop Search enables our users to perform a full text search on the\ncontents of their own computer, including email, files, instant messenger chats and web browser history.Users\ncan use this service to view web pages they have visited even when they are not online.Google Alerts.Google Alerts are email updates of the latest relevant Google results (web, news, etc.) based\non the user's choice of query or topic.Typical uses include monitoring a developing news story, keeping current\non a competitor or industry, getting the latest on a celebrity or event, or keeping tabs on a favorite sports team.Google Labs.Google Labs is our playground for our engineers and for adventurous Google users.On Google\nLabs, we post product prototypes and solicit feedback on how the technology could be used or improved.Current Google Labs examples include:Google Personalized Search—provides customized search results based on an individual user's interests.Froogle Wireless—gives people the ability to search for product information from their mobile phones\nand other wireless devices.", "pageIdentifier": "17" } ] } ] } } }
获取引用
如果指定了引文,则引文是指在搜索摘要中内嵌的数字。这些数字表示摘要中特定句子的来源搜索结果。
如需获取引用,请按以下步骤操作:
提交包含以下内容的搜索请求:
contentSearchSpec.summarySpec
并指定"includeCitations": true
。如需详细了解如何提交搜索请求,请参阅获取搜索结果。在以下示例中,
summarySpec
表示您想要搜索 摘要应根据前三个搜索词 结果,并且摘要中应包含相关引用。"contentSearchSpec": { "summarySpec": { "summaryResultCount": 3, "includeCitations": true }, "extractiveContentSpec": { "maxExtractiveAnswerCount" : 1} }
summaryResultCount
:要生成搜索的热门结果的数量 摘要。如果返回的结果数少于summaryResultCount
- 系统会根据所有结果生成摘要。 最大值为5
。includeCitations
:一个布尔值,用于指定引用是否 返回。maxExtractiveAnswerCount
:要返回的提取答案数量 每条搜索结果。默认值为 0,最大值为 1。
从搜索响应中获取摘要(包括引用)。每个响应中都会返回一个
summary
属性。以下是搜索响应末尾返回的摘要示例,其中包含引文和引文元数据:
"summary": { "summaryText": "BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse [1]. BigQuery supports all data types, works across clouds, and has built-in machine learning and business intelligence, all within a unified platform [2, 3].", "summaryWithMetadata": { "summary": "BigQuery is Google Cloud's fully managed and completely serverless enterprise data warehouse. BigQuery supports all data types, works across clouds, and has built-in machine learning and business intelligence, all within a unified platform.", "citationMetadata": { "citations": [ { "startIndex": "0", "endIndex": "101", "sources": [ { "uri": "gs://example-dataset/html/6344007140738632642.html", "title": "About BigQuery", "id": "b6344007140738632642", "referenceIndex": "0" }, { "uri": "gs://example-dataset/html/1365490014946172719.html", "title": "Google Cloud article", "id": "b1365490014946172719", "referenceIndex": "1" }, { "uri": "gs://example-dataset/html/2687910668117268120.html", "title": "BigQuery document", "id": "a2687910668117268120", "referenceIndex": "2" } ] }, { "startIndex": "103", "endIndex": "230", "sources": [ { "referenceIndex": "0" }, { "referenceIndex": "1" }, { "referenceIndex": "2", } ] } ] }, "references": [ { "title": "Sports in the United States", "docName": "projects/123/locations/global/collections/default_collection/dataStores/ds-123/branches/0/documents/b6344007140738632642", "uri": "https://example.com/bigqueryA" }, { "title": "Sports in the United States", "docName": "projects/123/locations/global/collections/default_collection/dataStores/ds-123/branches/0/documents/b1365490014946172719", "uri": "https://example.com/bigqueryB" }, { "title": "Sports in the United States", "docName": "projects/123/locations/global/collections/default_collection/dataStores/ds-123/branches/0/documents/a268791066811726812", "uri": "https://example.com/bigqueryC" } ] } }
summaryText
:搜索摘要,包含引用编号。引用 数字是指返回的搜索结果,索引为 1。对于 例如,[1]
表示句子被归因于第一次搜索 结果。[2, 3]
表示该句子同时归因于第二个和第三个搜索结果。citations
:对于摘要中包含引文的每个句子,列出该引文的元数据。startIndex
:表示句子的开头,以 unicode 字节。endIndex
:表示句子的结尾,以 unicode 字节。sources
:列出句子引文中包含的每个来源的referenceIndex
。referenceIndex
是分配给来源的编号。响应中并不总是明确返回第一个来源的referenceIndex
。由于referenceIndex
的索引为 0,因此第一个 来源的referenceIndex
始终为 0。references
:列出 摘要。元数据包括title
、docName
和uri
。
忽略恶意查询
恶意查询包含负面评论,或者旨在生成不安全、违反政策的输出。您可以指定不应针对对抗性查询返回搜索摘要。当系统忽略对抗性查询时,summaryText
属性会包含表示未返回任何搜索摘要的样本文字。即使对抗性查询也返回搜索文档,
但不包含搜索摘要
要指定不为对抗性查询返回任何搜索摘要, 请按以下步骤操作:
提交包含以下内容的搜索请求:
contentSearchSpec.summarySpec
并指定"ignoreAdversarialQuery": true
。如需详细了解 提交搜索请求,请参阅获取搜索结果。在以下示例中,
summarySpec
表示您想要搜索 摘要应根据前三个搜索词 结果,但不应为对抗性查询返回任何摘要。"contentSearchSpec": { "summarySpec": { "summaryResultCount": 3, "ignoreAdversarialQuery": true }, "extractiveContentSpec": { "maxExtractiveAnswerCount" : 1} }
summaryResultCount
:要生成搜索的热门结果的数量 摘要。如果返回的结果数量少于summaryResultCount
,系统会根据所有结果生成摘要。最大值为5
。ignoreAdversarialQuery
:一个布尔值,用于指定不进行搜索 应为对抗性查询返回摘要。maxExtractiveAnswerCount
:要返回的提取答案数量 每条搜索结果。默认值为 0,最大值为 1。
查看对抗性搜索返回的
summary
属性 请求。示例如下:
"summary": { "summaryText": "We do not have a summary for your query. Here are some search results.", "summarySkippedReasons": [ "ADVERSARIAL_QUERY_IGNORED" ] }
summaryText
:表示未返回任何搜索摘要的样本文本。summarySkippedReasons
:包含 summary-skipped 值的枚举 。
忽略非摘要搜索查询
非摘要搜索查询返回的结果不适合 摘要。例如,“为什么天空是蓝色的”以及“谁是最棒的足球运动员” “世界上的球员?”查询摘要,而“旧金山国际机场”和“全世界” 2026 年杯”。这类查询很可能是导航查询。您可以指定 不针对非摘要搜索查询返回任何搜索摘要。 系统会针对非摘要查询返回搜索文档,但不会返回搜索摘要。
如需指定不应针对非摘要查询返回搜索摘要,请按以下步骤操作:
提交包含以下内容的搜索请求:
contentSearchSpec.summarySpec
并指定"ignoreNonSummarySeekingQuery": true
。如需详细了解如何提交搜索请求,请参阅获取搜索结果。在以下示例中,
summarySpec
表示您希望显示搜索摘要,摘要应根据前三条搜索结果生成,但对于不查询摘要的查询,则不应返回摘要。"contentSearchSpec": { "summarySpec": { "summaryResultCount": 3, "ignoreNonSummarySeekingQuery": true }, "extractiveContentSpec": { "maxExtractiveAnswerCount" : 1} }
summaryResultCount
:用于生成搜索摘要的热门搜索结果的数量。如果返回的结果数少于summaryResultCount
- 系统会根据所有结果生成摘要。 最大值为5
。ignoreNonSummarySeekingQuery
:一个布尔值,用于指定不应针对非摘要查询返回搜索摘要。maxExtractiveAnswerCount
:为每个搜索结果返回的提取式回答的数量。默认值为 0,最大值为 1。
查看针对非摘要搜索请求返回的
summary
属性。示例如下:
"summary": { "summaryText": "We do not have a summary for your query. Here are some search results.", "summarySkippedReasons": [ "NON_SUMMARY_SEEKING_QUERY_IGNORED" ] }
summaryText
:表示未返回任何搜索摘要的样本文本。summarySkippedReasons
:包含跳过摘要原因的值的枚举。
获取自定义摘要
你可以通过提供自然语言指令获得自定义摘要。
您可以使用控制台为搜索 widget 启用此功能,也可以在 modelPromptSpec.preamble
字段中输入说明,为 API 启用此功能。
您可以请求自定义内容,如长度、详细程度、样式 输出内容(如“简单”)、输出语言、答案重点和格式(如 以表格、项目符号和 XML 的形式指定)。
例如,对于查询 What are the benefits of bigquery?
,您可以
输入自定义说明,如下例所示:
示例说明:
please show the answer format in an ordered list
答案示例:
The benefits of BigQuery are: 1. Increased business productivity 2. IT staff productivity 3. Reduced infrastructure costs 4. Loading and exporting data are free
说明示例:
give a very detailed answer
答案示例:
BigQuery is a serverless, highly scalable, and cost-effective cloud data warehouse that enables businesses to analyze all their data very quickly. It is a fully managed service that takes care of provisioning, scaling, and managing the underlying infrastructure, so you can focus on analyzing your data. BigQuery is also integrated with other Google Cloud services, such as Google Kubernetes Engine, Cloud Data Fusion, and Cloud Dataproc, making it easy to build and deploy data pipelines. Here are some of the benefits of using BigQuery: * **Fast and scalable:** BigQuery can process petabytes of data very quickly, and it can scale to handle even the most demanding workloads. * **Cost-effective:** BigQuery is a very cost-effective way to store and analyze data. You only pay for the data that you use, and there are no upfront costs or commitments. * **Secure:** BigQuery is a secure platform that meets the needs of even the most security-conscious organizations. * **Easy to use:** BigQuery is easy to use, even for non-technical users. It has a simple and intuitive user interface, and it supports a variety of data sources. * **Integrated with other Google Cloud services:** BigQuery is integrated with other Google Cloud services, making it easy to build and deploy data pipelines. If you are looking for a fast, scalable, and cost-effective way to analyze your data, then BigQuery is a great option.
自定义摘要的最佳实践
如果您打算使用此功能,请执行以下操作:
- 一次只能申请一项自定义。不合并 自定义设置,例如,请求使用法语的 HTML 表格。
- Google 建议您限制最终用户可以请求的定制内容,例如,提供包含一组预定义定制的选择器。
自定义摘要
您可以使用控制台获取仅针对搜索微件的自定义摘要 或者针对任何搜索请求使用 API
如需获取自定义摘要,请按以下步骤操作:
控制台
在 Google Cloud 控制台中,前往 Agent Builder 页面。
点击要修改的应用的名称。
依次前往配置 > 界面。
确保将搜索微件的搜索类型设置为搜索方式 答案或跟进搜索。如果选择了搜索,则无法使用此功能。
开启启用摘要自定义功能。
要输入摘要说明,请执行以下操作之一:
- 输入自由形式的说明:输入您自己的自然语言 序言字段中的说明。
- 使用模板说明:点击替换为模板,然后 选择一条预定义的模板说明选择预定义模板后,该模板会显示在前言字段中。
在预览窗格中进行搜索,测试为应用生成自定义摘要的效果。
要重置为最后保存的这组说明,请点击重置 前导码。
要将设置保存到微件,请点击保存并发布。
REST
提交包含以下内容的搜索请求:
contentSearchSpec.summarySpec
并在modelPromptSpec.preamble
中指定自定义指令。 有关提交搜索请求的详细信息,请参阅 获取搜索结果。在以下示例中,
summarySpec
表示您想要搜索 摘要应根据前三个搜索词 结果,并且此摘要应进行自定义,就像 向一个 10 岁的孩子解释的"contentSearchSpec": { "summarySpec": { "summaryResultCount": 3, "modelPromptSpec": { "preamble": "explain like you would to a ten year old" } } }
summaryResultCount
:用于生成搜索摘要的热门搜索结果的数量。如果返回的结果数量少于summaryResultCount
,系统会根据所有结果生成摘要。最大值为5
。preamble
:自定义说明。
从搜索响应中获取自定义摘要。
下面是返回的自定义摘要示例:
"summary": { "summaryText": "BigQuery is a serverless data warehouse that helps you analyze all your data very quickly. It's very easy to use and you don't need to worry about managing servers or infrastructure. BigQuery is also very scalable, so you can analyze large datasets without any problems." }
summaryText
:自定义搜索摘要。
指定总结模型
您可以指定要用于生成摘要的模型。
您可以按名称指定 stable
、preview
或特定的模型版本。
如需了解可用的模型版本,请参阅生成答案
模型版本和生命周期。
如需更改模型版本,请执行以下操作:
提交包含
ContentSearchSpec.SummarySpec.ModelSpec
的搜索请求,以指定模型版本。"contentSearchSpec": { "summarySpec": { "modelSpec": { "version": "MODEL_VERSION" } } }
MODEL_VERSION:指定要用于生成哪个模型 摘要。支持的值包括:
stable
:字符串。未指定值时的默认规范。stable
指向经过微调以生成回答的 GA 模型版本。stable
指向哪个模型 新的 GA 模型版本和以前的模型发布后会发生的变化 版本已停用。对于stable
请参阅答案生成模型版本和 生命周期。preview
:字符串。preview
指向用于问答的最新 Gemini 模型。如需详细了解 Gemini,请参阅多模态模型概览。- 要改为指定某个模型版本,请输入版本名称,例如
名称:
text-bison@002/answer_gen/v1
。如需了解受支持的版本,请参阅回答生成模型版本和生命周期。
例如,以下搜索请求将 preview
指定为模型
版本:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1/projects/exampleproject/locations/global/collections/default_collection/dataStores/exampledatastore/servingConfigs/default_search:search" \
-d '{
"query": "what is bigquery",
"contentSearchSpec": {
"summarySpec": {
"modelSpec": {
"version": "preview"
}
}
}
}'
搜索摘要的限制
使用 搜索摘要:
由于 LLM 用于生成搜索摘要和引用,因此 LLM 的限制也适用于 Vertex AI Search 摘要。
如需详细了解这些 LLM 限制,请参阅 Vertex AI 文档中的 PaLM API 限制。
需要复杂逻辑或分析机制的搜索查询 对世界的推理或理解可产生具有以下特征的搜索摘要: 包含不正确的信息(提示)或 非结构化数据或网站数据中存在的错误。
搜索摘要中的某些陈述可能不包含引文:
如果系统确定某条陈述不需要依据,则不会。 包含引用。“我发现了以下内容”或“您可以采用多种方法”等句子缺少引用。
缺少引文也可能表示未找到有效的参考文献。没有引文的事实可能不可靠。
在极少数情况下,引文可能会错误地归因于某个陈述。
LLM 可能会错误地解析复杂文档。在这种情况下,摘要可能不完整 错误。
由于自定义说明采用的是自然语言,因此请务必 并不能保证所有请求都适用于所有请求。