SlideShare a Scribd company logo
Synthetic Dialogue
Generation with Deep
Learning
Using TensorFlow
Nasar, Syed | August 2017
About me
Machine Learning and Big Data Architect
MS Computer Science, Machine Learning, Georgia Tech
Deep Learning Nanodegree, Udacity
Artificial Intelligence Nanodegree, Udacity
Connect
 Twitter : @techmazed
 LinkedIn : https://www.linkedin.com/in/knownasar
 Founder: Nashville Artificial Intelligence Society (twitter @AINashville)
What we’ll cover
The synthetic data generation challenge
Introducing Deep Learning
Introducing RNN & Sequence to Sequence model
Introducing NLP concepts
Brief introduction to TensorFlow & FloydHub
The solution approach
Code walkthrough
What next!
Question time
TheSyntheticDataGeneration Challenge
The problem
The challenge is to generate our own TV dialogue scripts by training a Neural Network with an existing
corpus of dialogues.
Dialogues from Simpson TV show:
The sentences 0 to 10:
[YEAR DATE 1989] © Twentieth Century Fox Film Corporation. All rights reserved.
Moe_Szyslak: (INTO PHONE) Moe's Tavern. Where the elite meet to drink.
Bart_Simpson: Eh, yeah, hello, is Mike there? Last name, Rotch.
Moe_Szyslak: (INTO PHONE) Hold on, I'll check. (TO BARFLIES) Mike Rotch. Mike Rotch. Hey, has anybody
seen Mike Rotch, lately?
Moe_Szyslak: (INTO PHONE) Listen you little puke. One of these days I'm gonna catch you, and I'm gonna
carve my name on your back with an ice pick.
Moe_Szyslak: What's the matter Homer? You're not your normal effervescent self.
Homer_Simpson: I got my problems, Moe. Give me another one.
Moe_Szyslak: Homer, hey, you should not drink to forget your problems.
Barney_Gumble: Yeah, you should only drink to enhance your social skills.
Introduction to
the important
concepts
Concepts
A brief discussion on the various
technologies, techniques and
concepts that we apply towards
the solution.
Deep
Learning
Recurrent
Neural
Network
(RNN)
Natural
Language
Processing
(NLP)
Technologies
What is Deep
Learning?
Neural networks with large number of
parameters and layers.
The layers belong to one of four
fundamental network architectures:
 Unsupervised Pre-Trained Networks
 Convolutional Neural Networks
 Recurrent Neural Networks
 Recursive Neural Networks
 Also Generative Adversarial
