SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Practical Deep Learning for NLP
Maarten Versteegh
NLP Research Engineer
Overview
● Deep Learning Recap
● Text classification:
– Convnet with word embeddings
● Sentiment analysis:
– ResNet
● Tips and tricks
What is this deep learning thing again?
Input
Hidden
Output
Activation
Error
Rectified Linear Units
Backpropagation involves repeated multiplication with derivative of activation function
→ Problem if result is always smaller than 1!
Text Classification
Traditional approach: BOW + TFIDF
“The car might also need a front end alignment”
"alignment" (0.323)
"also" (0.137)
"car" (0.110)
"end" (0.182)
"front" (0.167)
"might" (0.178)
"need" (0.157)
"the" (0.053)
"also need" (0.343)
"car might" (0.358)
"end alignment" (0.358)
"front end" (0.296)
"might also" (0.358)
"need front" (0.358)
"the car" (0.161)
F1-Score*
BOW+TFIDF+SVM Some number
20 newsgroups performance
(*) Scores removed
Deep Learning 1: Replace Classifier
Hidden x 256
x 512
x 1000
BOW
Features
Hidden
Output
from keras.layers import Input, Dense
from keras.models import Model
input_layer = Input(shape=(1000,))
fc_1 = Dense(512, activation='relu')(input_layer)
fc_2 = Dense(256, activation='relu')(fc_1)
output_layer = Dense(10, activation='softmax')(fc_2)
model = Model(input=input_layer, output=output_layer)
model.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(bow, newsgroups.target)
predictions = model.predict(features).argmax(axis=1)
F1-Score*
BOW+TFIDF+SVM Some number
BOW+TFIDF+SVD+ 2-layer NN Some slightly higher number
20 newsgroups performance
(*) Scores removed
What about the deep learning promise?
Convolutional Networks
Source: Andrej Karpathy
Pooling layer
Source: Andrej Karpathy
Convolutional networks
Source: Y. Kim (2014) Convolutional Networks for Sentence Classification
Word embedding
from keras.layers import Embedding
# embedding_matrix: ndarray(vocab_size, embedding_dim)
input_layer = Input(shape=(MAX_SEQUENCE_LENGTH,), dtype='int32')
layer = Embedding(
embedding_matrix.shape[0],
embedding_matrix.shape[1],
weights=[embedding_matrix],
input_length=max_sequence_length,
trainable=False
)(input_layer)
from keras.layer import Convolution1D, MaxPooling1D,
BatchNormalization, Activation
layer = Embedding(...)(input_layer)
layer = Convolution1D(
128, # number of filters
5, # filter size
activation='relu',
)(layer)
layer = MaxPooling1D(5)(layer)
Performance
F1-Score*
BOW+TFIDF+SVM Some number
CBOW+TFIDF+SVD+NN Some slightly higher number
ConvNet (3 layers) Quite a bit higher now
ConvNet (6 layers) Look mom, even higher!
(*) Scores removed
Sentiment Analysis
Data Set
Facebook posts from media organizations:
– CNN, MSNBC, NYTimes, The Guardian, Buzzfeed,
Breitbart, Politico, The Wall Street Journal, Washington
Post, Baltimore Sun
Measure sentiment as “reactions”
Title Org Like Love Wow Haha Sad Angry
Poll: Clinton up big on Trump in Virginia CNN 4176 601 17 211 11 83
It's a fact: Trump has tiny hands. Will
this be the one that sinks him?
Guardian 595 17 17 225 2 8
Donald Trump Explains His Obama-
Founded-ISIS Claim as ‘Sarcasm’
NYTimes 2059 32 284 1214 80 2167
Can hipsters stomach the unpalatable
truth about avocado toast?
Guardian 3655 0 396 44 773 69
Tim Kaine skewers Donald Trump's
military policy
MSNBC 1094 111 6 12 2 26
Top 5 Most Antisemitic Things Hillary
Clinton Has Done
Breitbart 1067 7 134 35 22 372
17 Hilarious Tweets About Donald
Trump Explaining Movies
Buzzfeed 11390 375 16 4121 4 5
Go deeper: ResNet
Convolutional Layers with shortcuts
He et al. Deep Residual Learning
for Image Recognition
Go deeper: ResNet
input_layer = ...
layer = Convolution1D(128, 5, activation='linear')
(input_layer)
layer = BatchNormalization()(layer)
layer = Activation('relu')(layer)
layer = Convolution1D(128, 5, activation='linear')(layer)
layer = BatchNormalization()(layer)
layer = Activation('relu')(layer)
block_output = merge([layer, input_layer], mode='sum')
block_output = Activation('relu')(block_output)
It's a fact: Trump has tiny hands.
(EMBEDDING_DIM=300)
ResNet Block
…
ResNet Block
The Guardian
(1-of-K)
Conv (128) x 10
%
Title + Message
News Org
MaxPooling
Dense
Dense
Cherry-picked predicted response
distribution*
Sentence Org Love Haha Wow Sad Angry
Trump wins the election Guardian 3% 9% 7% 32% 49%
Trump wins the election Breitbart 58% 30% 8% 1% 3%
*Your mileage may vary. By a lot. I
mean it.
Tips and Tricks
Initialization
● Break symmetry:
– Never ever initialize all your weights to
the same value
● Let initialization depend on activation
function:
– ReLU/PReLU → He Normal
– sigmoid/tanh → Glorot Normal
Choose an adaptive optimizer
Source: Alec Radford
Choose an adaptive optimizer
Choose the right model size
● Start small and keep adding layers
– Check if test error keeps going down
● Cross-validate over the number of units
● You want to be able to overfit
Y. Bengio (2012) Practical
recommendations for gradient-based
training of deep architectures
Don't be scared of overfitting
● If your model can't overfit, it also can't learn enough
● So, check that your model can overfit:
– If not, make it bigger
– If so, get more date and/or regularize
Source: wikipedia
Regularization
● Norm penalties on hidden layer weights, never
on first and last
● Dropout
● Early stopping
Size of data set
● Just get more data already
● Augment data:
– Textual replacements
– Word vector perturbation
– Noise Contrastive Estimation
● Semi-supervised learning:
– Adapt word embeddings to your domain
Monitor your model
Training loss:
– Does the model converge?
– Is the learning rate too low or too high?
Training loss and learning rate
Source: Andrej Karpathy
Monitor your model
Training and validation accuracy
– Is there a large gap?
– Does the training accuracy increase
while the validation accuracy
decreases?
Training and validation accuracy
Source: Andrej Karpathy
Monitor your model
● Ratio of weights to updates
● Distribution of activations and gradients
(per layer)
Hyperparameter optimization
After network architecture, continue with:
– Regularization strength
– Initial learning rate
– Optimization strategy (and LR decay
schedule)
Friends don't let friends do a full grid search!
Hyperparameter optimization
Friends don't let friends do a full grid search!
– Use a smart strategy like Bayesian
optimization or Particle Swarm Optimization
(Spearmint, SMAC, Hyperopt, Optunity)
– Even random search often beats grid search
Keep up to date: arxiv-sanity.com
We are hiring!
DevOps & Front-end
NLP engineers
Full-stack Python engineers
www.textkernel.com/jobs
Questions?
Source: http://visualqa.org/

