Categories
deep learning Natural Language Processing

Some Preliminary Resources for Deep Learning On NLP

Some list of Deep Learning on NLP – unsorted. 

  • fasttext
  • https://github.com/shashankg7/Deep-Learning-for-NLP-Resources
  • https://github.com/andrewt3000/DL4NLP/blob/master/README.md
  • https://github.com/oxford-cs-deepnlp-2017
  • https://github.com/keon/awesome-nlp#implementation                                             *
Categories
deep learning deep neural network DNN Machine Learning Natural Language Processing

What is the Difference between Deep Learning and Machine Learning?

AIDL member Bob Akili asked (rephrased):

What is the Difference between Deep Learning and Machine Learning?

Usually I don’t write a full blog message to answer member’s questions. But what is “deep” is such a fundamental concept in deep learning, yet there are many well-meaning but incorrect answers floating around.   So I think it is a great idea to answer the question clearly and hopefully disabuse some of the misconceptions as well. Here is a cleaned up and expanded version of my comment to the thread.

Deep Learning is Just a Subset of Machine Learning

First of all deep learning is just a subset of techniques of machine learning.  You may heard from  many “Deep Learning Consultants”-type: “deep learning is completely different from from Machine Learning”.   But then when we are talking about “deep learning” these days, we are really talking about “neural networks which has more than one layer”.  Since neural network is just one type of ML techniques, it doesn’t make any sense to call DL as “different” from ML.   It might work for marketing purpose, but the thought was clearly misleading.

Deep Learning is a kind of Representation Learning

So now we know that deep learning is a kind of machine learning.   We still can’t quite answer why it is special.  So let’s be more specific, deep learning is a kind of representation learning.  What is representation learning?  Representation learning is an opposite of another school of thought/practice: feature engineering. In feature engineering, humans are supposed to hand-craft features to make machine works better.   If you Kaggle before, this should be obvious to you, sometimes you just want to manipulate the raw inputs and create new feature to represent your data.

Yet in some domains which involve high-dimensional data such as images, speech or text, hand-crafting feature was found to be very difficult.  e.g. Using HOG type of approaches to do computer vision usually takes a 4-5 years of a PhD student.   So here we come back to representation learning – can computer automatically learn good features?

What is a “Deep” Technique?

Now we come to the part why deep learning is “deep” – usually we call a method “deep” when we are optimizing a nested function in the method.   So for example, if you can express such functions as a graph, you would find that it has multiple layers.  The term “deep” really is describing such “nestedness”.  That should explain why we typically called any artificial neural network (ANN) with more than 1 hidden layer as “deep”.   Or the general saying, “deep learning is just neural network which has more layers”.

(Another appropriate term is “hierarchical”. See footnote [4] for more detail.)

This is also the moment Karpathy in cs231n will show you the multi-layer CNN such that features are automatically learned from the simplest to more complex one. Eventually your last layer can just differentiate them using a linear classifier. As there is a “deep” structure that learn the right feature (last layer).   Note the key term here is “automatic”, all these Gabor-filter like feature are not hand-made.  Rather, they are results from back-propagation [3].

Are there Anything which is “Deep” but not a Neural Network?

Actually, there are plenty, deep Boltzmann machine? deep belief network? deep Gaussian process?  They are still discussed in unsupervised learning using neural network, but I always found that knowledge of graphical models is more important to understand them.

So is Deep Learning also a Marketing Term?

Yes and no. It depends on who you talk to.  If you talk with ANN researchers/practitioners, they would just tell you “deep learning is just neural network which has more than 1 hidden layer”.   Indeed, if you think from their perspective, the term “deep learning” could just be a short-form.  Yet as we just said, you can also called other methods “deep”.  So the adjective is not totally void of meaning.  But many people would also tell you that because “deep learning” has become such a marketing term, it can now mean many different things.  I will say more in next section.

Also the term “deep learning” has been there for a century.  Check out Prof. Schmidhuber’s thread for more details?

“No Way! X is not Deep but it is also taught in Deep Learning Class, You made a Horrible Mistake!”

I said it with much authority and I know some of you guys would just jump in and argue:

“What about word2vec? It is nothing deep at all, but people still call it Deep learning!!!”  “What about all wide architectures such as “wide-deep learning“?” “Arthur, You are Making a HORRIBLE MISTAKE!”

Indeed, the term “deep learning” is being abused these days.   More learned people, on the other hand, are usually careful to call certain techniques “deep learning”  For example,  in cs221d 2015/2016 lectures, Dr. Richard Socher was quite cautious to call word2vec as “deep”.  His supervisor, Prof. Chris Manning, who is an authority in NLP, is known to dispute whether deep learning is always useful in NLP, simply because some recent advances in NLP really due to deep learning [1][2].

