Skip to content

Text Classifier#

Use the Text Classifier node to classify (categorize) incoming data. Using the categories provided in the parameters (see below), each item is passed to the model to determine its category.

On this page, you'll find the node parameters for the Text Classifier node, and links to more resources.

Node parameters#

Input Prompt defines the input to classify. This is usually an expression that references a field from the input items. For example, this could be {{ $json.chatInput }} if the input is a chat trigger. By default it references the text field.

Categories: Add the categories that you want to classify your input as. Categories have a name and a description. Use the description to tell the model what the category means. This is important if the meaning isn't obvious. You can add as many categories as you like.

Node options#

  • Allow Multiple Classes To Be True: You can configure the classifier to always output a single class per item, or allow the model to select multiple classes.

  • When No Clear Match: This option allows you to define what happens if the model can't find a good match for an item. There are two options:

    • Discard Item (the default): If none of the categories are detected, the item is dropped.

    • Output on Extra, 'Other' Branch: Creates a separate output branch called 'Other', for when none of the categories are detected.

  • System Prompt Template: This option allows you to change the system prompt that's used for the classification. It uses the {categories} placeholder for the categories.

View n8n's Advanced AI documentation.

  • 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.