Contenu connexe

Tendances

Tendances (20)

Neural Networks and Deep Learning
Neural Networks and Deep LearningNeural Networks and Deep Learning
Neural Networks and Deep Learning
 
Deep Learning & NLP: Graphs to the Rescue!
Deep Learning & NLP: Graphs to the Rescue!Deep Learning & NLP: Graphs to the Rescue!
Deep Learning & NLP: Graphs to the Rescue!
 
Anthiil Inside workshop on NLP
Anthiil Inside workshop on NLPAnthiil Inside workshop on NLP
Anthiil Inside workshop on NLP
 
What Deep Learning Means for Artificial Intelligence
What Deep Learning Means for Artificial IntelligenceWhat Deep Learning Means for Artificial Intelligence
What Deep Learning Means for Artificial Intelligence
 
What Deep Learning Means for Artificial Intelligence
What Deep Learning Means for Artificial IntelligenceWhat Deep Learning Means for Artificial Intelligence
What Deep Learning Means for Artificial Intelligence
 
Deep Dialog System Review
Deep Dialog System ReviewDeep Dialog System Review
Deep Dialog System Review
 
Visual-Semantic Embeddings: some thoughts on Language
Visual-Semantic Embeddings: some thoughts on LanguageVisual-Semantic Embeddings: some thoughts on Language
Visual-Semantic Embeddings: some thoughts on Language
 
