Intent Classification — Generative AI based Application Architecture 3

Ali Khan
𝐀𝐈 𝐦𝐨𝐧𝐤𝐬.𝐢𝐨
17 min readSep 25, 2023

--

Table of Contents

Intent Classification in the context of Natural Language Understanding
Intent Classification & Generative AI-based Applications
Intent Classification Models
DIET (Dual Intent and Entity Transformer)
BERT (Bidirectional Encoder Representations from Transformers)
Rasa’s Embedding Intent Classifier
CNN (Convolutional Neural Network)
Intent Classifier Implementation Using RASA
Intent Classifier Implementation Using RASA-NLU 0.15.1
Pre-requisites & Installation
spaCy Pipeline Setup
Job board dataset for training the model
Training Classifier
intent_classifier_sklearn
Testing the model
Model Performance

Generative AI-based applications differ significantly from traditional AI chatbots. Traditional AI chatbots are usually goal-driven and purposely built to achieve a single objective. In the early stages of AI and ML architectures, the digital ecosystem was dominated by monolithic chatbots. These bots, though pioneering, were essentially deterministic. Their operational paradigm was binary — retrieve and respond based on pre-defined algorithmic logic. Such systems, widely embraced in customer support domains, faced the intricate challenge of user intent determination. To address this, ‘intent classification’ emerged as a crucial computational task, wherein each user input was processed, tokenized, and subsequently classified into a predefined taxonomy of intents using supervised learning models.

However, the advent of Generative AI heralded a paradigm shift. Empowered by sophisticated large language models, the modern applications introduced an element of versatility, far removed from the tunnel-vision focus of their predecessors. Generative AI wasn’t necessarily anchored to a specific goal. Instead, it cultivated an environment where user interactions evolved into fluid, generic conversations, almost echoing the spontaneity of human discourse. But this doesn’t render intent classification obsolete. On the contrary, it highlighted its significance in a new light. By adeptly determining user intent upfront, one could steer the conversation more efficiently, ensuring that users are seamlessly transitioned to prompts that resonate with their underlying objectives.

Intent Classification in the context of Natural Language Understanding

Natural Language Understanding (NLU) is a specialized subset of the broader domain of Natural Language Processing (NLP). While NLP encompasses a range of computational techniques focused on the syntactic processing and manipulation of human language — such as tokenization, part-of-speech tagging, and parsing — NLU delves deeper into the semantic and pragmatic layers of language comprehension. NLU is concerned with enabling machines to grasp the nuanced meanings, intentions, sentiments, and contexts embedded within textual data. It’s not just about analyzing the structural components of language but about interpreting the underlying semantics, making inferences, and discerning the intent behind language constructs. In essence, while NLP can be seen as the mechanical processing of language, NLU strives for a more profound, cognitive understanding, aiming to bridge the gap between mere linguistic form and the intricate tapestry of human meaning and intent.

Intent classification, within the ambit of Natural Language Understanding (NLU), is a pivotal task that focuses on deducing the specific purpose or objective behind a user’s input in a conversational context. Whereas NLU seeks to interpret the layered semantics and contextual nuances embedded within textual data, intent classification hones in on categorizing these inputs into predefined, actionable labels. In a technical framework, intent classification typically leverages supervised machine learning models, wherein tokenized and vectorized user utterances serve as input features, and the output constitutes a probabilistic distribution across potential intent labels. Advanced techniques, such as contextual embeddings derived from transformer architectures, further enhance the model’s ability to discern subtle differences in user intent, even when phrasings are lexically similar. In essence, intent classification operates at the confluence of syntactic processing and semantic interpretation, ensuring that user interactions in conversational AI systems are not only comprehended but also mapped to appropriate responses or actions with high precision.

