我已经使用supervised_embeddings
训练了rasa train nlu
Rasa NLU模型。对于我的特定用例,我现在需要获取输入的用户消息的嵌入,并将这些嵌入与NLU训练数据中的消息的嵌入进行比较。
是否有可能使用Python API加载经过训练的模型,并使用它来嵌入文本字符串?
@@ KOB不幸的是,我们没有相应的API。您可以查看https://github.com/RasaHQ/rasa/blob/master/rasa/nlu/classifiers/embedding_intent_classifier.py#L572处的代码,并使用message_embed
作为嵌入。随时提出任何其他问题。
此问题在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")