Deep learning - Conceptual understanding and applications
Deep learning - Conceptual understanding and applicationsDeep learning - Conceptual understanding and applications
Deep learning - Conceptual understanding and applications
 
Recurrent networks and beyond by Tomas Mikolov
Recurrent networks and beyond by Tomas MikolovRecurrent networks and beyond by Tomas Mikolov
Recurrent networks and beyond by Tomas Mikolov
 
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
 
Deep Learning - A Literature survey
Deep Learning - A Literature surveyDeep Learning - A Literature survey
Deep Learning - A Literature survey
 
Start a deep learning startup - tutorial
Start a deep learning startup - tutorialStart a deep learning startup - tutorial
Start a deep learning startup - tutorial
 
Deep Learning for Information Retrieval
Deep Learning for Information RetrievalDeep Learning for Information Retrieval
Deep Learning for Information Retrieval
 
Deep Learning Models for Question Answering
Deep Learning Models for Question AnsweringDeep Learning Models for Question Answering
Deep Learning Models for Question Answering
 
Deep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingDeep Learning for Natural Language Processing
Deep Learning for Natural Language Processing
 
ODSC East: Effective Transfer Learning for NLP
ODSC East: Effective Transfer Learning for NLPODSC East: Effective Transfer Learning for NLP
ODSC East: Effective Transfer Learning for NLP
 
Deep learning: the future of recommendations
Deep learning: the future of recommendationsDeep learning: the future of recommendations
Deep learning: the future of recommendations
 
Zero shot learning through cross-modal transfer
Zero shot learning through cross-modal transferZero shot learning through cross-modal transfer
Zero shot learning through cross-modal transfer
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural Networks
 
Deep Learning for Personalized Search and Recommender Systems
Deep Learning for Personalized Search and Recommender SystemsDeep Learning for Personalized Search and Recommender Systems
Deep Learning for Personalized Search and Recommender Systems
 

En vedette

NLP@Work Conference: email persuasion
NLP@Work Conference: email persuasionNLP@Work Conference: email persuasion
NLP@Work Conference: email persuasion
evolutionpd
 

En vedette (20)

AI Reality: Where are we now? Data for Good? - Bill Boorman
AI Reality: Where are we now? Data for Good? - Bill  BoormanAI Reality: Where are we now? Data for Good? - Bill  Boorman
AI Reality: Where are we now? Data for Good? - Bill Boorman
 
Chapter 02 #ml-professional
Chapter 02  #ml-professionalChapter 02  #ml-professional
Chapter 02 #ml-professional
 
Textkernel Talks - Neo4j usage in Textkernel
Textkernel Talks - Neo4j usage in TextkernelTextkernel Talks - Neo4j usage in Textkernel
Textkernel Talks - Neo4j usage in Textkernel
 
Uw database als waardevolle sourcing tool
Uw database als waardevolle sourcing toolUw database als waardevolle sourcing tool
Uw database als waardevolle sourcing tool
 
Python Learning for Natural Language Processing
Python Learning for Natural Language ProcessingPython Learning for Natural Language Processing
Python Learning for Natural Language Processing
 