Networks
Introducing Deep Learning
The behavior of neural networks is shaped by its network architecture.
A network’s architecture can be defined, in part, by:
• number of neurons
• number of layers
• types of connections between layers
A Neural Network is an algorithm
that learns to identify patterns in
data.
Backpropagation is a technique to
train a Neural Net by updating
weights via gradient descent.
Deep Learning:
many layer neural net + massive
data (big data) + massive compute
(GPU)
Multi-Layer Neural Network topology
Backpropagation
Learning
Backpropagation is an important part of
reducing error in a neural network
model.
General Neural Network Training
Pseudocode
function neural-network-learning( training-records ) returns network
network <- initialize weights (randomly)
start loop
for each example in training-records do
network-output = neural-network-output( network, example )
actual-output = observed outcome associated with example
update weights in network based on { example, network-output, actual-output }
end for
end loop when all examples correctly predicted or hit stopping conditions
return network
IntroducingRecurrentNeural Network
What is RNN?
Recurrent Neural Networks have
loops.
In the diagram (right), a chunk of neural
network, A, looks at some input xt and
outputs a value ht.
A loop allows information to be passed
from one step of the network to the next.
Consider what happens if we unroll the
loop:
The flow
Recurrent Neural Network
IntroducingNatural LanguageProcessing(NLP) concepts
Tokenize
Given a character sequence and a defined document unit, tokenization is the task of
chopping it up into pieces, called tokens, also sometimes throwing away certain
characters, such as punctuation.
Here is an example:
Input: Friends, Romans, Countrymen, lend me your ears;
Output: Friends || Comma || Romans || Comma || Countrymen || Comma || lend || me || your || ears || semicolon ||
bye bye!
One-Hot Encoding
One hot encoding technique is used to encode categorical integer features using a one-
hot scheme.
NeuralNetworktips& tricks
LSTMs
This basically handles the problem of vanishing and exploding gradients. LSTMs help
preserve the error that can be backpropagated through time and layers.
Image courtesy - http://deeplearning.net/tutorial/lstm.html
Logits
Logistic Function:
The logit function is the inverse of the
logistic function.
SoftMax
MulticlassClassificationModelOutputLayer
Cross Entropy & Embeddings
Brief introductionto technologies used
TensorFlow
TensorFlow is an open source software library by Google
To design, build, and train deep learning models
Why use:
Thoughtful design & Ease of use
Deploy computation to one or more CPUs or GPUs
TensorFlow alternatives: Theano, Torch, Caffe, Neon, and Keras
FloydHub
“Floydhub is Heroku for Deep Learning. A Platform-as-a-Service for training
and deploying your models in the cloud with a few simple commands.”
# Install locally and login
$pip install -U floyd-cli
$floyd login
# Run a Jupyter notebook on FloydHub
$ floyd run --mode jupyter --gpu
#Run a python code on GPU
$ floyd run --gpu "python mnist_cnn.py"
Demo Time
Let us look at the code
Get the helper function.
Load the data
Summary of the data
Sample Data
Create a word embedding
Transform the words to ids.
Two dictionaries:
• Dictionary to go from the words to
an id, we'll call vocab_to_int
• Dictionary to go from the id to
word, we'll call int_to_vocab
Look at vocab-to-int
Tokenize Punctuation
This dictionary will be used to token
the symbols and add the delimiter (||)
around it.
This separates the symbols as it's own
word, making it easier for the neural
network to predict on the next word.
Look at token dictionary
Let’s preprocess the data
Look at the pre-processed data
Build the Neural Network
We'll build the components
necessary to build a RNN by
implementing these functions
• get_inputs
• get_init_cell
• get_embed
• build_rnn
• build_nn
• get_batches Placeholders for Inputs
Build the Neural Network
• get_inputs
• get_init_cell
• get_embed
• build_rnn
• build_nn
• get_batches
Build RNN Cell and Initialize
Build the Neural Network
• get_inputs
• get_init_cell
• get_embed
• build_rnn
• build_nn
• get_batches
Word Embedding
Build the Neural Network
• get_inputs
• get_init_cell
• get_embed
• build_rnn
• build_nn
• get_batches
Build RNN
Name for the
operation
A tensor
Apply embedding Build RNN
Apply a fully
connected layer
Return the logits and
final state
Build the Neural Network
• get_inputs
• get_init_cell
• get_embed
• build_rnn
• build_nn
• get_batches
Build the Neural Network
Build the Neural Network
• get_inputs
• get_init_cell
• get_embed
• build_rnn
• build_nn
• get_batches
Create Batches
•The first element is a single batch of input with the shape [batch size, sequence length]
•The second element is a single batch of targets with the shape [batch size, sequence length]
Neural Network Training
Number of epochs = 50
Batch size = 256
Size of the RNNs = 256
Length of sequence = 10
Learning rate = 0.01
Tuning Hyperparameters
Get Inputs
Initialize cells
Build NN => logits
Apply Softmax
Calculate Loss
Compute Gradients
Apply Optimizer
Build the Graph
Neural Network Training
Loss function
Optimizer
Get batches
Initialize
variables
Initialize state
Enumerate
batches
Get inputs and
hyperparameters
Compute loss
Show batch
results every 100
Save trained
model
Train the neural network
Neural Network Training
Training output
Neural Network Training
Get Tensors
Script Generation
Choose Word
Generate TV Script
Script Generation
Load Model
Get Tensors
Setup Sentence
generation
Generate sentences
Dynamic input
Get prediction
Generated Script
Neural Network Training
Larger Dataset: https://www.kaggle.com/wcukierski/the-simpsons-by-the-data
Resources
The code associated with this presentation is available
here:
https://github.com/syednasar/talks/tree/master/synthetic-dialog
In case of any questions on the code or the
implementation, reach out at:
Email: techtalk@nasars.com or
Twitter: @techmazed
Whatcanyoudo from here?
References
&
Recommendations
•Visualizing and Understanding Recurrent Networks
(paper): https://arxiv.org/abs/1506.02078
•Blog by Andrej Karpathy:
http://karpathy.github.io/2015/05/21/rnn-
effectiveness/
Keep(deep)learning!
@techmazed