I think these cautions make sense.  Part of it is that calling everything “deep learning” just blurs what really should be credited in certain technical improvement.  The other part is we shouldn’t see deep learning as the only type of ML we want to study.  There are many ML techniques, some of them are more interesting and practical than deep learning in practice.  For example, deep learning is not known to work well with small data scenario.  Would I just yell at my boss and say “Because I can’t use deep learning, so I can’t solve this problem!”?  No, I would just test out random forest, support vector machines, GMM and all these nifty methods I learn over the years.

Misleading Claim About Deep Learning (I) – “Deep Learning is about Machine Learning Methods which use a lot of Data!”

So now we come to the arena of misconceptions, I am going to discuss two claims which many people have been drumming about deep learning.   But neither of them is the right answer to the question “What is the Difference between Deep and Machine Learning?

The first one you probably heard all the time, “Deep Learning is about ML methods which use a lot of data”.   Or people would tell you “Oh, deep learning just use a lot of data, right?”  This sounds about right, deep learning in these days does use a lot of data.  So what’s wrong with the statement?

Here is the answer: while deep learning does use a lot of data, before deep learningother techniques use tons of data too! e.g. Speech recognition before deep learning, i.e. HMM+GMM, can use up to 10k hours of speech. Same for SMT.  And you can do SVM+HOG on Imagenet. And more data is always better for those techniques as well. So if you say “deep learning use more data”, then you forgot the older techniques also can use more data.

What you can claim is that “deep learning is a more effective way to utilize data”.  That’s very true, because once you get into either GMM or SVM, they would have scalability issues.  GMM scales badly when the amount of data is around 10k hour.  SVM (with RBF-kernel in particular) is super tough/slow to use when you have ~1 million point of data.

Misleading Claim About Deep Learning II – “Deep Learning is About Using GPU and Having Data Center!”

This particular claim is different from the previous “Data Requirement” claim,  but we can debunk it in a similar manner.   The reason why it is wrong? Again before deep learning, people have GPUs to do machine learning already.  For example, you can use GPU to speed up GMM.   Before deep learning is hot, you need a cluster of machines to train acoustic model or language model for speech recognition.  You also need tons of RAM to train a language model for SMT.   So calling GPU/Data Center/RAM/ASIC/FPGA a differentiator of deep learning is just misleading.

You can say though “Deep Learning has change the computational model from distributed network model to more a single machine-centric paradigm (which each machine has one GPU).  But later approaches also tried to combine both CPU-GPU processing together”.  

Conclusion and “What you say is Just Your Opinion! My Theory makes Equal Sense!”

Indeed, you should always treat what you read on-line with a grain of salt.   Being critical is a good thing, having your own opinion is good.  But you should also try to avoid equivocate an issue.  Meaning: sometimes things have only one side, but you insist there are two equally valid answers.   If you do so, you are perhaps making a logical error in your thinking.   And a lot of people who made claims such as “deep learning is learning which use more data and use a lot of GPUS” are probably making such thinking errors.

Saying so, I would suggest you to read several good sources to judge my answer, they are:

  1. Chapter 1 of Deep Learning.
  2. Shakir’s Machine Learning Blog on a Statistical View of Deep Learning.  In particular, part VI, “What is Deep?
  3. Tombone’s post on Deep Learning vs Machine Learning vs Pattern Recognition

In any case, I hope that this article helps you. I thank Bob to ask the question, Armaghan Rumi Naik has debunked many misconceptions in the original thread – his understanding on machine learning is clearly above mine and he was able to point out mistakes from other commenters.  It is worthwhile for your reading time.

Footnotes

[1] See “Last Words: Computational Linguistics and Deep Learning
[2] Generally whether DL is useful in NLP is widely disputed topic. Take a look of Yoav Goldberg’s view on some recent GAN results on language generation. AIDL Weekly #18 also gave an expose on the issue.
[3] Perhaps another useful term is “hierarchical”.  In the case of ConvNet the term is right on.  As Eric Heitzman comments at AIDL:
“(deep structure) They are *not* necessarily recursive, but they *are* necessarily hierarchical since layers always form a hierarchical structure.”  After Eric’s comment, I think both “deep” and “hierarchical” are fair terms to describe methods in “deep learning”. (Of course, “hierarchical learning” is a much a poorer marketing term.)
[4] In earlier draft.  I use the term recursive to describe the term “deep”, which as Eric Heitzman at AIDL, is not entirely appropriate.  “Recursive” give people a feeling that the function is self-recursive or$latex f(f( \ldots f(f(*))))$. but actual function are more “nested”, like $latex f_1(f_2( \ldots f_{n-1}(f_n(*))))$. As a result, I removed the term “recursive” but just call the function “nested function”.
Of course, you should be aware that my description is not too mathematically rigorous neither. (I guess it is a fair wordy description though)