Intuition's Fall from Grace - Algorithms and Data in (Pre)-Selection by Colin...
Intuition's Fall from Grace - Algorithms and Data in (Pre)-Selection by Colin...Intuition's Fall from Grace - Algorithms and Data in (Pre)-Selection by Colin...
Intuition's Fall from Grace - Algorithms and Data in (Pre)-Selection by Colin...
 
Text mining meets neural nets
Text mining meets neural netsText mining meets neural nets
Text mining meets neural nets
 
Deep Learning for NLP
Deep Learning for NLP Deep Learning for NLP
Deep Learning for NLP
 
Thinking about nlp
Thinking about nlpThinking about nlp
Thinking about nlp
 
NLP
NLPNLP
NLP
 
Deep learning for text analytics
Deep learning for text analyticsDeep learning for text analytics
Deep learning for text analytics
 
NLP@Work Conference: email persuasion
NLP@Work Conference: email persuasionNLP@Work Conference: email persuasion
NLP@Work Conference: email persuasion
 
Using Deep Learning And NLP To Predict Performance From Resumes
Using Deep Learning And NLP To Predict Performance From ResumesUsing Deep Learning And NLP To Predict Performance From Resumes
Using Deep Learning And NLP To Predict Performance From Resumes
 
Deep Learning and Text Mining
Deep Learning and Text MiningDeep Learning and Text Mining
Deep Learning and Text Mining
 
Natural language processing (Python)
Natural language processing (Python)Natural language processing (Python)
Natural language processing (Python)
 
Natural Language Processing and Python
Natural Language Processing and PythonNatural Language Processing and Python
Natural Language Processing and Python
 
Classification Based Machine Learning Algorithms
Classification Based Machine Learning AlgorithmsClassification Based Machine Learning Algorithms
Classification Based Machine Learning Algorithms
 
Online algorithms in Machine Learning
Online algorithms in Machine LearningOnline algorithms in Machine Learning
Online algorithms in Machine Learning
 
PRML5
PRML5PRML5
PRML5
 
PyData 2015 Keynote: "A Systems View of Machine Learning"
PyData 2015 Keynote: "A Systems View of Machine Learning" PyData 2015 Keynote: "A Systems View of Machine Learning"
PyData 2015 Keynote: "A Systems View of Machine Learning"
 

Similaire à Practical Deep Learning for NLP

Semi-Supervised Insight Generation from Petabyte Scale Text Data
Semi-Supervised Insight Generation from Petabyte Scale Text DataSemi-Supervised Insight Generation from Petabyte Scale Text Data
Semi-Supervised Insight Generation from Petabyte Scale Text Data
Tech Triveni
 
Lec1cgu13updated.ppt
Lec1cgu13updated.pptLec1cgu13updated.ppt
Lec1cgu13updated.ppt
kalai75
 
Automatic Search Event-Summary
Automatic Search Event-SummaryAutomatic Search Event-Summary
Automatic Search Event-Summary
Xiwei Yan
 

Similaire à Practical Deep Learning for NLP (20)

Semi-Supervised Insight Generation from Petabyte Scale Text Data
Semi-Supervised Insight Generation from Petabyte Scale Text DataSemi-Supervised Insight Generation from Petabyte Scale Text Data
Semi-Supervised Insight Generation from Petabyte Scale Text Data
 
Certification Study Group - NLP & Recommendation Systems on GCP Session 5
Certification Study Group - NLP & Recommendation Systems on GCP Session 5Certification Study Group - NLP & Recommendation Systems on GCP Session 5
Certification Study Group - NLP & Recommendation Systems on GCP Session 5
 
.NET Fest 2017. Игорь Кочетов. Классификация результатов тестирования произво...
.NET Fest 2017. Игорь Кочетов. Классификация результатов тестирования произво....NET Fest 2017. Игорь Кочетов. Классификация результатов тестирования произво...
.NET Fest 2017. Игорь Кочетов. Классификация результатов тестирования произво...
 