More Related Content

What's hot

Deep learning - Conceptual understanding and applications
Deep learning - Conceptual understanding and applicationsDeep learning - Conceptual understanding and applications
Deep learning - Conceptual understanding and applications
Buhwan Jeong
 
Tutorial on Deep Learning
Tutorial on Deep LearningTutorial on Deep Learning
Tutorial on Deep Learning
inside-BigData.com
 
An introduction to Machine Learning (and a little bit of Deep Learning)
An introduction to Machine Learning (and a little bit of Deep Learning)An introduction to Machine Learning (and a little bit of Deep Learning)
An introduction to Machine Learning (and a little bit of Deep Learning)
Thomas da Silva Paula
 
Geek Night 17.0 - Artificial Intelligence and Machine Learning
Geek Night 17.0 - Artificial Intelligence and Machine LearningGeek Night 17.0 - Artificial Intelligence and Machine Learning
Geek Night 17.0 - Artificial Intelligence and Machine Learning
GeekNightHyderabad
 
Neural Networks and Deep Learning
Neural Networks and Deep LearningNeural Networks and Deep Learning
Neural Networks and Deep Learning
Asim Jalis
 
Deep learning
Deep learningDeep learning
Deep learning
Pratap Dangeti
 
An introduction to Deep Learning
An introduction to Deep LearningAn introduction to Deep Learning
An introduction to Deep Learning
David Rostcheck
 
Deep learning - A Visual Introduction
Deep learning - A Visual IntroductionDeep learning - A Visual Introduction
Deep learning - A Visual Introduction
Lukas Masuch
 
Deep Learning for Recommender Systems RecSys2017 Tutorial
Deep Learning for Recommender Systems RecSys2017 Tutorial Deep Learning for Recommender Systems RecSys2017 Tutorial
Deep Learning for Recommender Systems RecSys2017 Tutorial
Alexandros Karatzoglou
 
Introduction to Deep learning
Introduction to Deep learningIntroduction to Deep learning
Introduction to Deep learning
Massimiliano Ruocco
 
Modeling Electronic Health Records with Recurrent Neural Networks
Modeling Electronic Health Records with Recurrent Neural NetworksModeling Electronic Health Records with Recurrent Neural Networks
Modeling Electronic Health Records with Recurrent Neural Networks
Josh Patterson
 
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Oswald Campesato
 
Deep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorDeep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog Detector
Roelof Pieters
 
Python for Image Understanding: Deep Learning with Convolutional Neural Nets
Python for Image Understanding: Deep Learning with Convolutional Neural NetsPython for Image Understanding: Deep Learning with Convolutional Neural Nets
Python for Image Understanding: Deep Learning with Convolutional Neural Nets
Roelof Pieters
 
Deep learning intro
Deep learning introDeep learning intro
Deep learning intro
beamandrew
 
