I have trained a supervised_embeddings
Rasa NLU model using rasa train nlu
. For my specific use case, I now need to get the embeddings for inputted user messages, and compare the embeddings with those of messages in my NLU training data.
Is it possible to use the Python API to load the trained model, and use it to get the embedding of a string of text?
This was answered on the rasa forum. For easy reference - pass only_output_properties=False
to the interpreter.parse
method:
You can do this from within a python script:
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")