Cover image for Natural Language Processing in Action : Understanding, analyzing, and generating text with Python
Title:
Natural Language Processing in Action : Understanding, analyzing, and generating text with Python
Personal Author:
Physical Description:
xxix, 512 pages : illustrations ; 24 cm.
ISBN:
9781617294631
Abstract:
Modern NLP techniques based on machine learning radically improve the ability of software to recognise patterns, use context to infer meaning and accurately discern intent from poorly-structured text. Here, readers explore carefully chosen examples and expand their machine's knowledge which they can then apply to a range of challenges.

Available:*

Library
Item Barcode
Call Number
Material Type
Item Category 1
Status
Searching...
30000010371668 QA76.9.N38 L36 2019 Open Access Book Book
Searching...

On Order

Summary

Summary

Description

Modern NLP techniques based on machine learning radically improve the ability of software to recognize patterns, use context to infer meaning, and accurately discern intent from poorly-structured text. In Natural Language Processing in Action , readers explore carefully chosen examples and expand their machine's knowledge which they can then apply to a range of challenges.

Key Features

* Easy-to-follow

* Clear examples

* Hands-on-guide

Audience

A basic understanding of machine learning and some experience with a modern programming language such as Python, Java, C++, or

JavaScript will be helpful.

About the technology

Natural Language Processing (NLP) is the discipline of teaching computers to read more like people, and readers can see examples of it in everything from chatbots to the speech-recognition software on their phone.

Hobson Lane has more than 15 years of experience building autonomous systems that make important decisions on behalf of humans.

Hannes Hapke is an Electrical Engineer turned Data Scientist with experience in deep learning.

Cole Howard is a carpenter and writer turned Deep Learning expert.


Author Notes

Hobson Lane, Hannes Max Hapke, and Cole Howard are experienced NLP engineers who use these techniques in production.


Table of Contents