MDEC Data Matters Series: machine learning and Deep Learning, A Primer
MDEC Data Matters Series: machine learning and Deep Learning, A PrimerMDEC Data Matters Series: machine learning and Deep Learning, A Primer
MDEC Data Matters Series: machine learning and Deep Learning, A Primer
Poo Kuan Hoong
 
Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015
Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015
Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015
Turi, Inc.
 
Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중
Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중
Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중
datasciencekorea
 
Deep learning: the future of recommendations
Deep learning: the future of recommendationsDeep learning: the future of recommendations
Deep learning: the future of recommendations
Balázs Hidasi
 
Deep Learning And Business Models (VNITC 2015-09-13)
Deep Learning And Business Models (VNITC 2015-09-13)Deep Learning And Business Models (VNITC 2015-09-13)
Deep Learning And Business Models (VNITC 2015-09-13)
Ha Phuong
 

What's hot (20)

Deep learning - Conceptual understanding and applications
Deep learning - Conceptual understanding and applicationsDeep learning - Conceptual understanding and applications
Deep learning - Conceptual understanding and applications
 
Tutorial on Deep Learning
Tutorial on Deep LearningTutorial on Deep Learning
Tutorial on Deep Learning
 
An introduction to Machine Learning (and a little bit of Deep Learning)
An introduction to Machine Learning (and a little bit of Deep Learning)An introduction to Machine Learning (and a little bit of Deep Learning)
An introduction to Machine Learning (and a little bit of Deep Learning)
 
Geek Night 17.0 - Artificial Intelligence and Machine Learning
Geek Night 17.0 - Artificial Intelligence and Machine LearningGeek Night 17.0 - Artificial Intelligence and Machine Learning
Geek Night 17.0 - Artificial Intelligence and Machine Learning
 
Neural Networks and Deep Learning
Neural Networks and Deep LearningNeural Networks and Deep Learning
Neural Networks and Deep Learning
 
Deep learning
Deep learningDeep learning
Deep learning
 
An introduction to Deep Learning
An introduction to Deep LearningAn introduction to Deep Learning
An introduction to Deep Learning
 
Deep learning - A Visual Introduction
Deep learning - A Visual IntroductionDeep learning - A Visual Introduction
Deep learning - A Visual Introduction
 
Deep Learning for Recommender Systems RecSys2017 Tutorial
Deep Learning for Recommender Systems RecSys2017 Tutorial Deep Learning for Recommender Systems RecSys2017 Tutorial
Deep Learning for Recommender Systems RecSys2017 Tutorial
 
Introduction to Deep learning
Introduction to Deep learningIntroduction to Deep learning
Introduction to Deep learning
 
Modeling Electronic Health Records with Recurrent Neural Networks
Modeling Electronic Health Records with Recurrent Neural NetworksModeling Electronic Health Records with Recurrent Neural Networks
Modeling Electronic Health Records with Recurrent Neural Networks
 
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)
 
Deep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorDeep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog Detector
 
Python for Image Understanding: Deep Learning with Convolutional Neural Nets
Python for Image Understanding: Deep Learning with Convolutional Neural NetsPython for Image Understanding: Deep Learning with Convolutional Neural Nets
Python for Image Understanding: Deep Learning with Convolutional Neural Nets
 
Deep learning intro
Deep learning introDeep learning intro
Deep learning intro
 
MDEC Data Matters Series: machine learning and Deep Learning, A Primer
MDEC Data Matters Series: machine learning and Deep Learning, A PrimerMDEC Data Matters Series: machine learning and Deep Learning, A Primer
MDEC Data Matters Series: machine learning and Deep Learning, A Primer
 
Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015
Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015
Introduction to Deep Learning for Image Analysis at Strata NYC, Sep 2015
 
Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중
Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중
Deep Learning - 인공지능 기계학습의 새로운 트랜드 :김인중
 
Deep learning: the future of recommendations
Deep learning: the future of recommendationsDeep learning: the future of recommendations
Deep learning: the future of recommendations
 