History:
20170709 at 6: fix some typos.

20170711: fix more typos.

20170711 at 7:05 p.m.: I got a feedback from Eric Heitzman who points out that the term “recursive” can be deceiving.  Thus I wrote footnote [4].

If you like this message, subscribe the Grand Janitor Blog’s RSS feed. You can also find me (Arthur) at twitterLinkedInPlusClarity.fm. Together with Waikit Lau, I maintain the Deep Learning Facebook forum.  Also check out my awesome employer: Voci.

Categories
Natural Language Processing

What does an NLP Engineer do?

After taking the very enjoyable class from Prof.  Radev, I was browsing the forum for some interesting topics.   Here one I found, posted by an anonymous student, (rephrase)

“After taking this course, I still have only a vague grasp of what an NLP Software Engineer does on a daily basis.  Will the job involve data analysis and modeling? Or data engineering? Or theoretical NLP research? Could anybody share some thoughts?”

I took a stab, here is a  rewritten and extended version:

“It’s a good question, it’s also a tough one to answer well.   In general, it depends on the company you work on.   Let’s say you work in a bigger company which there is a research department, which is separated from standard programming team.   I would also add that some NLP engineers are actually managers.  So their role was mostly general organization of the activity of a team.

If you minus pure coding and pure programming task,  I would say there are usually 2 types of task you will encounter:

  1. NLP component update and improvement:  e.g. Say you are working on a word sense disambiguation routine.   Through data collection, you were able to increase the amount of the data by 10 times, so your boss assign you to re-train the existing SVM which you trained a while ago.     Your job in this case, is not that different from HW3 (Arthur: i.e. a WSD exercise using machine learning) : you are going to massage the data, train a model, benchmark it and present it to your group.  Hopefully and eventually deploy it to real-life.
  2. Integration: Now suppose you are more coding-oriented, then it’s possible that you are asked to incorporate a pre-existing program written by your colleagues.   So your major task is to be the one who is responsible for such process.   Note that this requires different skill set from a vanilla programmer, you do need to understand the underlying NLP technology quite well to integrate an NLP component.   Of course, there will be issues remained from your more research oriented colleague to you.  That includes speed or memory optimization, etc.

Both task 1 or 2 can be infinitely complex and difficult in real-life.  e.g. You might be handed a task which is very difficult to improve upon.  May be because previous research has exhausted most of the routes of improvement.   Then in that case, you will play the role of pure researcher and think up new methods to improve the task.  Or if you are working on modeling, then significant amount of your time would be spent on modeling, tending different experiments, as well as data preparation (see below).

Similarly, in task 2, you can be handed with a program which consists of 100k+ lines of C/C++ code.  You need to take care of all system-related issues, pop up gdb and spend couple of waking time to fix a multi-thread program.   Or you will need to make sure the plumbing of your application works with your researcher colleague.   Those are also difficult skills which take years to refine.

In my case, I am more an integrator on speech recognition components.    I also do quite a dose of R&D on other ML components (see this post).    In the past, my role was more on the pure research side.   For example, my BBN role was a kind of experimenter to work on unsupervised topic detection.

In any case,  I think Prof Radev’s class presents students a very good summary of what real-life NLP people do.  Because we are mostly try to practice on task 1 and task 2.

There are perhaps two exceptions of task 1 and 2:

  1. First exception I would mention is data preparation.  Normally you will have to prepare data yourself.  The very nice thing happens in our homework that a TA wrote a working XML parser for input data?  It seldom happens.   That explains why many people claim “data preparation is 80% of machine learning.
  2. The second exception is you might ask to analyze and present your results. i.e. data analysis.   Analysis is more the arena of statistics and data science.    It is also an important skill.  But in my experience, product-oriented engineers are spending less time on those aspects.  Because most of the time you are either researching or developing the product.  Your analytical skill is mostly used when you are stuck.   For example, I seldom use data analysis in my work (descriptive? exploratory? casual?) unless I saw a rare phenomenon.    But a data scientist is more likely to use those skills daily. “

Arthur

Categories
Dan Jurafsky Dependency Parsing Dragomir Radev HMM Language Modeling Machine Learning Natural Language Processing Parsing POS tagging Programming Python SMT Word Sense Disambiguation

Radev’s Coursera Introduction to Natural Language Processing – A Review