data science
data sciencedata science
data science
 
TensorFlow London 12: Oliver Gindele 'Recommender systems in Tensorflow'
TensorFlow London 12: Oliver Gindele 'Recommender systems in Tensorflow'TensorFlow London 12: Oliver Gindele 'Recommender systems in Tensorflow'
TensorFlow London 12: Oliver Gindele 'Recommender systems in Tensorflow'
 
Data Science
Data Science Data Science
Data Science
 
Lec1cgu13updated.ppt
Lec1cgu13updated.pptLec1cgu13updated.ppt
Lec1cgu13updated.ppt
 
Data science programming .ppt
Data science programming .pptData science programming .ppt
Data science programming .ppt
 
Lec1cgu13updated.ppt
Lec1cgu13updated.pptLec1cgu13updated.ppt
Lec1cgu13updated.ppt
 
Lec1cgu13updated.ppt
Lec1cgu13updated.pptLec1cgu13updated.ppt
Lec1cgu13updated.ppt
 
Distributed Models Over Distributed Data with MLflow, Pyspark, and Pandas
Distributed Models Over Distributed Data with MLflow, Pyspark, and PandasDistributed Models Over Distributed Data with MLflow, Pyspark, and Pandas
Distributed Models Over Distributed Data with MLflow, Pyspark, and Pandas
 
Data Science: The Product Manager's Primer
Data Science: The Product Manager's PrimerData Science: The Product Manager's Primer
Data Science: The Product Manager's Primer
 
AI and Deep Learning
AI and Deep Learning AI and Deep Learning
AI and Deep Learning
 
Troubleshooting Deep Neural Networks - Full Stack Deep Learning
Troubleshooting Deep Neural Networks - Full Stack Deep LearningTroubleshooting Deep Neural Networks - Full Stack Deep Learning
Troubleshooting Deep Neural Networks - Full Stack Deep Learning
 
Transfer Learning - from English to German, from Russian to Ukrainian
Transfer Learning - from English to German, from Russian to UkrainianTransfer Learning - from English to German, from Russian to Ukrainian
Transfer Learning - from English to German, from Russian to Ukrainian
 
Automatic Search Event-Summary
Automatic Search Event-SummaryAutomatic Search Event-Summary
Automatic Search Event-Summary
 
A field guide the machine learning zoo
A field guide the machine learning zoo A field guide the machine learning zoo
A field guide the machine learning zoo
 
BDACA1617s2 - Lecture7
BDACA1617s2 - Lecture7BDACA1617s2 - Lecture7
BDACA1617s2 - Lecture7
 
BDACA - Lecture7
BDACA - Lecture7BDACA - Lecture7
BDACA - Lecture7
 
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
 

Plus de Textkernel

Pablo de Pedraza: Labor market matching, economic cycle and online vacancies
Pablo de Pedraza: Labor market matching, economic cycle and online vacanciesPablo de Pedraza: Labor market matching, economic cycle and online vacancies
Pablo de Pedraza: Labor market matching, economic cycle and online vacancies
Textkernel
 
The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost
The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost
The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost
Textkernel
 

Plus de Textkernel (20)

Textkernel Emerce eRecruitment - 6 april 2017
Textkernel Emerce eRecruitment - 6 april 2017 Textkernel Emerce eRecruitment - 6 april 2017
Textkernel Emerce eRecruitment - 6 april 2017
 
Robots Will Steal Your Job but That's OK - Federico Pistono
Robots Will Steal Your Job but That's OK - Federico PistonoRobots Will Steal Your Job but That's OK - Federico Pistono
Robots Will Steal Your Job but That's OK - Federico Pistono
 
Semantic Interoperability in the Labour Market - Martin le Vrang, Team leader...
Semantic Interoperability in the Labour Market - Martin le Vrang, Team leader...Semantic Interoperability in the Labour Market - Martin le Vrang, Team leader...
Semantic Interoperability in the Labour Market - Martin le Vrang, Team leader...
 
