我们可以使用沃森对话只检索意图吗?

can we retrieve only the intent using watson conversation?

目前我们正在使用 Watson Natural Language Classifier 服务 (NLC) 来获取用户问题的意图。但是配置和维护 NLC 变得越来越困难,所以想知道是否可以使用 Watson Conversation 部分仅获取用户问题的意图,仅获取意图而不是来自服务的对话响应。

意图来自对话回复的一部分。如果设置参数 alternate_intents=true,则返回前 10 个意图。

您仍将获得其余的有效载荷,但您可以忽略它。我建议创建一个条件为 true 且仅此而已的对话节点。当找不到匹配的节点时,这将防止 SPEL 错误。

您的回复将如下所示。

{
  "alternate_intents": true,
  "context": { 
    "conversation_id": "6c256e10-ba3b-4d2b-84fc-740853879d4f",
    "system": { 
      "_node_output_map": { "True": [0] },
      "branch_exited": true,
      "branch_exited_reason": "completed",
      "dialog_request_counter": 1,
      "dialog_stack": [ { "dialog_node": "root" } ],
      "dialog_turn_counter": 1
    }
  },
  "entities": [],
  "input": { "text": "test" },
  "intents": [
      { "intent": "intent1", "confidence": 1.0 },
      { "intent": "intent2", "confidence": 0.9 },
      { "intent": "intent3", "confidence": 0.8 },
      { "intent": "intent4", "confidence": 0.7 },
      { "intent": "intent5", "confidence": 0.6 },
      { "intent": "intent6", "confidence": 0.5 },
      { "intent": "intent7", "confidence": 0.4 },
      { "intent": "intent8", "confidence": 0.3 },
      { "intent": "intent9", "confidence": 0.2 },
      { "intent": "intent10", "confidence": 0.1 }
  ],
  "output": {
    "log_messages": [],
    "nodes_visited": [ "True" ],
    "text": [ "" ]
  }
}

您只需要参考 json_response['intents']。此外,如果您只关心意图,则无需继续发回上下文。


补充一下。 NLC 和 Conversation 使用两种截然不同的学习模型。

  • NLC 使用 "Relative Confidence"
  • 对话使用"Absolute Confidence"

在 Relative 的情况下,找到的所有项目的置信度加起来为 1。通俗地说,NLC 自动假定答案只能在给出的意图中。

对于 Absolute,置信度仅与该意图有关。这意味着谈话可以理解您所说的内容可能不在所接受的培训中。这也意味着您的意向列表可以返回为空。

因此,如果之前给您 90% 的东西现在给您 60%,请不要惊慌。他们只是得分不同。