simple_intent_classifier_pytorch#
- class besser.agent.nlp.intent_classifier.simple_intent_classifier_pytorch.SimpleIntentClassifierTorch(nlp_engine, state)[source]#
Bases:
IntentClassifier
A Simple Pytorch-based Intent Classifier.
It works using a simple Neural Network (the prediction model) for text classification.
- Parameters:
- _model#
The intent classifier language model
- Type:
See also
- PAD = '<PAD>'#
- UNK = '<UNK>'#
- __intent_label_mapping#
A mapping of the intent labels and their corresponding intents.
- __total_labels#
The label (identifying the intent) of all training sentences.
- __total_labels_encoded#
The encoded label of all training sentences.
- __total_training_sentences#
All the processed training sentences of all intents of the intent classifier’s state.
- __total_training_sequences#
All the training sequences of all intents of the intent classifier’s state.
- __vocab#
The vocabulary of the intent classifier (i.e., all known tokens).
- _abc_impl = <_abc._abc_data object>#
- predict(message)[source]#
Predict the intent of a given message.
Instead of returning only the intent with the highest likelihood, return all predictions. Predictions include not only the intent scores but other information extracted from the message.
- Parameters:
message (str) – the message to predict the intent
- Returns:
the list of predictions made by the intent classifier.
- Return type:
- class besser.agent.nlp.intent_classifier.simple_intent_classifier_pytorch.TextClassifier(vocab_size, embed_dim, hidden_dim, output_dim, pad_idx, activation_last_layer)[source]#
Bases:
Module
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.