Pablo de Pedraza: Labor market matching, economic cycle and online vacancies
Pablo de Pedraza: Labor market matching, economic cycle and online vacanciesPablo de Pedraza: Labor market matching, economic cycle and online vacancies
Pablo de Pedraza: Labor market matching, economic cycle and online vacancies
 
New Developments in Machine Learning - Prof. Dr. Max Welling
New Developments in Machine Learning - Prof. Dr. Max WellingNew Developments in Machine Learning - Prof. Dr. Max Welling
New Developments in Machine Learning - Prof. Dr. Max Welling
 
Dr. Gábor Kismihók: Labour Market driven Learning Analytics
Dr. Gábor Kismihók: Labour Market driven Learning AnalyticsDr. Gábor Kismihók: Labour Market driven Learning Analytics
Dr. Gábor Kismihók: Labour Market driven Learning Analytics
 
The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost
The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost
The Agile Future of HR and Talent Acquisition - Prof. Dr. Armin Trost
 
Set the Hiring Managers’ Expectations: Using Big Data to answer Big Questions...
Set the Hiring Managers’ Expectations: Using Big Data to answer Big Questions...Set the Hiring Managers’ Expectations: Using Big Data to answer Big Questions...
Set the Hiring Managers’ Expectations: Using Big Data to answer Big Questions...
 
Human > Machine Interface - The future of HR | Perry Timms, Founder & Directo...
Human > Machine Interface - The future of HR | Perry Timms, Founder & Directo...Human > Machine Interface - The future of HR | Perry Timms, Founder & Directo...
Human > Machine Interface - The future of HR | Perry Timms, Founder & Directo...
 
Ton Sluiter: Breaking Barriers and Leveraging Data
Ton Sluiter: Breaking Barriers and Leveraging DataTon Sluiter: Breaking Barriers and Leveraging Data
Ton Sluiter: Breaking Barriers and Leveraging Data
 
How semantic search changes recruitment - Glen Cathey
How semantic search changes recruitment - Glen CatheyHow semantic search changes recruitment - Glen Cathey
How semantic search changes recruitment - Glen Cathey
 
The Role of Public Innovation and the Impact of Technology on Employment - Re...
The Role of Public Innovation and the Impact of Technology on Employment - Re...The Role of Public Innovation and the Impact of Technology on Employment - Re...
The Role of Public Innovation and the Impact of Technology on Employment - Re...
 
It’s all about Technology... oh wait! It’s not - Balazs Paroczay
It’s all about Technology... oh wait! It’s not - Balazs ParoczayIt’s all about Technology... oh wait! It’s not - Balazs Paroczay
It’s all about Technology... oh wait! It’s not - Balazs Paroczay
 
Innovatie en de Candidate Experience (Textkernel) - Recruitment Innovation Event
Innovatie en de Candidate Experience (Textkernel) - Recruitment Innovation EventInnovatie en de Candidate Experience (Textkernel) - Recruitment Innovation Event
Innovatie en de Candidate Experience (Textkernel) - Recruitment Innovation Event
 
Textkernel talks - introduction to Textkernel
Textkernel talks - introduction to TextkernelTextkernel talks - introduction to Textkernel
Textkernel talks - introduction to Textkernel
 
Jobfeed rapport: De Nederlandse online arbeidsmarkt in Q1 2015
Jobfeed rapport: De Nederlandse online arbeidsmarkt in Q1 2015Jobfeed rapport: De Nederlandse online arbeidsmarkt in Q1 2015
Jobfeed rapport: De Nederlandse online arbeidsmarkt in Q1 2015
 
Etat des lieux de l'offre d'emploi en ligne - Q1 2015
Etat des lieux de l'offre d'emploi en ligne - Q1 2015Etat des lieux de l'offre d'emploi en ligne - Q1 2015
Etat des lieux de l'offre d'emploi en ligne - Q1 2015
 