Deep Learning And Business Models (VNITC 2015-09-13)
Deep Learning And Business Models (VNITC 2015-09-13)Deep Learning And Business Models (VNITC 2015-09-13)
Deep Learning And Business Models (VNITC 2015-09-13)
 

Similar to Synthetic dialogue generation with Deep Learning

Deep Learning on Qubole Data Platform
Deep Learning on Qubole Data PlatformDeep Learning on Qubole Data Platform
Deep Learning on Qubole Data Platform
Shivaji Dutta
 
Deep Dive on Deep Learning (June 2018)
Deep Dive on Deep Learning (June 2018)Deep Dive on Deep Learning (June 2018)
Deep Dive on Deep Learning (June 2018)
Julien SIMON
 
Training course lect1
Training course lect1Training course lect1
Training course lect1
Noor Dhiya
 
Distributed deep learning_over_spark_20_nov_2014_ver_2.8
Distributed deep learning_over_spark_20_nov_2014_ver_2.8Distributed deep learning_over_spark_20_nov_2014_ver_2.8
Distributed deep learning_over_spark_20_nov_2014_ver_2.8
Vijay Srinivas Agneeswaran, Ph.D
 
Startup.Ml: Using neon for NLP and Localization Applications
Startup.Ml: Using neon for NLP and Localization Applications Startup.Ml: Using neon for NLP and Localization Applications
Startup.Ml: Using neon for NLP and Localization Applications
Intel Nervana
 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
Amr Rashed
 
The deep learning tour - Q1 2017
The deep learning tour - Q1 2017 The deep learning tour - Q1 2017
The deep learning tour - Q1 2017
Eran Shlomo
 
Introduction of Deep Learning
Introduction of Deep LearningIntroduction of Deep Learning
Introduction of Deep Learning
Myungjin Lee
 
Deep Learning Demystified
Deep Learning DemystifiedDeep Learning Demystified
Deep Learning Demystified
Affine Analytics
 
Artificial Intelligence and Deep Learning in Azure, CNTK and Tensorflow
Artificial Intelligence and Deep Learning in Azure, CNTK and TensorflowArtificial Intelligence and Deep Learning in Azure, CNTK and Tensorflow
Artificial Intelligence and Deep Learning in Azure, CNTK and Tensorflow
Jen Stirrup
 
Georgia Tech cse6242 - Intro to Deep Learning and DL4J
Georgia Tech cse6242 - Intro to Deep Learning and DL4JGeorgia Tech cse6242 - Intro to Deep Learning and DL4J
Georgia Tech cse6242 - Intro to Deep Learning and DL4J
Josh Patterson
 
NLP and Deep Learning for non_experts
NLP and Deep Learning for non_expertsNLP and Deep Learning for non_experts
NLP and Deep Learning for non_experts
Sanghamitra Deb
 
Final training course
Final training courseFinal training course
Final training course
Noor Dhiya
 
Deep Learning Enabled Question Answering System to Automate Corporate Helpdesk
Deep Learning Enabled Question Answering System to Automate Corporate HelpdeskDeep Learning Enabled Question Answering System to Automate Corporate Helpdesk
Deep Learning Enabled Question Answering System to Automate Corporate Helpdesk
Saurabh Saxena
 
Machine learning the next revolution or just another hype
Machine learning   the next revolution or just another hypeMachine learning   the next revolution or just another hype
Machine learning the next revolution or just another hype
Jorge Ferrer
 
Deep Learning with Microsoft R Open
Deep Learning with Microsoft R OpenDeep Learning with Microsoft R Open
Deep Learning with Microsoft R Open
Poo Kuan Hoong
 
Deep Learning with CNTK
Deep Learning with CNTKDeep Learning with CNTK
Deep Learning with CNTK
Ashish Jaiman
 
A Platform for Accelerating Machine Learning Applications
 A Platform for Accelerating Machine Learning Applications A Platform for Accelerating Machine Learning Applications
