你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Text Groundedness Detection Operations - Detect Groundedness Options
检测地面
此同步 API 用于分析语言模型输出,以确定是否与用户提供的信息相符或识别虚构内容。
POST {endpoint}/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
endpoint
|
path | True |
string |
支持的认知服务终结点(协议和主机名,例如:https://.cognitiveservices.azure.com). |
api-version
|
query | True |
string minLength: 1 |
用于此操作的 API 版本。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
groundingSources | True |
string[] |
利用大量的地面源来验证 AI 生成的文本。 限制:单个请求中可以分析的地面源总量限制为 55K 个字符。 |
text | True |
string maxLength: 7500 |
需要检查的特定文本。 |
domain |
要分析的文本的域。 允许的值:医疗、泛型。 此字段是可选的,默认值为 Generic。 |
||
llmResource |
LLM 资源的连接详细信息。 仅当“推理”字段设置为 true 时,才会使用此字段;否则,将忽略它。 |
||
qna |
QnA 方案中用户的问题输入。 此字段是可选的,但如果任务类型设置为 QnA,则它是必需的。 |
||
reasoning |
boolean |
一个值,该值指示输出是否包含标识的地面性解释。 此字段是可选的,默认值为 false。 |
|
task |
文本分析的任务类型。 任务类型:QnA、摘要。 此字段是可选的,默认值为“摘要”。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
请求已成功。 |
|
Other Status Codes |
意外的错误响应。 标头 x-ms-error-code: string |
安全性
Ocp-Apim-Subscription-Key
类型:
apiKey
在:
header
OAuth2Auth
类型:
oauth2
流向:
application
令牌 URL:
https://login.microsoftonline.com/common/oauth2/v2.0/token
作用域
名称 | 说明 |
---|---|
https://cognitiveservices.azure.com/.default |
示例
Detect Groundedness
示例请求
POST {endpoint}/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview
{
"domain": "Generic",
"task": "Summarization",
"text": "The sun rises from the west.",
"groundingSources": [
"The sun rises from the east due to the visual effect caused by the Earth"
],
"reasoning": true,
"llmResource": {
"resourceType": "AzureOpenAI",
"azureOpenAIEndpoint": "https://your-azure-openai-name.openai.azure.com",
"azureOpenAIDeploymentName": "deployment-1130"
}
}
示例响应
{
"ungroundedDetected": true,
"ungroundedPercentage": 0,
"ungroundedDetails": [
{
"text": "string",
"offset": {
"utf8": 0,
"utf16": 0,
"codePoint": 0
},
"length": {
"utf8": 28,
"utf16": 28,
"codePoint": 28
},
"reason": "The sun rises from the east due to the visual effect caused by the Earth"
}
]
}
定义
名称 | 说明 |
---|---|
Analyze |
地面检测的请求。 |
Analyze |
地面检测的响应。 |
Azure. |
错误对象。 |
Azure. |
包含错误详细信息的响应。 |
Azure. |
包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。 |
Groundedness |
要分析的文本的域。 允许的值:医疗、泛型。 此字段是可选的,默认值为 Generic。 |
Groundedness |
文本分析的任务类型。 任务类型:QnA、摘要。 此字段是可选的,默认值为“摘要”。 |
Index |
索引详细信息。 |
LLMResource |
LLM 资源的连接详细信息。 |
LLMResource |
LLM 资源类型。 默认值为 AzureOpenAI。 |
Qn |
QnA 选项的请求。 |
Ungroundedness |
有关标识为非前景的文本的详细信息。 |
AnalyzeTextGroundednessOptions
地面检测的请求。
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
domain | Generic |
要分析的文本的域。 允许的值:医疗、泛型。 此字段是可选的,默认值为 Generic。 |
|
groundingSources |
string[] |
利用大量的地面源来验证 AI 生成的文本。 限制:单个请求中可以分析的地面源总量限制为 55K 个字符。 |
|
llmResource |
LLM 资源的连接详细信息。 仅当“推理”字段设置为 true 时,才会使用此字段;否则,将忽略它。 |
||
qna |
QnA 方案中用户的问题输入。 此字段是可选的,但如果任务类型设置为 QnA,则它是必需的。 |
||
reasoning |
boolean |
一个值,该值指示输出是否包含标识的地面性解释。 此字段是可选的,默认值为 false。 |
|
task | Summarization |
文本分析的任务类型。 任务类型:QnA、摘要。 此字段是可选的,默认值为“摘要”。 |
|
text |
string maxLength: 7500 |
需要检查的特定文本。 |
AnalyzeTextGroundednessResult
地面检测的响应。
名称 | 类型 | 说明 |
---|---|---|
ungroundedDetails |
通过具体示例和百分比提供对无据内容的见解。 |
|
ungroundedDetected |
boolean |
指示文本是否表现出无据性。 |
ungroundedPercentage |
number (float) |
指定标识为非前景的文本的比例,表示为 0 到 1 之间的小数,其中 0 表示无地面内容,1 表示完全停地的内容。 |
Azure.Core.Foundations.Error
错误对象。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
服务器定义的错误代码集之一。 |
details |
导致此报告错误的特定错误的详细信息数组。 |
|
innererror |
包含与当前对象有关错误的更具体信息的对象。 |
|
message |
string |
错误的人工可读表示形式。 |
target |
string |
错误的目标。 |
Azure.Core.Foundations.ErrorResponse
包含错误详细信息的响应。
名称 | 类型 | 说明 |
---|---|---|
error |
错误对象。 |
Azure.Core.Foundations.InnerError
包含有关错误的更具体信息的对象。 根据Microsoft一个 API 指南 - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses。
名称 | 类型 | 说明 |
---|---|---|
code |
string |
服务器定义的错误代码集之一。 |
innererror |
内部错误。 |
GroundednessDomain
要分析的文本的域。 允许的值:医疗、泛型。 此字段是可选的,默认值为 Generic。
值 | 说明 |
---|---|
Generic | |
Medical |
GroundednessTask
文本分析的任务类型。 任务类型:QnA、摘要。 此字段是可选的,默认值为“摘要”。
值 | 说明 |
---|---|
QnA | |
Summarization |
IndexDetails
索引详细信息。
名称 | 类型 | 说明 |
---|---|---|
codePoint |
integer (int64) |
使用代码点格式指示索引。 |
utf16 |
integer (int64) |
指示编码为 UTF-16 时的索引。 |
utf8 |
integer (int64) |
指示编码为 UTF-8 时的索引。 |
LLMResource
LLM 资源的连接详细信息。
名称 | 类型 | 默认值 | 说明 |
---|---|---|---|
azureOpenAIDeploymentName |
string |
部署模型名称。 |
|
azureOpenAIEndpoint |
string |
Azure OpenAI 资源的终结点。 |
|
resourceType | AzureOpenAI |
LLM 资源类型。 默认值为 AzureOpenAI。 |
LLMResourceType
LLM 资源类型。 默认值为 AzureOpenAI。
值 | 说明 |
---|---|
AzureOpenAI |
Azure OpenAI 资源类型。 |
QnAOptions
QnA 选项的请求。
名称 | 类型 | 说明 |
---|---|---|
query |
string maxLength: 7500 |
QnA 方案中用户的问题输入。 |
UngroundednessDetails
有关标识为非前景的文本的详细信息。
名称 | 类型 | 说明 |
---|---|---|
length |
地面文本的长度。 |
|
offset |
从地面文本开始时的偏移量。 |
|
reason |
string |
检测到的无前景性的解释,增强了理解。 仅当输入中的“推理”字段设置为真正的“reason”字段时,才会返回。 |
text |
string |
地面文本。 |