<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Intuition Engineering on Medium]]></title>
        <description><![CDATA[Stories by Intuition Engineering on Medium]]></description>
        <link>https://medium.com/@intuition.engin?source=rss-e4a84f435807------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T44lpmVcMgkzDy9E2mTalQ.jpeg</url>
            <title>Stories by Intuition Engineering on Medium</title>
            <link>https://medium.com/@intuition.engin?source=rss-e4a84f435807------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 07:46:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@intuition.engin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Chars2vec: character-based language model for handling real world texts with spelling errors and…]]></title>
            <link>https://medium.com/hackernoon/chars2vec-character-based-language-model-for-handling-real-world-texts-with-spelling-errors-and-a3e4053a147d?source=rss-e4a84f435807------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3e4053a147d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Intuition Engineering]]></dc:creator>
            <pubDate>Thu, 28 Feb 2019 07:46:20 GMT</pubDate>
            <atom:updated>2019-07-24T07:49:34.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAvyOmNO4q1PAa-qEyrc5g.jpeg" /></figure><h3>Chars2vec: character-based language model for handling real world texts with spelling errors and human slang</h3><p>This paper describes our open source character-based language model <a href="https://github.com/IntuitionEngineeringTeam/chars2vec"><strong>chars2vec</strong></a>. This model was developed with Keras library (TensorFlow backend) and now is available for Python 2.7 and 3.0+.</p><h3>Introduction</h3><p>Creating and using word embeddings is the mainstream approach for handling most of the NLP tasks. Each word is matched with a numeric vector which is then used in some way if the word appears in text. Some <strong>simple models use one-hot word embeddings or initialise words with random vectors or with integer numbers</strong>. The drawback of such models is obvious – such word vectorisation methods do not represent any semantic connections between words.</p><p>There are <strong>other language models, called semantic, collating words related by sense with the affine embedding vectors</strong>. In fact these models represent contextual proximity of various words: such models are trained on a large corpora of existing texts such as encyclopedias, news texts or literature. The result is that the words appearing in similar contexts in these texts are represented by proximal vectors. The classic examples of semantic language models are <a href="https://www.tensorflow.org/tutorials/representation/word2vec">Word2Vec</a> and <a href="https://nlp.stanford.edu/projects/glove/">GloVe</a>. Some of the more modern semantic language models (<a href="https://arxiv.org/abs/1801.06146">ULMFiT</a>, <a href="https://allennlp.org/elmo">ELMo</a>) are based on the recurrent neural networks (RNNs) and on other neural network architectures.</p><p>Semantic models contain some information about the sense of words extracted while training on large texts corpora but they operate with a fixed vocabulary (usually lacking some rarely used words). This is a significant drawback for solving some of NLP problems. <strong>If a number of important words in a text does not belong to the vocabulary of a semantic language model then it is non-efficient in solving some kinds of NLP tasks — the model won’t be able to interpret these words</strong>. Such a case could arise if we try to process texts written by humans (these could be replies, comments, applications, documents or posts in web). These texts could contain slang, some rare words from specific areas, or given names which are not presented in language vocabulary and, accordingly, in semantic models. Typos also produce “new” words without any collated embedding.</p><p>A good example is the task of processing user’s comments to movies while building a movie recommender system based on <a href="https://grouplens.org/datasets/movielens/">MovieLens</a> dataset. Words “like Tarantino” could often be found among peoples comments; errors or typos in director’s surname “Tarantino” produce a number of “new” words like “Taratino”, “Torantino”, “Tarrantino”, “Torontino”, etc. The ability to extract this “Tarantino” feature from users comments would obviously improve movies relevance metric and recommendations quality as well as extraction of various other features represented by non-vocabulary words, either very specific like surnames, or produced by typos and erroneous spelling.</p><blockquote>To solve the problem we have described it would be appropriate to use a language model that would create word embeddings based only on their spelling and would collate similar vectors to similarly spelled words.</blockquote><h3>About chars2vec model</h3><p>We have developed the chars2vec language model based on symbolic embeddings of words. <strong>The model represents each sequence of symbols of arbitrary length with a fixed length vector, the similarity in words spelling is represented by the distance metric between vectors.</strong> This model is not dictionary based (it does not store a fixed dictionary of words with corresponding vector representations), that is why it’s initialisation and usage procedures do not require significant computational resources. Chars2vec library could be installed via pip:</p><pre>&gt;&gt;&gt; pip install chars2vec</pre><p>The following code snippet creates chars2vec embeddings (with dimension 50) and projects these embedding vectors on a plane with the help of PCA, outputting an image depicting the geometrical meaning of the described model:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5115fbf84693f6d481d79aa1b7e4de07/href">https://medium.com/media/5115fbf84693f6d481d79aa1b7e4de07/href</a></iframe><p>Execution of this code produces the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjqy3VkVQK51BXsI7qOv4A.png" /></figure><p>We can see that the similarly spelled words are represented by the neighbouring vectors. Yet the model is based on a recurrent neural network accepting a sequence of symbols of a word, not on analysis of the facts of letters or patterns presence in a word. The more changes such as additions, deletions or replacements we make in a word the further its embedding would stand from the original.</p><h3>Application of character-based models</h3><p>The idea of text analysis on character level is not new — there are models creating embeddings for each symbol and then creating symbolic word embedding with the help of an averaging procedure. The averaging procedure is the bottleneck — such models provide some sort of solutions of the problems stated above, unfortunately, not the optimal ones, because the search of the proper form of each word’s embedding creation from the symbols embedding vectors requires additional training if we want to encode some information about the symbols relative positioning and symbolic patterns besides the mere fact of symbols presence in a word.</p><p>One of the pioneering NLP models processing texts on the character level is <a href="https://github.com/karpathy/char-rnn">karpathy/char-rnn</a>. This model takes some text as an input and trains a recurrent neural network (RNN) to predict the next symbol of a given sequence of characters. There are other RNN based character-level language models such as <a href="https://offbit.github.io/how-to-read/">Character-Level Deep Learning in Sentiment Analysis</a>. In some cases the convolutional neural networks (CNNs) are used to process a sequence of characters, check out <a href="https://arxiv.org/pdf/1508.06615v4.pdf">Character-Aware Neural Language Models</a>, an example of CNNs usage for texts classification could be found in the paper <a href="https://arxiv.org/pdf/1509.01626.pdf">Character-level Convolutional Networks for Text Classification</a>.</p><p>A prime example of a character-based language model is the model implemented in the <a href="https://github.com/facebookresearch/fastText">fastText</a> library by Facebook. The fastText model creates symbolic word embeddings and solves texts classification problem based on their symbolic representation. This technology is based on the analysis of multiple n-grams forming words instead of RNNs which makes this model very sensitive to typos and spelling errors as far as they can significantly change the range of n-grams forming a word. Yet this model provides embeddings of words missing from the language vocabulary.</p><h3>Model architecture</h3><p>Each chars2vec model has a fixed list of characters used for words vectorisation: the characters from this list are represented by various one-hot vectors which are fed to the model when the character appears in the text; the characters absent in the list are ignored in the vectorisation procedure. We trained models designed to process English texts; these models use a list of the most popular of ASCII characters — all English letters, digits and the most popular punctuation:</p><pre>[‘!’, ‘“‘, ‘#’, ‘$’, ‘%’, ‘&amp;’, “‘“, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-’, ‘.’, ‘/’, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘:’, ‘;’, ‘&lt;’, ‘=’, ‘&gt;’, ‘?’, ‘@’, ‘_’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ’n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’]</pre><p>The model is not case sensitive, it converts any symbol’s case to the lower one.</p><p>Chars2vec is implemented with the help of Keras library based on TensorFlow. The neural network creating words embeddings has the following architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*YpwI_8WVXJ329bUyqmC6eQ.jpeg" /></figure><p>A sequence of one-hot vectors of an arbitrary length representing the sequence of characters in a word, passes through two LSTM layers, the output is the embedding vector of the word.</p><p>To train a model we have used an extended neural network including chars2vec model as a part. To be more specific, we are dealing with a neural network taking two sequences of one-hot vectors representing two different words as an input, creating their embeddings with one chars2vec model, calculating the norm of the difference between these embedding vectors and feeding it into the last layer of the network with the sigmoid activation function. The output of this neural network is a number ranging from 0 to 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*0aX4CoKeFrOcVjlC88Tc3w.jpeg" /></figure><p>The extended neural network is trained on pairs of words, in training data a pair of “similar” words is labeled with 0 value, and a pair of “not similar” with 1. In fact we define the “similarity” metric as a number of substitutions, additions and removals of characters that have to be performed to make one word from the other. This brings us to the way of obtaining such training data — it can be generated by taking a multitude of words and then performing various changes upon them to obtain a new set of words. A subset of new words produced by changes in one original word would naturally be similar to this original word and such pairs of words would have label 0. Words from different subsets would obviously have more differences and should be labeled with 1.</p><p>The size of the initial words set, the number of words in each subset, the maximum number of changing operations upon a word within one subset define the result of model training and model’s vectorisation rigidity. The optimal values of these parameters should be chosen regarding the language specifics and the particular task. The other important point is keeping the whole training set balanced (none of the two classes should prevail).</p><p>The second part of the extended neural network has only one edge which weight could be adjusted during training process; this part of the network applies monotonous function to the embedding vectors difference norm. The training dataset dictates that this second part should output 0 for “similar” word pairs and 1 for “not similar”, so while training the extended model the inner chars2vec model learns to form neighbouring embedding vectors for the “similar” word pairs and distant ones for the “not similar” pairs.</p><p>We have trained chars2vec models for English language with embedding dimensions of 50, 100, 150, 200 and 300. The project source code is available in the <a href="https://github.com/IntuitionEngineeringTeam/chars2vec">repo</a> along with the model training and usage examples (we’ve trained the model on our dataset for a new language).</p><h3>Train your own chars2vec model</h3><p>The following code snippet shows the way to train your own chars2vec model instance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1acfdbaa018ae165fa3a73630fa098e9/href">https://medium.com/media/1acfdbaa018ae165fa3a73630fa098e9/href</a></iframe><p>A list of characters model_chars that the model would use for words vectorisation should be defined as well as the model’s dimension dim and path to the model storage folder path_to_model. Training set (X_train, y_train) consists of pairs of “similar” and “not similar” words. X_train is a list of word pairs, and y_train is a list of their binary similarity metric scores (0 or 1).</p><p>It is important that all the characters from the model_chars list should be present in the set of words of the training dataset — if a character is absent or appears very seldom then unstable model behaviour could be observed once this character is met in the test dataset. The reason is that the corresponding one-hot vector has been rarely fed into the model’s input layer and some weights of the model’s first layer have always been multiplied by zero meaning their tuning has never been performed.</p><p>Another advantage of chars2vec model is the ability to solve various NLP problems for an arbitrary language lacking open pertained language models. This model could provide better solutions of some texts classification or clustering problems than classic models if you are processing texts with specific vocabularies.</p><h3>Benchmarks</h3><p>We have performed benchmarking on the IMDb dataset for the reviews classification task using various words embeddings. IMDb is an open dataset of movie reviews which could be positive or negative so it is a binary text classification task with 50k reviews as the training set and 50k set for tests.</p><p>Along with chars2vec embeddings we have tested several prominent embedding models like <a href="https://nlp.stanford.edu/projects/glove/">GloVe</a>, <a href="https://code.google.com/archive/p/word2vec/">word2vec</a> by Google (“pre-trained vectors trained on part of Google News dataset (about 100 billion words). The model contains 300-dimensional vectors for 3 million words and phrases”), <a href="https://fasttext.cc/docs/en/english-vectors.html">fastText</a> (wiki-news model with dimension 300, “1 million word vectors trained on Wikipedia 2017, UMBC webbase corpus and statmt.org news dataset (16B tokens)”).</p><p>The classifier model looks the following way: each review is vectorised by averaging the embedding vectors of all the words comprising it. If a word is out of the model dictionary, a zero vector is assigned to it. We have used a standart tokenisation procedure along with stop words by NLTK library. The classifier we chose was the linearSVM. The table below shows test accuracies for the most popular models we have benchmarked this way. We should point out that our chars2vec model is about 3 oders lighter than the semantic models relying on large vocabularies and still demonstrates quite reasonable results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jllN9CixlFWr6pAr8TEZPA.png" /></figure><p>We see some space for chars2vec model improvements needed to compete with the results of the semantic models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3e4053a147d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/chars2vec-character-based-language-model-for-handling-real-world-texts-with-spelling-errors-and-a3e4053a147d">Chars2vec: character-based language model for handling real world texts with spelling errors and…</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recommender systems with deep learning architectures]]></title>
            <link>https://medium.com/data-science/recommender-systems-with-deep-learning-architectures-1adf4eb0f7a6?source=rss-e4a84f435807------2</link>
            <guid isPermaLink="false">https://medium.com/p/1adf4eb0f7a6</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Intuition Engineering]]></dc:creator>
            <pubDate>Wed, 31 Oct 2018 16:05:25 GMT</pubDate>
            <atom:updated>2018-10-31T16:05:25.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFN_VCDIDlWQtFIMHQx9fg.png" /><figcaption>iki daily feed screenshot</figcaption></figure><p><strong>This post adresses the general problem of constructing a deep learning based recommender system. The particular architecture discribed in the paper is the one powering the new smart feed of the </strong><a href="https://about.iki.ai/"><strong>iki service</strong></a><strong>, pushing your skills on daily basis — to check its performance, please try </strong><a href="https://app.iki.ai/"><strong>product beta</strong></a><strong>.</strong></p><p>If you feel familiar with the general idea of recommender systems, mainstream approaches and would like to go straight to the details of our solution, please skip first two sections of the paper.</p><h3>Introduction</h3><p>Recommender systems have changed the way we interact with lots of services. Instead of providing static data they bring interactive experience, an option to leave your feedback and to personalise the information you are given. A recommender system creates personalised informational flows independently for each user but also takes into account behaviour of all users of a service.</p><p>Often it is impossible for a user to choose among the variety of the given options by checking each of them be that movies in an online cinema, consumer goods in an online store or any other content. In case there is lot of content in a service a user faces the problem of informational overload. One of the ways to solve this problem is taking advantage of the targeted recommendations.</p><p>One of the examples of a service where targeted content plays crucial role is <a href="https://iki.ai/">iki</a>. iki is your personal career and professional consultant powered by machine learning and artificial intelligence related technologies. After a user has defined the areas of his professional interests, iki creates daily content feed developing knowledge and chosen skills with the help of the recommender system with the deep learning architecture described below.</p><h3>A general description of recommender systems problem setting</h3><p>The main objects present in any recommender systems are users U, items R and some interactions between them. These interactions are usually presented as a matrix F(|U|x |R|), each cell containing some information about an interaction — the fact that an item has been viewed / bought, the given rating, like / dislike or something else. Depending on the number of users and items in a system the F matrix can become enormously large. But each user normally gives some ratings or interacts only with a small percent of items in the system which results in a very sparse ratings matrix. It is known that one can reduce the number of independent parameters of a sparse model without a significant loss of information. We come to the problem of the right presentation of the rating data in a recommender system: we have to map each user to some vector space by means of a vector with a fixed length n, n&lt;&lt;|U| and each item — to another vector space by means a vector with a fixed length m, m&lt;&lt;|R|. One of the most popular solutions of this problem is SVD (<a href="https://en.wikipedia.org/wiki/Singular_value_decomposition">Singular Value Decomposition</a>) of the F matrix which gives us two matrices with shapes |U| x n and n x |R| for a given n with their product being the best approximation of the matrix F. The lines of the first matrix are vectors corresponding to users, the lines of the second one are vectors, corresponding to system’s items; let us call these vectors the “SVD embeddings” of users and items correspondingly.</p><p>The <strong>traditional method</strong> of creating prognosis <strong>in recommender systems is</strong> <strong>collaborative filtering</strong>. The main assumption of this method is that users having given similar ratings of some items in the past tend to give similar ratings to other items in the future. One of the most popular methods of solving the collaborative filtering problem is creation of user’s and item’s dense embeddings with the SVD of the initial sparse ratings matrix F. To predict the value of a new rating of user u on item i we have to calculate a scalar product of the corresponding user’s and item’s SVD embeddings.</p><p>There are several open libraries providing instruments for construction of various recommender systems based on users ratings matrix. Among others we could name various methods of matrix factorisation (SVD, Non-negative matrix factorization NMF)<em>, </em>different variations of nearest neighbours algorithm, co-clustering methods, user based and item based models. The examples of such solutions are <a href="http://surpriselib.com/">Surprise library</a> and <a href="https://github.com/lyst/lightfm">LightFM library</a>.</p><p>Besides the information about users interactions with items there usually is some other data in a recommender system describing users and items separately. This data could be variative and heterogeneous — items and users could contain some textual descriptions, numerical characteristics, categorical features, images and other types of data. The way of processing and usage of this data depends on the particular problem and is not a universal part of recommender systems.</p><blockquote><strong>The</strong> <strong>main </strong>properties or<strong> metrics of a recommender system are</strong> recommendations <strong>relevance</strong> and <strong>scalability</strong> in case of really large numbers of users or items. That setting brings the common <strong>recommender system’s architecture consisting of two</strong> sequential <strong>blocks</strong>: <strong>candidates generator</strong>, choosing a relatively small subset from the large items set, and <strong>ranking module</strong>, giving a rating of relevance to user’s interests to each item in the chosen subset. This rating is often used to rank items in the order the user will see them.</blockquote><h3>Deep learning powered recommender system architecture</h3><p>Content based recommender system with a deep learning architecture is closely related to the actual content present in the system. Futher on we shall dive into details of iki recommender system to describe the DL approach.</p><p>In iki user’s interactions with content are views and ratings — a user can like or dislike any content element. An item in our case is a webpage with a blog, an article, a tutorial, a course, or some other content providing professional knowledge. Each content element has textual description or is a text itself.</p><p>Content embeddings are the result of text vectorisation procedure. We used <a href="https://nlp.stanford.edu/projects/glove/">GloVe language model</a> with 300 dimensions to vectorise separate words. GloVe is a language model developed at Stanford University, resembling word2vec (preserving semantic similarity of words). The difference is that besides keeping semantics GloVe takes advantage of the statistical approach, taking in account the number of words occurrence in text corpus.</p><p>We count tf-idf weights of all the occurring words in the text corpus, then the vectors corresponding to content elements are calculated as a weighted sum of GloVe vectors of words in this content element with tf-idf weights.</p><p>A user can add to his profile some information regarding his current and past jobs (such as position name and description of each job). Our system processes this data and extracts a list of professional skills of each user with a special language model <a href="https://towardsdatascience.com/deep-learning-for-specific-information-extraction-from-unstructured-texts-12c5b9dceada">Skills Extractor</a> developed for this purpose. In a nutshell the idea of this model is to learn the semantics of “skills” on the corpus of English CVs and to be able to extract previously unseen skills from an unstructured English text. A user can also add some skills manually. To tune the content feed a user has to select some areas of professional interests on our hierarchical cloud of tags similar to Apple Music mechanics. iki offers several hundreds of professional interests to be selected as a part of user’s content feed. User’s skills and selected tags are used in our recommender system as user’s features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iG7vIW2hp870OQ_W_rEZzg.jpeg" /><figcaption>iki recommender system architecture</figcaption></figure><p>Another set of features used to train our recommender system are content and users embeddings obtained after applying SVD to the user’s ratings matrix. This is not the only usage of the information about ratings and views in the system — we create user’s vector representation describing his viewed and rated content. This is done the following way: having content’s vector representation let us take the minimum, the maximum and the average value of each coordinate on the whole corpus of user’s viewed content. This operation results in three vectors with the same length as the content embeddings. We perform the same operation on the set of liked and disliked content obtaining another 6 vectors with the same length. These dense embeddings are also used as a user’s feature during recommender system training step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtuOyhp3nz_jvgAT_6dPlw.jpeg" /><figcaption>User’s liked, disliked and viewed content in content vector space depicted as a 3D space for simplicity</figcaption></figure><h3>Candidates generation</h3><p>For each tag (content topic) our recommender system creates a separate set of recommendations and, particularly, selects a subset of candidates for further ranking. <strong>The goal of iki recommender system is not only to provide the content on corresponding topic but also to rank content elements by quality and expertise level to fit the resulting feed to each user’s level of expertise</strong>.</p><p>Let us go deeper into details of the candidates generation step. For each tag our system selects candidates for ranking with the help of the following mechanics: the content elements that recently have received particular user’s positive ratings are selected along with the sets of content elements surrounding these selected ones (we take the union of several neighbourhoods in the content embeddings space) are added to the candidates space. We also take in consideration the set of users with similar recent activity on the selected tag (a cosine distance between ratings and views vectors is calculated for this set of users). The set of content elements recently viewed or rated is also added to the set of candidates. Variation of the described neighbourhoods radius provides different number of generated candidates.</p><h3>Candidates ranking</h3><p>For each tag a separate neural network instance is trained and used for content candidates ranking. Each neural net instance is trained and then used for ranking on the content subset corresponding to this tag. The ranking net takes some data about the content element and the user as an input and outputs some number between 1 and -1 as the predicted rating used for the final ranking of the content elements. The model is trained on the set of given ratings and views; each sample of the set is comprised of a user and a content element, the target value is 1 for like, -1 for dislike and 0 if the user just viewed the content without giving it any rating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T09QlePcdOUGkFzR.jpg" /><figcaption>iki ranking neural net architecture</figcaption></figure><p>The ranking net has 6 inputs with different dimensions. The first input takes information about user’s selected tags and his skills which is transformed in a dense user profile embedding in the next layer. This information allows system to take into account other interests (tags) of the particular user while ranking content corresponding to particular interest. There is a finite number of tags in iki so the information about them is encoded with a fixed length binary encoded vector (1 for selected tags, 0 for the rest).</p><p>The skills extracted from user’s CV with SkillsExtractor may be quite variative so we statistically normalise them to eliminate really rare phrases and to end up with a fixed length set. Then we vectorise skills in the same binary way as we have already done with tags. During the periodic recommender system training we update the actual set of skills.</p><p>The next two inputs take user’s vector representations we have described before comprised of the rated and viewed averaged content embeddings. Their outputs are united in the next layer which creates dense user’s embedding in the content embeddings space — we call it dense user preference embedding. These two embeddings are united with the other inputs taking SVD embeddings of content and user as well as the content embedding. The obtained vector is passed forward and goes through several dense layers of the neural net. The activation function of the last net’s layer is tanh which gives us an output value in [-1, 1] corridor.</p><p>The problem of the cold start in iki is solved the following way: for a particular tag without any ratings the system recommends a new user a set of random content elements with significant distance among each other. This provides a variety of quite different content elements for a new user to choose from at the beginning of his experience.</p><h3>Results and model’s benchmark</h3><p>We have tested various recommender system models and combinations (like SVD, NNMF et al.) at the research phase before constructing the final model described above. The model we ended up with obviously shows the best results accuracy on the specific iki dataset. <strong>Providing a meaningful benchmark for a deep learning based recommender system is not a trivial task because the ranking net’s architecture is tailored to a specific type of data</strong> and it is quite obvious that this specific architecture outperforms any interaction matrix based recommender system just as it takes advantage of more data used to form predicted score.</p><p>The other problem is that when you do not have a large enough real user base with all the profile and ratings data, it is hard to simulate the real recommender system performance. You can generate a dataset, but it is no sense in generating a noisy one, so you will tailor some sets of skills and experience and preferences to some users and your recommender system will decode this information and tailor the recommendations to the artificial user profiles you have generated. This approach leaves no room for the real world spontaneous user’s actions processing which really matters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1adf4eb0f7a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/recommender-systems-with-deep-learning-architectures-1adf4eb0f7a6">Recommender systems with deep learning architectures</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RedBlackPy — fast and scalable Series for scientific and quantitative research in Python]]></title>
            <link>https://medium.com/@intuition.engin/redblackpy-fast-and-scalable-series-for-scientific-and-quantitative-research-in-python-cad49b5c6d3?source=rss-e4a84f435807------2</link>
            <guid isPermaLink="false">https://medium.com/p/cad49b5c6d3</guid>
            <category><![CDATA[series]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[research]]></category>
            <dc:creator><![CDATA[Intuition Engineering]]></dc:creator>
            <pubDate>Fri, 10 Aug 2018 12:40:42 GMT</pubDate>
            <atom:updated>2019-03-05T13:36:25.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fv0qVZUNEu1IQVIyQKKivQ.png" /></figure><p>We want to present our brand new open source library <a href="https://intuitionengineeringteam.github.io/RedBlackPy/"><strong>RedBlackPy</strong></a>. Now it is available for Python 3.6+ on MacOS and Linux (Windows in near future).<br>It is distributed under Apache License 2.0. You can easily install it via pip:</p><pre>&gt;&gt;&gt; pip install redblackpy</pre><p>Article structure:</p><ul><li><a href="#ddb6"><strong>Highlights. What is RedBlackPy?</strong></a></li><li><a href="#982d"><strong>Why red-black trees? Simple explanation of red-black trees balancing.</strong></a></li><li><a href="#0c4f"><strong>Series and SeriesIterator. Features, code examples and benchmarks.</strong></a></li></ul><h3>Highlights</h3><p>RedBlackPy is a Python library with data structures based on red-black trees. In some sense, it can be considered as an additional library for <a href="https://pandas.pydata.org/">pandas</a>. Pandas containers are aimed at efficient work with static data, i.e. once you load it, you do not add any more elements or delete them because of computational costs. RedBlackPy, on the opposite, was designed for efficient work with dynamic and ordered data, we include benchmarks for core operations. The other important advantage of RedBlackPy is good scalability. The first release is presented by two classes: <strong>Series </strong>and <strong>SeriesIterator</strong>. For Cython users we have included pxd definitions files for these classes.</p><p><strong>Series </strong>is a mapping data structure to keep 1-d data, which:</p><ul><li>Keeps data in order, sorted by keys.</li><li>Provides fast operations to work with dynamic data: insertion, deletion, get item by key, set item by key.</li><li>Provides all basics numeric data types with a specific number of bits (numpy’s dtype analogue): unsigned integers, signed integers, <br>floating points. Certainly, you can keep any Python objects in this container.</li><li>Provides convinient user interface to work with time series or scientific evaluations: access by any key using interpolation. Interpolation is built into getitem operator and does not use additional memory. Arithmetic operations as for vectors, data shifting over the index.</li></ul><p><strong>SeriesIterator </strong>is an iterator-generator for efficient iterating over multiple <strong>Series </strong>objects. For example, if you’re given a set of Series objects and need to construct an ordered union of keys of these Series then you just need to initialize a <strong>SeriesIterator</strong>. This iterator does not use additional memory to concatenate keys, it generates next value of the union inplace.</p><p>In our team we use these data structures for handling predictive modelling problems and in financial time series analysis tasks.</p><h3>Why Red-black trees?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tK47NRULv-zptbn8MR798Q.png" /><figcaption>Figure 1. Red-black tree example from wikipedia.org. Leaves are noted as NIL.</figcaption></figure><p>Red-black tree is a well-known data structure (for example, C++ STL <strong>map </strong>and <strong>set </strong>are based on red-black trees). There is a lot of information about red-black trees so we would not go through all the details here. We’ll just introduce the main ideas of the concept so that the audience not familiar with this structure will get the idea of the self-balancing logic. Here we assume that our reader is familiar with the basics of binary search trees. <strong>The statements and proofs in this section are not required to understand the following sections.</strong></p><p><strong>Definition 1. </strong><em>Red-black tree is a self-balancing binary search tree which satisfies the following conditions:</em></p><ol><li><em>Each node is either red or black.</em></li><li><em>The root is black.</em></li><li><em>All leaves are black.</em></li><li><em>If a node is red, then both its children are black.</em></li><li><em>Every simple path from the root to any of leaves nodes (NIL on Figure1.) contains the same number of black nodes.</em></li></ol><p>A self-balancing means that insertion and deletion operations include some modifications to keep tree balanced. But what exactly means that a tree is balanced?</p><p><strong>Definition 2. </strong><em>A</em><strong><em> </em></strong><em>binary search tree is said to be </em><strong><em>balanced of order 𝑛 </em></strong><em>if <br>the difference in lengths of the longest simple path and the shortest simple path (each path goes from the root to leaves) equals </em><strong><em>𝑛</em></strong><em>.</em></p><p>Can we color any binary search tree with respect to conditions of <a href="#beaa">Definition 1</a>? The next proposition gives the answer to this question.</p><p><strong>Proposition 1. </strong><em>Let </em><strong>T </strong><em>be a red-black tree</em>. <em>Then </em><strong><em>T </em></strong><em>is balanced of order </em><strong><em>m, <br></em></strong><em>where </em><strong><em>m </em></strong>≤ <strong>height</strong>(<strong>T</strong>)/2.<br><strong>Proof. </strong>Consider arbitrary simple path 𝜸 of length <strong>height</strong>(<strong>T</strong>)<strong> </strong>in <strong>T</strong><em>. </em>Also, consider another simple path 𝜼 from root to arbitrary leave node. According to conditions 2–4 (<a href="#beaa">Definition 1</a>) minimal possible number of black nodes in 𝜸 equals to⎡<strong>height</strong>(<strong>T</strong>)<strong>/</strong>2⎤. At the same time, the maximum possible number of black nodes in path 𝜼 is equal to <strong>length</strong>(𝜼). According to condition 5 we obtain the required assertion. ◀︎</p><p>Now we know that lengths of any two simple paths from the root to leaves nodes in red-black tree differ not more than twice. As the height of a binary search tree defines the complexity of a search operation, the next question appears. What can we say about the height of an arbitrary red-black tree?</p><p><strong>Proposition 2. </strong><em>Let </em><strong>T </strong><em>be a red-black tree with </em><strong><em>n </em></strong><em>nodes</em>. <em>Then</em> <em>the following holds:<br></em><strong>height</strong>(<strong>T</strong>)<em> </em>≤ 2 log(n +1), where log is binary logarithm.<br><strong>Proof. </strong>By Proposition 1 any simple path from root to leaves in <strong>T </strong>has length not less than <strong>height</strong>(<strong>T</strong>)<strong>/</strong>2. Therefore <strong><em>n </em></strong>is not less than number of nodes in the first⎡<strong>height</strong>(<strong>T</strong>)<strong>/</strong>2⎤levels (1st level is the root, 2nd is the root children, etc.).<br>Thus we get obvious lower bound for <strong><em>n </em></strong>and it implies the statement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IvRXAt60X2JsLxrro_9I0A.png" /></figure><p>◀︎</p><p>By <a href="#8d6c">Proposition 2</a> the search operation in red-black trees has logarithmic in size complexity. It turns out that there is an efficient algorithm (logarithmic complexity) to insert or delete a node. This algorithm includes modifications (so called rotations) to keep the tree complying with <a href="#beaa">Definition 1</a>.</p><p>Our choice of the core data structure was initially defined by the problems we have faced in quantitative research. We had defined the objectives through the prism of financial series processing, but the resulting solution could be applied to a bunch of other problems in an obvious way. For instance, if you are working with trading market data, you have multiple time series and their keys do not necessarily coincide. But we know that the current stock state (active orders) equals to the state of the last modification (price change). It means that we have to deal with piecewise constant signals and we naturally come to floor interpolation (see <a href="#398a">Figure 2</a>). From the other side if we are working with an order book, for example, we have a very frequently changing structure and so a fast realization of the insertion and deletion operations is needed. One could briefly define the following objectives:</p><ul><li>Keep data sorted (for interpolation)</li><li>Scalability to process up to millions of items</li><li>Fast modification operations</li><li>Fast items access, fast iterating</li><li>Convenient unconstrained and optimized interpolation methods to construct values inplace. We include several interpolations: floor, ceil, linear, keys only (see docs).</li><li>Convinient iterating over multiple asynchronous time series</li><li>Vector arithmetic operations</li></ul><p>Using arrays and hash tables as the core data structures is very expensive in this case because of frequent memory reallocation, rehashing, data shifting when you insert or delete an element. To avoid these effects we have decided to use self-balancing binary trees.</p><h3>Series and SeriesIterator</h3><p><strong>Note. </strong>In this section we present some benchmarks. All tests have been carried out on a MacBook Pro (Retina, 13-inch, Early 2015) 2,7 GHz Intel Core i5.</p><p>Now let us consider some simple use cases and benchmarks for the main operations. We would like to mention that we do not compete with Pandas Series and it would not be correct to compare RedBlackPy Series and Pandas Series in terms of competition because their core data structures are different. By demonstrating benchmark results we’d like to show that the proper choice of a data structure for specific problem is an important step in the R&amp;D process.</p><h4>Interpolation</h4><p>Interpolation is built into getitem operator. You can initialize Series with the specific interpolation type, you can also change it after initialization. Interpolation does not create a new item, it uses neighbours to calculate a value inplace (see <a href="#398a">Figure 2</a>). The code example listed below shows how interpolation works. :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8bfc0555166b50740fe4246abf9d27c/href">https://medium.com/media/c8bfc0555166b50740fe4246abf9d27c/href</a></iframe><p>The figure below schematically describes interpolation logic. Assume we’ve got a discrete signal with 5 points. By making a query for a value of some key we obtain different results depending on interpolation type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NbewkecbrkSJcnPD7ZP17Q.png" /><figcaption>Figure 2. Interpolation examples. The initial data is presented by a discrete signal with 5 points.</figcaption></figure><h4>SeriesIterator</h4><p>The <strong>SeriesIterator</strong> class provides efficient iterating over a sorted union of keys of multiple Series objects. This class is also based on the red-black tree concept. Red-black tree is used as min-heap in case of forward iterator and as max-heap in case of reversed iterator. This heap uses <strong>k </strong>memory cells, where <strong>k </strong>is the number of Series objects. The figure below schematically describes the work of <strong>SeriesIterator</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8qMTLV9KdtH9nDG1qzmRVw.png" /></figure><p>Now let us create ten Series objects with random data and evaluate the execution time of an iteration loop. In the code snippet below we create <strong>SeriesIterator </strong>from the list of Series, each Series object contains 100 000 items. After initialization we are iterating over the sorted union of keys of these Series objects forward and backward.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afbfbd0d05649ffecceb83f8ce79455d/href">https://medium.com/media/afbfbd0d05649ffecceb83f8ce79455d/href</a></iframe><p>For ten Series objects each containing 100 000 elements, forward and reverse loops took 0.95 seconds and 0.92 seconds respectively. This time has been obtained on MacBook Pro (Retina, 13-inch, Early 2015).</p><h4>Core operations benchmarks</h4><p>We shall provide test results for some simple code snippets to show the main difference between two data structures, specifically between Pandas.Series and RedBlackPy.Series.</p><p>Each function is tested on containers of the following sizes: 10³, 10⁴, 10⁵, 10⁶.<br>To plot the results we have used logarithmic scale of the time axis.</p><p>As we can see in the results below RedBlackPy outperforms Pandas in insertion, deletion and search (get item) operations. For instance, iterating over a list of one million keys and calling getitem operator took 11.8 seconds for Pandas.Series and 2.7 seconds for RedBlackPy.Series in case of random list of keys. But Pandas outperforms RedBlackPy in iterating over Series because of continuous memory allocation. For the same reasons arithmetic operators work in RedBlackPy slower than in Pandas. Modern processors support vector instructions (SSE, AVX) and usage of aligned and continuous allocated memory provides optimisation of arithmetic operators for vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjKqzjkXCixSegMKdmREsw.png" /><figcaption>Figure 3. RedBlackPy and Pandas Series benchmarks</figcaption></figure><p>In case you are iterating over a sorted list of keys and calling getitem operator it makes sense to use so called ‘itermode’ of RedBlackPy Series. For a Series with million items execution of the code snippet below took 0.5 seconds. Just call one method and get a good speedup (in this case about 20 times faster than Pandas).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/004756199cabc7e3e017a7b13f0eed07/href">https://medium.com/media/004756199cabc7e3e017a7b13f0eed07/href</a></iframe><p>Here is the open source <a href="https://intuitionengineeringteam.github.io/RedBlackPy/">RedBlackPy</a> repository. We shall be grateful for any feedback on the project. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cad49b5c6d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep learning for specific information extraction from unstructured texts]]></title>
            <link>https://medium.com/data-science/deep-learning-for-specific-information-extraction-from-unstructured-texts-12c5b9dceada?source=rss-e4a84f435807------2</link>
            <guid isPermaLink="false">https://medium.com/p/12c5b9dceada</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[natural-language]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Intuition Engineering]]></dc:creator>
            <pubDate>Sat, 21 Jul 2018 11:06:05 GMT</pubDate>
            <atom:updated>2018-07-31T10:31:31.267Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*55sCYsXj4BXvTx-Lbkd0ow.jpeg" /></figure><p>This is the first one of the series of technical posts related to our work on <a href="https://iki.ai/">iki</a> project, covering some applied cases of Machine Learning and Deep Learning techniques usage for solving various Natural Language Processing and Understanding problems.</p><p><strong>In this post we shall tackle the problem of extracting some particular information form an unstructured text</strong>. We needed to extract our users’ skills from their Curriculam Vitaes (CVs) even if they are written in an arbitrary way such as “was deploying quantitative trading algorithms on production server”.</p><p><strong>This post has a </strong><a href="http://intuition.engineering/skills"><strong>demo page</strong></a>, check our model’s performance on your CV.</p><h4>Linguistic models</h4><p>Modern linguistic models (<a href="https://arxiv.org/abs/1801.06146">ULMfit</a>, <a href="https://allennlp.org/elmo">ELMo</a>) use unsupervised learning techniques such as creating RNNs embeddings on large texts corpora to gain some primal “knowledge” of the language structures before a more specific supervised training step. In some cases on the contrary you need a model trained on a very specific and small dataset. These models possess nearly zero knowledge of the general linguistic structures and work only with special text features. A classic example would be a naive sentiment analysis tool for movie reviews or news datasets — the simplest working model could operate only with “good” or “bad” adjectives synonyms and some emphasising words presence. In our research we took advantages of both approaches.</p><p>Generally when some corpus of texts is analysed we are looking at the whole vocabulary of each text. Popular methods of texts vectorisation, such as <em>tfidf, </em><a href="https://www.tensorflow.org/tutorials/word2vec"><em>word2vec</em></a><em> or </em><a href="https://nlp.stanford.edu/projects/glove/"><em>GloVe</em></a><em> </em>models are using the whole document’s vocabulary to create its vector except of stopwords (such as articles, pronouns, and other quite generic language elements bringing little semantic sense in such a statistical averaging procedure). If there is a more specific task and you have some additional information about the texts corpus, you could probably state that some information is more valuable than the other. For example, to perform some analysis on a corpus of cooking recipes it would be important to extract ingredients or dish names classes from the texts. The other example is extracting professional skills from the CVs’ corpus. If we could vectorise each CV by relating it with a vector of extracted skills it would let us perform much more successful industry positions clustering, for example.</p><p>Example:</p><p><strong><em>CV:</em></strong><em> Data scientist, hands on expertise in machine learning, big data, development, statistics and analytics. With my team of data scientists implemented Python machine learning model ensembles, stacking, and feature engineering demonstrating high accuracy rates in predictive analytics. Created a recommender system using Doc2Vec words embeddings and neural networks.</em></p><p><strong><em>Extracted professional skills:</em></strong><em> machine learning, big data, development, statistics, analytics, Python machine learning model ensembles, stacking, feature engineering, predictive analytics, Doc2Vec, words embeddings, neural networks.</em></p><h4>Step 1: Parts of speech tagging</h4><p>The task of entities extraction is a part of text mining class problems — extracting some structured information from an unstructured text. Let us take a close look at the suggested entities extraction methodology. As far as skills are mainly present in so-called noun phrases the first step in our extraction process would be entity recognition performed by <a href="https://www.nltk.org/">NLTK library</a> built-in methods (checkout Extracting Information from Text, <a href="https://www.nltk.org/book/ch07.html">NLTK book, part 7</a>). Part of speech tagging method extracts noun phrases (NP) and builds trees representing relationships between noun phrases and the other parts of the sentence. NLTK library has a number of tools performing such phrase decomposition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BwkQ3sl9jESciEPlyZu4Wg.png" /><figcaption><em>NLTK book, chapter 7, pic 2.2: An example of a simple regular expression based NP Chunker.</em></figcaption></figure><p>We can define a model as a regular expression giving the sentence decomposition (for example, we can define a phrase as a number of adjectives plus a noun) or we can teach a model on a labeled number of texts from NLTK with extracted noun phrases examples in them. This step results in receiving a number of entities among which some are the target skills and some are not — besides skills CV could contain some other entities such as places, persons, objects, organisations, whatever.</p><h4>Step 2: Deep learning architecture for candidates classification</h4><p>The next step is entities classification. Here the objective is quite simple — to tell skills from “not skills”. The set of features used for training is composed regarding the structure of the candidate phrase and the context. Obviously, to train a model we had to create a labeled training set, we did it manually for 1500 extracted entities with skills and “not skills” among them.</p><blockquote>We have never tried to fit our model to some finite set of hardcoded skills, the core idea behind the model was to learn semantics of skills in English CVs and to use the model for extraction of the unseen skills.</blockquote><p>Each word’s vector is comprised of such binary features as occurrence of numbers or other special characters (skills often contain numbers and symbols: C#, Python3), capitalisation of the first letter or of the whole word (SQL). We also check if a word appears in the English language vocabulary and in some thematic lists such as names, geographical names, etc. The final model using listed features has shown 74.4% correct results on the test set of entities. Usage of another binary feature describing presence of the popular English prefixes and suffixes in a candidate improved model’s performance up to 77.3% correct results on test set. And the addition of one-hot vectors encoding parts of speech to the models’ features set boosted our results to 84.6%.</p><p>A reliable semantic words embedding model could not be trained on a CV dataset, it is too small and narrow, to mitigate the problem you should use words embeddings trained on some other, really large dataset. We used GloVe model vectors with 50 dimensions which improved our models’ performance up to 89.1% correct results on a test set. <strong>You can play with the final model in our </strong><a href="https://intuition.engineering/skills"><strong>demo</strong></a><strong> by uploading a text from your CV.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ORQjzTETyHJomGjtiJqScA.png" /></figure><p>Popular part of speech taggers (<a href="https://www.nltk.org/book/ch05.html">NLTK POS tagger</a>, <a href="https://nlp.stanford.edu/software/tagger.html">Stanford POS tagger</a>) often make mistakes in the CV’s phrases tagging task. The reason is that often a CV text neglects grammar in order to highlight experience and to give it some structure (people start sentences with a predicate, not with a subject, sometimes phrases miss appropriate grammatical structure), a lot of words are specific terms or names. We had to write our own POS tagger solving the aforementioned problems.</p><p>The classification is performed with a Keras neural network with three input layers each designed to take special class of data. The first input layer takes a variable length vector comprised of the described above features of the candidate phrases which could have arbitrary number of words. This feature vector is processed with an LSTM layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jNjvDvTaIhodaIiqRJ_hw.png" /></figure><p>The second variable length vector brings the context structure information. For the given window size n we take n neighbouring words to the right and n words to the left of our candidate phrase, vector representations of these words are concatenated into the variable length vector and passed to the LSTM layer. We found that the optimal n=3.</p><p>The third input layer has fixed length and processes the vector with the general information about the candidate phrase and its context — coordinatewise maximum and minimum values of word vectors in the phrase and its context which, among the other information, represent the presence or absence of many binary features in the whole phrase.</p><p>We called this architecture SkillsExtractor, here it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qExsGPU0_exp_8wmC0NO-w.png" /><figcaption>Skills Extractor network architecture</figcaption></figure><p>It’s Keras implementation looks the following way:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cae904540817a79e6721d2aa80cda1b5/href">https://medium.com/media/cae904540817a79e6721d2aa80cda1b5/href</a></iframe><p>The best result in model training has been achieved with the Adam optimiser with learning rate decreased to 0.0001. We chose binary_crossentropy as the loss function because the model is designed to classify in two classes.</p><p>To make its’ usage handy, let us add fit method performing neural net’s training and automatic stopping with the usage of cross validation and predict function, forming the prognosis for the feature vector of the candidate phrase.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73654d53b04178d98de1f81d05401836/href">https://medium.com/media/73654d53b04178d98de1f81d05401836/href</a></iframe><p>pad_sequences function converts a list of feature sequences to a 2d array with width equal to the longest sequence in the list. This is made to bring variable length data going to the LSTM layers to the format needed for model training.</p><p>onehot_transformfunction converts the target values 0 and 1 to one-hot vectors [1,0] and [0,1]</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0610620f3a17e0b2b9feabea2e083f32/href">https://medium.com/media/0610620f3a17e0b2b9feabea2e083f32/href</a></iframe><p>As long as the numbers of words in an entity and in its context are arbitrary, the usage of a sparse fixed length vector does not look reasonable. Thus the recurrent neural nets processing vectors of the arbitrary lengths here come as a handy and quite natural solution. Our tests proved that the architecture using dense layers to deal with fixed length vectors and LSTM layers for handling varied length vectors is optimal.</p><p>Several architectures have been tested with different combinations of dense layers with LSTM ones. The resulting architecture configuration (the size and number of the layers) showed the best results on cross-validation test which corresponds to the optimal usage of training data. Further model tuning could be performed by increasing the training data set size along with scaling the layers size and number appropriately, doing latter with the same dataset would lead to model overfitting.</p><h4>Results</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ce994e95a86071f5b4da1f3a80fcbd4/href">https://medium.com/media/2ce994e95a86071f5b4da1f3a80fcbd4/href</a></iframe><p>All the CVs used for model training were from the IT industry. We were delighted to see that our model also showed quite reasonable performance on the dataset of CVs belonging to other industries such as Design and Finance. Obviously processing CVs with entirely different structure and style would result in a lower model performance. We would also like to mention that our understanding of the “skills” concept could vary from someone elses’. One of the hard cases for our model would be telling skills from new companies names as skills are often equal to software frameworks and sometimes you cannot tell wether this is a startup name mentioned or a new JS framework or a Python library. Nevertheless in most cases our model could be a useful tool for automatic CV analysis and along with some statistical methods could solve wide range of data science tasks on an arbitrary CV corpus.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12c5b9dceada" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/deep-learning-for-specific-information-extraction-from-unstructured-texts-12c5b9dceada">Deep learning for specific information extraction from unstructured texts</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>