As I promised earlier, I was going to review Prof.  Dragomir Radev’s introductory class on natural language processing.   Few words about Prof. Radev: from his Wikipedia entry, Prof Radev is an award winning Professor, who co-found North American Computational Linguistics Olympiad (NACLO), which is the equivalent of USAMO in computational linguistics. He was also the coach of U.S. coach of International Language Olympiad 2011 and helped the team won several medals [1].    I think these are great contributions to the speech and language community.  In late 90s, when I was still in undergraduate, there was not much recognition of computational language processing as an important computation skill.    With competition in high-school or college level, there will be a generation of young minds who would aspire to build intelligent conversation agent, robust speech recognizer and versatile question and answering machine.   (Or else everyone would think Linux kernel is the only cool hack in town. 🙂 )

The Class

So how about the class?  I got to say I am more than surprised and happy with it.   I was searching for an intro NLP class, so the two natural choices was Prof. Jurafsky’ and Manning’ s and Prof.  Collin’s Natural Language Processing.   Both classes received great praise and comments and few of my friends recommend to take both.   Unfortunately, there was no class offering recently so I could only watch the material off-line.

Then there comes the Radev’s class,  it is as Prof. Radev explains: “more introductory” than Collin’s class and “more focused on Linguistics and resources” than Jurafsky and Manning.   So it is good for two types of learners:

  1. Those who just started out in NLP.
  2. Those who want to gather useful resources and start projects on NLP.

I belong to both types.   My job requires me to have more comprehensive knowledge of language and speech processing.

The Syllabus and The Lectures

The class itself is a brief survey of many important topics of NLP.   There are the basics:  parsing, tagging, language modeling.  There are the advanced topics such as summarization, statistical machine translation (SMT), semantic analysis and dialogue modeling.   The lectures, except occasionally mistakes, are quite well done and filled with interesting examples.

My only criticism is perhaps the length of videos, I would hope that most videos I watch would be less than 10 minutes.    That makes it easier to rotate with my other daily tasks.

The material is not too difficult to absorb for newcomers.   For starter, advanced topic such as  SMT is not covered in too much detail mathematically.  (So no need to derive EM on IBM models.)  That I think it’s quite appropriate for first time learners like me.

One more unique feature of the lectures: it fills with interesting NACLO problems.    While NACLO is more a high-school level competition, most of the problems are challenging even for experienced practitioners.  And I found them quite stimulating.

The Prerequisites and The Homework Assignments

To me, the fun part is the homework.   There were 3 of them, they focus on,

  1. Nivre’s Dependency Parser,
  2. Language Modeling and POS Tagging,
  3. Word Sense Disambiguation

All homework are based on python.   If you know what you are doing, they are not that difficult to do.   For me, I spent around 12-14 hours on each.   (Those are usually weekends.) Just like Ng’s Machine Learning class,   you need to match numbers with  the golden reference.   I think that’s the right approach to learn any machine learning task the first time.   Blindly come up with a system and hope it works never get you anywhere.

The homework does speak about an issue of the class, i.e. you do need to know the basics of Machine Learning .  Also, if you never had any programming experience would find the homework very difficult.   This probably described many linguistic students but never take any computer science classes.  [3]    You can still “power it through” and pass.  But it can be unnecessarily hard.

So I will recommend you first take the Ng’s class or perhaps the latest Machine Learning specialization from Guestrin and Fox first.   Those are the classes which would give you some basics of programming as well as basic concept of Machine Learning.

If you didn’t take any machine learning class, one way to go through more difficult classes like this is to read forum messages.   There are many nice people in the course was answering various questions.   To be frank, if the forum doesn’t exist, then it will take me around 3 times more time to finish all assignments.

Final Word

All-in-all, I highly recommend Prof. Radev’s class to anyone who is interested in NLP.    As I mentioned though, the class does require prerequisite such as basics of programming and machine learning.   So  I would recommend any learners to first take the Ng’s class before taking this one.

In any case, I want to thank Prof. Radev and all teaching staffs who prepare this wonderful course.   I also thank to many classmates who help me through the homework.

Arthur

Postscript at 2017 April

After I wrote this review, Coursera had since upgraded to the new format.  It’s a pity none of the NLP classes, including Prof. Radev’s survive.   To bad for NLP lovers!

There is also a seismic shift in the field of NLP toward deep learning. While deep learning does not dominate evaluations like in computer vision or speech recognition, it is perhaps the most actively researched direction right now.  So if you are curious about what’s new, consider to take the latest Standford cs224n 2017 or Oxford’s Deep Learning for NLP.

[1] http://www.eecs.umich.edu/eecs/about/articles/2010/Radev-Linguistics.html

[2] Week 1 Lecture 1 Introduction

[3] One anecdote:  In the forum, some students was asking why you can’t just sum all data points of a class together and pour into scikit-learn’s fit().    I don’t blame the student because she started late and lacks of prerequisite.   She later finished all assignment and I really admire her determination.