A Platform for Accelerating Machine Learning Applications
NVIDIA Taiwan
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)
Julien SIMON
 
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksA Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
Amazon Web Services
 

Similar to Synthetic dialogue generation with Deep Learning (20)

Deep Learning on Qubole Data Platform
Deep Learning on Qubole Data PlatformDeep Learning on Qubole Data Platform
Deep Learning on Qubole Data Platform
 
Deep Dive on Deep Learning (June 2018)
Deep Dive on Deep Learning (June 2018)Deep Dive on Deep Learning (June 2018)
Deep Dive on Deep Learning (June 2018)
 
Training course lect1
Training course lect1Training course lect1
Training course lect1
 
Distributed deep learning_over_spark_20_nov_2014_ver_2.8
Distributed deep learning_over_spark_20_nov_2014_ver_2.8Distributed deep learning_over_spark_20_nov_2014_ver_2.8
Distributed deep learning_over_spark_20_nov_2014_ver_2.8
 
Startup.Ml: Using neon for NLP and Localization Applications
Startup.Ml: Using neon for NLP and Localization Applications Startup.Ml: Using neon for NLP and Localization Applications
Startup.Ml: Using neon for NLP and Localization Applications
 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
 
The deep learning tour - Q1 2017
The deep learning tour - Q1 2017 The deep learning tour - Q1 2017
The deep learning tour - Q1 2017
 
Introduction of Deep Learning
Introduction of Deep LearningIntroduction of Deep Learning
Introduction of Deep Learning
 
Deep Learning Demystified
Deep Learning DemystifiedDeep Learning Demystified
Deep Learning Demystified
 
Artificial Intelligence and Deep Learning in Azure, CNTK and Tensorflow
Artificial Intelligence and Deep Learning in Azure, CNTK and TensorflowArtificial Intelligence and Deep Learning in Azure, CNTK and Tensorflow
Artificial Intelligence and Deep Learning in Azure, CNTK and Tensorflow
 
Georgia Tech cse6242 - Intro to Deep Learning and DL4J
Georgia Tech cse6242 - Intro to Deep Learning and DL4JGeorgia Tech cse6242 - Intro to Deep Learning and DL4J
Georgia Tech cse6242 - Intro to Deep Learning and DL4J
 
NLP and Deep Learning for non_experts
NLP and Deep Learning for non_expertsNLP and Deep Learning for non_experts
NLP and Deep Learning for non_experts
 
Final training course
Final training courseFinal training course
Final training course
 
Deep Learning Enabled Question Answering System to Automate Corporate Helpdesk
Deep Learning Enabled Question Answering System to Automate Corporate HelpdeskDeep Learning Enabled Question Answering System to Automate Corporate Helpdesk
Deep Learning Enabled Question Answering System to Automate Corporate Helpdesk
 
Machine learning the next revolution or just another hype
Machine learning   the next revolution or just another hypeMachine learning   the next revolution or just another hype
Machine learning the next revolution or just another hype
 
Deep Learning with Microsoft R Open
Deep Learning with Microsoft R OpenDeep Learning with Microsoft R Open
Deep Learning with Microsoft R Open
 
Deep Learning with CNTK
Deep Learning with CNTKDeep Learning with CNTK
Deep Learning with CNTK
 
A Platform for Accelerating Machine Learning Applications
 A Platform for Accelerating Machine Learning Applications A Platform for Accelerating Machine Learning Applications
A Platform for Accelerating Machine Learning Applications
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)
 
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech TalksA Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
A Deeper Dive into Apache MXNet - March 2017 AWS Online Tech Talks
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

