ALIYUN::Bailian::Index

更新时间:
复制 MD 格式

ALIYUN::Bailian::Index类型用于创建知识库。

语法

{
  "Type": "ALIYUN::Bailian::Index",
  "Properties": {
    "Name": String,
    "SourceType": String,
    "StructureType": String,
    "WorkspaceId": String,
    "ChunkMode": String,
    "CategoryIds": List,
    "ConnectId": String,
    "ChunkSize": Integer,
    "Description": String,
    "Database": String,
    "DocumentIds": List,
    "DenseSimilarityTopK": Integer,
    "EnableRewrite": Boolean,
    "EnableHeaders": Boolean,
    "EmbeddingModelName": String,
    "KnowledgeScene": String,
    "KnowledgeType": String,
    "MetaExtractColumns": List,
    "OverlapSize": Integer,
    "PipelineRetrieveRateLimitStrategy": String,
    "PipelineCommercialCu": Integer,
    "PipelineCommercialType": String,
    "RerankMode": String,
    "RerankModelName": String,
    "RerankInstruct": String,
    "RerankMinScore": Number,
    "SinkInstanceId": String,
    "SparseSimilarityTopK": Integer,
    "SinkRegion": String,
    "SinkType": String,
    "Separator": String,
    "TableIds": List,
    "Table": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

Name

String

是

是

知识库名称。

长度为1-20个字符。支持中文、英文、数字、下划线(_)、连字符(-)、句点(.)和冒号(:)。

SourceType

String

是

否

数据源类型。

取值:

  • DATA_CENTER_CATEGORY:导入指定类目中的文件。

  • DATA_CENTER_FILE:导入指定文件。

StructureType

String

是

否

知识库类型。

取值:

  • unstructured:文档检索或音视频知识库。

  • structured:数据查询或图片问答知识库。

WorkspaceId

String

是

否

工作空间ID。

知识库将创建在该工作空间中。

CategoryIds

List

否

否

创建知识库时要导入的类目ID。

当 SourceType 为 DATA_CENTER_CATEGORY 时必填。

ChunkMode

String

否

否

切片策略。

更多说明,请参见创建和使用知识库。

可能取值(不支持同时传入多个值):

  • length:按长度切分。严格按照您指定的ChunkSize和OverlapSize切分。 若您未传入这两个参数,系统将采用默认值(ChunkSize为 500,OverlapSize为 100)。按长度切分不支持Separator(即使传入也不生效)。

  • page:按页切分。如果指定了ChunkSize,切分时将一并考虑(未传入时,将使用默认值 500)。按页切分不支持OverlapSize和Separator(即使传入也不生效)。

  • h1:按照一级标题切分。如果指定了ChunkSize,切分时将一并考虑(未传入时,将使用默认值 500)。按照一级标题切分不支持OverlapSize和Separator(即使传入也不生效)。

  • h2:按照二级标题切分。如果指定了ChunkSize,切分时将一并考虑(未传入时,将使用默认值 500)。按照二级标题切分不支持OverlapSize和Separator(即使传入也不生效)。

  • regex:按照正则切分,此时必须指定Separator参数。如果指定了ChunkSize,切分时将一并考虑(未传入时,将使用默认值 500)。按正则切分不支持OverlapSize(即使传入也不生效)。

如果不指定,默认使用智能分块。

ChunkSize

Integer

否

否

切片大小,即每个文本切片的最大字符数。

取值范围为 [1-6000]。默认值为 500。如果 ChunkSize 小于 100,则必须同时设置 OverlapSize。

ConnectId

String

否

否

连接ID。

可在数据连接页面的数据连接器卡片上获取。该参数替换了 datasourceCode 参数,后续需统一使用 connectId。 创建数据查询类知识库时还需填写 table 参数。

Database

String

否

否

结构化知识库的数据库名称。

无

DenseSimilarityTopK

Integer

否

是

向量检索 Top K。

按向量相似度检索最相似的前 K 个文本切片。取值范围为 [0-100]。默认值为 100。DenseSimilarityTopK + SparseSimilarityTopK 必须小于等于 200。仅在 UpdateIndex 中支持,CreateIndex 中不支持。

Description

String

否

是

知识库描述。

长度为0-1000个字符。

DocumentIds

List

否

否

创建知识库时要导入的文档ID。

当 SourceType 为 DATA_CENTER_FILE 时必填。

EmbeddingModelName

String

否

否

知识库使用的向量模型。默认值为 text-embedding-v3。

向量模型用于将原始输入 prompt 和知识文本转换为数值化向量,以便对二者进行相似度比较。text-embedding-v4 模型在语种支持、代码片段向量化效果和向量维度选择等方面,相比 text-embedding-v3 模型进行了全面升级,适用于大部分场景。更多信息,请参见文本与多模态向量化。取值范围:

  • text-embedding-v4

  • text-embedding-v3(默认)

EnableHeaders

Boolean

否

否

是否为文档解析开启标题。

默认值为 false。

EnableRewrite

Boolean

否

否

是否开启多轮对话改写。

默认值为 true。

KnowledgeScene

String

否

否

知识库场景。

设置约束: 此参数的取值完全依赖于您所设置的 knowledgeType。

取值与联动关系:

  • 当 knowledgeType 为 document 时,knowledgeType 可设置为 basic_document_qa(基础文档问答)、visual_document_qa(图文并茂回复)或 lite_document_qa(极速问答)、visual_perception_qa(视觉理解)。

  • 当 knowledgeType 为 table 时,knowledgeType 设置为 basic_table_qa(基础表格问答)。

  • 当 knowledgeType 为 image 时,knowledgeType 设置为 image_qa(图片问答)。

  • 当 knowledgeType 为 multimedia 时,knowledgeType 设置为 basic_multimedia_qa(音视频搜索问答)。

KnowledgeType

String

否

否

知识库类型分类。

此参数的取值必须与您选择的 structureType 匹配,并决定了 knowledgeScene 的可用值。

取值范围:

  • document: 文档搜索。需与 structureType: unstructured 配合使用。

  • table: 数据查询。需与 structureType: structured 配合使用。

  • image: 图片问答。需与 structureType: structured 配合使用。

  • multimedia: 音视频搜索。需与 structureType: unstructured 配合使用。

MetaExtractColumns

List

否

否

元数据提取配置。

更多信息,请参考MetaExtractColumns属性。

OverlapSize

Integer

否

否

重叠大小,即相邻文本切片之间重叠的字符数。

取值范围为 [0-1024]。默认值为 100。必须小于 ChunkSize。

PipelineCommercialCu

Integer

否

是

企业版的 RCU 数量。

仅当 PipelineCommercialType 为 enterprise 时需要设置。取值范围为 [1-200]。

PipelineCommercialType

String

否

是

知识库规格类型。

取值:

  • standard:标准版。(默认值)

  • enterprise:企业版。

PipelineRetrieveRateLimitStrategy

String

否

否

企业版的检索限流策略。

默认值为 downgrade。

RerankInstruct

String

否

否

自定义重排序指令。

当 RerankMode 为 custom 时必填。

RerankMinScore

Number

否

是

相似度阈值。

只有相似度得分超过该值的文本切片才会被召回。取值范围为 [0.01-1.00]。默认值为 0.01。

RerankMode

String

否

否

重排序模式。

取值:

  • qa:问答场景(默认)。

  • similar:相似度场景。

  • custom:自定义重排序指令,需要提供 RerankInstruct。

RerankModelName

String

否

否

知识库使用的重排序模型。不指定时默认值为 qwen3-rerank。

排序模型是位于知识库外部的评分系统,它会计算用户问题与知识库中每个文本切片的相似度分数并按此降序排列,并返回分数最高的前 K 个文本切片。取值范围:

  • qwen3-rerank-hybrid:qwen3-rerank(hybrid)排序。

  • qwen3-rerank(默认):qwen3-rerank 排序。

  • gte-rerank-hybrid:gte-rerank(hybrid)排序

  • gte-rerank:gte-rerank 排序。

Separator

String

否

否

切片分隔符。

仅当 ChunkMode 为 regex 时生效。

SinkInstanceId

String

否

否

向量存储实例ID。

当 SinkType 为 ADB 时必填。

SinkRegion

String

否

否

向量存储实例所属的地域。

当 SinkType 为 ADB 时必填。

SinkType

String

否

否

向量存储类型。

更多信息,请参见创建和使用知识库。取值范围:

  • BUILT_IN:将向量数据托管在阿里云百炼平台中。

  • ADB:AnalyticDB for PostgreSQL 数据库。如需高级功能,如管理、审计和监控数据库,推荐选择 ADB。

SparseSimilarityTopK

Integer

否

是

关键词检索 Top K。

通过关键词精确匹配检索文本切片。取值范围为 [0-100]。默认值为 100。DenseSimilarityTopK + SparseSimilarityTopK 必须小于等于 200。仅在 UpdateIndex 中支持,CreateIndex 中不支持。

Table

String

否

否

结构化知识库的表名称。

无

TableIds

List

否

否

创建知识库时要导入的表ID。

无

MetaExtractColumns语法

"MetaExtractColumns": [
  {
    "EnableLlm": Boolean,
    "Desc": String,
    "Type": String,
    "Value": String,
    "EnableSearch": Boolean,
    "Key": String
  }
]

MetaExtractColumns属性

属性名称

类型

必须

允许更新

描述

约束

Key

String

是

否

元数据字段名称。

长度为1-50个字符,必须为英文或下划线。

Type

String

是

否

元数据字段的提取方式。

取值范围:

  • constant:常量。

  • variable:变量。

  • custom_prompt:大模型。

  • regular:正则。

  • keywords:关键词搜索。

Desc

String

否

否

元数据字段描述。

长度为0-1000个字符。

EnableLlm

Boolean

否

否

该元数据字段是否参与模型回复生成。

无

EnableSearch

Boolean

否

否

该元数据字段是否参与知识库检索。

无

Value

String

否

否

元数据字段的值。

无

返回值

Fn::GetAtt

  • Id:知识库索引的唯一ID。

示例

场景 1 :创建知识库索引

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 在百炼平台创建一个简单的非结构化知识库索引,使用内置向量存储,从数据中心文件导入。
  en: Create a simple unstructured knowledge base index on Bailian platform with built-in vector storage, importing from data center files.
Parameters:
  WorkspaceId:
    Type: String
    Label:
      zh-cn: 工作空间ID
      en: Workspace ID
    Description:
      zh-cn: 百炼平台的工作空间ID,知识库将创建在此工作空间下。
      en: The workspace ID of the Bailian platform. The knowledge base will be created in this workspace.
  IndexName:
    Type: String
    Label:
      zh-cn: 知识库名称
      en: Index Name
    Description:
      zh-cn: 知识库名称,1-20个字符,支持中英文、数字、下划线、短划线、句号和冒号。
      en: Knowledge base name, 1-20 characters. Supports Chinese, English, numbers, underscores, hyphens, periods and colons.
    MinLength: 1
    MaxLength: 20
    Default: my-knowledge-base
  DocumentIds:
    Type: CommaDelimitedList
    Label:
      zh-cn: 文档ID列表
      en: Document IDs
    Description:
      zh-cn: 数据中心中已上传的文件ID列表,用于导入到知识库。
      en: List of file IDs already uploaded in the data center, to be imported into the knowledge base.
Resources:
  Index:
    Type: ALIYUN::Bailian::Index
    Properties:
      WorkspaceId:
        Ref: WorkspaceId
      Name:
        Ref: IndexName
      SourceType: DATA_CENTER_FILE
      StructureType: unstructured
      DocumentIds:
        Ref: DocumentIds
      SinkType: BUILT_IN
      Description:
        Ref: ALIYUN::StackName
Outputs:
  IndexId:
    Description:
      zh-cn: 知识库索引ID。
      en: Knowledge base index ID.
    Label:
      zh-cn: 知识库索引ID
      en: Index ID
    Value:
      Fn::GetAtt:
        - Index
        - Id
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - WorkspaceId
          - IndexName
          - DocumentIds
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "在百炼平台创建一个简单的非结构化知识库索引,使用内置向量存储,从数据中心文件导入。",
    "en": "Create a simple unstructured knowledge base index on Bailian platform with built-in vector storage, importing from data center files."
  },
  "Parameters": {
    "WorkspaceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "工作空间ID",
        "en": "Workspace ID"
      },
      "Description": {
        "zh-cn": "百炼平台的工作空间ID,知识库将创建在此工作空间下。",
        "en": "The workspace ID of the Bailian platform. The knowledge base will be created in this workspace."
      }
    },
    "IndexName": {
      "Type": "String",
      "Label": {
        "zh-cn": "知识库名称",
        "en": "Index Name"
      },
      "Description": {
        "zh-cn": "知识库名称,1-20个字符,支持中英文、数字、下划线、短划线、句号和冒号。",
        "en": "Knowledge base name, 1-20 characters. Supports Chinese, English, numbers, underscores, hyphens, periods and colons."
      },
      "MinLength": 1,
      "MaxLength": 20,
      "Default": "my-knowledge-base"
    },
    "DocumentIds": {
      "Type": "CommaDelimitedList",
      "Label": {
        "zh-cn": "文档ID列表",
        "en": "Document IDs"
      },
      "Description": {
        "zh-cn": "数据中心中已上传的文件ID列表,用于导入到知识库。",
        "en": "List of file IDs already uploaded in the data center, to be imported into the knowledge base."
      }
    }
  },
  "Resources": {
    "Index": {
      "Type": "ALIYUN::Bailian::Index",
      "Properties": {
        "WorkspaceId": {
          "Ref": "WorkspaceId"
        },
        "Name": {
          "Ref": "IndexName"
        },
        "SourceType": "DATA_CENTER_FILE",
        "StructureType": "unstructured",
        "DocumentIds": {
          "Ref": "DocumentIds"
        },
        "SinkType": "BUILT_IN",
        "Description": {
          "Ref": "ALIYUN::StackName"
        }
      }
    }
  },
  "Outputs": {
    "IndexId": {
      "Description": {
        "zh-cn": "知识库索引ID。",
        "en": "Knowledge base index ID."
      },
      "Label": {
        "zh-cn": "知识库索引ID",
        "en": "Index ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "Index",
          "Id"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "WorkspaceId",
            "IndexName",
            "DocumentIds"
          ]
        }
      ]
    }
  }
}

