SlideShare a Scribd company logo
Machine Learning Applied -
Contextual Chatbots Coding,
Oracle JET andTensorFlow
Andrejus Baranovskis, CEO andTechnical Expert, Red Samurai Consulting
Oracle ACE Director and Oracle Groundbreaker Ambassador
Oracle ExpertsTeam
ADF, JET, ORACLE FUSION, ORACLE CLOUD, MACHINE LEARNING
Oracle PaaS Partner Community Award for Outstanding Java Cloud
Service Contribution 2017
Session Goal
HowTo BuildYour Own Machine Learning Chatbot
AGENDA
• Technical Architecture
• Solution WalkThrough
• Machine Learning Introduction
• Implementation Points
TECHNICAL ARCHITECTURE
Machine Learning Chatbot Context Communication Chatbot UI
Classification Chatbot messaging
Oracle JET
Chatbot Custom application logic
Generic listener
Oracle JET
CHATBOT CONTEXT
• Chatbot framework needs a structure in which conversational intents are
defined (this can be JSON file)
• Conversational intent contains:
• tag (unique name)
• patterns (sentence patterns for neural network text classifier)
• responses (one will be used as a response)
SOLUTION WALKTHROUGH
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
GENTLE INTRODUCTIONTO MACHINE
LEARNING
LEARNING AND INFERENCE
Training data Feature vector Learning algorithm Model
Test data Feature vector Model Prediction
KEY PARAMETERS
• Cost Function - score for each candidate parameter, shows sum of
errors in predicting.The higher the cost, the worse the model
parameters will be
• Epoch - each step of looping through all data to update the model
parameters
• Learning rate - the size of the learning step
REGRESSION
Regression
algorithm
Input Output
Continuous
Continuous
Discrete
REGRESSION EXAMPLE
w - parameter to be found usingTensorFlow
CLASSIFICATION
f{x}
Input Output
DiscreteContinuous
Discrete
Classifier
CLASSIFICATION EXAMPLE
Linear boundary line learned from the training data - equal probability for both groups
WHYTENSORFLOW?
• TensorFlow has become the tool of choice to implement machine
learning solutions
• Developed by Google and supported by its flourishing community
• Gives a way to easily implement industry-standard code
CLASSIFICATION IMPLEMENTATION
STEP 1: PREPARING DATA
• Tokenise patterns into array of words
• Lower case and stem all words. Example: Pharmacy => pharm.
Attempt to represent related words
• Create list of classes - intents
• Create list of documents - combination between list of patterns and
list of intents
STEP 1: PREPARING DATA
STEP 2: PREPARINGTENSORFLOW INPUT
• [X: [0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, ...N],Y: [0, 0, 1, 0, 0, 0, ...M]]
• [X: [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, ...N],Y: [0, 0, 0, 1, 0, 0, ...M]]
• Array representing pattern with 0/1. N = vocabulary size. 1 when
word position in vocabulary is matching word from pattern
• Array representing intent with 0/1. M = number of intents. 1 when
intent position in list of intents/classes is matching current intent
STEP 2: PREPARINGTENSORFLOW INPUT
STEP 3:TRAINING NEURAL NETWORK
• Use tflearn - deep learning library featuring a higher-level API forTensorFlow
• Define X input shape - equal to word vocabulary size
• Define two layers with 8 hidden neurones - optimal for text classification task
(based on experiments)
• DefineY input shape - equal to number of intents
• Apply regression to find the best equation parameters
STEP 3:TRAINING NEURAL NETWORK
• Define Deep Neural Network model (DNN)
• Run model.fit to construct classification model. Provide X/Y inputs,
number of epochs and batch size
• Per each epoch, multiple operations are executed to find optimal
model parameters to classify future input converted to array of 0/1
STEP 3:TRAINING NEURAL NETWORK
• Batch size:
• Smaller batch size requires less memory. Especially important for datasets
with large vocabulary
• Typically networks train faster with smaller batches.Weights and network
parameters are updated after each propagation
• The smaller the batch the less accurate estimate of the gradient (function
which describes the data) could be
STEP 3:TRAINING NEURAL NETWORK
STEP 4: INITIAL MODELTESTING
• Tokenise input sentence - split it into array of words
• Create bag of words (array with 0/1) for the input sentence - array
equal to the size of vocabulary, with 1 for each word found in input
sentence
• Run model.predict with given bag of words array, this will return
probability for each intent
STEP 4: INITIAL MODELTESTING
STEP 5: REUSETRAINED MODEL
• For better reusability, it is recommended to create separate
TensorFlow notebook, to handle classification requests
• We can reuse previously created DNN model, by loading it with
TensorFlow pickle
STEP 5: REUSETRAINED MODEL
STEP 6:TEXT CLASSIFICATION
• Define REST interface, so that function will be accessible outside
TensorFlow
• Convert incoming sentence into bag of words array and run
model.predict
• Consider results with probability higher than 0.25 to filter noise
• Return multiple identified intents (if any), together with assigned probability
STEP 6:TEXT CLASSIFICATION
IMPLEMENTATION POINTS
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
 Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
