跳至主要内容

获取嵌入节点

Get Embedding Node Screenshot

概述

Get Embedding节点用于为给定输入文本生成向量嵌入。当您需要将文本转换为可用于K近邻搜索等任务的数值表示时,该节点特别有用。

该节点要求在运行图时上下文中必须有一个可用的集成。该集成负责生成嵌入向量。目前唯一支持的集成是OpenAI。然而,在父应用程序中运行Rivet时,您可以注册自定义集成。

输入项

标题数据类型描述默认值备注
InputstringThe text for which the embedding should be generated.(required)The input will be coerced into a string if it is not a string.
IntegrationstringThe name of the integration to use for generating the embedding.(required if the input toggle for Integration is enabled)The input will be coerced into a string if it is not a string.

示例1:为文本生成嵌入向量

  1. 创建一个文本节点并将文本设置为"Hello, world!"
  2. 创建一个Get Embedding节点并将Text节点连接到其Input输入端口。
  3. 运行图表。Get Embedding节点的Embedding输出应包含输入文本的向量嵌入。

Get Embedding Node Example 1

错误处理

如果运行图表时上下文中集成不可用,Get Embedding Node 将会报错。如果未提供Input输入,它也会报错。

常见问题

问:什么是嵌入(embedding)?

A: 嵌入(embedding)是一段文本的数值表示形式。嵌入对于执行K近邻搜索非常有用,这是AI应用中的常见操作。

问:我可以使用自己的集成吗?

A: 是的,您可以使用自己的集成,方法是在运行图表时将其传递给上下文。该集成必须实现EmbeddingGenerator接口,其中包括一个用于生成嵌入的方法。

另请参阅