是否可以加载经过训练的Rasa NLU模型并进行推理以获取嵌入物

问题描述 投票:0回答:2

我已经使用supervised_embeddings训练了rasa train nlu Rasa NLU模型。对于我的特定用例,我现在需要获取输入的用户消息的嵌入,并将这些嵌入与NLU训练数据中的消息的嵌入进行比较。

是否有可能使用Python API加载经过训练的模型,并使用它来嵌入文本字符串?

python tensorflow rasa-nlu rasa
2个回答
0
投票

@@ KOB不幸的是,我们没有相应的API。您可以查看https://github.com/RasaHQ/rasa/blob/master/rasa/nlu/classifiers/embedding_intent_classifier.py#L572处的代码,并使用message_embed作为嵌入。随时提出任何其他问题。


0
投票

此问题在rasa forum上得到了回答。为了方便参考-将only_output_properties=False传递给interpreter.parse方法:

您可以在python脚本中执行此操作:

from rasa.nlu.model import Interpreter

interpreter = Interpreter.load('models/nlu-xyz/nlu')) ## this should be an extracted model
result = interpreter.parse('hello world',only_output_properties=False)
embeds = result.get("text_sparse_features")
© www.soinside.com 2019 - 2024. All rights reserved.