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