场景 2 :创建知识库索引并配置自定义策略与 API Key

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 在百炼平台创建知识库索引并配置自定义切分策略、Embedding模型、Rerank模型和元数据提取,同时创建API Key用于访问。
  en: Create a knowledge base index on Bailian platform with custom chunking strategy, embedding model, rerank model, and metadata extraction, along with an API Key for access.
Parameters:
  WorkspaceId:
    Type: String
    Label:
      zh-cn: 工作空间ID
      en: Workspace ID
    Description:
      zh-cn: 百炼平台的工作空间ID,知识库将创建在此工作空间下。
      en: The workspace ID of the Bailian platform. The knowledge base will be created in this workspace.
  IndexName:
    Type: String
    Label:
      zh-cn: 知识库名称
      en: Index Name
    Description:
      zh-cn: 知识库名称,1-20个字符。
      en: Knowledge base name, 1-20 characters.
    MinLength: 1
    MaxLength: 20
    Default: custom-kb
  CategoryIds:
    Type: CommaDelimitedList
    Label:
      zh-cn: 类目ID列表
      en: Category IDs
    Description:
      zh-cn: 数据中心中的类目ID列表,将导入该类目下的所有文件。
      en: List of category IDs in the data center. All files under these categories will be imported.
  EmbeddingModelName:
    Type: String
    Label:
      zh-cn: Embedding模型
      en: Embedding Model
    Description:
      zh-cn: 知识库使用的Embedding模型。
      en: The embedding model used by the knowledge base.
    AllowedValues:
      - text-embedding-v3
      - text-embedding-v4
    Default: text-embedding-v3
  RerankModelName:
    Type: String
    Label:
      zh-cn: Rerank模型
      en: Rerank Model
    Description:
      zh-cn: 知识库使用的Rerank模型。
      en: The rerank model used by the knowledge base.
    AllowedValues:
      - qwen3-rerank
      - qwen3-rerank-hybrid
      - gte-rerank
      - gte-rerank-hybrid
    Default: qwen3-rerank
  ChunkSize:
    Type: Number
    Label:
      zh-cn: 切分块大小
      en: Chunk Size
    Description:
      zh-cn: 文本切片的最大字符数,范围1-6000。
      en: Maximum number of characters per text chunk, range 1-6000.
    Default: 500
    MinValue: 1
    MaxValue: 6000
  OverlapSize:
    Type: Number
    Label:
      zh-cn: 重叠大小
      en: Overlap Size
    Description:
      zh-cn: 相邻文本切片之间的重叠字符数,范围0-1024,必须小于切分块大小。
      en: Number of overlapping characters between adjacent text chunks, range 0-1024. Must be less than ChunkSize.
    Default: 100
    MinValue: 0
    MaxValue: 1024
