I want to use cosine similarity to identify the intent and pass it to RASA Core. In other words, I want to replace the NLU part with some other similarity calculation method. How to do it?
Currently, there is four classifiers implemented in Rasa-NLU:
If you use embedding_intent_classifier.py
by default it is used cosine similarity:
"similarity_type": 'cosine', # string 'cosine' or 'inner'
How to customize your pipeline?
language: "en"
pipeline:
- name: "tokenizer_whitespace"
- name: "ner_crf"
- name: "ner_synonyms"
- name: "intent_featurizer_count_vectors"
- name: "intent_classifier_tensorflow_embedding"
See here for more details.
How to define my own Components?
Inherit from parent object Component
and implement your own. If you need to define tfidf
and cosine
read here, and then compare your code with here.
from rasa_nlu.components import Component
class MyComponent(Component):
def __init__(self, component_config=None):
pass
def train(self, training_data, cfg, **kwargs):
pass
def process(self, message, **kwargs):
pass
def persist(self, model_dir):
pass
@classmethod
def load(cls, model_dir=None, model_metadata=None, cached_component=None,
**kwargs):
Also do not forget to add it into pipeline:
pipeline:
- name: "MyComponent"