Skip to content

文本分类器节点#

使用文本分类器节点对输入数据进行分类(归类)。根据参数中提供的类别(见下文),每个项目都会被传递给模型以确定其所属类别。

本页将介绍文本分类器节点的参数配置,并提供更多相关资源的链接。

节点参数#

  • 输入提示:定义需要分类的输入内容。通常是一个引用输入项字段的表达式。例如,如果输入来自聊天触发器,可以是 {{ $json.chatInput }}。默认情况下引用 text 字段。
  • 分类类别:添加您希望输入数据被分类的类别。每个类别包含名称和描述。使用描述向模型解释该类别的含义,这在含义不明显时尤为重要。您可以添加任意数量的类别。

节点选项#

  • 允许多个类别为真:可配置分类器为每个项目始终输出单一类别(关闭此选项),或允许模型选择多个类别(开启此选项)。
  • 当无明确匹配时:定义当模型无法找到合适匹配项时的处理方式。有两种选择:
    • 丢弃项目(默认):如果节点未检测到任何类别,则丢弃该项目。
    • 输出到额外的'其他'分支:创建一个名为其他的独立输出分支。当节点未检测到任何类别时,将项目输出到此分支。
  • 系统提示模板:使用此选项更改用于分类的系统提示。其中 {categories} 占位符会被替换为实际类别列表。

  • 启用自动修正:启用后,节点会自动修正模型输出以确保符合预期格式。这是通过将模式解析错误发送给LLM并要求其修正来实现的。

相关资源#

查看 n8n 的高级 AI 文档。

AI glossary#

  • completion: Completions are the responses generated by a model like GPT.
  • hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
  • vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
  • vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.