Resources:
  Index:
    Type: ALIYUN::Bailian::Index
    Properties:
      WorkspaceId:
        Ref: WorkspaceId
      Name:
        Ref: IndexName
      SourceType: DATA_CENTER_CATEGORY
      StructureType: unstructured
      CategoryIds:
        Ref: CategoryIds
      SinkType: BUILT_IN
      Description: Knowledge base with custom configuration
      EmbeddingModelName:
        Ref: EmbeddingModelName
      RerankModelName:
        Ref: RerankModelName
      RerankMode: qa
      ChunkSize:
        Ref: ChunkSize
      OverlapSize:
        Ref: OverlapSize
      ChunkMode: length
      EnableRewrite: true
      EnableHeaders: true
      MetaExtractColumns:
        - Key: doc_source
          Type: constant
          Value: data-center
          Desc: Document source
          EnableSearch: true
          EnableLlm: false
        - Key: doc_keywords
          Type: keywords
          Desc: Extracted keywords
          EnableSearch: true
          EnableLlm: true
  ApiKey:
    Type: ALIYUN::Bailian::ApiKey
    Properties:
      Description:
        Fn::Sub: API Key for ${IndexName}
Outputs:
  IndexId:
    Description:
      zh-cn: 知识库索引ID。
      en: Knowledge base index ID.
    Label:
      zh-cn: 知识库索引ID
      en: Index ID
    Value:
      Fn::GetAtt:
        - Index
        - Id
  ApiKeyValue:
    Description:
      zh-cn: API Key值,用于调用百炼服务。
      en: API Key value for calling Bailian service.
    Label:
      zh-cn: API Key
      en: API Key
    Value:
      Fn::GetAtt:
        - ApiKey
        - Key
  ApiKeyId:
    Description:
      zh-cn: API Key ID。
      en: API Key ID.
    Label:
      zh-cn: API Key ID
      en: API Key ID
    Value:
      Fn::GetAtt:
        - ApiKey
        - ApiKeyId
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - WorkspaceId
          - IndexName
          - CategoryIds
      - Parameters:
          - EmbeddingModelName
          - RerankModelName
          - ChunkSize
          - OverlapSize
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "在百炼平台创建知识库索引并配置自定义切分策略、Embedding模型、Rerank模型和元数据提取,同时创建API Key用于访问。",
    "en": "Create a knowledge base index on Bailian platform with custom chunking strategy, embedding model, rerank model, and metadata extraction, along with an API Key for access."
  },
  "Parameters": {
    "WorkspaceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "工作空间ID",
        "en": "Workspace ID"
      },
      "Description": {
        "zh-cn": "百炼平台的工作空间ID,知识库将创建在此工作空间下。",
        "en": "The workspace ID of the Bailian platform. The knowledge base will be created in this workspace."
      }
    },
    "IndexName": {
      "Type": "String",
      "Label": {
        "zh-cn": "知识库名称",
        "en": "Index Name"
      },
      "Description": {
        "zh-cn": "知识库名称,1-20个字符。",
        "en": "Knowledge base name, 1-20 characters."
      },
      "MinLength": 1,
      "MaxLength": 20,
      "Default": "custom-kb"
    },
    "CategoryIds": {
      "Type": "CommaDelimitedList",
      "Label": {
        "zh-cn": "类目ID列表",
        "en": "Category IDs"
      },
      "Description": {
        "zh-cn": "数据中心中的类目ID列表,将导入该类目下的所有文件。",
        "en": "List of category IDs in the data center. All files under these categories will be imported."
      }
    },
    "EmbeddingModelName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Embedding模型",
        "en": "Embedding Model"
      },
      "Description": {
        "zh-cn": "知识库使用的Embedding模型。",
        "en": "The embedding model used by the knowledge base."
      },
      "AllowedValues": [
        "text-embedding-v3",
        "text-embedding-v4"
      ],
      "Default": "text-embedding-v3"
    },
    "RerankModelName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Rerank模型",
        "en": "Rerank Model"
      },
      "Description": {
        "zh-cn": "知识库使用的Rerank模型。",
        "en": "The rerank model used by the knowledge base."
      },
      "AllowedValues": [
        "qwen3-rerank",
        "qwen3-rerank-hybrid",
        "gte-rerank",
        "gte-rerank-hybrid"
      ],
      "Default": "qwen3-rerank"
    },
    "ChunkSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "切分块大小",
        "en": "Chunk Size"
      },
      "Description": {
        "zh-cn": "文本切片的最大字符数,范围1-6000。",
        "en": "Maximum number of characters per text chunk, range 1-6000."
      },
      "Default": 500,
      "MinValue": 1,
      "MaxValue": 6000
    },
    "OverlapSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "重叠大小",
        "en": "Overlap Size"
      },
      "Description": {
        "zh-cn": "相邻文本切片之间的重叠字符数,范围0-1024,必须小于切分块大小。",
        "en": "Number of overlapping characters between adjacent text chunks, range 0-1024. Must be less than ChunkSize."
      },
      "Default": 100,
      "MinValue": 0,
      "MaxValue": 1024
    }
  },
  "Resources": {
    "Index": {
      "Type": "ALIYUN::Bailian::Index",
      "Properties": {
        "WorkspaceId": {
          "Ref": "WorkspaceId"
        },
        "Name": {
          "Ref": "IndexName"
        },
        "SourceType": "DATA_CENTER_CATEGORY",
        "StructureType": "unstructured",
        "CategoryIds": {
          "Ref": "CategoryIds"
        },
        "SinkType": "BUILT_IN",
        "Description": "Knowledge base with custom configuration",
        "EmbeddingModelName": {
          "Ref": "EmbeddingModelName"
        },
        "RerankModelName": {
          "Ref": "RerankModelName"
        },
        "RerankMode": "qa",
        "ChunkSize": {
          "Ref": "ChunkSize"
        },
        "OverlapSize": {
          "Ref": "OverlapSize"
        },
        "ChunkMode": "length",
        "EnableRewrite": true,
        "EnableHeaders": true,
        "MetaExtractColumns": [
          {
            "Key": "doc_source",
            "Type": "constant",
            "Value": "data-center",
            "Desc": "Document source",
            "EnableSearch": true,
            "EnableLlm": false
          },
          {
            "Key": "doc_keywords",
            "Type": "keywords",
            "Desc": "Extracted keywords",
            "EnableSearch": true,
            "EnableLlm": true
          }
        ]
      }
    },
    "ApiKey": {
      "Type": "ALIYUN::Bailian::ApiKey",
      "Properties": {
        "Description": {
          "Fn::Sub": "API Key for ${IndexName}"
        }
      }
    }
  },
  "Outputs": {
    "IndexId": {
      "Description": {
        "zh-cn": "知识库索引ID。",
        "en": "Knowledge base index ID."
      },
      "Label": {
        "zh-cn": "知识库索引ID",
        "en": "Index ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "Index",
          "Id"
        ]
      }
    },
    "ApiKeyValue": {
      "Description": {
        "zh-cn": "API Key值,用于调用百炼服务。",
        "en": "API Key value for calling Bailian service."
      },
      "Label": {
        "zh-cn": "API Key",
        "en": "API Key"
      },
      "Value": {
        "Fn::GetAtt": [
          "ApiKey",
          "Key"
        ]
      }
    },
    "ApiKeyId": {
      "Description": {
        "zh-cn": "API Key ID。",
        "en": "API Key ID."
      },
      "Label": {
        "zh-cn": "API Key ID",
        "en": "API Key ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ApiKey",
          "ApiKeyId"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "WorkspaceId",
            "IndexName",
            "CategoryIds"
          ]
        },
        {
          "Parameters": [
            "EmbeddingModelName",
            "RerankModelName",
            "ChunkSize",
            "OverlapSize"
          ]
        }
      ]
    }
  }
}