Presentatie Jobfeed België
Presentatie Jobfeed BelgiëPresentatie Jobfeed België
Presentatie Jobfeed België
 
Webinar: Vacatures in Nederland (Jobfeed & Jacco Valkenburg)
Webinar: Vacatures in Nederland (Jobfeed & Jacco Valkenburg)Webinar: Vacatures in Nederland (Jobfeed & Jacco Valkenburg)
Webinar: Vacatures in Nederland (Jobfeed & Jacco Valkenburg)
 
Textkernel - Recruiting Innovation Day München (DE)
Textkernel - Recruiting Innovation Day München (DE)Textkernel - Recruiting Innovation Day München (DE)
Textkernel - Recruiting Innovation Day München (DE)
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Practical Deep Learning for NLP

  • 1. Practical Deep Learning for NLP Maarten Versteegh NLP Research Engineer
  • 2. Overview ● Deep Learning Recap ● Text classification: – Convnet with word embeddings ● Sentiment analysis: – ResNet ● Tips and tricks
  • 3. What is this deep learning thing again?
  • 5. Rectified Linear Units Backpropagation involves repeated multiplication with derivative of activation function → Problem if result is always smaller than 1!
  • 7. Traditional approach: BOW + TFIDF “The car might also need a front end alignment” "alignment" (0.323) "also" (0.137) "car" (0.110) "end" (0.182) "front" (0.167) "might" (0.178) "need" (0.157) "the" (0.053) "also need" (0.343) "car might" (0.358) "end alignment" (0.358) "front end" (0.296) "might also" (0.358) "need front" (0.358) "the car" (0.161)
  • 8. F1-Score* BOW+TFIDF+SVM Some number 20 newsgroups performance (*) Scores removed
  • 9. Deep Learning 1: Replace Classifier Hidden x 256 x 512 x 1000 BOW Features Hidden Output
  • 10. from keras.layers import Input, Dense from keras.models import Model input_layer = Input(shape=(1000,)) fc_1 = Dense(512, activation='relu')(input_layer) fc_2 = Dense(256, activation='relu')(fc_1) output_layer = Dense(10, activation='softmax')(fc_2) model = Model(input=input_layer, output=output_layer) model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) model.fit(bow, newsgroups.target) predictions = model.predict(features).argmax(axis=1)
  • 11. F1-Score* BOW+TFIDF+SVM Some number BOW+TFIDF+SVD+ 2-layer NN Some slightly higher number 20 newsgroups performance (*) Scores removed
  • 12. What about the deep learning promise?
  • 15. Convolutional networks Source: Y. Kim (2014) Convolutional Networks for Sentence Classification
  • 17. from keras.layers import Embedding # embedding_matrix: ndarray(vocab_size, embedding_dim) input_layer = Input(shape=(MAX_SEQUENCE_LENGTH,), dtype='int32') layer = Embedding( embedding_matrix.shape[0], embedding_matrix.shape[1], weights=[embedding_matrix], input_length=max_sequence_length, trainable=False )(input_layer)
  • 18. from keras.layer import Convolution1D, MaxPooling1D, BatchNormalization, Activation layer = Embedding(...)(input_layer) layer = Convolution1D( 128, # number of filters 5, # filter size activation='relu', )(layer) layer = MaxPooling1D(5)(layer)
  • 19. Performance F1-Score* BOW+TFIDF+SVM Some number CBOW+TFIDF+SVD+NN Some slightly higher number ConvNet (3 layers) Quite a bit higher now ConvNet (6 layers) Look mom, even higher! (*) Scores removed
  • 21. Data Set Facebook posts from media organizations: – CNN, MSNBC, NYTimes, The Guardian, Buzzfeed, Breitbart, Politico, The Wall Street Journal, Washington Post, Baltimore Sun Measure sentiment as “reactions”
  • 22. Title Org Like Love Wow Haha Sad Angry Poll: Clinton up big on Trump in Virginia CNN 4176 601 17 211 11 83 It's a fact: Trump has tiny hands. Will this be the one that sinks him? Guardian 595 17 17 225 2 8 Donald Trump Explains His Obama- Founded-ISIS Claim as ‘Sarcasm’ NYTimes 2059 32 284 1214 80 2167 Can hipsters stomach the unpalatable truth about avocado toast? Guardian 3655 0 396 44 773 69 Tim Kaine skewers Donald Trump's military policy MSNBC 1094 111 6 12 2 26 Top 5 Most Antisemitic Things Hillary Clinton Has Done Breitbart 1067 7 134 35 22 372 17 Hilarious Tweets About Donald Trump Explaining Movies Buzzfeed 11390 375 16 4121 4 5
  • 23. Go deeper: ResNet Convolutional Layers with shortcuts He et al. Deep Residual Learning for Image Recognition
  • 24. Go deeper: ResNet input_layer = ... layer = Convolution1D(128, 5, activation='linear') (input_layer) layer = BatchNormalization()(layer) layer = Activation('relu')(layer) layer = Convolution1D(128, 5, activation='linear')(layer) layer = BatchNormalization()(layer) layer = Activation('relu')(layer) block_output = merge([layer, input_layer], mode='sum') block_output = Activation('relu')(block_output)
  • 25. It's a fact: Trump has tiny hands. (EMBEDDING_DIM=300) ResNet Block … ResNet Block The Guardian (1-of-K) Conv (128) x 10 % Title + Message News Org MaxPooling Dense Dense
  • 26. Cherry-picked predicted response distribution* Sentence Org Love Haha Wow Sad Angry Trump wins the election Guardian 3% 9% 7% 32% 49% Trump wins the election Breitbart 58% 30% 8% 1% 3% *Your mileage may vary. By a lot. I mean it.
  • 28. Initialization ● Break symmetry: – Never ever initialize all your weights to the same value ● Let initialization depend on activation function: – ReLU/PReLU → He Normal – sigmoid/tanh → Glorot Normal
  • 29. Choose an adaptive optimizer Source: Alec Radford Choose an adaptive optimizer
  • 30. Choose the right model size ● Start small and keep adding layers – Check if test error keeps going down ● Cross-validate over the number of units ● You want to be able to overfit Y. Bengio (2012) Practical recommendations for gradient-based training of deep architectures
  • 31. Don't be scared of overfitting ● If your model can't overfit, it also can't learn enough ● So, check that your model can overfit: – If not, make it bigger – If so, get more date and/or regularize Source: wikipedia
  • 32. Regularization ● Norm penalties on hidden layer weights, never on first and last ● Dropout ● Early stopping
  • 33. Size of data set ● Just get more data already ● Augment data: – Textual replacements – Word vector perturbation – Noise Contrastive Estimation ● Semi-supervised learning: – Adapt word embeddings to your domain
  • 34. Monitor your model Training loss: – Does the model converge? – Is the learning rate too low or too high?
  • 35. Training loss and learning rate Source: Andrej Karpathy
  • 36. Monitor your model Training and validation accuracy – Is there a large gap? – Does the training accuracy increase while the validation accuracy decreases?
  • 37. Training and validation accuracy Source: Andrej Karpathy
  • 38. Monitor your model ● Ratio of weights to updates ● Distribution of activations and gradients (per layer)
  • 39. Hyperparameter optimization After network architecture, continue with: – Regularization strength – Initial learning rate – Optimization strategy (and LR decay schedule)
  • 40. Friends don't let friends do a full grid search!
  • 41. Hyperparameter optimization Friends don't let friends do a full grid search! – Use a smart strategy like Bayesian optimization or Particle Swarm Optimization (Spearmint, SMAC, Hyperopt, Optunity) – Even random search often beats grid search
  • 42. Keep up to date: arxiv-sanity.com
  • 43. We are hiring! DevOps & Front-end NLP engineers Full-stack Python engineers www.textkernel.com/jobs