我有Tensorflow和Jupyter的功能设置。我已经将Tensorflow==1.14配置为在gpu上运行
现在回答问题: 我正在使用一个叫做DeepPavlov的开源对话AI框架。它已经启动并运行(在配置端),但是我没有太多从笔记本调用python的经验(或者根本没有)。我可以在控制台上运行此代码,但这不是我的目标。我的问题是:
我有一个普通的python代码:
from deeppavlov import build_model, configs
model = build_model(configs.squad.squad, download=True)
model(['DeepPavlov is library for NLP and dialog systems.'], ['What is DeepPavlov?'])
这是我的输出:
2020-04-20 07:08:23.478 INFO in 'deeppavlov.download'['download'] at line 117: Skipped http://files.deeppavlov.ai/deeppavlov_data/squad_model_1.4_cpu_compatible.tar.gz download because of matching hashes
2020-04-20 07:08:37.884 INFO in 'deeppavlov.download'['download'] at line 117: Skipped http://files.deeppavlov.ai/embeddings/wiki-news-300d-1M.vec download because of matching hashes
2020-04-20 07:08:38.343 INFO in 'deeppavlov.download'['download'] at line 117: Skipped http://files.deeppavlov.ai/embeddings/wiki-news-300d-1M-char.vec download because of matching hashes
2020-04-20 07:08:38.364 INFO in 'deeppavlov.models.preprocessors.squad_preprocessor'['squad_preprocessor'] at line 310: SquadVocabEmbedder: loading saved tokens vocab from C:\Users\Administrator\.deeppavlov\models\squad_model\emb\vocab_embedder.pckl
2020-04-20 07:08:39.158 INFO in 'deeppavlov.models.preprocessors.squad_preprocessor'['squad_preprocessor'] at line 310: SquadVocabEmbedder: loading saved chars vocab from C:\Users\Administrator\.deeppavlov\models\squad_model\emb\char_vocab_embedder.pckl
2020-04-20 07:08:40.599 INFO in 'deeppavlov.core.layers.tf_layers'['tf_layers'] at line 615:
Warning! tf.contrib.cudnn_rnn.CudnnCompatibleGRUCell is used. It is okay for inference mode, but if you train your model with this cell it could NOT be used with tf.contrib.cudnn_rnn.CudnnGRUCell later.
2020-04-20 07:08:41.185 INFO in 'deeppavlov.core.layers.tf_layers'['tf_layers'] at line 615:
Warning! tf.contrib.cudnn_rnn.CudnnCompatibleGRUCell is used. It is okay for inference mode, but if you train your model with this cell it could NOT be used with tf.contrib.cudnn_rnn.CudnnGRUCell later.
2020-04-20 07:08:41.520 INFO in 'deeppavlov.core.layers.tf_layers'['tf_layers'] at line 615:
Warning! tf.contrib.cudnn_rnn.CudnnCompatibleGRUCell is used. It is okay for inference mode, but if you train your model with this cell it could NOT be used with tf.contrib.cudnn_rnn.CudnnGRUCell later.
2020-04-20 07:08:41.748 INFO in 'deeppavlov.core.layers.tf_layers'['tf_layers'] at line 615:
Warning! tf.contrib.cudnn_rnn.CudnnCompatibleGRUCell is used. It is okay for inference mode, but if you train your model with this cell it could NOT be used with tf.contrib.cudnn_rnn.CudnnGRUCell later.
2020-04-20 07:09:23.205 INFO in 'deeppavlov.core.models.tf_model'['tf_model'] at line 51: [loading model from C:\Users\Administrator\.deeppavlov\models\squad_model\model]
INFO:tensorflow:Restoring parameters from C:\Users\Administrator\.deeppavlov\models\squad_model\model
[['library for NLP and dialog systems'], [14], [8040850.5]]
它正常运行,但没有给我任何交互选项,比如提示或其他什么,它只是停止了
我的目标是得到一个提示,在那里我可以输入和获得输出(文本等)。我知道我可能在使用python笔记本/手机时犯了一些非常基本的错误,如果您需要更多信息,请询问。谢谢
DeepPavlov附带了一系列由TensorFlow和Keras提供动力的预定义组件,用于解决NLP相关问题
您使用的是BERT进行问答。上下文问答是在给定上下文(例如,维基百科中的一段)中查找问题答案的任务,其中每个问题的答案都是上下文的一部分
模型在调用
model(contexts_list, questions_list)
时返回以下结果示例1:
输出-
答案返回答案列表、答案开始列表(答案在第14个字符处)和登录列表
示例2:从here复制了圣雄甘地的上下文
输出-
或者,您可以构建与模型交互的deeppavlov。您可以通过使用交互参数和模型配置文件的名称从命令行运行模型来与模型交互(-d表示下载所有必需的文件)。否则,您可以使用Python Jupyter代码中的build_模型,如下例所示
安装附件-
示例1-
输出-
示例2-
输出-
希望这能回答你的问题。快乐学习
相关问题 更多 >
编程相关推荐