场景 3 :创建企业级知识库方案

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 创建完整的企业级百炼知识库方案,包含ADB向量存储实例、企业级知识库索引(高级检索配置)、API Key访问控制(IP白名单),实现高可用知识库服务。
  en: Create a complete enterprise-level Bailian knowledge base solution including ADB vector storage instance, enterprise knowledge base index with advanced retrieval configuration, and API Key with IP whitelist access control.
Parameters:
  WorkspaceId:
    Type: String
    Label:
      zh-cn: 工作空间ID
      en: Workspace ID
    Description:
      zh-cn: 百炼平台的工作空间ID。
      en: The workspace ID of the Bailian platform.
  IndexName:
    Type: String
    Label:
      zh-cn: 知识库名称
      en: Index Name
    Description:
      zh-cn: 知识库名称,1-20个字符。
      en: Knowledge base name, 1-20 characters.
    MinLength: 1
    MaxLength: 20
    Default: enterprise-kb
  DocumentIds:
    Type: CommaDelimitedList
    Label:
      zh-cn: 文档ID列表
      en: Document IDs
    Description:
      zh-cn: 数据中心中已上传的文件ID列表。
      en: List of file IDs already uploaded in the data center.
  ZoneId:
    Type: String
    Label:
      zh-cn: 可用区
      en: Availability Zone
    Description:
      zh-cn: ADB实例所在的可用区。
      en: The availability zone for the ADB instance.
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      AutoSelectFirst: true
  VpcId:
    Type: String
    Label:
      zh-cn: VPC ID
      en: VPC ID
    Description:
      zh-cn: ADB实例所属的VPC。
      en: The VPC for the ADB instance.
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
  VSwitchId:
    Type: String
    Label:
      zh-cn: 交换机ID
      en: VSwitch ID
    Description:
      zh-cn: ADB实例所属的交换机。
      en: The VSwitch for the ADB instance.
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
      ZoneId: ${ZoneId}
  DenseSimilarityTopK:
    Type: Number
    Label:
      zh-cn: 向量检索TopK
      en: Dense Similarity Top K
    Description:
      zh-cn: 通过向量相似度检索最相似的K个文本切片,范围0-100。
      en: Retrieve the K most similar text chunks by vector similarity, range 0-100.
    Default: 80
    MinValue: 0
    MaxValue: 100
  SparseSimilarityTopK:
    Type: Number
    Label:
      zh-cn: 关键词检索TopK
      en: Sparse Similarity Top K
    Description:
      zh-cn: 通过关键词精确匹配检索文本切片,范围0-100。DenseSimilarityTopK + SparseSimilarityTopK 必须 <= 200。
      en: Retrieve text chunks by exact keyword matching, range 0-100. DenseSimilarityTopK + SparseSimilarityTopK must be <= 200.
    Default: 60
    MinValue: 0
    MaxValue: 100
  RerankMinScore:
    Type: Number
    Label:
      zh-cn: 相似度阈值
      en: Rerank Min Score
    Description:
      zh-cn: 仅召回相似度分数超过该值的文本切片,范围0.01-1.00。
      en: Only recall text chunks with similarity score exceeding this value, range 0.01-1.00.
    Default: 0.2
  AllowedIpList:
    Type: CommaDelimitedList
    Label:
      zh-cn: API Key允许的IP白名单
      en: API Key Allowed IP List
    Description:
      zh-cn: 允许访问API的IP地址列表。
      en: List of IP addresses allowed to access the API.
    Default:
      - 0.0.0.0/0
