I have created a ‘sentence-similarity’ model using ‘sentence_transformers’. I wanted to include that in rasa custom action. Sentence similarity is one of the functionality my chatbot perform. But I am getting an error 'ModuleNotFoundError: No module named ‘sentence_transformers’ whenever I try to run ‘rasa run actions’ command.
sentence_transformers package is installed in the virtual environment I am using.
Note: I have also read, it is doable with REST API call. But I don’t want to do that.
Could you share the custom action code that is using the similarity feature? In essense you should merely need to import it, but I’m wondering if you’re running rasa run actions from the correct virtual environment. Could you confirm the venv by running rasa --version just before running rasa run actions?
Could you explain the use-case for sentence similarity a bit more? You want your custom action to tell the user if their message is similar to something it saw before?
Thank you very much for your reply. Yes the virtual environment is same for both the rasa and the transformer model. I created a separate class for the model and it is running fine independently but when I call it in custom action class it was causing the error.
I was able to find the way around to solve the issue by using hugging face and downloading the whole model and mean_pooling method: sentence-transformers/all-mpnet-base-v2 · Hugging Face
The sentence similarity model I am using to score the similarity of two sentences (the similarity of user utterance and the statements in my knowledge base)
I am still unable to understand why the class is working independently but when called in custom action it create error. Here is the code for reference