QUESTIONS
CONTACTS
• Andrejus Baranovskis (https://andrejusb.blogspot.com)
• Email: abaranovskis@redsamuraiconsulting.com
• Twitter: @andrejusb
• LinkedIn: https://www.linkedin.com/in/andrejus-baranovskis-251b392
• Web: http://redsamuraiconsulting.com
REFERENCES
• Source Code - https://github.com/abaranovskis-redsamurai/shenzhen
• Contextual Chatbot inTensorFlow - https://bit.ly/2pFbTw4
• TensorFlow Book - http://tensorflowbook.com/

More Related Content

PPTX
Text Classification
PPTX
Presentation on Text Classification
PPTX
Word vectorization(embedding) with nnlm
PPTX
Text categorization
PDF
Topic Modeling for Information Retrieval and Word Sense Disambiguation tasks
PDF
NLP - Sentiment Analysis
PPTX
Tdm probabilistic models (part 2)
PPTX
Text categorization
Text Classification
Presentation on Text Classification
Word vectorization(embedding) with nnlm
Text categorization
Topic Modeling for Information Retrieval and Word Sense Disambiguation tasks
NLP - Sentiment Analysis
Tdm probabilistic models (part 2)
Text categorization

What's hot (20)

PPTX
The vector space model
PPTX
Text classification with Weka
PDF
On Semi-Supervised Learning and Beyond
PPTX
Term weighting
PPTX
2015 07-tuto1-phrase mining
PDF
Text classification-php-v4
PPTX
ClassifyingIssuesFromSRTextAzureML
PDF
MaxEnt (Loglinear) Models - Overview
PDF
Ai group-seminar-2013 nbc
PPT
Text classification using Text kernels
PDF
Understanding the Machine Learning Algorithms
PPT
slides
PPT
[ppt]
PPTX
Boolean,vector space retrieval Models
PDF
Java -lec-6
PPTX
PPTX
Topic Pages. From articles to answers.
PDF
An Overview of Naïve Bayes Classifier
PPT
Ir models
PDF
Machine Learning Comparative Analysis - Part 1
The vector space model
Text classification with Weka
On Semi-Supervised Learning and Beyond
Term weighting
2015 07-tuto1-phrase mining
Text classification-php-v4
ClassifyingIssuesFromSRTextAzureML
MaxEnt (Loglinear) Models - Overview
Ai group-seminar-2013 nbc
Text classification using Text kernels
Understanding the Machine Learning Algorithms
slides
[ppt]
Boolean,vector space retrieval Models
Java -lec-6
Topic Pages. From articles to answers.
An Overview of Naïve Bayes Classifier
Ir models
Machine Learning Comparative Analysis - Part 1
Ad

Similar to Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow (20)

PDF
Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
PPTX
Smart Health Chatbot health care for patients.pptx
PDF
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
PDF
Оформление пайплайна в NLP проекте​, Виталий Радченко. 22 июня, 2019
PPT
presentation.ppt
PPTX
NLP Introduction and basics of natural language processing
PDF
NLP and Deep Learning for non_experts
PDF
Rasa NLU and ML Interpretability
PPTX
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
PPTX
Deep Learning for Machine Translation
DOCX
DLT UNIT-3.docx
PDF
Machine Learning for Software Maintainability
PDF
LLMs in Production: Tooling, Process, and Team Structure
PDF
Engineering Intelligent NLP Applications Using Deep Learning – Part 2
PDF
MongoDB .local London 2019: Fast Machine Learning Development with MongoDB
PDF
MongoDB .local London 2019: Fast Machine Learning Development with MongoDB
PPTX
Neural Models for Information Retrieval
PDF
Implementing Conceptual Search in Solr using LSA and Word2Vec: Presented by S...
PPTX
Introduction to tensorflow
PDF
MongoDB World 2019: Fast Machine Learning Development with MongoDB
Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow
Smart Health Chatbot health care for patients.pptx
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
Оформление пайплайна в NLP проекте​, Виталий Радченко. 22 июня, 2019
presentation.ppt
NLP Introduction and basics of natural language processing
NLP and Deep Learning for non_experts
Rasa NLU and ML Interpretability
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Deep Learning for Machine Translation
DLT UNIT-3.docx
Machine Learning for Software Maintainability
LLMs in Production: Tooling, Process, and Team Structure
Engineering Intelligent NLP Applications Using Deep Learning – Part 2
MongoDB .local London 2019: Fast Machine Learning Development with MongoDB
MongoDB .local London 2019: Fast Machine Learning Development with MongoDB
Neural Models for Information Retrieval
Implementing Conceptual Search in Solr using LSA and Word2Vec: Presented by S...
Introduction to tensorflow
MongoDB World 2019: Fast Machine Learning Development with MongoDB
Ad

More from andrejusb (19)

PDF
Machine Learning Applied - Tabular Dataset Models and Sentiment Analysis
PDF
JavaScript Development on Steroids with Oracle Visual Builder
PDF
Reliable, Fast, Engaging Offline-First Architecture for JavaScript Applications
PDF
Microservice Approach for Web Development with Micro Frontends
PDF
Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and Tensorflow
PDF
Oracle Development Cloud Service
PPTX
Oracle Java Cloud Service: How to Estimate Production System Performance
PPTX
Essential Kit for Oracle JET Programming
PDF
Oracle JET and ADF BC REST Production Experience with Oracle Java Cloud
PDF
Offline Web with Oracle JET
PPTX
End-to-End Cloud: Oracle Java Cloud, Oracle Mobile Cloud Service, Oracle MAF,...
PDF
Forms, ADF and JET a Non-Aggression Pact
PPTX
Oracle JET CRUD and ADF BC REST
PPTX
Oracle JET and WebSocket
PPTX
Oracle Alta UI Patterns for Enterprise Applications and Responsive UI Support
PPTX
ADF Mythbusters UKOUG'14
PPTX
Data Caching Strategies for Oracle Mobile Application Framework
PPTX
ADF Development Survival Kit
PPTX
ADF Anti-Patterns: Dangerous Tutorials
Machine Learning Applied - Tabular Dataset Models and Sentiment Analysis
JavaScript Development on Steroids with Oracle Visual Builder
Reliable, Fast, Engaging Offline-First Architecture for JavaScript Applications
Microservice Approach for Web Development with Micro Frontends
Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and Tensorflow
Oracle Development Cloud Service
Oracle Java Cloud Service: How to Estimate Production System Performance
Essential Kit for Oracle JET Programming
Oracle JET and ADF BC REST Production Experience with Oracle Java Cloud
Offline Web with Oracle JET
End-to-End Cloud: Oracle Java Cloud, Oracle Mobile Cloud Service, Oracle MAF,...
Forms, ADF and JET a Non-Aggression Pact
Oracle JET CRUD and ADF BC REST
Oracle JET and WebSocket
Oracle Alta UI Patterns for Enterprise Applications and Responsive UI Support
ADF Mythbusters UKOUG'14
Data Caching Strategies for Oracle Mobile Application Framework
ADF Development Survival Kit
ADF Anti-Patterns: Dangerous Tutorials

Recently uploaded (20)

PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
Introduction to Information and Communication Technology
PDF
Testing WebRTC applications at scale.pdf
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Internet___Basics___Styled_ presentation
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Digital Literacy And Online Safety on internet
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
international classification of diseases ICD-10 review PPT.pptx
Decoding a Decade: 10 Years of Applied CTI Discipline
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
522797556-Unit-2-Temperature-measurement-1-1.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Job_Card_System_Styled_lorem_ipsum_.pptx
WebRTC in SignalWire - troubleshooting media negotiation
Introduction to Information and Communication Technology
Testing WebRTC applications at scale.pdf
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Internet___Basics___Styled_ presentation
Module 1 - Cyber Law and Ethics 101.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
An introduction to the IFRS (ISSB) Stndards.pdf
Sims 4 Historia para lo sims 4 para jugar
PptxGenJS_Demo_Chart_20250317130215833.pptx
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Digital Literacy And Online Safety on internet
introduction about ICD -10 & ICD-11 ppt.pptx

Machine Learning Applied - Contextual Chatbots Coding, Oracle JET and TensorFlow

  • 1. Machine Learning Applied - Contextual Chatbots Coding, Oracle JET andTensorFlow Andrejus Baranovskis, CEO andTechnical Expert, Red Samurai Consulting Oracle ACE Director and Oracle Groundbreaker Ambassador
  • 2. Oracle ExpertsTeam ADF, JET, ORACLE FUSION, ORACLE CLOUD, MACHINE LEARNING Oracle PaaS Partner Community Award for Outstanding Java Cloud Service Contribution 2017
  • 3. Session Goal HowTo BuildYour Own Machine Learning Chatbot
  • 4. AGENDA • Technical Architecture • Solution WalkThrough • Machine Learning Introduction • Implementation Points
  • 6. Machine Learning Chatbot Context Communication Chatbot UI Classification Chatbot messaging Oracle JET
  • 7. Chatbot Custom application logic Generic listener Oracle JET
  • 8. CHATBOT CONTEXT • Chatbot framework needs a structure in which conversational intents are defined (this can be JSON file) • Conversational intent contains: • tag (unique name) • patterns (sentence patterns for neural network text classifier) • responses (one will be used as a response)
  • 12. LEARNING AND INFERENCE Training data Feature vector Learning algorithm Model Test data Feature vector Model Prediction
  • 13. KEY PARAMETERS • Cost Function - score for each candidate parameter, shows sum of errors in predicting.The higher the cost, the worse the model parameters will be • Epoch - each step of looping through all data to update the model parameters • Learning rate - the size of the learning step
  • 15. REGRESSION EXAMPLE w - parameter to be found usingTensorFlow
  • 17. CLASSIFICATION EXAMPLE Linear boundary line learned from the training data - equal probability for both groups
  • 18. WHYTENSORFLOW? • TensorFlow has become the tool of choice to implement machine learning solutions • Developed by Google and supported by its flourishing community • Gives a way to easily implement industry-standard code
  • 20. STEP 1: PREPARING DATA • Tokenise patterns into array of words • Lower case and stem all words. Example: Pharmacy => pharm. Attempt to represent related words • Create list of classes - intents • Create list of documents - combination between list of patterns and list of intents
  • 22. STEP 2: PREPARINGTENSORFLOW INPUT • [X: [0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, ...N],Y: [0, 0, 1, 0, 0, 0, ...M]] • [X: [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, ...N],Y: [0, 0, 0, 1, 0, 0, ...M]] • Array representing pattern with 0/1. N = vocabulary size. 1 when word position in vocabulary is matching word from pattern • Array representing intent with 0/1. M = number of intents. 1 when intent position in list of intents/classes is matching current intent
  • 24. STEP 3:TRAINING NEURAL NETWORK • Use tflearn - deep learning library featuring a higher-level API forTensorFlow • Define X input shape - equal to word vocabulary size • Define two layers with 8 hidden neurones - optimal for text classification task (based on experiments) • DefineY input shape - equal to number of intents • Apply regression to find the best equation parameters
  • 25. STEP 3:TRAINING NEURAL NETWORK • Define Deep Neural Network model (DNN) • Run model.fit to construct classification model. Provide X/Y inputs, number of epochs and batch size • Per each epoch, multiple operations are executed to find optimal model parameters to classify future input converted to array of 0/1
  • 26. STEP 3:TRAINING NEURAL NETWORK • Batch size: • Smaller batch size requires less memory. Especially important for datasets with large vocabulary • Typically networks train faster with smaller batches.Weights and network parameters are updated after each propagation • The smaller the batch the less accurate estimate of the gradient (function which describes the data) could be
  • 28. STEP 4: INITIAL MODELTESTING • Tokenise input sentence - split it into array of words • Create bag of words (array with 0/1) for the input sentence - array equal to the size of vocabulary, with 1 for each word found in input sentence • Run model.predict with given bag of words array, this will return probability for each intent
  • 29. STEP 4: INITIAL MODELTESTING
  • 30. STEP 5: REUSETRAINED MODEL • For better reusability, it is recommended to create separate TensorFlow notebook, to handle classification requests • We can reuse previously created DNN model, by loading it with TensorFlow pickle
  • 32. STEP 6:TEXT CLASSIFICATION • Define REST interface, so that function will be accessible outside TensorFlow • Convert incoming sentence into bag of words array and run model.predict • Consider results with probability higher than 0.25 to filter noise • Return multiple identified intents (if any), together with assigned probability
  • 45. CONTACTS • Andrejus Baranovskis (https://andrejusb.blogspot.com) • Email: [email protected] • Twitter: @andrejusb • LinkedIn: https://www.linkedin.com/in/andrejus-baranovskis-251b392 • Web: http://redsamuraiconsulting.com
  • 46. REFERENCES • Source Code - https://github.com/abaranovskis-redsamurai/shenzhen • Contextual Chatbot inTensorFlow - https://bit.ly/2pFbTw4 • TensorFlow Book - http://tensorflowbook.com/