是否可以加载经过训练的 Rasa NLU 模型和 运行 推理以获得嵌入
Is it possible to load a trained Rasa NLU model and run inference to get embeddings
我已经使用 rasa train nlu
训练了 supervised_embeddings
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")
我已经使用 rasa train nlu
训练了 supervised_embeddings
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")