In traditional AI chatbots, intent classification plays an instrumental role in ensuring efficient and contextually relevant user interactions. Unlike advanced generative models that can dynamically construct responses, traditional chatbots predominantly operate on rule-based or template-driven systems. Within these systems, understanding the user’s specific intention is paramount to delivering an appropriate pre-defined response or triggering a certain action. Intent classification in this context involves mapping user utterances to a discrete set of predefined classes or “intents.” For example, in a customer support chatbot, utterances like “I need help with my order” and “My order is incorrect” might both map to an “order_issue” intent, leading the chatbot to retrieve a relevant troubleshooting response.

The process typically starts with the extraction of features from the user’s input, often using techniques like bag-of-words, TF-IDF vectorization, or even more advanced embeddings. These features are then fed into a supervised machine learning model, which has been trained on a labelled dataset consisting of various user utterances and their corresponding intents. Once the user’s intent is identified, the chatbot consults its decision-making framework — often a combination of rule-based logic and decision trees — to determine the most suitable response or action. In essence, intent classification in traditional AI chatbots acts as a crucial bridge between raw user input and the bot’s repository of responses, ensuring that the conversation stays coherent, goal-oriented, and user-centric.

Intent Classification & Generative AI-based Applications

In generative AI-based applications, especially those harnessing the power of models like GPT, the dialogue is more dynamic, fluid, and less constrained by predefined templates. However, this very flexibility can pose a challenge: ensuring the generated content remains aligned with the user’s primary intent. This is where intent classification comes into its own, serving as a strategic preprocessing step to refine and direct the generative capabilities of such models.

By initially classifying the user’s intent, generative AI applications can be primed to generate content that’s more contextually relevant. Once an input’s intent is ascertained, it can be used to choose or even modify the prompt for the GPT-based dialogue system. For instance, if a user’s input is classified under the “technical_support” intent, a GPT model can be primed with a prompt like “Providing technical guidance on,” ensuring that the generated content is in line with technical support.

Moreover, certain applications might involve multiple GPT models or variants, each fine-tuned for specific domains or tasks. In such scenarios, intent classification can act as a routing mechanism, directing the user’s query to the most appropriate generative model. This ensures not just relevance but also optimizes computational resources by invoking the right model for the right task.

Furthermore, by integrating intent classification, generative applications can achieve a balance between open-ended creativity and goal-oriented precision. While the GPT model brings to the table its vast knowledge and generative prowess, intent classification ensures that this power is harnessed in a direction that aligns with the user’s expectations and the application’s objectives. In essence, intent classification acts as a guiding beacon, ensuring that the vast ocean of possibilities offered by generative AI is navigated purposefully, leading to meaningful and contextually apt interactions.

Intent Classification Models

Let me give you an overview of intent classification models, with a specific emphasis on the DIET (Dual Intent and Entity Transformer) architecture, among others.

DIET (Dual Intent and Entity Transformer)

