Cortex Knowledge Extensions

Cortex Knowledge Extensions (CKEs) 是 :doc:` Cortex Search Service </user-guide/snowflake-cortex/cortex-search/cortex-search-overview>`,可以在 Snowflake Marketplace 上共享,也可以通过 专用列表组织列表 共享。它们可用于检索增强生成 (RAG) 架构,以将授权内容和专有内容集成到 Cortex AI 应用程序中。例如,CKEs 可用于将来自非结构化内容(例如文章、市场研究、书籍或论坛帖子)的知识集成到 Cortex AI 应用程序(例如聊天机器人和代理系统)中。

CKE 的工作原理

以下是它的工作原理:

  1. 提供商将其文本数据上传到其账户中的表中,并在表上创建 Cortex Search Service。然后,Cortex Search Service 将在 Snowflake Marketplace 上共享。在 Snowflake Marketplace 上共享的 Cortex Search Service 称为 Cortex Knowledge Extension (CKE)。

  2. 使用者使用 Cortex AISQL 或带有 CKE 的 Cortex Agent API 来构建使用 Cortex AI 的应用程序(例如聊天机器人)。

  3. 当向集成了 CKE 的 Cortex AI 应用程序提供提示时,该提示将传递给 CKE,以通过执行语义搜索来获取相关知识。相关知识将返回给 Cortex AI 应用程序的 LLM 并进行推理,然后再向用户返回带有引用来源和归因的答案。

展示 CKE 工作流程的流程图:从提供商的 Cortex Search Service,到搜索索引,再到针对使用者提示提供的回复。

CKE 功能

Cortex Knowledge Extensions 的一些主要功能包括:

下文将对这些功能进行更详细的描述。

内容保护

提供商可以限制其 CKE 中在 24 小时内可返回给使用者的索引内容的百分比。这可以通过使用以下命令设置阈值来实现。该阈值并非应用于单个文档级别,而是应用于整个索引内容库。使用者只能访问 CKE 中阈值百分比的索引内容。

有关 cke_content_protection 字段的更多信息,请参阅 列表清单参考

-- Use CREATE to create a new CKE listing with content protection.
-- Use ALTER to update an existing listing with content protection.

-- This example creates a CKE listing targeting to two accounts.
create external listing CKE_LISTING
share CKE_SHARE as
$$
title: "CKE Listing Title"
description: "Cortex Knowledge Extension Listing Description"
listing_terms:
  type: "STANDARD"
auto_fulfillment:
  refresh_type: "SUB_DATABASE"
  refresh_schedule: "1440 MINUTE"
targets:
  accounts:
    - "ORG1.ACCOUNT1"
    - "ORG2.ACCOUNT2"
cke_content_protection:
  enable: true,
  threshold: 0.2
$$

-- describe listing CKE_LISTING
-- See the manifest_yaml column for the cke_content_protection setting
Copy

当使用者达到阈值时,对 CKE 的查询将被阻止执行,并且使用者会收到以下错误:

You have reached the content protection threshold. Please try again later.

阈值刷新后,使用者可以重新查询数据。

管理

您可以通过登录 Snowsight <https://app.snowflake.cn/_deeplink/provider-studio> `_ 并导航到 :ui:`Provider Studio » Home 页面来查看 CKE 执行的查询数量。Analytics 部分显示已执行的查询数量。

试用支持

作为提供商,您可以为客户提供 CKE 的 有限试用,以便他们在决定购买之前试用您的产品。

获利

Cortex Knowledge Extensions 有两种获利方式:通过 订阅 使用平台上 Snowflake Marketplace Monetization 功能获利,或者通过`平台外 <https://other-docs.snowflake.cn/en/collaboration/provider-listings-creating-publishing#label-listings-free-private-create>`_ 获利。

区域可用性

Cortex Knowledge Extensions 可在任何提供 Cortex Search 的区域使用。

主要注意事项

请记住,当客户使用您的 Cortex Knowledge Extensions 时,在禁用 :doc:` Cortex Search Service </user-guide/snowflake-cortex/cortex-search/cortex-search-overview>` 时要小心,因为此操作会破坏客户的应用程序。

有关 Cortex Knowledge Extensions 的高级调整,请参阅 Cortex Search 文档。

引用来源

为确保 CKE 提供引用来源,在配置 Cortex Search Service 时,请确保在索引列中包含指向文档来源的 SOURCE_URL 列。LLMs 或 Snowflake Intelligence 可以使用它来提供明确的归属信息以及指向源材料的超链接。

将 CKE 发布到 Snowflake Marketplace

创建要发布到 Marketplace 的 Cortex Search Service 后,创建列表。确保将您创建的 Cortex Search Service 对象指向要发布的对象。

与 CKE 对话

您可以使用以下方法来向 CKE 提问。

  • 使用 Cortex Search Playground:

    1. 在 Snowsight 中,导航至 AI & ML » Cortex Search

    2. Database/Schema 下拉菜单中选择 CKE。

    3. 点击右上角的 Playground

    4. 输入搜索查询并查看结果

  • 使用 Snowflake Intelligence:

  • 使用 Cortex Agent API:

    • 使用 Cortex Agent API,并在 CREATE CORTEX SEARCH 参数中指定共享的 CKE。有关更多信息,请参阅 :doc:` Cortex Agent API</user-guide/snowflake-cortex/cortex-agents>` 文档。

更新 CKE

对于定期推出新内容或更新内容的提供商来说,让 CKE 保持最新状态是一个常见用例。为确保您的 Cortex Knowledge Extension 保持最新状态,请执行以下操作:

  1. 确保已通过将新的/更新的文档插入 Snowflake 账户的某些独立过程更新了包含内容的基础表。

  2. 查看 Cortex Search Service 目标延迟。Cortex Search Service 配置为刷新数据并让数据新鲜度保持在特定 target_lag 水平。有关 target_lag 的更多信息,请参阅 Cortex Search 使用 SQL 主题。

  3. 运行以下命令,确保 Cortex Search Service 正在编制索引。

    -- Get the status of the search service
    DESCRIBE CORTEX SEARCH SERVICE cke_simple_cortex_search_service;
    
    -- If the indexing status is suspended, you can resume it with the following command
    ALTER CORTEX SEARCH SERVICE cke_simple_cortex_search_service RESUME INDEXING;
    
    Copy

CKE 和自动履行

使用者只能访问其所在区域提供的 Cortex Knowledge Extension。提供商可以通过在 Provider Studio 中为其 Cortex Knowledge Extension 列表启用 自动履行,自动将其 Cortex Search Service 复制到远程使用者区域。

限制

语言: 中文