【问题标题】:deeppavlov intent dstc2 classification output not clear (python)deeppavlov 意图 dstc2 分类输出不清楚(python)
【发布时间】:2018-12-31 04:35:27
【问题描述】:

我正在关注此文档: https://github.com/deepmipt/DeepPavlov/blob/master/docs/components/classifiers.rst#id53

我的代码如下:

import os
from deeppavlov import build_model, configs

os.environ["KERAS_BACKEND"] = "tensorflow"

CONFIG_PATH =  configs.classifiers.intents_dstc2_big
model = build_model(CONFIG_PATH, download=True)
print(model(["Hello"]))

我期待这样的输出:

"goals": {"pricerange": "cheap"},
"db_result": null,
"dialog-acts": [{"slots": [["pricerange", "cheap"]], "act": "inform"}]}

但是,我得到的只是一个这样的数字数组:

[[0.004440320190042257, 0.0035526982974261045, 0.003814868861809373, 0.004386670421808958, 0.0026496422942727804, 0.004122086800634861, 0.004859328735619783, 0.005762884858995676, 0.006169301923364401, 0.9743947386741638, 0.005218957085162401, 0.004720163065940142, 0.006856555584818125, 0.0047727120108902454, 0.008368589915335178, 0.011183635331690311, 0.007578883320093155, 0.005414197687059641, 0.008248056285083294, 0.005105976946651936, 0.005934832151979208, 0.005890967790037394, 0.005130860488861799, 0.005532102193683386, 0.005490032024681568, 0.0046647703275084496, 0.004590084310621023, 0.004707065410912037]]

我应该如何正确显示或使用输出?

【问题讨论】:

    标签: python machine-learning nlp artificial-intelligence


    【解决方案1】:

    intents_dstc2_big 模型不会为您提供正确的 DSTC2 输出,而是根据原始数据集中的 actslot 值识别话语的意图。

    例如,

    "goals": {"food": "dontcare", "pricerange": "cheap", "area": "south"},
    "db_result": null,
    "dialog-acts": [{"slots": [], "act": "thankyou"}, {"slots": [], "act": "bye"}]}
    

    此消息包含两个意图(thankyou, bye)

    为了获得意图方面的输出,您应该稍微更改配置。

    import os
    from deeppavlov import build_model, configs, train_model
    from deeppavlov.core.common.file import read_json
    
    os.environ["KERAS_BACKEND"] = "tensorflow"
    
    model_config = read_json(configs.classifiers.intents_dstc2_big)
    model_config['chainer']['out'] =  ['y_pred_labels']
    
    model = build_model(model_config, download=True)
    print(model(["thank you good bye"]))
    

    更多输出选项您可以找到in the configuration file

    如果这对您有足够的帮助,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-17
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-06
      • 2017-02-09
      • 2012-05-05
      相关资源
      最近更新 更多