<?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 Ahmad Khan on Medium]]></title>
        <description><![CDATA[Stories by Ahmad Khan on Medium]]></description>
        <link>https://medium.com/@ahmad.khan.22?source=rss-9165a76dbff8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RDHPUzQHSgiJEwt1tbEAyQ.jpeg</url>
            <title>Stories by Ahmad Khan on Medium</title>
            <link>https://medium.com/@ahmad.khan.22?source=rss-9165a76dbff8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:27:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmad.khan.22/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[Improving Embedding-Based Candidate Generation for Recommender Systems with a Two-Tower Model]]></title>
            <link>https://medium.com/glassdoor-engineering/improving-embedding-based-candidate-generation-for-recommender-systems-with-a-two-tower-model-c222123beb7f?source=rss-9165a76dbff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c222123beb7f</guid>
            <category><![CDATA[self-supervised-learning]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[two-tower-model]]></category>
            <dc:creator><![CDATA[Ahmad Khan]]></dc:creator>
            <pubDate>Wed, 18 Mar 2026 15:18:12 GMT</pubDate>
            <atom:updated>2026-03-19T02:27:01.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*H3RWIxBqr60xwEFcuz31vw.png" /></figure><h3>Overview</h3><p>At Glassdoor (part of Indeed), millions of professionals come to learn about workplaces, ask career questions, and share experiences through our Community platform. When users open the Community Home Feed, they expect to see posts that are relevant to their interests, industry, and career stage.</p><p>However, generating that feed is not a simple task.</p><p>At any moment, thousands of new posts across hundreds of community feeds compete for attention. From discussions about interview experiences to workplace culture questions and industry advice, the platform contains a diverse and constantly evolving stream of content. The challenge is to quickly identify which of these posts are most relevant for each user.</p><p>To address this problem, we built a <strong>multi-stage machine learning recommendation system</strong> that efficiently sources, filters, and ranks posts before they appear in the user’s feed. In a previous post, <a href="https://medium.com/glassdoor-engineering/inside-glassdoors-multi-stage-recommendation-system-cee58b52a75a">Inside Glassdoor’s Multi-Stage Recommendation System</a>, we described the architecture of this system and how the different stages work together to deliver personalized content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*GqIr2fncLua7XYorjh4Tsw.png" /><figcaption><em>Snapshot of the Glassdoor Community Home Feed</em></figcaption></figure><p>At a high level, the system consists of four stages:</p><ol><li><strong>Candidate Generation</strong> — retrieves a large set of potentially relevant posts</li><li><strong>Filtering</strong> — removes posts that are undesirable, duplicated, or already seen</li><li><strong>Ranking</strong> — predicts which posts a user is most likely to engage with</li><li><strong>Ordering</strong> — applies heuristics to maintain diversity and freshness in the feed</li></ol><p>Each stage progressively narrows the set of posts until only the most relevant posts remain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*6id_uZ3Cifn8r8zRvfANrw.png" /><figcaption>4 Stage ML RecSys Design</figcaption></figure><p>In this blog post, we focus on the <strong>Candidate Generation stage</strong>, which is responsible for retrieving an initial pool of potentially relevant posts from a very large pool of posts across many different feeds.</p><p>For Candidate Generation, we developed a <strong>Two-Tower Neural Network Model</strong> that learns embeddings for users and posts based on real interaction data.</p><p>In the rest of this blog post, we will walk through:</p><ul><li>how the Two-Tower architecture works</li><li>how we train embeddings using user-post interactions</li><li>improvements to model training such as mixed negative sampling and self-supervised learning</li><li>and how this model improved engagement on the Glassdoor Community feed</li></ul><h3>Embedding Based Candidate Generation</h3><p>Candidate generation is a large search and retrieval problem. Given thousands (or millions) of posts, the goal is to find a small subset of posts that could be relevant to a user. Additionally, we want to ensure:</p><ol><li><strong>High recall</strong> — ensure that relevant posts are included in the candidate set so later ranking stages can select the best ones</li><li><strong>Low latency</strong> — retrieve candidates quickly enough to support real-time feed generation</li></ol><p>For problems requiring both high recall and low latency, <strong>Approximate Nearest Neighbor (ANN) </strong>embedding search is a practical solution. We embed both users and posts into a vector database and perform ANN retrieval to efficiently find posts whose embeddings are most similar to a given user.</p><p>There are many algorithms that can generate such embeddings for ANN. At Glassdoor in the past we have experimented with pre-trained language models. Our first iteration simply used the GloVe language model. Later, we used the more powerful Sentence Transformer model to embed users and posts based on the content they interacted with. But these embedding methods used pre-trained, out of the box, models not fine-tuned on actual user-post interactions and mostly calculated semantic similarity for user and posts based on text similarity.</p><p>To address these limitations, we moved to an enhanced approach last year using a trained <strong>Two Tower Neural Network Model </strong>where<strong> </strong>we train the user and post embeddings based on the user-post interaction prediction task itself.</p><h3>Two-Tower Model for ANN-Based Candidate Generation</h3><p>In a multi-stage recommender system, <strong>Two-Tower models</strong> are commonly used in industry in the <strong>Candidate Generation stage</strong> to generate embeddings.</p><p>A Two-Tower model consists of:</p><ul><li>a <strong>User Tower</strong>, which embeds a user’s profile and platform engagement using computed and other metadata user features</li><li>a <strong>Post Tower</strong>, which embeds posts using post features into the same embedding space</li></ul><p>Each tower is a neural network model, in our case a stack of linear layers followed by a ReLU Activation, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*4DyVRcTDRRnSvf-5pHxMlg.png" /><figcaption>Two Tower Neural Network Model Architecture</figcaption></figure><p>Both towers are trained jointly so that users are close in the vector embedding space to posts they are likely to interact with and far from those they are less likely to interact with. For our Two Tower model, we utilize the following user and post features to generate the embeddings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*e7mixh-bPOTL_sZrd2YFjw.png" /><figcaption>User and Post Tower Input Features for Two Tower Model</figcaption></figure><p>For text-based fields (like post text, comment text, topics), we generate semantic embeddings using a pre-trained Sentence Transformer model. These embeddings are then concatenated with structured features and used as inputs to the Two-Tower neural network.</p><h3>Two Tower Model Training</h3><p>To learn meaningful user and post embeddings, two-tower models are typically trained using <strong>Contrastive Loss or Noise Contrastive Estimation </strong>style objectives, often implemented as <strong>sampled softmax</strong> over <strong>in-batch negatives</strong>.</p><p>In our case the core idea was to transform recommendation into a <strong>binary discrimination problem</strong>: given a user embedding, the model must assign a higher similarity score (e.g: dot product) to a <em>true (positive) post interaction’s embedding </em>than to a set of <em>negative (noise) posts embedding </em>sampled from the post corpus.</p><p>Specifically, for each training example:</p><ul><li>A <strong>positive post</strong> is drawn using the user’s historical post interactions. These are posts the user actually interacted with (i.e: clicked, reacted) previously in our training data.</li><li>Multiple <strong>negative posts</strong> are sampled. These are posts the user did not interact with in our training data.</li></ul><p>The model computes similarity scores (dot products) between the user embedding and both positive and negative post embeddings. A contrastive style loss then encourages the positive user-post pair to score higher than the negative user-post pairs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*NrWNe-HlBNbEJb8QCG5amw.png" /><figcaption>Two Tower Training Loss Objective</figcaption></figure><p>This objective approximates a full softmax over all posts — which would be computationally infeasible at scale — while still learning an embedding space where relevant user–post pairs are close and irrelevant pairs are far apart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*I-fdenz-MQp2rYZ2a79GIA.png" /><figcaption>Illustration of changes in user and positive/negative post embeddings after model training</figcaption></figure><h3>Two Tower Model Training Optimizations</h3><p>One of the key challenges in training two-tower models is <strong>choosing which negative posts to show the model</strong>. If all negatives are random or trivial, the model quickly learns to separate “obvious” non-relevant posts, but struggles with more subtle distinctions. If all negatives are other posts in the batch, then the model only learns embeddings for popular posts more likely to show up in batches of user-post interactions while ignoring the long tail of less popular posts entirely. This is where <strong>Mixed Negative Sampling</strong> comes in, an idea described in the Google paper<a href="https://research.google/pubs/mixed-negative-sampling-for-learning-two-tower-neural-networks-in-recommendations/"> Mixed Negative Sampling for Learning Two-tower Neural Networks in Recommendations </a>which we also use for training the Two Tower model.</p><p><strong>Mixed Negative Sampling</strong> combines two different types of negative streams when training the model.</p><ol><li><strong>In-Batch Negatives</strong>: Other posts in the same training batch act as negatives for a given user. This is efficient and can be done via just matrix multiplication during batch training.</li><li><strong>Random Negatives: </strong>Posts sampled uniformly from the entire post corpus.</li></ol><p>By mixing negatives from these two sources, the model learns a richer embedding space for both popular and less popular posts.</p><p>Another improvement to the Two Tower model training we implemented is adding a <strong>Self-Supervised Learning (SSL) loss</strong> alongside the main contrastive loss objective. This helps the model learn richer embeddings that capture intrinsic structure in user and post behavior, not just interactions. The approach is inspired by work from another Google paper <a href="https://arxiv.org/abs/2007.12865"><em>“Self-supervised Learning for Large-scale Item Recommendations”</em></a><em>.</em></p><p>The idea is to create <strong>augmented views</strong> of users or posts by masking part of the user and post’s input feature vector with zero values. These augmentations generate multiple “views” of the same underlying entity’s input feature vector. The model is also trained on an additional auxiliary contrastive task where positives and negatives are defined as follows.</p><ul><li><em>Positive pairs</em>: Two augmented feature vector views from the same underlying users (or posts)</li><li><em>Negative pairs</em>: Two augmented feature vector views from different underlying users (or posts)</li></ul><p>Formally, the SSL loss encourages embeddings from the same entity to be <strong>close in the latent space</strong>, while embedding views from different originating sources remain far apart. Combined with the standard contrastive loss, this gives the model two complementary learning signals:</p><ol><li><strong>Supervised contrastive task (main contrastive loss)</strong> — teaches the model which posts a user is likely to interact with</li><li><strong>Self-supervised task</strong> — teaches the model the underlying structure of user behavior and posts independent of interactions</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmBR7LPP6vWpOSjrKUvOUQ.png" /><figcaption>Source: <a href="https://arxiv.org/abs/2007.12865"><em>“Self-supervised Learning for Large-scale Item Recommendations”</em></a></figcaption></figure><p>This helps to improve generalization to rare or long-tail posts which are never seen during training using just the supervised contrastive task and also improves embeddings for sparsely engaged users who don’t have much platform engagement history. It also captures similarity between users and posts beyond just explicit interactions.</p><h3>Model Evaluation and AB Test Results</h3><p>The new Two Tower model was trained with 2 months of our historical user-post community interaction data and tested offline on the following one week of separate test data. Offline results showed the model improving offline retrieval metrics such as Precision@K, Recall@K, F1@K, HitRate@K by 40–60% relative to our previous Sentence Transformer embedding baseline.</p><p>We then validated the model’s impact through a series of A/B tests. Cumulatively, the model drove a substantial improvement in user community engagement, measured by a metric we define internally: <strong>eCRAUs</strong> (Engaged Community Registered Active Users), which counts users who took <em>any</em> engagement action (including clicks, reactions, or comments).</p><ul><li><strong>+5%</strong> cumulative, statistically significant, improvement in the total number of <strong>eCRAUs</strong></li><li><strong>+5% </strong>cumulative<strong>, </strong>statistically significant, improvement in<strong> Clicks per User</strong>, while post reactions and comments increased by more than 10%, though not statistically significant</li></ul><p>Beyond direct engagement metrics, the model also delivered a noticeable improvement in our <strong>feed diversification</strong>. Users were shown post impressions from a wider variety of less common feeds, rather than the feed being dominated only by the biggest or most popular ones. These positive, statistically significant, results led to the adoption of the Two Tower model as part of our 4 Stage ML RecSys in production.</p><p>We further assessed the quality of the new Two Tower embeddings with embedding clustering analysis. We reduced the high-dimensional embeddings to 2D (using T-SNE) for visualization, and compared the new Two Tower embeddings against our old baseline using just Sentence Transformer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*6690H3IxIcmHu0fso2FVrw.png" /><figcaption>(Left) Previous Sentence Transformer Embedding Clusters vs (Right) New Two Tower Embedding Clusters</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*FfQi-IN4keYrH_0umZarYA.png" /><figcaption>Visual Analysis Summary of Embedding Clusters</figcaption></figure><p>This qualitative analysis was also supported by quantitative evaluations of the embeddings using clustering quality metrics like <strong>Silhouette Score</strong> and the <strong>Calinski-Harabasz Index</strong>, which also showed major improvement.</p><h3>Model Deployment</h3><p>The Two Tower model was deployed in production using MLflow and the model was served through a REST endpoint used by our Community Home Feed Recommendation System Service for inference. During inference, the client service sends the user ID and user features or post ID and post features and the model service returns the computed Two Tower based embeddings using the deployed model for users and posts. We precomputed these embeddings offline in batches and indexed them in our internal OpenSearch vector database for fast embedding retrieval using ANN search for real-time inference when the user opened their home feed.</p><p>More information around our ML Engineering and Experimentation architecture that we built for the Two-Tower model will be shared in a follow-up blog post.</p><p>Stay tuned for more!</p><h3>References</h3><ol><li><a href="https://research.google/pubs/mixed-negative-sampling-for-learning-two-tower-neural-networks-in-recommendations/">Mixed Negative Sampling for Learning Two-tower Neural Networks in Recommendations</a></li><li><a href="https://arxiv.org/abs/2007.12865">Self-supervised Learning for Large-scale Item Recommendations</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c222123beb7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/glassdoor-engineering/improving-embedding-based-candidate-generation-for-recommender-systems-with-a-two-tower-model-c222123beb7f">Improving Embedding-Based Candidate Generation for Recommender Systems with a Two-Tower Model</a> was originally published in <a href="https://medium.com/glassdoor-engineering">Glassdoor Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personalized Fishbowl Recommendations with Learned Embeddings: Part 2]]></title>
            <link>https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-2-78a16b04d396?source=rss-9165a76dbff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a16b04d396</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Ahmad Khan]]></dc:creator>
            <pubDate>Tue, 05 Apr 2022 00:24:03 GMT</pubDate>
            <atom:updated>2022-04-05T00:24:03.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/984/0*p4sNfCvLRC3fUSVk" /></figure><h3>Introduction</h3><p>In the<a href="https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-1-6031abe84661"> previous blog post</a>, we saw how we can utilize text based embeddings to help recommend <em>posts</em> to <em>users</em> on<a href="https://www.fishbowlapp.com/"> Fishbowl</a>, a professional networking community that was recently acquired by Glassdoor, in which working professionals can have workplace related conversations with other peers in industry. On Fishbowl, users can anonymously write what’s on their mind in posts and also comment on posts from other anonymous users in what we call “bowls” or “feeds”; a collection of posts related to a certain industry or topic.</p><p><a href="https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-1-6031abe84661">Previously</a> we discussed how in the<em> </em>absence of clear negative signals from click stream data we cannot as easily use a supervised learning setup to rank items to users. Given the inputs we used were text based, we can instead use more unsupervised methods like <em>Doc2Vec</em> [1] to generate post text embeddings. We can treat the text of the posts as individual documents and use those to train a Doc2Vec model to generate a post text embedding. For users, we can take the average<em> </em>post text embedding of the posts the user liked and consider that as the user embedding. We can also add the user embeddings of other users who liked a post into our post embedding calculation so we incorporate some “<em>collaborative</em>” notion of what other similar users liked as opposed to a pure content similarity ranking. We can next compute the cosine similarity between the user and posts embeddings and use the similarity score to rank posts to recommend to users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ypqJ8Z-dqhzlZ-tY" /><figcaption>Ranking via Embeddings Overview</figcaption></figure><p>However, such an approach can have some shortcomings. First the text of the post is just one of many features we can use for personalization. We can also leverage other user provided information when users agree to sign up like the employer, job title, work city of a user as features. In addition, the bowl or feed name and its description can be considered important features for posts as posts under the same feed tend to be about similar topics.</p><p>Second, the previous Doc2Vec approach trained a Doc2Vec content model from scratch on our Fishbowl corpus of posts. But such a dataset may not be large enough to fully capture all the semantic English knowledge which would limit the quality of our trained text embeddings. Finally instead of text based embeddings we can also learn embeddings tailored for our custom recommendation task with neural networks.</p><h3>Transfer Learning for Text Content Embeddings</h3><p>In NLP a lot of recent research in <em>Transfer Learning</em> uses pre-trained high quality language models, first trained on much larger corpora of data like Wikipedia, and later fine tuned for other custom tasks on small custom data. In doing so we benefit from all the pre-existing knowledge of a larger language model and then further refine our model’s knowledge base on our custom learning task. For this project, we utilized Transfer Learning by using pre-trained GloVe and BERT models fine tuned on our Fishbowl corpus.</p><h4>GloVe Based Embeddings</h4><p>GloVe [2] presumes that ratios of word-word co-occurrence probabilities can encode some form of meaning. It learns word embeddings by factorizing a global co-occurrence word-word matrix where each entry in the co-occurrence matrix indicates the number of times a word co-occurs with another within its context. Words that frequently co-occur like “Google” and “interviews” are more likely to be closer to each other in the embedding vector space than words that co-occur less frequently like “Google” and “running”. The standard 100 embedding dimensional GloVe model available<a href="https://nlp.stanford.edu/projects/glove/"> online</a> has already been pre-trained on a large corpus of Wikipedia and Twitter posts which we can next fine tune further on our custom Fishbowl corpus of post texts and comments.</p><p>How can we utilize a pre-trained GloVe model for our recommendation purposes? Recall we now have 6 text based features to generate an embedding representation of posts and users and not just post text.</p><ul><li><strong><em>Post Text</em></strong><em>: </em>the text of the Fishbowl post. In the case of a user this is an empty string.</li><li><strong>Company</strong>: the company the user claims to work in. In the case of posts this is the company of the user who made the post.</li><li><strong><em>Job Title:</em></strong> the user’s job title shared by the user. In the case of posts this is the job title of the user who made the post.</li><li><strong><em>City Location</em></strong><em>:</em> the city the user claims to work in. In the case of posts this is the work city of the user who made the post.</li><li><strong><em>Feed Name:</em></strong> the name of the feed or “bowl” the Fishbowl post was made in. In the case of users this is an empty string.</li><li><strong><em>Feed Description:</em></strong> the description of the feed or “bowl” the Fishbowl post was made in. In the case of users this is an empty string.</li></ul><p>We can pass each of our 6 text feature inputs above individually into the GloVe model to get 6 GloVe output embeddings each of 100 dimensions for each feature. But GloVe gives us embeddings for individual words and not entire phrases or sentences. Our inputs can indeed be phrases and in the case of post text even multiple sentences. We need a way to generate embeddings for the entire input sentence. We do so by simply taking the <em>mean</em> Glove embedding of all the input words instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v4onafFCuHvaITMB" /><figcaption><em>Glove Mean Word Embedding Aggregation (N = length of input text)</em></figcaption></figure><p>Next, we concat each of the 6x100 dimension GloVe input feature’s mean embeddings into one final GloVe content embedding of 600 dimensions. We can also try summing instead of concatenating but in our case concatenation performed better. If a feature doesn’t make sense like the post text in the case of a user we just concat a zero 100 dimensional embedding for such a feature. This approach gives us a glove content embedding for both users and posts of the same dimension and in the same vector embedding space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TgPvtix5eAi-MnQZ" /><figcaption><em>Glove Post Content Embedding Logic</em></figcaption></figure><p>One issue with concatenating is that as the number of features increases, repeated concatenation of each new feature can end up causing a very large output content embedding size. So to ensure the output embedding size remains small we utilize Principal Components Analysis (PCA) to reduce the output GloVe content embedding into a smaller 128 dimensional but still useful representation. Reducing a long vector to its top principal components (ideally) retains most of the variance in the data. This is not just a computation and memory optimization. As we will see later this optimization is also useful from a ML theory perspective in improving model performance.</p><p>So far we have also only considered content data for a post. Popularity of a post can be a major indicator for someone liking a post. Posts that get many reactions can encourage others to react to them as well and can also signal as a proxy indicator for post quality. At Fishbowl we measure 5 types of reactions on a post: <em>Like, Helpful, Smart, Funny and Uplifting</em>. In addition, we also consider the total reactions, number of comments, number of shares as measures of post popularity. We next concatenate these 8 reaction features after scaling them into our concatenated 600 dimension glove content embedding prior to the PCA reduction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WFWTXyzCvW9B4Qmi" /><figcaption><em>Glove Content Embedding Logic with Reaction Counts and PCA Reduction</em></figcaption></figure><p>Similar to what we discussed in the <a href="https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-1-6031abe84661">prior</a> blog post, we can next also incorporate information from other similar users or posts. For the<em> post embeddings,</em> we can add in the average of the <em>GloVe user content embeddings</em> of all users who liked the post into the post embedding calculation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*AaG5UgglKyk8Suyf" /><figcaption>Equation 1: Post Embedding Aggregation Logic (U = user ids who liked the post and M = Number of users who liked the post, and beta = scalar to weight each component in aggregation)</figcaption></figure><p>For <em>user embeddings</em>, we can add the <em>Glove post content embeddings</em> of the other posts the user liked into the<em> </em>final user embedding<em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*9cVFQSraeeWh2fWP" /><figcaption><em>Equation 2: User Embedding Aggregation Logic (P = post ids the user liked and N = Number of posts the user liked, and alpha = scalar to weight each component in aggregation)</em></figcaption></figure><p>These output embeddings from equation 1 and 2 are the final GloVe based embeddings that we use to compute for users and posts for ranking purposes.</p><h4>BERT Based Embeddings</h4><p>We can also follow a similar approach using BERT[3]. But BERT can give us multiple contextual embeddings for each word, not just one static word embedding. The basic BERT model has 12 attention layers. Each attention map can be considered encoding one context or representation for a word.</p><p>This makes generating a single embedding for an input word using BERT tricky. One approach could be to sum up or concatenate the embedding values of all or the last few attention outputs. This is not really the best assumption as it does defeat the purpose of BERT. A better approach could be to utilize the <em>Sentence BERT</em> [4] modeling paradigm which learns an embedding of the entire sentence instead of individual words. However, for simplicity, in our case, we take the average embedding output of the last 4 attention layers as our word embedding although Sentence BERT is something we want to revisit later. The rest of the embedding aggregation logic is the same as the GloVe approach where the final content embedding is the average of all the input feature words followed by a PCA reduction.</p><p>To generate the above word embeddings that are custom to our Fishbowl corpus we also have to first <em>fine tune</em> the BERT model on Fishbowl data. One of the advantages of BERT, and Transformers in general, is that they are very good at learning representations from larger sequences vs just nearby context words. So to take advantage of this additional representational capacity of Transformers, during fine tuning, we don’t just pass in the post text as input, like we would for fine-tuning GloVe or Doc2Vec, but also concatenate the six text inputs as <em>CONCAT(user company, user title, user location, post text, feed_name, feed description) </em>into one long input “<em>document</em>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*miL9U7ez3Defk5Qt" /><figcaption><em>BERT Fine Tuning Setup for Custom Fishbowl Feature Inputs</em></figcaption></figure><p>We use this document as the input to the BERT model for fine tuning so it can attend to al other input features as well when learning word representations through the same masked word prediction learning task.</p><h3><strong>Embeddings via Contrastive Learning</strong></h3><h4>Siamese Network Embeddings</h4><p>The above approaches are premised on the assumption that text feature embeddings are enough to generate good user or post embedding representations. To factor in information from other similar users we do so in a very manual fashion in <em>equations 1 and 2</em> earlier by adding in the content embeddings of other users who liked the post into a final post embedding. This however may miss other aspects of user and post similarity. We now instead try to learn embeddings based on what similar or dissimilar users liked <em>automatically</em> through learned weights via a neural network instead of manually aggregating via equations 1 and 2.</p><p>One particular approach we want to emphasize is learning embedding representations via a contrastive<em> triplet loss</em> function [5]. A triplet loss, takes a query (<em>anchor</em>) input and computes the euclidean distance between a positive instance associated with the query and the distance between a negative instance associated with the query input. It then takes the difference between the distance values of the negative pair and the positive pair. Instead of euclidean distance we can also use cosine similarity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Rww5EBxK9Q6YXN1" /><figcaption>Triplet Loss Function (Source:<a href="https://lilianweng.github.io/posts/2021-05-31-contrastive/"> https://lilianweng.github.io/posts/2021-05-31-contrastive/</a>)</figcaption></figure><p>The loss will be smaller when the positive pair’s distance is low and the negative pair’s distance is high and it will be bigger when the positive pair’s distance is high and the negative pair’s similarity is small. Therefore minimizing this loss during training encourages the model to learn similar embedding representations of positive instances for a given query input (since that reduces the distance for positive pairs) and dissimilar embedding representations for negative instances of a given query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dyKOW2UOxRz5FSNA" /><figcaption><em>Source: FaceNet — A Unified Embedding for Face Recognition and Clustering [5]</em></figcaption></figure><p>To generate the positive and negative pairs, we do so <em>implicitly</em> in a self supervised manner. We assume if a user liked a post during our training period then this is a “<em>positive</em>” pair. A negative is a randomly selected post from the same feed the positive post is from. If our corpus of posts in each feed is very large, and the average number of posts liked by a user is small, then the probability of what we consider a negative actually being a false negative is small. So with some confidence we can assume that the user did not like the other posts in a batch. Generating negatives on the fly is critical to make training quick and simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*gV_dwAJqDsjoYYpu" /><figcaption>Siamese Network with Glove Content Embeddings Input</figcaption></figure><p>We have two parallel neural networks with weights not shared between them. One each to learn user and post embeddings in what can be described as a “<em>siamese network</em>” [6]. Each neural network can be any kind of architecture but in our case we have two linear layers of size 256 and 128 with a ReLu activation in between. The output of each neural network is what we consider the embedding representation. For inputs, the precomputed <em>GloVe post content embedding </em>described earlier is passed in the post neural network. And the <em>GloVe user content embedding </em>is passed into the user neural network.</p><p>We next compute the cosine similarity between the user and posts network output embeddings for each positive user-post pair, and the same for the negative pairs. After which we compute the <em>triplet loss</em> and back-propagate.</p><h4>Graph Convolutional Network Embeddings</h4><p>The above contrastive <em>siamese network </em>can only consider information that is carried in each batch of user-post pairs. In our previous blog post, we had mentioned how a graph structure can carry information from neighbors in a graph. But the problem with Word2vec based context window methods like <em>DeepWalk</em> is that they only learn embeddings of the input IDs in our training input vocabulary. When new users join Fishbowl or new posts are made there is no way to lookup an embedding for them in such dynamic networks.</p><p>Instead of learning embeddings for input IDs we instead learn a generalized aggregation and encoding function based on input IDs <em>feature values </em>so that we can generalize to new, unseen posts or users as long as we have features for those. To do so we can extend the previous contrastive learning setup by further <em>pooling feature information from neighbors</em> in a graph when we try to learn the output embeddings.</p><p>Such networks are often referred to as <em>Graph Convolutional Networks (GCN)</em>. One such architecture we consider first published by Pinterest is <em>PinSage</em> [7]. Based on the ideas in <em>PinSage</em>, we also consider a user-post undirected bipartite graph where each undirected edge is between a user and a post if the user liked the post. To incorporate graph structure information we also pass in feature information from neighbors of an input vertex up to K hops away in the graph. But how do we pool information features from all the K hop neighbors?</p><p>One such way could be to take the mean feature values of the K hop neighbors. Alternatively, we can parameterize and learn a weight matrix which automatically learns how to pool these features in a weighted fashion. We try both approaches. Additionally, we want to keep the input vertex’s feature information as well so concatenate the input node’s features and the pooled neighborhood feature values of the K hop neighbors into one longer vector. This is passed into a smaller dimensional linear layer with a non linear ReLu activation. Output from this layer can be thought to encode the final embedding for an input vertex.</p><p>To actually learn the weights to generate such embeddings we utilize the same contrastive <em>triplet loss</em> as the <em>siamese network </em>earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*Wy3pS_zxo_ZedfYL" /><figcaption>“Convolve” operation which aggregates feature information from neighbors in a graph from <em>“Graph convolutional neural networks for web-scale recommender systems.” [7]</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q0GG1PyAdONcnpbk" /><figcaption>Source: <em>“Graph convolutional neural networks for web-scale recommender systems.”[7]</em></figcaption></figure><p><strong>Sampling Neighbors: </strong>There can be a huge number of K hop neighbors for a node. The worst case complexity here is pooling information from the entire V vertices in the graph. This can make computation slow and memory intensive. Instead of pooling information from all K hop neighbors, the authors instead propose to <em>sample up to T neighbors</em> based on their importance to the input node. We determine importance based on the degree of each node. This sampling operation controls the memory footprint of the algorithm. Additionally, it adds an element of randomness every time the same user input is seen during training which makes model generalization better. In our implementation we experiment on small T values up to 50.</p><p><strong>Hard Negatives: </strong>We introduce the concept of “<em>hard negatives</em>” during training. Now we consider a post as “<em>negative</em>” if it is from one of the bowls a user is subscribed in, is a top 25 liked post in that bowl, and if the user never liked that post. The quality of a negative can be critical in helping the model learn. The previous setup may not be as strong a contrast because there is a possibility that the user may never have seen the post if they were never part of the bowl and as such may not really be a true negative interaction. We choose harder negatives to minimize such <em>exposure bias</em><strong>. </strong>By only considering the top posts of these bowls for potential negatives, we also increase the probability the user actually saw the post and did not like it as top posts are more likely to be seen.</p><h3>Results</h3><p>We evaluate our models by training them on 12 months of historical data and evaluating them over the next week of data after the training period as the test period. For each user in the test period, we generate its embedding based on training data (to avoid leakage) and we also get the test period embedding of all the test period posts they were eligible to see during the test period. Next, we rank all posts for each user by the cosine similarity of the user-post embedding pairs. We consider the top ranked K posts from the test period as posts a user would have been recommended.</p><p>We can evaluate model performance using metrics like <em>Precision@K </em>and <em>Recall@K</em>. Precision@K defined as the percentage of top K posts that the user actually liked during the test period. Recall@K defined as the percentage of all posts that the user liked which were recommended in the top K posts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZVfjsxVNTHPDz4Vt" /><figcaption>Offline Testing Results for models relative to Doc2Vec Baseline (K=10)</figcaption></figure><p>Using the original Doc2Vec model as a baseline, we can see that the GloVe embedding model based on the 6 input text features does relatively best. Amongst the self learning Neural Network aggregation algorithms they both do slightly worse than just using GloVe. Adding the PCA reduction to keep only the top 128 components improves performance for the Glove based embeddings model. The GloVe based embedding model with PCA is also the model we shipped for testing in production.</p><h3>Discussion</h3><p>We hypothesize the improved generalization with PCA comes from condensing the embedding vector into a smaller dimensional space removing the noise from many less useful feature values. Additionally, many of our inputs and their corresponding embedding values are repetitive (for example, a post with the same user company and the bowl name, or a post asking the same question about a job as the job title of the user who made the post) so many input feature embedding values can be highly correlated.</p><p>A point to note about the Neural Network models. Both the Siamese and Graph Convolutional Networks converge very quickly despite adding hard negatives shown below. We stop training after 3 epochs. Further training leads to severe overfitting. Similarly, increasing the representational complexity of the model by either adding more layers, or in the case of the GCN increasing K to pool information from more than just neighbors, leads to worse performance on test data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6H4Z5t3QaOwr-7WR" /><figcaption>Hyper-parameter Tuning for Neural Network based embeddings</figcaption></figure><p>This suggests our data doesn’t necessarily warrant an overly complex model. Perhaps just pooling information from immediate neighbors is enough to get good performance. If we look at the original GloVe aggregation algorithm this is kind of what we do although manually by pooling in embeddings of all the users who liked the post into the post embedding calculation or the posts the user liked in the user embedding calculation.</p><p>Therefore the GloVe based aggregation model is somewhat similar to the GCN. The major difference being that in the GCN we have additional learned weights to aggregate neighbor features and to encode the output embedding as opposed to just summing neighbor features with equal weight with the Glove based model. <em>Such reduced model complexity can help improve generalization when there is potential overfitting.</em></p><p>We do however suspect that a better method of sampling negatives may have improved the overall quality of the neural network models as some improvement is observed by switching to harder negatives.</p><h3>Conclusion</h3><p>This wraps up our two part discussion of generating embeddings for Fishbowl user-post recommendations in the absence of more implicit user clickstream or impression data.</p><p>In this blog post we extended our previous recommendation model based on relatively unsupervised or self supervised techniques by utilizing some key machine learning ideas. We showed how we can add more and varied text features to improve recommendations. We explored the power of Transfer Learning via pre-trained language models like GloVe and BERT, and explored how to automatically learn customized embeddings through Siamese and Graph Convolutional Networks with the help of a Contrastive Loss.</p><p>All these ideas can be useful in recommendations when negative labels aren’t implicitly available and a supervised learning setup is hard to establish.</p><p>Even if such data is present, embedding similarity can still be very useful as a first stage for ranking and filtering via K-NN retrieval over a very large volumes of candidates. We can then always further refine our ranking using more complex supervised learning methods later.</p><p>We hope you enjoyed this discussion!</p><h3>References</h3><ol><li><em>Le, Q., &amp; Mikolov, T. (2014, June). Distributed representations of sentences and documents. In International conference on machine learning (pp. 1188–1196). PMLR.</em></li><li><em>Pennington, Jeffrey, Richard Socher, and Christopher D. Manning. “Glove: Global vectors for word representation.” Proceedings of the 2014 conference on empirical methods in natural language processing (EMNLP). 2014.</em></li><li><em>Devlin, Jacob, et al. “Bert: Pre-training of deep bidirectional transformers for language understanding.” arXiv preprint arXiv:1810.04805 (2018).</em></li><li><em>Reimers, Nils, and Iryna Gurevych. “Sentence-bert: Sentence embeddings using siamese bert-networks.” arXiv preprint arXiv:1908.10084 (2019).</em></li><li><em>Schroff, Florian, Dmitry Kalenichenko, and James Philbin. “Facenet: A unified embedding for face recognition and clustering.” Proceedings of the IEEE conference on computer vision and pattern recognition. 2015.</em></li><li><em>Koch, Gregory, Richard Zemel, and Ruslan Salakhutdinov. “Siamese neural networks for one-shot image recognition.” ICML deep learning workshop. Vol. 2. 2015.</em></li><li><em>Ying, Rex, et al. “Graph convolutional neural networks for web-scale recommender systems.” Proceedings of the 24th ACM SIGKDD international conference on knowledge discovery &amp; data mining. 2018.</em></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a16b04d396" width="1" height="1" alt=""><hr><p><a href="https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-2-78a16b04d396">Personalized Fishbowl Recommendations with Learned Embeddings: Part 2</a> was originally published in <a href="https://medium.com/glassdoor-engineering">Glassdoor Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personalized Fishbowl Recommendations with Learned Embeddings: Part 1]]></title>
            <link>https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-1-6031abe84661?source=rss-9165a76dbff8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6031abe84661</guid>
            <category><![CDATA[fishbowl]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[doc2vec]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[glassdoor]]></category>
            <dc:creator><![CDATA[Ahmad Khan]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 21:48:23 GMT</pubDate>
            <atom:updated>2022-01-07T21:48:23.918Z</atom:updated>
            <content:encoded><![CDATA[<p>Glassdoor recently acquired <a href="https://www.fishbowlapp.com/">Fishbowl</a>, a professional networking community where working professionals can have workplace related conversations with other peers in the industry.</p><p>Fishbowl users can anonymously write posts and see posts from other anonymous users in what we call “bowls”: a collection of posts related to a certain workplace, industry or topic. Bowls can be an effective way to gain insights into workplace topics and conversations. The anonymous nature of the app can further encourage honest and frank discussion on topics users may otherwise feel uncomfortable discussing. Users can subscribe to different bowls and then see new posts from their subscribed bowls show up in their main home feed when they open the app.</p><p>Every day Fishbowl users post thousands of new posts. With a growing and increasingly active user base that number will keep increasing. Surfacing the most interesting content to users can therefore become increasingly challenging with scale and a lack of personalization can detract from the overall user experience. Given the large number of possible posts to recommend and the small number of posts that can be surfaced to the user in app at any time, we have a typical recommendation system problem.</p><h3>From Global Rankings to Personalized Recommendations</h3><p>To personalize the posts recommended to a user we decided to use Machine Learning shortly after Glassdoor’s acquisition. Prior to this Fishbowl just used the recency and global popularity of a post to sort what to show users in app.</p><p>At the time of starting the project we also did not collect any explicit user click data that could have defined our problem into a classic supervised learning problem (e.g: predicting the probability of a user clicking a post given they saw the post). While we collected data on what posts a user anonymously liked or commented on we did not collect good data on if they saw or clicked a post at the time. Why is this important?</p><p>If training a supervised model, we can use such <em>implicit labels </em>based on user activity but we would not only need the implicit positive engagement label (e.g: post liked after user clicked the post) but also an implicit negative engagement label (e.g: post clicked but not liked by user) to allow the model to discriminate between positive and negative engagement. In a more straightforward setting when these binary implicit labels exist we can train a classical supervised ML model (e.g: gradient boosting, logistic regression, etc) and interpret the model output as a probability of positive engagement. We can then use these probabilistic scores for ranking purposes.</p><p>However, in the absence of click data we do not have as strong an implicit signal for a negative interaction. If a user did not like a post, it can be either because they did not actually like the post or because they did not see it entirely. This means there is some ambiguity in what actually constitutes a negative training instance. In the absence of clear negative engagement labels, we instead resorted to<strong> </strong>somewhat more <em>unsupervised embedding </em>methods to generate personalized recommendations for users.</p><h3>Embeddings for Personalized Recommendations</h3><p>Our goal is to find similar posts to recommend to users based on what they or users similar to them liked in the past. If we can project users and posts into a shared vector embedding space, we can compute the similarity between users and posts and use the similarity score for ranking purposes. The key assumption being that similar posts and users cluster together in the embedding space. There are many common similarity metrics (e.g: euclidean, manhattan distance) but here we use cosine similarity. Since we want to compare vectors it makes sense to measure their affinity by the strength of their dot product which can give us a sense of how aligned two vectors are. Recall that two vectors will have a bigger dot product if they point in similar directions and smaller if they point in different directions.</p><p>But how do we find similar users and posts given posts and users are two distinct entities? Also much of our data is raw text and not numerical feature representations. For Part 1 of this project we consider only the text of the post as the feature used for computing similarity and ranking. So we first need a way to also convert post texts to numerical representations.</p><h3>From Text to Embeddings</h3><p>Embedding methods have become really popular especially within the NLP domain. LDA [1] is a popular method to represent text as a vector of “topic” probabilities. And one of the first methods to utilize neural networks to generate embeddings of words was Word2Vec [2]. Later Doc2Vec [3] extended that model to generate embeddings for entire sentences.</p><h4>Word2Vec and Doc2Vec</h4><p>A very quick recap on Word2Vec and Doc2Vec. Word2Vec (SkipGram) generates embeddings in an unsupervised manner where each given word is used to predict every other word in its context. The context of a word is the group of K words around it in a sentence. Words that occur in the context of another word more often will end up being pushed closer to each other in the embedding space while those that rarely occur will end up being more distant. Doc2Vec utilizes the same paradigm but instead of learning word embedding learns the embedding of the entire sentence/document as well by adding an extra weight matrix for the document id the words are coming from. By doing this we are not just predicting the words in a context of a word but also if they are coming from a similar document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y0G_4-lvHJx7sfWr" /><figcaption>Doc2Vec Architecture (Credit: Doc2Vec Paper[3])</figcaption></figure><h4>Content Doc2Vec Model</h4><p>We utilize Doc2vec to generate such embeddings of posts. Our first model, the <em>content doc2vec model</em> generates a<em> post content (text) embedding </em>for each post by treating each post’s text as a unique document during training.</p><p>The content doc2vec model can learn semantic similarities between posts. Ideally posts that have similar texts will have high similarity scores. However, our goal is to find similarities between users and posts, not similarities between posts. No such embedding for users exists using just a <em>content doc2vec model</em> trained on a corpus of Fishbowl posts. Therefore, to compute a user embedding, we instead take the <em>average post content (text) embedding</em> of all the posts a user liked during the training period. This gives us a representation of both users and posts in the same embedding space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*QJd15rQU9A83arXn4gAotg.png" /><figcaption><em>where P = posts the user liked and N = number of posts the user liked</em></figcaption></figure><p>A pure content model is good for capturing some notion of semantic similarity between users or between posts and we can consider it from the lens of <em>content filtering</em>. But it doesn’t capture any aspect of what other similar users liked (i.e:<em> collaborative filtering</em>). Semantic similarity alone can be just one of the dozens of reasons a user may like a post, many of which may have little to do with how similar the content of the post is to previous posts a user liked. It might be that a user is more predisposed to liking content that is from users from their own company or their own industry etc. This is where including some aspect of “<em>collaborative filtering</em>” can be beneficial.</p><p>To incorporate such information we also average the embedding of all the users who liked the post into the post embedding calculation in addition to the learned <em>post content (text) embedding</em> of the post itself that we get from the <em>content doc2vec model</em> as shown below. To avoid any accidental leaking we also exclude the post for which the embedding is being calculated from all User Embedding calculations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*AG_dCs1qxKOYYl-uTuCm3A.png" /><figcaption>where U = users who liked the post and M = number of users who liked the post</figcaption></figure><h4>Graph Doc2Vec Model</h4><p>An alternative way to incorporate collaborative information, is to view Fishbowl recommendations as a graph learning problem. We can view Fishbowl as a graph where the vertices are defined as the set of all unique user ids and post ids. And an edge is defined as an undirected edge between a user id and a post id if the user liked a post as shown below on some hypothetical data. We can then aggregate information from a vertex’s neighbors by traversing this graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4sIC84A6l-ASW-40" /><figcaption><em>Fishbowl Content Graph</em></figcaption></figure><p>We extend the idea of Doc2Vec to this graph setting. Each vertex in the graph (either a user id or post id) is considered a unique document id. Each document id comprises the following as its document content (words): the list of first 100 vertices (users or post ids) visited from a starting document id via Breadth First Search. Why BFS?</p><p>Since Breadth First Search traverses a graph level by level this ensures we capture immediate neighbors of a vertex id first before moving to further distant descendants of a node which would be of lower importance for a user or post’s document representation. Each visited vertex id in this list is considered as a single “word” in the document for which the embedding is learned along with the entire document embedding.</p><p>For example for the hypothetical user id 876ylt in the fishbowl graph above the following could be the returned document if we assume a document length of 5</p><blockquote><em>[5ddeb1b2c7, 987abr48y, 5901088cag, 675abr45, 78564kju]</em></blockquote><p>And for the hypothetical post ID 78564kju the following could be the document with length 5</p><blockquote><em>[5901088cag, 675abr45, 987abr48y, 8954563, 8796yit]</em></blockquote><p>Running Doc2Vec on this corpus of vertex ids visited during graph traversal from a starting vertex gives us an embedding representation of each vertex in the graph (user id or post id).</p><h4>Graph DeepWalk Model</h4><p>An alternative embedding method that utilizes graphs to generate embeddings is proposed in DeepWalk [4]. DeepWalk initiates a random walk from each node in a graph up to a certain length T. The list of nodes on the random walk originating from the starting node is considered a unique “sentence” and each “word” is a unique vertex visited during the random walk. For each node Deepwalk generates a few random walks so we have multiple “sentences” from the same starting node. After generating a corpus of such random walk sentences, DeepWalk then trains a Word2Vec SkipGram model where the context is defined as the k surrounding vertices for each vertex in each sentence during a random walk. This method also yields powerful representations of each node in a graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HfgcXQNfgBYKIkx4" /></figure><h3>From Embeddings to Serving Recommendations</h3><p>Training each of the three models above gives us an embedding representation for each post and user id present during training. For the graph model we decided to keep the Doc2Vec BFS model as it gives slightly better performance.</p><p>We concatenate the user embedding and post embedding from each model into one final <em>hybrid embedding</em> that captures both aspects of content and user similarity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yEdJiN_enU_s39fZ" /><figcaption>User Embedding Generation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JURIJFW4_LFK9Rub" /><figcaption>Post Embedding Generation</figcaption></figure><p>Each of the content and graph models are deployed via MLFlow as a REST API service. To serve recommendations, we are provided a list of candidate posts to rank for each user. The candidate posts for each user are only from bowls a user is subscribed to as users cannot see posts from bowls in which they are not subscribed to. On average each user has about 200 new candidate posts to rank per request. We then query the graph and content models to generate the cosine similarity between the user’s hybrid embedding and each candidate post’s hybrid embedding, and rank all candidate posts for a user by their cosine similarity. We then serve the top-ranked K posts to the user per the client’s request. On average the whole inference process takes about 9 ms/batch request.</p><h3>Conclusion</h3><p>In this blog post we saw how in the absence of labeled data we can utilize embedding methods to generate reasonable Fishbowl post recommendations. In the next blog post we will see how we can improve upon this approach even further.</p><p>Here we train a content model from scratch using Doc2Vec, but our Fishbowl corpus is still relatively small. This might not be enough data to learn all the semantic nuances of the English language. In the next post we will see how we can leverage transfer learning using pre-trained models like GloVe or BERT pre-trained on much larger data (e.g: Wikipedia) to generate embeddings for our text features that are more semantically meaningful.</p><p>Secondly, post text is just one data point we can leverage for personalization. We next also consider other text features like user title, user company, user location, post feed name, post feed description to generate high-quality embeddings.</p><p>Finally, the graph embedding methods described above assume all post ids or user ids already exist during prediction requests. This is an unreasonable assumption as the Fishbowl graph is extremely dynamic with hundreds of new posts being added every day and new users joining the network. New posts are also the one that get the most engagement on a given day. As such a graph that did not see a post during training will generate no meaningful embedding for such new highly engaging posts. This makes the graph vertex ID embedding methods not ideal for real-time inference. In the next blog post we will see how we can circumvent this problem and still utilize a graph structure by using feature information of vertices instead of the vertex id itself for training to generate high-quality embeddings.</p><p>Stay tuned for more!</p><h3>References</h3><ol><li><em>Blei, D.M., A.Y. Ng, and M.I. Jordan, Latent dirichlet allocation. Journal of machine Learning research, 2003. 3(Jan): p. 993–1022.</em></li><li><em>Mikolov, T., Chen, K., Corrado, G., &amp; Dean, J. (2013). Efficient estimation of word representations in vector space. arXiv preprint arXiv:1301.3781.</em></li><li><em>Le, Q., &amp; Mikolov, T. (2014, June). Distributed representations of sentences and documents. In International conference on machine learning (pp. 1188–1196). PMLR.</em></li><li><em>Perozzi, B., Al-Rfou, R., &amp; Skiena, S. (2014, August). Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 701–710).</em></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6031abe84661" width="1" height="1" alt=""><hr><p><a href="https://medium.com/glassdoor-engineering/personalized-fishbowl-recommendations-with-learned-embeddings-part-1-6031abe84661">Personalized Fishbowl Recommendations with Learned Embeddings: Part 1</a> was originally published in <a href="https://medium.com/glassdoor-engineering">Glassdoor Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>