Forewordp. xiii
Prefacep. xv
Acknowledgmentsp. xxi
About this bookp. xxiv
About the authorsp. xxvii
About the cover illustrationp. xxix
Part 1 Wordy Machinesp. 1
1 Packets of thought (NLP overview)p. 3
1.1 Natural language vs. programming languagep. 4
1.2 The magicp. 4
Machines that conversep. 5
The mathp. 6
1.3 Practical applicationsp. 8
1.4 Language through a computer's "eyes"p. 9
The language of locksp. 10
Regular expressionsp. 11
A simple chatbotp. 12
Another wayp. 16
1.5 A brief overflight of hyperspacep. 19
1.6 Word order and grammarp. 21
1.7 A chatbot natural language pipelinep. 22
1.8 Processing in depthp. 25
1.9 Natural language IQp. 27
2 Build your vocabulary (word tokenization)p. 30
2.1 Challenges (a preview of stemming)p. 32
2.2 Building your vocabulary with a tokenizerp. 33
Dot productp. 41
Measuring bag-of words overlapp. 42
A token improvementp. 43
Extending your vocabulary with n-gramsp. 48
Normalizing your vocabularyp. 54
2.3 Sentimentp. 62
VADER-A rule-based sentiment analyzerp. 64
Naive Bayesp. 65
3 Math with words (TF-IDF vectors)p. 70
3.1 Bag of wordsp. 71
3.2 Vectorizingp. 76
Vector spacesp. 79
3.3 Zipf's Lawp. 83
3.4 Topic modelingp. 86
Return of Zipfp. 89
Relevance rankingp. 90
Toolsp. 93
Alternativesp. 93
Okapi BM25p. 95
What's nextp. 95
4 Finding meaning in word counts (semantic analysis)p. 97
4.1 From word counts to topic scoresp. 98
TF-IDF vectors and lemmatizationp. 99
Topic vectorsp. 99
Thought experimentp. 101
An algorithm for scoring topicsp. 105
An LDA classifierp. 107
4.2 Latent semantic analysisp. 111
Your thought experiment made realp. 113
4.3 Singular value decompositionp. 116
U-left singular vectorsp. 118
S-singular valuesp. 119
VT-right singular vectorsp. 120
SVD matrix orientationp. 120
Truncating the topicsp. 121
4.4 Principal component analysisp. 123
PCA on 3D vectorsp. 125
Stop horsing around and gel back to Nil1p. 126
Using PCA for SMS message semantic analysisp. 128
Using truncated SVD for SMS message semantic analysisp. 130
How well does LSA work for spam classification?p. 131
4.5 Latent Dirichlet allocation (LDiA)p. 134
The LDiA ideap. 135
LDiA topic model for SMS messagesp. 137
LDiA + LDA = spam classifierp. 140
A fairer comparison: 32 LDiA topicsp. 142
4.6 Distance and similarityp. 143
4.7 Steering with feedbackp. 146
Linear discriminant analysisp. 147
4.8 Topic vector powerp. 148
Semantic searchp. 150
Improvementsp. 152
Part 2 Deeper Learning (Neural Networks)p. 153
5 Baby steps with neural networks (perceptrons and backpropagation)p. 155
5.1 Neural networks, the ingredient listp. 156
Perceptronp. 157
A numerical perceptronp. 157
Detour through biasp. 158
Let's go skiing-the error surfacep. 172
Off the chair lift, onto the slopep. 173
Let's shake things up a bitp. 174
Keras: neural networks in Pythonp. 175
Onward and deepwardp. 179
Normalization: input, with stylep. 179
6 Reasoning with word vectors (Word2vec)p. 181
6.1 Semantic queries and analogiesp. 182
Analogy questionsp. 183
6.2 Word vectorsp. 184
Vector-oriented reasoningp. 187
How to compute Word2vec representationsp. 191
How to use thegensim.word2vec modulep. 200
How to generate your own word vector representationsp. 202
Word2vec vs. GloVe (Global Vectors)p. 205
FastTextp. 205
Word2vec vs. LSAp. 206
Visualizing word relationshipsp. 207
Unnatural wordsp. 214
Document similarity with Doc2vecp. 215
7 Getting words in order with convolutional neural networks (CNNs)p. 218
7.1 Learning meaningp. 220
7.2 Toolkitp. 221
7.3 Convolutional neural netsp. 222
Building blocksp. 223
Step size (stride)p. 224
Filter compositionp. 224
Paddingp. 226
Learningp. 228
7.4 Narrow windows indeedp. 228
Implementation in Keras: prepping the datap. 230
Convolutional neural network architecturep. 235
Poolingp. 236
Dropoutp. 238
The cherry on the sundaep. 239
Let's get to learning (training)p. 241
Using the model in a pipelinep. 243
Where do you go from here?p. 244
8 Loopy (recurrent) neural networks (RNNs)p. 247
8.1 Remembering with recurrent networksp. 250
Backpropagation through timep. 255
When do we update what?p. 257
Recapp. 259
There's always a catchp. 259
Recurrent neural net with Kerasp. 260
8.2 Putting things togetherp. 264
8.3 Let's get to learning our past selvesp. 266
8.4 Hyperparametersp. 267
8.5 Predictingp. 269
Statefulnessp. 270
Two-way streetp. 271
What is this thing?p. 272
9 Improving retention with long short-term memory networksp. 274
9.1 LSTMp. 275
Backpropagation through timep. 284
Where does the rubber hit the road?p. 287
Dirty datap. 288
Back to the dirty datap. 291
Words are hard Letters are easierp. 292
My turn to chatp. 298
My turn to speak more clearlyp. 300
Learned how to say, but not yet whatp. 308
Other kinds of memoryp. 308
Going deeperp. 309
10 Sequence-to-sequence models and attentionp. 311
10.1 Encoder-decoder architecturep. 312
Decoding thoughtp. 313
Look familiar?p. 315
Sequence-to-sequence conversationp. 316
LSTM reviewp. 317
10.2 Assembling a sequence-to-sequence pipelinep. 318
Preparing your dataset for the sequence-to-sequence trainingp. 318
Sequence-to-sequence model in Kerasp. 320
Sequence encoderp. 320
Thought decoderp. 322
Assembling the sequence-to-sequence networkp. 323
10.3 Training the sequence-Co-sequence networkp. 324
Generate output sequencesp. 325
10.4 Building a chatbot using sequence-to-sequence network?p. 326
Preparing the corpus for your trainingp. 326
Building your character dictionaryp. 327
Generate one-hot encoded training setsp. 328
Train your sequence-to-sequence chatbotp. 329
Assemble the model for sequence generationp. 330
Predicting a sequencep. 330
Generating a responsep. 331
Converse with your chatbotp. 331
10.5 Enhancementsp. 332
Reduce training complexity with bucketingp. 332
Paying attentionp. 333
10.6 In the real worldp. 334
Part 3 Getting Real (Real-World NLP Chalenges)p. 337
11 Information extraction (named entity extraction and question answering)p. 339
11.1 Named entities and relationsp. 339
A knowledge basep. 340
Information extractionp. 343
11.2 Regular patternsp. 343
Regular expressionsp. 344
Information extraction as NIL feature extractionp. 345
11.3 Information worth extractingp. 346
Extracting GPS locationsp. 347
Extracting datesp. 347
11.4 Extracting relationships (relations)p. 352
Part-of-speech (POS) taggingp. 353
Entity name normalizationp. 357
Relation normalization and extractionp. 358
Word patternsp. 358
Segmentationp. 359
Why won't split('.!?') work?p. 360
Sentence segmentation with regular expressionsp. 361
11.5 In the real worldp. 363
Getting chatty (dialog engines)p. 365
12.1 Language skillp. 366
Modern approachesp. 367
A hybrid approachp. 373
12.2 Pattern-matching approachp. 373
A pattern-matching chatbot with AIMLp. 375
A net-work view of pattern matchingp. 381
12.3 Groundingp. 382
12.4 Retrieval (search)p. 384
The context challengep. 384
Example retrieval-based chatbotp. 386
A search-based chatbotp. 389
12.5 Generative modelsp. 391
Chat about NLPIAp. 392
Pros and cons of each approachp. 394
12.6 Four-wheel drivep. 395
The Will to succeedp. 395
12.7 Design processp. 396
12.8 Trickeryp. 399
Ask questions with predictable answersp. 399
Be entertainingp. 399
When all else fails, searchp. 400
Being popularp. 400
Be a connectorp. 400
Getting emotionalp. 400
12.9 In the real worldp. 401
13 Scaling up (optimization, parallelization, and batch processing)p. 403
13.1 Too much of a good thing (data)p. 404
13.2 Optimizing NLP algorithmsp. 404
Indexingp. 405
Advanced, indexingp. 406
Advanced indexing with Annoyp. 408
Why use approximate indexes at all?p. 412
An indexing workaround: discrelizingp. 413
13.3 Constant RAM algorithmsp. 414
Gensimp. 414
Graph computingp. 415
13.4 Parallelizing your NLP computationsp. 416
Training NLP models on GPUsp. 416
Renting vs. buyingp. 417
GPU rental optionsp. 418
Tensor processing unitsp. 419
13.5 Reducing the memory footprint during model trainingp. 419
13.6 Gaining model insights with TensorBoardp. 422
How to visualize word embeddingsp. 423
Appendix A Your NLP toolsp. 427
Appendix B Playful Python and regular expressionsp. 434
Appendix C Vectors and matrices (linear algebra fundamentals)p. 440
Appendix D Machine learning tools and techniquesp. 446
Appendix E Setting up your AWS GPUp. 459
Appendix F Locality sensitive hashingp. 473
Resourcesp. 481
Glossaryp. 490
Indexp. 497