Resources:
  ADBInstance:
    Type: ALIYUN::ADB::DBCluster
    Properties:
      ZoneId:
        Ref: ZoneId
      VPCId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
      DBClusterDescription:
        Fn::Sub: Vector storage for ${IndexName}
      DBClusterClass: T8
      DBClusterCategory: Basic
      DBClusterVersion: '3.0'
      Mode: Reserved
      PayType: Postpaid
      DBNodeGroupCount: 1
      DBNodeStorage: 100
  Index:
    Type: ALIYUN::Bailian::Index
    DependsOn: ADBInstance
    Properties:
      WorkspaceId:
        Ref: WorkspaceId
      Name:
        Ref: IndexName
      SourceType: DATA_CENTER_FILE
      StructureType: unstructured
      DocumentIds:
        Ref: DocumentIds
      SinkType: ADB
      SinkInstanceId:
        Ref: ADBInstance
      SinkRegion:
        Ref: ALIYUN::Region
      Description: Enterprise knowledge base with ADB vector storage
      EmbeddingModelName: text-embedding-v3
      RerankModelName: qwen3-rerank
      RerankMode: custom
      RerankInstruct: Rank documents by relevance to the user query, prioritizing accuracy and completeness of information.
      RerankMinScore:
        Ref: RerankMinScore
      ChunkSize: 800
      OverlapSize: 150
      ChunkMode: length
      EnableRewrite: true
      EnableHeaders: true
      PipelineCommercialType: enterprise
      PipelineCommercialCu: 4
      DenseSimilarityTopK:
        Ref: DenseSimilarityTopK
      SparseSimilarityTopK:
        Ref: SparseSimilarityTopK
      MetaExtractColumns:
        - Key: doc_category
          Type: constant
          Value: enterprise-doc
          Desc: Document category
          EnableSearch: true
          EnableLlm: false
        - Key: doc_summary
          Type: custom_prompt
          Value: Please summarize the key points of this document in one sentence.
          Desc: AI-generated document summary
          EnableSearch: true
          EnableLlm: true
        - Key: doc_keywords
          Type: keywords
          Desc: Extracted keywords
          EnableSearch: true
          EnableLlm: true
  ApiKey:
    Type: ALIYUN::Bailian::ApiKey
    Properties:
      Description:
        Fn::Sub: API Key for ${IndexName}
      AuthSetModel:
        AuthSetMode: Custom
        AccessIps:
          Ref: AllowedIpList
