deeppavlov意图dstc2分类输出不清晰 (python)

我正在参考以下文档:https://github.com/deepmipt/DeepPavlov/blob/master/docs/components/classifiers.rst#id53

我的代码如下:

import osfrom deeppavlov import build_model, configsos.environ["KERAS_BACKEND"] = "tensorflow"CONFIG_PATH =  configs.classifiers.intents_dstc2_bigmodel = 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]]

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


回答:

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 osfrom deeppavlov import build_model, configs, train_modelfrom deeppavlov.core.common.file import read_jsonos.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"]))

你可以在配置文件中找到更多输出选项。

请告诉我这是否对你有足够的帮助。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注