Bag of Tricks for Efficient Text Classification
1–10 of 16 posts
Re: Bag of Tricks for Efficient Text Classification
#2Re: Bag of Tricks for Efficient Text Classification
#3How a sequence of words is feeded to non-recurrent network?
Re: Bag of Tricks for Efficient Text Classification
#4How a sequence of words is feeded to non-recurrent network?
They represent the sequence as a bag of n-grams, and feed that into the classifier, rather than feeding the sequence directly. The paper basically combines variants on a few old techniques (although a few of the variants are significant and recent), but the interesting result is that they show that put together in the right way and tweaked a little, they're competitive in accuracy with state-of-the-art deep neural ne…
Re: Bag of Tricks for Efficient Text Classification
#5Other researchers have noted[2] that with a set of command line flags that vw is almost the same as the system described in the paper, specifically, "vw --ngrams 2 --log_multi [K] --nn 10".
Behind the speed of both methods is use of ngrams^, the feature hashing trick (think Bloom filter except for features) that has been the basis of VW since it began, hierarchical softmax (think finding an item in O(log n) using a balanced binary tree instead of an O(n) array traversal) and using a shallow instead of deep model.
I am still interested in the more detailed insights the team from Facebook AI Research may provide but the initial paper is a little light and they're still in the process of releasing the source code.
^ Illustrating ngrams: "the cat sat on the mat" => "the cat", "cat sat", "sat on", "on the", "the mat" - you lose complex positional and ordering information but for many text classification tasks that's fine.
[1]: https://github.com/JohnLangford/vowpal_wabbit/wiki
[2]: https://twitter.com/haldaume3/status/751208719145328640
Re: Bag of Tricks for Efficient Text Classification
#6For anyone who is interested in efficiently classifying text, I can't recommend Vowpal Wabbit[1] (VW) enough. It's blazingly fast and has been used in both production and research. It also has a billion options out of the box for various different set-ups. Other researchers have noted[2] that with a set of command line flags that vw is almost the same as the system described in the paper, specifically, "vw --ngrams 2…
Re: Bag of Tricks for Efficient Text Classification
#7For anyone who is interested in efficiently classifying text, I can't recommend Vowpal Wabbit[1] (VW) enough. It's blazingly fast and has been used in both production and research. It also has a billion options out of the box for various different set-ups. Other researchers have noted[2] that with a set of command line flags that vw is almost the same as the system described in the paper, specifically, "vw --ngrams 2…
Thanks for the detailed comment! It's interesting that simple and classical techniques are so competitive for text, but not for images. What do you think is different about text that makes simple methods so effective, or equivalently what is different about images that yields such massive improvements from using convolutional deep neural nets?
For many languages, and many tasks performed on these languages, features have already been discretely provided. If you take English, split on the space character, and then throw those into a standard classifier (Naive Bayes, SVM, logistic regression), you're likely to get a reasonable result. If you add n-grams, so a little bit of collocation information, you tend to do even better. For most tasks, you may even make the simplifying assumption that features don't even interact at all. Even naive use of these methods will get you 90% of the way in many NLP tasks with very little computational overhead (as is evidence in this article).
For other languages, generating those features is a more complicated matter. Chinese is written without spaces between words for example. Extracting such discrete features from there requires an extra step in the pipeline. The way in which you split the characters can also depend on context, requiring an interaction between these components. This interaction is very iffy when it's in a pipeline and you don't have gradients flowing end to end, as is the case with most deep learning systems.
Images are far more like the latter case. There are few discrete features that can be easily extracted from images. Images are also scarily high dimensional - the number of pixels, the number of colours, the interaction between pixels, etc. Using human generated methods of feature extraction on this is fraught with a lot of complicated hand tuning and a lot of misses.
tldr; Text, by virtue of being human generated, is far more structured and far more amenable to easily extracting discrete representative features. For images, we just never really found a highly effective way of producing discrete representative features by hand. Deep learning, by virtue of providing the feature extraction in an automated manner directed by the loss on the task, has helped solve a major issue that plagued computer vision.
Re: Bag of Tricks for Efficient Text Classification
#8For anyone who is interested in efficiently classifying text, I can't recommend Vowpal Wabbit[1] (VW) enough. It's blazingly fast and has been used in both production and research. It also has a billion options out of the box for various different set-ups. Other researchers have noted[2] that with a set of command line flags that vw is almost the same as the system described in the paper, specifically, "vw --ngrams 2…
Thanks for the detailed comment! It's interesting that simple and classical techniques are so competitive for text, but not for images. What do you think is different about text that makes simple methods so effective, or equivalently what is different about images that yields such massive improvements from using convolutional deep neural nets?
Now look at a bag-of-words view of a movie review:
set(['and', 'predecessor,', 'immersive;', 'script,', 'is', 'an', 'engaging', 'as', 'home', 'still', 'its', 'film', 'identity.', 'puts', 'dazzling', 'issues', 'visually', 'colorful', 'While', 'not', 'spin', 'on', 'of', 'while', 'the', 'predictable,'])
It's not certain, but there's definitely a lot more information there.The predict loop of a linear model works like this (written with sparse vectors, implemented as dictionaries):
def predict(classes, weights, features):
scores = {clas: 0 for clas in classes}
for feature in features:
for clas, weight in weights[feature].items():
scores[clas] += weight
return max(scores, key=lambda clas: scores[clas])
This function is the same for Naive Bayes, Maximum Entropy, linear-kernel SVM, Averaged Perceptron...etc.All you get to do is attach a weight to each feature, which you'll sum. You can make the features larger or smaller slices of the input, but that's all the structure you get.
Note that linear models have massive disadvantages for speech recognition, too. Linear models don't work very well if you have an analog signal.
Re: Bag of Tricks for Efficient Text Classification
#9Earlier quoted context omitted.
Thanks for the detailed comment! It's interesting that simple and classical techniques are so competitive for text, but not for images. What do you think is different about text that makes simple methods so effective, or equivalently what is different about images that yields such massive improvements from using convolutional deep neural nets?
Imagine looking at an image as a "bag of pixels": shuffle them all up, and look at the resulting image. What do you see? Nothing useful, right? Now look at a bag-of-words view of a movie review: set(['and', 'predecessor,', 'immersive;', 'script,', 'is', 'an', 'engaging', 'as', 'home', 'still', 'its', 'film', 'identity.', 'puts', 'dazzling', 'issues', 'visually', 'colorful', 'While', 'not', 'spin', 'on', 'of', 'while'…
Re: Bag of Tricks for Efficient Text Classification
#10For anyone who is interested in efficiently classifying text, I can't recommend Vowpal Wabbit[1] (VW) enough. It's blazingly fast and has been used in both production and research. It also has a billion options out of the box for various different set-ups. Other researchers have noted[2] that with a set of command line flags that vw is almost the same as the system described in the paper, specifically, "vw --ngrams 2…
Thanks for the detailed comment! It's interesting that simple and classical techniques are so competitive for text, but not for images. What do you think is different about text that makes simple methods so effective, or equivalently what is different about images that yields such massive improvements from using convolutional deep neural nets?
The basic idea is how can you start reducing the pattern space. So, for images, don't consider all colors and only consider brightness.