Outputs:
  IndexId:
    Description:
      zh-cn: 知识库索引ID。
      en: Knowledge base index ID.
    Label:
      zh-cn: 知识库索引ID
      en: Index ID
    Value:
      Fn::GetAtt:
        - Index
        - Id
  ADBInstanceId:
    Description:
      zh-cn: ADB向量存储实例ID。
      en: ADB vector storage instance ID.
    Label:
      zh-cn: ADB实例ID
      en: ADB Instance ID
    Value:
      Ref: ADBInstance
  ApiKeyValue:
    Description:
      zh-cn: API Key值,用于调用百炼服务。
      en: API Key value for calling Bailian service.
    Label:
      zh-cn: API Key
      en: API Key
    Value:
      Fn::GetAtt:
        - ApiKey
        - Key
  ApiKeyId:
    Description:
      zh-cn: API Key ID。
      en: API Key ID.
    Label:
      zh-cn: API Key ID
      en: API Key ID
    Value:
      Fn::GetAtt:
        - ApiKey
        - ApiKeyId
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - WorkspaceId
          - IndexName
          - DocumentIds
      - Parameters:
          - ZoneId
          - VpcId
          - VSwitchId
      - Parameters:
          - DenseSimilarityTopK
          - SparseSimilarityTopK
          - RerankMinScore
          - AllowedIpList
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "创建完整的企业级百炼知识库方案,包含ADB向量存储实例、企业级知识库索引(高级检索配置)、API Key访问控制(IP白名单),实现高可用知识库服务。",
    "en": "Create a complete enterprise-level Bailian knowledge base solution including ADB vector storage instance, enterprise knowledge base index with advanced retrieval configuration, and API Key with IP whitelist access control."
  },
  "Parameters": {
    "WorkspaceId": {
      "Type": "String",
      "Label": {
        "zh-cn": "工作空间ID",
        "en": "Workspace ID"
      },
      "Description": {
        "zh-cn": "百炼平台的工作空间ID。",
        "en": "The workspace ID of the Bailian platform."
      }
    },
    "IndexName": {
      "Type": "String",
      "Label": {
        "zh-cn": "知识库名称",
        "en": "Index Name"
      },
      "Description": {
        "zh-cn": "知识库名称,1-20个字符。",
        "en": "Knowledge base name, 1-20 characters."
      },
      "MinLength": 1,
      "MaxLength": 20,
      "Default": "enterprise-kb"
    },
    "DocumentIds": {
      "Type": "CommaDelimitedList",
      "Label": {
        "zh-cn": "文档ID列表",
        "en": "Document IDs"
      },
      "Description": {
        "zh-cn": "数据中心中已上传的文件ID列表。",
        "en": "List of file IDs already uploaded in the data center."
      }
    },
    "ZoneId": {
      "Type": "String",
      "Label": {
        "zh-cn": "可用区",
        "en": "Availability Zone"
      },
      "Description": {
        "zh-cn": "ADB实例所在的可用区。",
        "en": "The availability zone for the ADB instance."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "AutoSelectFirst": true
      }
    },
    "VpcId": {
      "Type": "String",
      "Label": {
        "zh-cn": "VPC ID",
        "en": "VPC ID"
      },
      "Description": {
        "zh-cn": "ADB实例所属的VPC。",
        "en": "The VPC for the ADB instance."
      },
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
    },
    "VSwitchId": {
      "Type": "String",
      "Label": {
        "zh-cn": "交换机ID",
        "en": "VSwitch ID"
      },
      "Description": {
        "zh-cn": "ADB实例所属的交换机。",
        "en": "The VSwitch for the ADB instance."
      },
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}",
        "ZoneId": "${ZoneId}"
      }
    },
    "DenseSimilarityTopK": {
      "Type": "Number",
      "Label": {
        "zh-cn": "向量检索TopK",
        "en": "Dense Similarity Top K"
      },
      "Description": {
        "zh-cn": "通过向量相似度检索最相似的K个文本切片,范围0-100。",
        "en": "Retrieve the K most similar text chunks by vector similarity, range 0-100."
      },
      "Default": 80,
      "MinValue": 0,
      "MaxValue": 100
    },
    "SparseSimilarityTopK": {
      "Type": "Number",
      "Label": {
        "zh-cn": "关键词检索TopK",
        "en": "Sparse Similarity Top K"
      },
      "Description": {
        "zh-cn": "通过关键词精确匹配检索文本切片,范围0-100。DenseSimilarityTopK + SparseSimilarityTopK 必须 <= 200。",
        "en": "Retrieve text chunks by exact keyword matching, range 0-100. DenseSimilarityTopK + SparseSimilarityTopK must be <= 200."
      },
      "Default": 60,
      "MinValue": 0,
      "MaxValue": 100
    },
    "RerankMinScore": {
      "Type": "Number",
      "Label": {
        "zh-cn": "相似度阈值",
        "en": "Rerank Min Score"
      },
      "Description": {
        "zh-cn": "仅召回相似度分数超过该值的文本切片,范围0.01-1.00。",
        "en": "Only recall text chunks with similarity score exceeding this value, range 0.01-1.00."
      },
      "Default": 0.2
    },
    "AllowedIpList": {
      "Type": "CommaDelimitedList",
      "Label": {
        "zh-cn": "API Key允许的IP白名单",
        "en": "API Key Allowed IP List"
      },
      "Description": {
        "zh-cn": "允许访问API的IP地址列表。",
        "en": "List of IP addresses allowed to access the API."
      },
      "Default": [
        "0.0.0.0/0"
      ]
    }
  },
  "Resources": {
    "ADBInstance": {
      "Type": "ALIYUN::ADB::DBCluster",
      "Properties": {
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VPCId": {
          "Ref": "VpcId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "DBClusterDescription": {
          "Fn::Sub": "Vector storage for ${IndexName}"
        },
        "DBClusterClass": "T8",
        "DBClusterCategory": "Basic",
        "DBClusterVersion": "3.0",
        "Mode": "Reserved",
        "PayType": "Postpaid",
        "DBNodeGroupCount": 1,
        "DBNodeStorage": 100
      }
    },
    "Index": {
      "Type": "ALIYUN::Bailian::Index",
      "DependsOn": "ADBInstance",
      "Properties": {
        "WorkspaceId": {
          "Ref": "WorkspaceId"
        },
        "Name": {
          "Ref": "IndexName"
        },
        "SourceType": "DATA_CENTER_FILE",
        "StructureType": "unstructured",
        "DocumentIds": {
          "Ref": "DocumentIds"
        },
        "SinkType": "ADB",
        "SinkInstanceId": {
          "Ref": "ADBInstance"
        },
        "SinkRegion": {
          "Ref": "ALIYUN::Region"
        },
        "Description": "Enterprise knowledge base with ADB vector storage",
        "EmbeddingModelName": "text-embedding-v3",
        "RerankModelName": "qwen3-rerank",
        "RerankMode": "custom",
        "RerankInstruct": "Rank documents by relevance to the user query, prioritizing accuracy and completeness of information.",
        "RerankMinScore": {
          "Ref": "RerankMinScore"
        },
        "ChunkSize": 800,
        "OverlapSize": 150,
        "ChunkMode": "length",
        "EnableRewrite": true,
        "EnableHeaders": true,
        "PipelineCommercialType": "enterprise",
        "PipelineCommercialCu": 4,
        "DenseSimilarityTopK": {
          "Ref": "DenseSimilarityTopK"
        },
        "SparseSimilarityTopK": {
          "Ref": "SparseSimilarityTopK"
        },
        "MetaExtractColumns": [
          {
            "Key": "doc_category",
            "Type": "constant",
            "Value": "enterprise-doc",
            "Desc": "Document category",
            "EnableSearch": true,
            "EnableLlm": false
          },
          {
            "Key": "doc_summary",
            "Type": "custom_prompt",
            "Value": "Please summarize the key points of this document in one sentence.",
            "Desc": "AI-generated document summary",
            "EnableSearch": true,
            "EnableLlm": true
          },
          {
            "Key": "doc_keywords",
            "Type": "keywords",
            "Desc": "Extracted keywords",
            "EnableSearch": true,
            "EnableLlm": true
          }
        ]
      }
    },
    "ApiKey": {
      "Type": "ALIYUN::Bailian::ApiKey",
      "Properties": {
        "Description": {
          "Fn::Sub": "API Key for ${IndexName}"
        },
        "AuthSetModel": {
          "AuthSetMode": "Custom",
          "AccessIps": {
            "Ref": "AllowedIpList"
          }
        }
      }
    }
  },
  "Outputs": {
    "IndexId": {
      "Description": {
        "zh-cn": "知识库索引ID。",
        "en": "Knowledge base index ID."
      },
      "Label": {
        "zh-cn": "知识库索引ID",
        "en": "Index ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "Index",
          "Id"
        ]
      }
    },
    "ADBInstanceId": {
      "Description": {
        "zh-cn": "ADB向量存储实例ID。",
        "en": "ADB vector storage instance ID."
      },
      "Label": {
        "zh-cn": "ADB实例ID",
        "en": "ADB Instance ID"
      },
      "Value": {
        "Ref": "ADBInstance"
      }
    },
    "ApiKeyValue": {
      "Description": {
        "zh-cn": "API Key值,用于调用百炼服务。",
        "en": "API Key value for calling Bailian service."
      },
      "Label": {
        "zh-cn": "API Key",
        "en": "API Key"
      },
      "Value": {
        "Fn::GetAtt": [
          "ApiKey",
          "Key"
        ]
      }
    },
    "ApiKeyId": {
      "Description": {
        "zh-cn": "API Key ID。",
        "en": "API Key ID."
      },
      "Label": {
        "zh-cn": "API Key ID",
        "en": "API Key ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ApiKey",
          "ApiKeyId"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "WorkspaceId",
            "IndexName",
            "DocumentIds"
          ]
        },
        {
          "Parameters": [
            "ZoneId",
            "VpcId",
            "VSwitchId"
          ]
        },
        {
          "Parameters": [
            "DenseSimilarityTopK",
            "SparseSimilarityTopK",
            "RerankMinScore",
            "AllowedIpList"
          ]
        }
      ]
    }
  }
}