{"id":943,"date":"2017-11-30T11:49:51","date_gmt":"2017-11-30T16:49:51","guid":{"rendered":"http:\/\/haleyai.com\/wordpress\/?p=943"},"modified":"2018-07-14T17:18:38","modified_gmt":"2018-07-14T22:18:38","slug":"simple-fast-effective-active-learning","status":"publish","type":"post","link":"http:\/\/haleyai.com\/wordpress\/2017\/11\/30\/simple-fast-effective-active-learning\/","title":{"rendered":"Simple, Fast, Effective, Active Learning"},"content":{"rendered":"<p>Recently, we \u201cread\u201d ten thousand recipes or so from a cooking web site.\u00a0 The purpose of doing so was to produce a formal representation of those recipes for use in temporal reasoning by a robot.<\/p>\n<p>Our task was to produce ontology by reading the recipes subject to conflicting goals.\u00a0 On the one hand, the ontology was to be accurate so that the robot could reason, plan, and answer questions robustly.\u00a0 On the other hand, the ontology was to be produced automatically (with minimal human effort).<a href=\"#_ftn1\">[1]<\/a><\/p>\n<p>In order to minimize human effort while still obtaining deep parses from which we produce ontology, we used more techniques from statistical natural language processing than we typically do in knowledge acquisition for deep QA, compliance, or policy automation.\u00a0 (Consider that NLP typically achieves less than 90% <span style=\"text-decoration: underline;\">syntactic<\/span> accuracy while such work demands near 100% <span style=\"text-decoration: underline;\">semantic<\/span> accuracy.)<a href=\"#_ftn2\">[2]<\/a><\/p>\n<p>In the effort, we refined some prior work on representing words as vectors and semi-supervised learning.\u00a0 In particular, we adapted semi-supervised, active learning similar to <a href=\"http:\/\/www.anthology.aclweb.org\/W\/W15\/W15-1511.pdf\">Stratos &amp; Collins 2015<\/a> using enhancements to the canonical correlation analysis (CCA) of <a href=\"http:\/\/www.jmlr.org\/papers\/volume16\/dhillon15a\/dhillon15a.pdf\">Dhillon et al 2015<\/a> to obtain accurate part of speech tagging, as conveyed in the following graphic from Stratos &amp; Collins:<\/p>\n<p><a href=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/Stratos-POS-tagging-using-active-learning-over-CCA-word-embeddings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-944\" title=\"Stratos POS tagging using active learning over CCA word embeddings\" src=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/Stratos-POS-tagging-using-active-learning-over-CCA-word-embeddings.png\" alt=\"\" width=\"387\" height=\"289\" srcset=\"http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/Stratos-POS-tagging-using-active-learning-over-CCA-word-embeddings.png 387w, http:\/\/haleyai.com\/wordpress\/wp-content\/uploads\/Stratos-POS-tagging-using-active-learning-over-CCA-word-embeddings-300x224.png 300w\" sizes=\"auto, (max-width: 387px) 100vw, 387px\" \/><\/a><\/p>\n<h2><!--more-->Parts of Speech<\/h2>\n<p>In many NLP pipelines, a \u201cparser\u201d receives its input from the output of a part of speech \u201ctagger\u201d.\u00a0 Most typically in such pipelines, the tagger outputs one part of speech tag for each token (e.g., word) in the input.<\/p>\n<p>We typically permit all the possible parts of speech to be considered during parsing rather than pruning some parts of speech during tagging.\u00a0 This allows us to find the right parse for many sentences that would otherwise be missed.\u00a0 For example, if a part of speech tagger selects the right tag 95% of the time, 1 out of 20 words will have the wrong tag.\u00a0 For text that contains an average of 15 or more words per sentence, relying on such tagging results in parsing failures for too many sentences.<\/p>\n<p>Our client accepted that a more automated approach could not rival curated parses.\u00a0 But we agreed to minimize the initial use of human effort in a phase I approach.\u00a0 Thus, we needed to estimate the probabilities of parts of speech for a domain-specific vocabulary (i.e., for cooking).<\/p>\n<p>The typical part of speech <a href=\"https:\/\/en.wikipedia.org\/wiki\/Part-of-speech_tagging\">tagger<\/a> uses a hidden Markov model (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Hidden_Markov_model\">HMM<\/a>) trained over a large <a href=\"https:\/\/en.wikipedia.org\/wiki\/Brown_Corpus\">corpus<\/a> of manually tagged text.\u00a0 Our task constraints precluded the human effort to tag much of the recipe text, however.<\/p>\n<p>We needed a method that minimized the investment required for such \u201csupervised\u201d learning\u2026<\/p>\n<h2>Simple Semi-Supervised POS Tagging<\/h2>\n<p>Stratos and Collins\u2019 MINITAGGER demonstrated the use of active learning to achieve state of the art accuracy while requiring an astonishingly small fraction of the human tagging effort of other approaches.\u00a0 There are few reasons for this impressive result, especially the use of fairly low-dimensional word-embeddings with efficient support vector machinery (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Support_vector_machine\">SVM<\/a>).<\/p>\n<h2>Distributed Representations of Words<\/h2>\n<p>There is a lot of literature on distributed representation of words.\u00a0 Typically, such representations are points in a high-dimensional space in which \u201csimilar\u201d words are \u201cclose\u201d.\u00a0 Such representations include <a href=\"https:\/\/www.tensorflow.org\/tutorials\/word2vec\">Word2Vec<\/a> and <a href=\"https:\/\/nlp.stanford.edu\/projects\/glove\/\">GloVe<\/a>.\u00a0 The former vectors were obtained using neural networks while the latter were derived from co-occurrence matrices (from which GloVe derives the co-occurrence probabilities which are the basis for the algorithm).<\/p>\n<p>In some ways, the distributed representation of words is similar to the use of latent semantic analysis (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Latent_semantic_analysis\">LSA<\/a>) to represent the meaning of documents as vectors.\u00a0 LSA, in turn, is similar to principal components analysis (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Principal_component_analysis\">PCA<\/a>), except that LSA uses term\/document frequencies rather than term co-variance.\u00a0 Both use singular value decomposition (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Singular-value_decomposition\">SVD<\/a>) which is also used in canonical correlation analysis (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Canonical_correlation\">CCA<\/a>).<\/p>\n<h2>Canonical Correlation Analysis (CCA)<\/h2>\n<p>CCA determines relationships between two <a href=\"https:\/\/onlinecourses.science.psu.edu\/stat505\/node\/63\">sets of variables<\/a> without considering either set as dependent or independent, per se. In the case of word embeddings, the vector representations of words comprise one set of variables and the contexts in which those words occur comprise the other.<\/p>\n<p>How we define the context of a word can vary. \u00a0A context of the immediately preceding word would correspond to a bigram model, one word to each side would correspond to a trigram model, etc.\u00a0 We stuck with the window size of 5 as in the Stratos &amp; Collins and Dhillon et al papers.\u00a0 Longer window sizes do not improve performance on syntactic tasks like part of speech tagging but do provide better representation of semantics for tasks like word sense disambiguation, as suggested in <a href=\"https:\/\/nlp.stanford.edu\/pubs\/glove.pdf\">Pennington et al 2014<\/a>.<a href=\"#_ftn3\">[3]<\/a><\/p>\n<p>Computing the co-occurrence matrices for a vocabulary of V words requires on the order of V<sup>3<\/sup> cells.\u00a0 For our target of at least 300,000 \u201cwords\u201d in a multi-giga-word corpus, that\u2019s a large number!<a href=\"#_ftn4\">[4]<\/a> We adapted Dhillon\u2019s spectral learning toolkit (<a href=\"https:\/\/github.com\/paramveerdhillon\/swell\">swell<\/a>) and its use of the C++ linear algebra package <a href=\"http:\/\/eigen.tuxfamily.org\/index.php?title=Main_Page\">Eigen<\/a> to get past some memory issues and produced various sets of word vectors of dimensionality from 50, as used in Stratos &amp; Collins to 300, as in GloVe and other representations.<a href=\"#_ftn5\">[5]<\/a><\/p>\n<p>We evaluated the longer ones subjectively and found them to be state of the art, as expected given <a href=\"http:\/\/www.jmlr.org\/papers\/volume16\/dhillon15a\/dhillon15a.pdf\">Dhillon et al 2015<\/a>.\u00a0 We used the shorter ones to train a support vector machine (SVM) roughly as in MINITAGGER and as described below.<\/p>\n<p>We also experimented with a variety of techniques to improve the resulting word vectors, including tokenization of several dozen different kinds of tokens (e.g., numbers or identifiers of various types, dates, times) and careful consideration of case rather than ubiquitous case folding.\u00a0 These adjustments to the co-occurrence matrices resulted in subjectively superior word vectors in smaller dimensionality or when given a smaller corpus.\u00a0 (The selected corpus has only a few million words for 10,000 recipes.)<\/p>\n<h2>Support Vector Machine (SVM)<\/h2>\n<p>Using the <a href=\"https:\/\/www.csie.ntu.edu.tw\/~cjlin\/liblinear\/\">libSVM<\/a> package and the following features, most of which are as in MINITAGGER (albeit within a Java package), we enjoyed the performance of the resulting active learning system, which would be impractical using less rapidly trainable alternatives, as suggested in <a href=\"http:\/\/www.anthology.aclweb.org\/W\/W15\/W15-1511.pdf\">Stratos &amp; Collins 2015<\/a>.<\/p>\n<ul>\n<li>One of several case features for the focal word<\/li>\n<li>One of several token type features for the focal word<\/li>\n<li>Prefixes and suffixes up to length 4 of the focal word<\/li>\n<li>50-dimensional eigen vectors for each of 5 words<\/li>\n<li>Optional part of speech for each of 5 words<\/li>\n<\/ul>\n<p>So now we can take a modest corpus in new domains and train an excellent part of speech tagger very easily.\u00a0 And we can improve its performance as much as needed using active training.<\/p>\n<h2>Further Reading<\/h2>\n<p>For more background, see our recent post, <a href=\"http:\/\/haleyai.com\/wordpress\/2017\/11\/27\/of-kahlman-filters-and-hidden-markov-models\/\">Of Kalman Filtering and Hidden Markov Models<\/a>, especially the comments by authors from BBN on the need for such active learning in some contexts.<\/p>\n<p>Also consider the following from <a href=\"http:\/\/www.jmlr.org\/papers\/volume16\/dhillon15a\/dhillon15a.pdf\">Dhillon et al 2015<\/a>:<\/p>\n<ul>\n<li>The most classic and successful algorithm for learning word embeddings is Latent Semantic Analysis (LSA), which works by performing SVD on the word by document matrix.<\/li>\n<li>Unfortunately, the state-of-the-art embedding methods suffer from a number of short-comings:\n<ul>\n<li>They are slow to train (especially, the Deep Learning based approaches).<\/li>\n<li>They are sensitive to the scaling of the embeddings (e.g., LSA\/PCA)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>And the following from <a href=\"https:\/\/pdfs.semanticscholar.org\/f00b\/1ef1014b4ef66846383fc2743776e510aed8.pdf\">Rastogi et al 2015<\/a> (<a href=\"http:\/\/www.cs.jhu.edu\/~prastog3\/mvlsa\/mvlsa_poster.pdf\">poster<\/a>):<\/p>\n<ul>\n<li>LSA is an application of PCA to a single term-document co-occurrence matrix. CCA learns linear projections that are maximally correlated to each other from two views, Generalized CCA is a family of extensions of CCA to maximize correlation across multiple views.<\/li>\n<li>Multiview LSA is a way of utilizing hundreds of data sources to learn representations for millions of words\/phrases that outperform baselines like Word2Vec and Glove.<\/li>\n<\/ul>\n<hr size=\"1\" \/><a href=\"#_ftnref1\">[1]<\/a> There were other challenges, one of which was the unique vocabulary of cooking, including various words and phrases from multiple languages.\u00a0 Another was the lack of grammatical structure in the web site content.\u00a0 The content was much less formal than Wikipedia and not much more formal than Twitter.\u00a0 It was rife with spelling errors, little or no discernable grammar, odd formatting, punctuation, etc.<\/p>\n<p><a href=\"#_ftnref2\">[2]<\/a> <a href=\"https:\/\/nlp.stanford.edu\/~manning\/papers\/tagging.pdf\">Toutanova et al 2003<\/a> describe the Stanford POS tagger as follows: \u201c\u2026 a part-of-speech tagger with a per-position tag\u00a0 accuracy\u00a0 of\u00a0 97.24%,\u00a0 and\u00a0 a\u00a0 whole-sentence\u00a0 correct rate of 56.34% on Penn Treebank WSJ data.\u00a0 This is the best automatically learned part-of-speech tagging result known to us\u2026\u201d<\/p>\n<p><a href=\"#_ftnref3\">[3]<\/a> The GloVe paper demonstrated that an asymmetric window (i.e., shifted \u201cleft\u201d) does not work as well for syntactic tasks, such as part of speech tagging (as seems intuitive and as suggested in Tautanova et al 2003).<\/p>\n<p><a href=\"#_ftnref4\">[4]<\/a> The cooking corpus had only a few million words, so a much smaller \u201cvocabulary\u201d was fine there.<\/p>\n<p><a href=\"#_ftnref5\">[5]<\/a> MINITAGGER is written in Python and uses MATLAB which we needed to replace for commercial reasons.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, we \u201cread\u201d ten thousand recipes or so from a cooking web site.\u00a0 The purpose of doing so was to produce a formal representation of those recipes for use in temporal reasoning by a robot. Our task was to produce ontology by reading the recipes subject to conflicting goals.\u00a0 On the one hand, the ontology &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/haleyai.com\/wordpress\/2017\/11\/30\/simple-fast-effective-active-learning\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Simple, Fast, Effective, Active Learning&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[195,16],"tags":[720,726,736,722,739,895,214,729,738,741,735,742,723,740,721],"class_list":["post-943","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-natural-language","tag-active-learning","tag-cca","tag-eigen","tag-glove","tag-lsa","tag-machine-learning","tag-nlp","tag-part-of-speech-tagging","tag-pca","tag-support-vector-machines","tag-svd","tag-svm","tag-word-embeddings","tag-word-vectors","tag-word2vec"],"_links":{"self":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/comments?post=943"}],"version-history":[{"count":10,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/943\/revisions"}],"predecessor-version":[{"id":1511,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/posts\/943\/revisions\/1511"}],"wp:attachment":[{"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/media?parent=943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/categories?post=943"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/haleyai.com\/wordpress\/wp-json\/wp\/v2\/tags?post=943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}