Synthetic dialogue generation with Deep Learning

  • 1. Synthetic Dialogue Generation with Deep Learning Using TensorFlow Nasar, Syed | August 2017
  • 2. About me Machine Learning and Big Data Architect MS Computer Science, Machine Learning, Georgia Tech Deep Learning Nanodegree, Udacity Artificial Intelligence Nanodegree, Udacity Connect  Twitter : @techmazed  LinkedIn : https://www.linkedin.com/in/knownasar  Founder: Nashville Artificial Intelligence Society (twitter @AINashville)
  • 3. What we’ll cover The synthetic data generation challenge Introducing Deep Learning Introducing RNN & Sequence to Sequence model Introducing NLP concepts Brief introduction to TensorFlow & FloydHub The solution approach Code walkthrough What next! Question time
  • 5. The problem The challenge is to generate our own TV dialogue scripts by training a Neural Network with an existing corpus of dialogues. Dialogues from Simpson TV show: The sentences 0 to 10: [YEAR DATE 1989] © Twentieth Century Fox Film Corporation. All rights reserved. Moe_Szyslak: (INTO PHONE) Moe's Tavern. Where the elite meet to drink. Bart_Simpson: Eh, yeah, hello, is Mike there? Last name, Rotch. Moe_Szyslak: (INTO PHONE) Hold on, I'll check. (TO BARFLIES) Mike Rotch. Mike Rotch. Hey, has anybody seen Mike Rotch, lately? Moe_Szyslak: (INTO PHONE) Listen you little puke. One of these days I'm gonna catch you, and I'm gonna carve my name on your back with an ice pick. Moe_Szyslak: What's the matter Homer? You're not your normal effervescent self. Homer_Simpson: I got my problems, Moe. Give me another one. Moe_Szyslak: Homer, hey, you should not drink to forget your problems. Barney_Gumble: Yeah, you should only drink to enhance your social skills.
  • 6. Introduction to the important concepts Concepts A brief discussion on the various technologies, techniques and concepts that we apply towards the solution. Deep Learning Recurrent Neural Network (RNN) Natural Language Processing (NLP) Technologies
  • 7. What is Deep Learning? Neural networks with large number of parameters and layers. The layers belong to one of four fundamental network architectures:  Unsupervised Pre-Trained Networks  Convolutional Neural Networks  Recurrent Neural Networks  Recursive Neural Networks  Also Generative Adversarial Networks Introducing Deep Learning The behavior of neural networks is shaped by its network architecture. A network’s architecture can be defined, in part, by: • number of neurons • number of layers • types of connections between layers A Neural Network is an algorithm that learns to identify patterns in data. Backpropagation is a technique to train a Neural Net by updating weights via gradient descent. Deep Learning: many layer neural net + massive data (big data) + massive compute (GPU) Multi-Layer Neural Network topology
  • 8. Backpropagation Learning Backpropagation is an important part of reducing error in a neural network model. General Neural Network Training Pseudocode function neural-network-learning( training-records ) returns network network <- initialize weights (randomly) start loop for each example in training-records do network-output = neural-network-output( network, example ) actual-output = observed outcome associated with example update weights in network based on { example, network-output, actual-output } end for end loop when all examples correctly predicted or hit stopping conditions return network
  • 10. What is RNN? Recurrent Neural Networks have loops. In the diagram (right), a chunk of neural network, A, looks at some input xt and outputs a value ht. A loop allows information to be passed from one step of the network to the next. Consider what happens if we unroll the loop:
  • 13. Tokenize Given a character sequence and a defined document unit, tokenization is the task of chopping it up into pieces, called tokens, also sometimes throwing away certain characters, such as punctuation. Here is an example: Input: Friends, Romans, Countrymen, lend me your ears; Output: Friends || Comma || Romans || Comma || Countrymen || Comma || lend || me || your || ears || semicolon || bye bye!
  • 14. One-Hot Encoding One hot encoding technique is used to encode categorical integer features using a one- hot scheme.
  • 16. LSTMs This basically handles the problem of vanishing and exploding gradients. LSTMs help preserve the error that can be backpropagated through time and layers. Image courtesy - http://deeplearning.net/tutorial/lstm.html
  • 17. Logits Logistic Function: The logit function is the inverse of the logistic function.
  • 19. Cross Entropy & Embeddings
  • 21. TensorFlow TensorFlow is an open source software library by Google To design, build, and train deep learning models Why use: Thoughtful design & Ease of use Deploy computation to one or more CPUs or GPUs TensorFlow alternatives: Theano, Torch, Caffe, Neon, and Keras
  • 22. FloydHub “Floydhub is Heroku for Deep Learning. A Platform-as-a-Service for training and deploying your models in the cloud with a few simple commands.” # Install locally and login $pip install -U floyd-cli $floyd login # Run a Jupyter notebook on FloydHub $ floyd run --mode jupyter --gpu #Run a python code on GPU $ floyd run --gpu "python mnist_cnn.py"
  • 23. Demo Time Let us look at the code
  • 24. Get the helper function. Load the data Summary of the data Sample Data
  • 25. Create a word embedding Transform the words to ids. Two dictionaries: • Dictionary to go from the words to an id, we'll call vocab_to_int • Dictionary to go from the id to word, we'll call int_to_vocab Look at vocab-to-int
  • 26. Tokenize Punctuation This dictionary will be used to token the symbols and add the delimiter (||) around it. This separates the symbols as it's own word, making it easier for the neural network to predict on the next word. Look at token dictionary
  • 27. Let’s preprocess the data Look at the pre-processed data
  • 28. Build the Neural Network We'll build the components necessary to build a RNN by implementing these functions • get_inputs • get_init_cell • get_embed • build_rnn • build_nn • get_batches Placeholders for Inputs
  • 29. Build the Neural Network • get_inputs • get_init_cell • get_embed • build_rnn • build_nn • get_batches Build RNN Cell and Initialize
  • 30. Build the Neural Network • get_inputs • get_init_cell • get_embed • build_rnn • build_nn • get_batches Word Embedding
  • 31. Build the Neural Network • get_inputs • get_init_cell • get_embed • build_rnn • build_nn • get_batches Build RNN Name for the operation A tensor
  • 32. Apply embedding Build RNN Apply a fully connected layer Return the logits and final state Build the Neural Network • get_inputs • get_init_cell • get_embed • build_rnn • build_nn • get_batches Build the Neural Network
  • 33. Build the Neural Network • get_inputs • get_init_cell • get_embed • build_rnn • build_nn • get_batches Create Batches •The first element is a single batch of input with the shape [batch size, sequence length] •The second element is a single batch of targets with the shape [batch size, sequence length]
  • 34. Neural Network Training Number of epochs = 50 Batch size = 256 Size of the RNNs = 256 Length of sequence = 10 Learning rate = 0.01 Tuning Hyperparameters
  • 35. Get Inputs Initialize cells Build NN => logits Apply Softmax Calculate Loss Compute Gradients Apply Optimizer Build the Graph Neural Network Training Loss function Optimizer
  • 36. Get batches Initialize variables Initialize state Enumerate batches Get inputs and hyperparameters Compute loss Show batch results every 100 Save trained model Train the neural network Neural Network Training
  • 39. Generate TV Script Script Generation Load Model Get Tensors Setup Sentence generation Generate sentences Dynamic input Get prediction
  • 40. Generated Script Neural Network Training Larger Dataset: https://www.kaggle.com/wcukierski/the-simpsons-by-the-data
  • 41. Resources The code associated with this presentation is available here: https://github.com/syednasar/talks/tree/master/synthetic-dialog In case of any questions on the code or the implementation, reach out at: Email: techtalk@nasars.com or Twitter: @techmazed
  • 43. References & Recommendations •Visualizing and Understanding Recurrent Networks (paper): https://arxiv.org/abs/1506.02078 •Blog by Andrej Karpathy: http://karpathy.github.io/2015/05/21/rnn- effectiveness/