(Ref: https://arxiv.org/pdf/2004.09936.pdf)
At its core, DIET is designed to handle both intent classification and entity recognition, two pivotal tasks in Natural Language Understanding (NLU) that often interplay in conversational AI scenarios. Unlike traditional models that handle these tasks in isolation, DIET integrates them into a single end-to-end architecture. It employs a transformer-based approach, enabling it to capture context from both previous and subsequent tokens in a given sequence. After generating contextual embeddings for input sequences, DIET employs separate output layers for intent and entity predictions, thereby leveraging shared semantic representations for both tasks. The joint nature of this architecture often leads to enhanced performance, especially in scenarios where intent and entities are closely interwoven.

BERT (Bidirectional Encoder Representations from Transformers)

(Ref: https://medium.com/@nutanbhogendrasharma/step-by-step-intent-recognition-with-bert-1473202b8597)
While not exclusively an intent classification model, BERT’s architecture has been widely adopted for this purpose. BERT captures context bidirectionally, which is instrumental in understanding nuanced user intents in a conversation. Fine-tuning BERT on specific intent classification tasks allows it to generate highly contextual embeddings, which can then be fed into a classification layer to predict specific intents.

Rasa’s Embedding Intent Classifier

(Ref: https://medium.com/@tatiana.parshina/understanding-rasa-tensorflow-intent-classifier-e9d4ef019c6)
Before the advent of DIET, Rasa, a popular open-source platform for building chatbots, utilized an embedding-based approach for intent classification. This model works by converting both user messages and intents into high-dimensional vectors in a shared space. The model is trained in such a way that vectors of similar intents and corresponding user messages lie closer in this shared space. When a new message is processed, it’s transformed into a vector, and its intent is determined based on proximity to existing intent vectors.

CNN (Convolutional Neural Network)

(Ref: https://www.analyticsvidhya.com/blog/2021/12/intent-classification-with-convolutional-neural-networks/)
CNNs, traditionally recognized for their prowess in image processing, have also found applications in intent classification. In this context, they are utilized to detect local patterns or features in input sentences, effectively capturing context within defined window sizes. Multiple convolutional layers, with varying window sizes, can capture different granularities of information, making CNNs adept at understanding intricate intent patterns in user messages.

To summarize, intent classification models, whether DIET, BERT, or others, are instrumental in distilling user intent from natural language inputs. The choice of architecture often depends on the specific requirements of the application, the interplay of intent and entities, and the availability of training data. The continuous evolution of these models reflects the growing complexity and demands of modern conversational AI systems.

Intent Classifier Implementation Using RASA

Intent Classifier

As a part of the reference architecture for modern generative AI based applications when I started searching for the appropriate intent classification model, my first option was RASA open-source platform. My acquaintance with RASA dates back to 2019 during a university course assignment. Back then RASA NLU was available as a python package named rasa-nlu (https://pypi.org/project/rasa-nlu/#history).
In this article, I will describe the implementation of Intent Classifier using both rasa-nlu package and RASA platform.

Intent Classifier Implementation Using RASA-NLU 0.15.1

Warning: This uses a pretty old version of python and spacy package. It is slow and model performance is not very accurate.

Pre-requisites & Installation

  1. Python 3.7.x
  2. spaCy 2.3.7
# Start a new pipenv in the shell
pipenv shell
# Initialize pyenv
pyenv init - | source
# Invoke the python environment based on version 3.7 (make sure you have 3.7 installed using pyenv install 3.7
pyenv shell 3.7
# Upgrade pip for better package compatibility
pip install --upgrade pip
# Install the required Python packages
pip install rasa-nlu spacy==2.3.7 sklearn_crfsuite
# Download the English model for Spacy to be used with Rasa NLU.
python -m spacy download en

spaCy Pipeline Setup

spaCy is a popular open-source library for Natural Language Processing (NLP) that provides robust linguistic capabilities. The core of spaCy’s functionality revolves around its processing pipeline, which is a series of stages that raw text undergoes to be processed into linguistic annotations. RASA NLU leverages the capabilities of the spaCy library for intent classification. Below is the config file for the spaCy pipeline setup to process our training dataset.

language: "en"

pipeline:
- name: "nlp_spacy"
- name: "tokenizer_spacy"
- name: "intent_entity_featurizer_regex"
- name: "intent_featurizer_spacy"
- name: "ner_crf"
- name: "ner_synonyms"
- name: "intent_classifier_sklearn"

Let's dissect each component of this pipeline:

`language: "en"`:
This specifies that the primary language for processing is English.

`nlp_spacy`:
This initializes the spaCy library in pipeline and loads the English language model from spaCy. It's the foundational component that other spaCy-dependent components rely upon.

`tokenizer_spacy`:
This component tokenizes the user's message using the spaCy tokenizer. Essentially, it breaks the text into individual words or tokens. For English, this usually means splitting words at spaces and punctuation.

`intent_entity_featurizer_regex`:
This component searches for user-defined patterns (regular expressions) in the training data. If a pattern is found, the message text will be enriched with a corresponding feature. It's a way to capture specific patterns that might be significant for intent classification or entity recognition.

`intent_featurizer_spacy`:
Post-tokenization, this component utilizes spaCy's pre-trained word vectors to convert each token into a vector representation. These vectors capture semantic meaning, and their collective representation in a sentence is used to determine the intent of the message.

`ner_crf`:
This component employs the Conditional Random Field (CRF) algorithm to recognize and categorize entities in the text. CRFs are particularly effective for tasks where context around a word is crucial for its proper categorization.

`ner_synonyms`:
Post entity recognition, if certain entities are found to be synonymous (as defined in the training data), this component will replace detected entities with the preferred synonym. For example, if "USA" is a synonym for "United States", all mentions of "USA" will be replaced with "United States" before further processing.

`intent_classifier_sklearn`:
The final component in the pipeline is responsible for intent classification. It uses the Scikit-learn library to train a model that categorizes user messages into corresponding intents. The features for this classifier come from the previous components in the pipeline, especially the vector representation from intent_featurizer_spacy.

This pipeline, in essence, crafts a pathway wherein user messages undergo a series of transformations — from tokenization to vectorization, followed by entity recognition and intent classification. Leveraging spaCy's capabilities ensures the model has a robust understanding of the underlying linguistic structures and semantics.

Job board dataset for training the model

Rasa NLU 0.15 (which is an older version) employs a specific structure for its training data in JSON format. The core components of this JSON structure are the common_examples, regex_features, and entity_synonyms.

Here’s a breakdown of the rasa-dataset.json structure for Rasa NLU version 0.15:

rasa_nlu_data:
The root key under which all the NLU training data is structured.

common_examples:
An array of training examples, with each entry having:

  • text: The user's message as raw text.
  • intent: The intent label corresponding to the message.
  • entities: An array detailing any entities present in the text. Each entity has:
  • start: The starting character position of the entity in the text.
  • end: The ending character position of the entity in the text.
  • value: The actual value of the entity.
  • entity: The category or type of the entity.

regex_features:
An array of regular expression patterns for extracting entities or aiding in intent classification.

  • name: Name of the regex pattern (typically indicative of its use).
  • pattern: The actual regex pattern.

entity_synonyms:
An array of synonyms for different entity values.

  • value: The canonical form of the entity.
  • synonyms: An array of alternative names or synonyms for the value.

Here’s a brief example to illustrate the structure:

{
"rasa_nlu_data": {
"regex_features": [
{
"name": "zipcode",
"pattern": "[0-9]{5}"
},
{
"name": "greet",
"pattern": "hey[^\\s]*"
},
{
"name": "job_id",
"pattern": "job_?[0-9]{4,6}"
},
{
"name": "email",
"pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"
}
],
"entity_synonyms": [
{
"value": "resume",
"synonyms": [
"CV",
"curriculum vitae",
"bio-data",
"resumé"
]
},
{
"value": "full-time",
"synonyms": [
"full time",
"permanent",
"fulltime"
]
},
{
"value": "part-time",
"synonyms": [
"part time",
"temporary",
"parttime"
]
}
],
"common_examples": [
{
"text": "hey",
"intent": "greet",
"entities": []
},
{
"text": "howdy",
"intent": "greet",
"entities": []
},
{
"text": "I'd like to register",
"intent": "register",
"entities": []
},
{
"text": "How can I sign up?",
"intent": "register",
"entities": []
},
{
"text": "I want to create an account",
"intent": "register",
"entities": []
},
{
"text": "Can you help me with registration?",
"intent": "register",
"entities": []
},
{
"text": "I'd like to create an account for the employment site.",
"intent": "register",
"entities": [
{
"start": 36,
"end": 51,
"value": "employment site",
"entity": "platform"
}
]
},
{
"text": "How do I register for the job site?",
"intent": "register",
"entities": [
{
"start": 23,
"end": 31,
"value": "job site",
"entity": "platform"
}
]
},
{
"text": "Sign me up for the career portal.",
"intent": "register",
"entities": [
{
"start": 16,
"end": 30,
"value": "career portal",
"entity": "platform"
}
]
},
{
"text": "I am looking for a software developer job.",
"intent": "job_search",
"entities": [
{
"start": 18,
"end": 35,
"value": "software developer",
"entity": "job_role"
}
]
},
{
"text": "Are there any jobs available near Chicago?",
"intent": "job_search",
"entities": [
{
"start": 34,
"end": 41,
"value": "Chicago",
"entity": "location"
}
]
},
{
"text": "Show me the latest openings for data scientists.",
"intent": "job_search",
"entities": [
{
"start": 33,
"end": 47,
"value": "data scientists",
"entity": "job_role"
}
]
},
{
"text": "I want to see marketing positions available.",
"intent": "job_search",
"entities": [
{
"start": 15,
"end": 24,
"value": "marketing",
"entity": "job_role"
}
]
},
{
"text": "Are there any jobs for accountants right now?",
"intent": "job_search",
"entities": [
{
"start": 18,
"end": 29,
"value": "accountants",
"entity": "job_role"
}
]
},
{
"text": "I need to find a position in HR.",
"intent": "job_search",
"entities": [
{
"start": 26,
"end": 28,
"value": "HR",
"entity": "job_role"
}
]
},
{
"text": "Can you list jobs in project management?",
"intent": "job_search",
"entities": [
{
"start": 23,
"end": 39,
"value": "project management",
"entity": "job_role"
}
]
},
{
"text": "I'd like to update my resume.",
"intent": "update_profile",
"entities": [
{
"start": 19,
"end": 25,
"value": "resume",
"entity": "profile_element"
}
]
},
{
"text": "Can I change my CV here?",
"intent": "update_profile",
"entities": [
{
"start": 14,
"end": 16,
"value": "CV",
"entity": "profile_element"
}
]
},
{
"text": "I want to modify my professional details.",
"intent": "update_profile",
"entities": []
},
{
"text": "How can I refresh my profile information?",
"intent": "update_profile",
"entities": []
},
{
"text": "Is it possible to upload a new version of my CV?",
"intent": "update_profile",
"entities": [
{
"start": 38,
"end": 40,
"value": "CV",
"entity": "profile_element"
}
]
},
{
"text": "I need to make changes to my resume on the platform.",
"intent": "update_profile",
"entities": [
{
"start": 26,
"end": 32,
"value": "resume",
"entity": "profile_element"
}
]
},
{
"text": "What job roles are suitable for my skills?",
"intent": "career_advice",
"entities": [
{
"start": 31,
"end": 37,
"value": "skills",
"entity": "career_aspect"
}
]
},
{
"text": "Can you suggest career paths based on my experience?",
"intent": "career_advice",
"entities": [
{
"start": 39,
"end": 49,
"value": "experience",
"entity": "career_aspect"
}
]
},
{
"text": "Given my qualification, which industry should I explore?",
"intent": "career_advice",
"entities": [
{
"start": 6,
"end": 19,
"value": "qualification",
"entity": "career_aspect"
}
]
},
{
"text": "How do my skills match up in the current job market?",
"intent": "career_advice",
"entities": [
{
"start": 9,
"end": 15,
"value": "skills",
"entity": "career_aspect"
}
]
},
{
"text": "Considering my years of experience, which positions should I target?",
"intent": "career_advice",
"entities": [
{
"start": 12,
"end": 29,
"value": "years of experience",
"entity": "career_aspect"
}
]
},
{
"text": "I'm a recent graduate. What career advice do you have for someone with my educational background?",
"intent": "career_advice",
"entities": [
{
"start": 69,
"end": 89,
"value": "educational background",
"entity": "career_aspect"
}
]
},
{
"text": "Are there any specific roles that align with my skillset?",
"intent": "career_advice",
"entities": [
{
"start": 48,
"end": 56,
"value": "skillset",
"entity": "career_aspect"
}
]
},
{
"text": "How can I improve my skills for a managerial position considering my MBA?",
"intent": "skills_development",
"entities": [
{
"start": 24,
"end": 30,
"value": "skills",
"entity": "development_aspect"
},
{
"start": 68,
"end": 71,
"value": "MBA",
"entity": "qualification"
}
]
},
{
"text": "What courses should I take to be a data scientist given my computer science degree?",
"intent": "skills_development",
"entities": [
{
"start": 56,
"end": 72,
"value": "computer science",
"entity": "qualification"
}
]
},
{
"text": "I have 5 years of experience in marketing. What skills do I need to hone to progress further?",
"intent": "skills_development",
"entities": [
{
"start": 9,
"end": 28,
"value": "5 years of experience",
"entity": "experience"
},
{
"start": 29,
"end": 39,
"value": "marketing",
"entity": "job_role"
}
]
},
{
"text": "After leaving college without graduating, which certifications can I pursue to get a stable job?",
"intent": "skills_development",
"entities": [
{
"start": 6,
"end": 38,
"value": "leaving college without graduating",
"entity": "education_status"
}
]
}
]
}
}

Training Classifier

The following code facilitates the training process for a Rasa NLU model. The training dataset is loaded from a file named ‘rasa-dataset.json’. Using a configuration sourced from ‘config_spacy.yaml’, the code initializes a training mechanism. This mechanism is then employed to train a model based on the previously loaded training data. Once training is complete, the model is saved to the ‘./projects/’ directory for future use.

# Importing the necessary modules from the Rasa NLU package
from rasa_nlu.training_data import load_data # For loading training data from a file
from rasa_nlu.model import Trainer # For training the NLU model
from rasa_nlu import config # For loading the configuration settings

# Loading the training data from the 'rasa-dataset.json' file
train_data = load_data('rasa-dataset.json')

# Initializing the Trainer with configuration settings from 'config_spacy.yaml'
trainer = Trainer(config.load("./config_spacy.yaml"))

# Training the model using the loaded training data
trainer.train(train_data)

# Saving the trained model to the './projects/' directory and storing the path in 'model_directory'
model_directory = trainer.persist('./projects/')

intent_classifier_sklearn

The intent_classifier_sklearn is an intent classification component used within older versions of Rasa NLU, and as the name suggests, it leverages the Scikit-learn library for the classification task.

Let’s delve into its implementation:

  1. Feature Extraction: Before any machine learning model can be trained, the text data needs to be converted into numerical format. This is done through feature extraction. In Rasa NLU’s pipeline, there might be prior components like intent_featurizer_spacy or others that generate these features. The features could be based on word embeddings, TF-IDF scores, or other numerical representations.
  2. Classifier: intent_classifier_sklearn primarily uses the RandomForestClassifier from the Scikit-learn library, though it can be configured to use other algorithms like gradient boosting or linear SVM. RandomForest is an ensemble method that fits multiple decision tree classifiers on various sub-samples of the dataset and uses averaging to improve the predictive accuracy and control over-fitting.
  3. Training: Once the training data is featurized, the RandomForest classifier (or whichever algorithm is configured) is trained using the features as inputs and intents as labels. This results in a model that can predict intents based on the features of any given input text.
  4. Prediction: During prediction, an incoming message is similarly featurized. The trained classifier then predicts the intent of the message based on its features.
  5. Model Storage: After training, the classifier, along with its associated configuration and feature processors, are stored as part of the Rasa model. This allows the model to be loaded later for predictions without needing to be retrained.
  6. Hyperparameter Tuning: The component provides options for hyperparameter tuning. You can specify parameters like the number of trees in the forest, the function to measure the quality of a split, and others to optimize the performance of the classifier.
  7. Dependencies: The intent_classifier_sklearn relies on Scikit-learn and other dependencies like numpy and scipy for its operations.

Testing the model

# Importing the Interpreter class from the Rasa NLU package, which allows for loading trained models and interpreting textual inputs
from rasa_nlu.model import Interpreter

# Defining a sample user message that we want to interpret
message = "I am searching for jobs in Germany."

# Loading a pre-trained Rasa NLU model from a specified directory path
interpreter = Interpreter.load('./projects/default/model_20230923-192843')

# Using the loaded interpreter to process (or parse) the message, extracting intent, entities, and other relevant information
output = interpreter.parse(message)

# Printing the resulting output, which will include identified intent, entities, confidence scores, and potentially other details
print(output)

Model Performance

While testing the model with different messages the results were not very encouraging.

(ali) ali@M ~/g/intent-classifier (rasa-nlu)> python test.py
{'intent': {'name': 'update_profile', 'confidence': 0.3023838000208362}, 'entities': [], 'intent_ranking': [{'name': 'update_profile', 'confidence': 0.3023838000208362}, {'name': 'career_advice', 'confidence': 0.22744898460585175}, {'name': 'skills_development', 'confidence': 0.22246987960748008}, {'name': 'job_search', 'confidence': 0.08947641236395079}, {'name': 'register', 'confidence': 0.08584189840473723}, {'name': 'affirm', 'confidence': 0.05549376518790116}, {'name': 'greet', 'confidence': 0.016885259809243134}], 'text': 'I am looking for job, can you help me?'}
(ali) ali@M ~/g/intent-classifier (rasa-nlu)> python test.py
{'intent': {'name': 'update_profile', 'confidence': 0.328414129050524}, 'entities': [], 'intent_ranking': [{'name': 'update_profile', 'confidence': 0.328414129050524}, {'name': 'skills_development', 'confidence': 0.23069194094701223}, {'name': 'career_advice', 'confidence': 0.20469660952554386}, {'name': 'job_search', 'confidence': 0.10286700573474712}, {'name': 'register', 'confidence': 0.06880687215812596}, {'name': 'affirm', 'confidence': 0.04927197712771269}, {'name': 'greet', 'confidence': 0.015251465456333938}], 'text': 'I am looking for a job in marketing, can you help me?'}
(ali) ali@M ~/g/intent-classifier (rasa-nlu)> python test.py
{'intent': {'name': 'career_advice', 'confidence': 0.38346800557019695}, 'entities': [], 'intent_ranking': [{'name': 'career_advice', 'confidence': 0.38346800557019695}, {'name': 'skills_development', 'confidence': 0.2422831903644018}, {'name': 'update_profile', 'confidence': 0.18069351083971125}, {'name': 'job_search', 'confidence': 0.10412826888014762}, {'name': 'affirm', 'confidence': 0.04187077116284822}, {'name': 'register', 'confidence': 0.03252457838504852}, {'name': 'greet', 'confidence': 0.015031674797645375}], 'text': 'Show me the latest openings for data scientists.'}
(ali) ali@M ~/g/intent-classifier (rasa-nlu)> python test.py
{'intent': {'name': 'skills_development', 'confidence': 0.30513553355390893}, 'entities': [], 'intent_ranking': [{'name': 'skills_development', 'confidence': 0.30513553355390893}, {'name': 'career_advice', 'confidence': 0.2814913430449979}, {'name': 'update_profile', 'confidence': 0.18325350925586498}, {'name': 'job_search', 'confidence': 0.0941391408868582}, {'name': 'affirm', 'confidence': 0.059104538047146736}, {'name': 'register', 'confidence': 0.05158605699688622}, {'name': 'greet', 'confidence': 0.025289878214337227}], 'text': 'I would like to register.'}

In the next article, I will use the latest version of RASA open-source platform that uses the DIET intent classifier and gives much better results. We shall discuss the out-of-domain problem related to intent classification.

--

--

Ali Khan
𝐀𝐈 𝐦𝐨𝐧𝐤𝐬.𝐢𝐨

Experienced DevOps advocate & AWS-certified Technical Architect. Innovator in cloud solutions, microservices, and ML applications.