Skip to content

情感分析节点#

¥Sentiment Analysis node

使用“情感分析”节点分析传入文本数据的情感。

¥Use the Sentiment Analysis node to analyze the sentiment of incoming text data.

语言模型使用节点选项中的 情感分类 来确定每个项目的情感倾向。

¥The language model uses the Sentiment Categories in the node options to determine each item's sentiment.

节点参数#

¥Node parameters

  • 待分析文本定义情感分析的输入文本。这是一个引用输入项中某个字段的表达式。例如,如果输入来自聊天或消息源,则该属性可以是 {{ $json.chatInput }}。默认情况下,它需要一个 text 字段。

¥Text to Analyze defines the input text for sentiment analysis. This is an expression that references a field from the input items. For example, this could be {{ $json.chatInput }} if the input is from a chat or message source. By default, it expects a text field.

节点选项#

¥Node options

  • 情感类别:定义要对输入进行分类的类别。

¥Sentiment Categories: Define the categories that you want to classify your input as.

  • 默认情况下,这些是 Positive, Neutral, Negative。你可以自定义这些类别以适应你的特定用例,例如使用 Very Positive, Positive, Neutral, Negative, Very Negative 进行更精细的分析。

    ¥By default, these are Positive, Neutral, Negative. You can customize these categories to fit your specific use case, such as Very Positive, Positive, Neutral, Negative, Very Negative for more granular analysis.

  • 包含详细结果:启用此选项后,输出中包含情感强度和置信度分数。请注意,这些分数是由语言模型生成的估计值,仅供参考,并非精确测量值。

¥Include Detailed Results: When turned on, this option includes sentiment strength and confidence scores in the output. Note that these scores are estimates generated by the language model and are rough indicators rather than precise measurements.

  • 系统提示模板:使用此选项可更改用于情感分析的系统提示。它使用 {categories} 占位符来表示类别。

¥System Prompt Template: Use this option to change the system prompt that's used for the sentiment analysis. It uses the {categories} placeholder for the categories.

  • 启用自动修复:启用后,节点会自动修复模型输出,以确保其符合预期格式。将模式解析错误发送给 LLM 并请求其修复。

¥Enable Auto-Fixing: When enabled, the node automatically fixes model outputs to ensure they match the expected format. Do this by sending the schema parsing error to the LLM and asking it to fix it.

使用说明#

¥Usage Notes

模型温度设置#

¥Model Temperature Setting

强烈建议将连接语言模型的温度设置为 0 或接近 0 的值。这有助于确保结果尽可能确定,从而在多次运行中提供更一致、更可靠的情感分析。

¥It's strongly advised to set the temperature of the connected language model to 0 or a value close to 0. This helps ensure that the results are as deterministic as possible, providing more consistent and reliable sentiment analysis across multiple runs.

语言注意事项#

¥Language Considerations

节点的性能可能因输入文本的语言而异。

¥The node's performance may vary depending on the language of the input text.

为了获得最佳结果,请确保你选择的语言模型支持输入语言。

¥For best results, ensure your chosen language model supports the input language.

处理大量数据#

¥Processing Large Volumes

分析大量文本时,请考虑将输入拆分为更小的块,以优化处理时间和资源使用。

¥When analyzing large amounts of text, consider splitting the input into smaller chunks to optimize processing time and resource usage.

迭代细化#

¥Iterative Refinement

对于复杂的情感分析任务,你可能需要反复调整系统提示和类别,才能达到预期结果。

¥For complex sentiment analysis tasks, you may need to iteratively refine the system prompt and categories to achieve the desired results.

示例用法#

¥Example Usage

基本情感分析#

¥Basic Sentiment Analysis

  1. 将数据源(例如,RSS 源、HTTP 请求)连接到情感分析节点。

¥Connect a data source (for example, RSS Feed, HTTP Request) to the Sentiment Analysis node. 2. 将 "待分析文本" 字段设置为相关的项属性(例如,博客文章内容使用 {{ $json.content }})。

¥Set the "Text to Analyze" field to the relevant item property (for example, {{ $json.content }} for blog post content). 3. 保留默认情感类别。

¥Keep the default sentiment categories. 4. 将节点的输出连接到不同的路径,以便分别处理正面、中性和负面情绪。

¥Connect the node's outputs to separate paths for processing positive, neutral, and negative sentiments differently.

自定义类别分析#

¥Custom Category Analysis

  1. 将“情感类别”更改为 Excited, Happy, Neutral, Disappointed, Angry

¥Change the Sentiment Categories to Excited, Happy, Neutral, Disappointed, Angry. 2. 调整你的工作流程以处理这五种输出类别。

¥Adjust your workflow to handle these five output categories. 3. 使用此设置以更细致的情感类别分析客户反馈。

¥Use this setup to analyze customer feedback with more nuanced emotional categories.

相关资源#

¥Related resources

View n8n's Advanced AI documentation.