{'fraction_non_alphanumeric': 0.027845241457215477, 'fraction_numerical': 0.005478678339452132, 'mean_word_length': 4.918602707671736, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Fighting Redundancy and Model Decay with Embeddings

Every day, hundreds of millions of new Tweets containing over 40 languages of ever-shifting vernacular flow through Twitter. Models that attempt to extract insight from this firehose of information must face the torrential covariate shift that is endemic to the Twitter platform. While regularly-retrained algorithms can maintain performance in the face of this shift, fixed model features that fail to represent new trends and tokens can quickly become stale, resulting in performance degradation. To mitigate this problem we employ learned features, or embedding models, that can efficiently represent the most relevant aspects of a data distribution. Sharing these embedding models across teams can also reduce redundancy and multiplicatively increase cross-team modeling productivity. In this paper, we detail the commoditized tools, algorithms and pipelines that we have developed and are developing at Twitter to regularly generate high quality, up-to-date embeddings and share them broadly across the company.


INTRODUCTION
Most Machine Learning algorithms operate on vectors. However, many entities' natural vector representation is very sparse or highdimensional. For example, text is often represented as a series of sparse one-hot vectors, graphs are often written as highly-sparse adjacency matrices, and pixel representations of images and videos are high-dimensional and over-determined.
Unfortunately, many powerful models work best on low-dimensional dense entity representations. To address this mismatch, researchers have developed a variety of methods for generating embeddings or low-dimensional learned representations. These methods compress sparse or high-dimensional structure into small information-dense vectors. For example, matrix factorization and co-occurrence techniques like in [16] [3] [20] extract low-dimensional latent vectors from large and sparse matrices. Furthermore, neural network-based techniques like [13] and [24] extract nonlinear structure from redundant high -dimensional signals.
Recently, there has been a great deal of research on generating embeddings for arbitrary entities and employing them in production Machine Learning systems. For example, the authors of [5] use entity embeddings to simplify the Youtube recommendation problem. In addition, the authors of [26] describe an algorithm for generating generic entity co-embeddings.
In this paper we introduce the embedding algorithms and tools that we are developing to simplify Machine Learning at Twitter. Our paper is organized as follows. First, we present some of the challenges that are unique to Twitter. Next, we describe our embeddings technical stack, including our integrations with Airflow, a central Feature Registry, and a benchmarking system. We then outline a few Machine Learning tasks at Twitter that we solve through the application of the learned embeddings. Finally, we describe several of the embedding algorithms that we employ.

UNIQUE CHALLENGES OF TWITTER DATA
Twitter's platform presents a variety of unique challenges to any Machine Learning system. The amount of data to consume is massive (the so called firehose): every day, Twitter's 300+ million monthly active users author several hundred million Tweets. Further, because of Twitter's focus on real time information dissemination each Tweet needs to be processed and delivered to users within microseconds.
Second, due to the myriad of text-based content, the presence of largely disjoint Twitter "interest groups", and Twitter's skewed follow graph (such that most nodes have only a few edges while some have tens of millions), most Machine Learning algorithms at Twitter naturally operate on sparse data. This can make training models particularly difficult [27] [28] and force teams to rely on algorithms like binning or feature hashing [25].
Third, the distribution of Twitter data is in constant flux. Topics that are trending now might essentially disappear in weeks, days, or even hours. For example, a specific event like an election or game may dominate conversations for a short period of time, and then die out. The detrimental effect of this kind of covariate shift on performance in described in [23] [19].
We demonstrate this effect by computing the percent overlap between this week's most popular 5K @ mentions, linked websites, hashtags and words, with those that were most popular last week, a month ago and a year ago ( Figure 1). We observe that especially for mentions, linked websites, and hashtags, the frequency of overlap drops off quickly. A model trained a month ago will have been trained with less than 50% of today's most popular hashtags.
In addition to this coverage dropoff, the meanings of words also change over time. This is not only a problem at Twitter: lingual shift is endemic to any text-based online platform. To see how this is problematic, consider a model that accepts text as inputs, where the text is represented as a series of word embeddings [16] [14]. As words shift in meaning, word vector models become stale and degrade the performance of all models that depend on them. To illustrate this effect, we trained a series of skipgram word embedding models over the last several years of Tweet data and observed that certain word relationships changed dramatically over that time period. We show some clear examples in Figure 2. Luckily, we can employ entity embeddings to solve all three of these problems. First, since entity embeddings are low dimensional, they reduce the computational load on Machine Learning models across teams. Second, since entity embeddings are dense representations of sparse structure, they naturally work well with most Machine Learning approaches. Third, since regularly retrained embeddings naturally represent the most relevant aspects of data distributions, embeddings can reduce the impact of covariate shift on Twitter.

OUR EMBEDDINGS TECHNICAL STACK
Unlike hand-crafted features, which are generated by rule-based algorithms, learned embeddings are themselves outputs of models. These models must be trained from data, regularly retrained and benchmarked alongside the models that they are used with and served at scale. We are developing a series of tools that make it simpler for teams to customize, develop, access and share embeddings.

Workflows.
At Twitter, we have integrated Airflow [1] into our technical stack in order to manage complex Machine Learning workflows. Airflow allows us to replace the glued-together ad-hoc scripts that form most Machine Learning workflows into reusable programmatic components. Importantly, the various components can be very different in nature. For example, many embedding pipelines include both Scalding (Twitter's Scala Map-Reduce library) for data collection and DeepBird (Twitter's Python and Lua Deep Learning library)  Tweets written  during different time periods show significantly different relationships between words. for training. By defining a pipeline and scheduling it to regularly execute, we are able to maintain fresh embedding models and win the battle against data distribution shift. In addition, establishing a "workflow" abstraction for all of the components of an embedding pipeline makes it easier for engineers to reason about the pipeline as a whole, rather than as a series of complex components. Furthermore, since each pipeline is built from modular components it's simple to adapt embedding generation pipelines into larger systems. In order to support end-to-end hyperparameter optimization, we have also integrated Airflow with Whetlab [10]. To give an example, our Word2Vec pipeline consists of the following steps: (1) Execute a series of Scalding jobs to collect recent Tweets, concatenate them into conversations, identify commonly used words and phrases, and form skipgram pairs. (2) Execute our DeepBird Co-Occurrence Pipeline to generate word vector embeddings and publish them to the Feature Registry (See "Co-Embeddings"). This pipeline is fully automated and scheduled to run at regular intervals.
Feature Registry. We are in the process of rolling out Feature Registry, a central feature management store that allows teams to easily manage and share extracted features, including entity embeddings. It provides a unified access layer for any kind of raw, derived or learned feature (Figure 3), thereby abstracting the complexity of feature generation and streamlining the model construction and deployment process. Features for each Twitter entity, such as users and Tweets, are stored in the Feature Registry and made available for easy access by any model that operates on that entity. Feature Registry is also integrated tightly with Airflow, which allows us to automatically publish new versions of embeddings and their respective benchmarks to the Feature Registry. This kind of centralized feature sharing tool dramatically reduces the effort required for teams to develop Machine Learning pipelines.
Embedding Benchmarking System. Unlike with a classification or regression model, it's notoriously difficult to measure the quality of an embedding. One of the reasons for this is that different teams use embeddings differently. For example, while some teams use user embeddings as model inputs, others use them in nearest neighbor systems. To mitigate this problem we have developed a variety of standard benchmarking tasks for each type of embedding. Every time an embedding is retrained it is automatically re-evaluated on these benchmarks, and the results are published in the Feature Registry along with the embeddings. Some examples of the task we include in our benchmarking are: • User Topic Prediction. During onboarding, Twitter users may indicate which topics interest them. The ROC-AUC of a logistic regression trained on user embeddings to predict those topics is a measure of that embedding's ability to represent user interests. • Metadata Prediction. Certain users provide their demographic information (such as gender, age, etc). The ROC-AUC of a logistic regression trained on user embeddings to predict this metadata is a measure of how well that embedding might perform on a downstream Machine Learning task. • User Follow Jaccard. We can estimate the similarity of two users' tastes by the Jaccard index of the sets of accounts that the users follow. Over a set of user pairs, the rank order correlation between the users' embedding similarity (as determined with a similarity metric like Dot Similarity uv, Cosine Similarity uv ∥u ∥ ∥v ∥ or Euclidian Similarity 1 − ∥u −v ∥) and their follow sets' Jaccard index is a measure of how well the embedding groups users.
See Table 1 for some embeddings' results on these tasks.

EXAMPLE TASKS
We now introduce two tasks that we will refer back to several times throughout the rest of the paper as concrete examples of tasks on which embeddings can improve performance. We also now introduce the strategies we use to incorporate embeddings into our solutions to these tasks.

Tweet Email Recommendations
One of the most important objectives at Twitter is motivating existing users to enter the platform and interact with new Tweets. One of the best ways to do this is to identify which Tweets a user might find interesting and email those Tweets to that user. An "Email Recommendation" is considered successful if the user chooses to click the Tweet in the email. Therefore the Tweet Email Recommendation problem is: given a user and a Tweet, determine whether the user would click on this Tweet in an email.

New User Follow Recommendations
The very first experience users have after creating a Twitter account is the New User Experience (NUX), where users are asked to upload an address book, select their interests, and then receive recommendations for accounts to follow. Since the accounts followed from this step compose a user's entire original timeline, there is a large potential for these recommendations to make or break the initial Twitter experience. In addition, since this recommendation must occur immediately after a user signs up, many of the most important signals (such as the Tweets a user likes or the other accounts they follow) are absent. We will focus on one important submodule of the overall recommendation algorithm: Follow Prediction. Given the information about a user that is present at signup time and a potential account to follow, predict whether the user will choose to follow this account (and not unfollow shortly after signup).

Solving Tweet Email Recommendations and New User Follow Recommendations
A simple solution to both the Tweet Email Recommendation and New User Follow Recommendation problems is to use a model like a multi layer perceptron (MLP) that accepts user and Tweet/Accountto-Follow features. These features might include include descriptive data like Tweet length, creator information, existing engagement statistics, user metadata, etc. In order to eke the maximal performance out of these features, we applied techniques like Feature Hashing, MDL and the sparse cross-product transformation [25] [6]. In order to evaluate the degree to which embeddings can improve the performance of these models, teams at Twitter have developed versions of the wide-and-deep (WAD) model [4] that accepts both conventional sparse features and pre-computed embeddings. The model architecture is presented in Figure 4. Note that since the conventional sparse features are already very heavily engineered for their respective problems, providing additional improvements  on top of these features with a generic embedding model is not a simple task.

EMBEDDING STRATEGIES
In the next several sections we describe the techniques that we use to embed entities at Twitter.

Matrix Factorization
One of the most popular approaches for representing users in terms of their interactions with items (e.g. Tweets, other users) is the Low Rank Matrix Factorization paradigm. In this approach we form the sparse user-item affinity matrix and approximate it as the product of a low-rank user matrix and a low-rank item matrix. The reasons for Matrix Factorization's popularity are easy to understand: it's simple to interpret (each dimension within the low-rank embeddings can be interpreted as an underlying "latent factor") and there exist a variety of high-quality implementations that are suitable to large datasets [11] [15] [22]. We now introduce two examples of Matrix Factorization's successes at Twitter.
Consumer-Producer Engagement Matrix Factorization. On Twitter, users are classified into one of two roles based on their behavior patterns: Producers and Consumers. Producers are users who have relatively large numbers of high quality followers, e.g. celebrities, activists, or politicians, while Consumers are all other users. By gathering and organizing engagement data (e.g. Likes, Retweets) between Consumers and Producers, we can form the sparse affinity matrix X where each entry x i j represents the engagement strength of a Producer j to a Consumer i. To get rid of noise, reduce the matrix sparsity and improve efficiency, we prune the graph with following steps: (1) Get the set of all follows from normal active users and find the 1 million users that have the most follows in this set. This is the set of producers.
(2) Form X r aw from the set of engagements between normal active users and these producers. (3) Compute the row and column sums of X r aw and use these sums to normalize each element x r aw i, j : Although normalizing the rows of a matrix before performing SVD is a common practice [7] we found that applying normalization to both the columns and rows helped reduce the impact of Twitter's heavily lopsided follow graph and improve performance.   Table 4: Evaluation of the SVD Producer embeddings versus a baseline follow graph embedding on three benchmark tasks.
After the above construction and pruning steps, we can perform singular value decomposition (SVD) on the normalized matrix X : Where Σ is the diagonal singular value matrix and the columns of U and V are the left and right singular vectors respectively. To obtain a low-rank factorization of X , we take the top-k singular values and associated left/right singular vectors. Since the magnitude of singular value i reflects the significance of both the i t h left and the i th right singular vectors, it's natural to absorb the square root of singular values into U and V to form the Consumers' and Producers' embedding matrices U * and V * : In Table 2 we demonstrate that incorporating the user embeddings that we generate with this technique consistently improves the performance of the Email Recommendation model across all levels of user activity. In Table 3, we demonstrate that incorporating Producer embeddings into the NUX model can improve performance over using just a user embedding.
In order to quantify the performance of these Producer embeddings in a more direct manner, we also compute user embeddings with the DeepWalk algorithm [18] and evaluate the results on three tasks with human labeled data: (1) LOS-Accounts: In this task, we train a logistic regression model on the top 10,000 producer embeddings to classify them into one of 59 human-determined interest categories. We measure the model's performance as its classification accuracy.
(2) Known-For and Interested-In: In these tasks, for each of the top 100,000 producers we train a multi-output linear regression model on that producer's embedding to predict the degree to which that producer is respectively "known for" and "interested in" each of 6011 tags (e.g. "news", "hollywood", "gastronomy", "women in science", etc.). We measure the model's performance as the average value of the NDCG between the model induced and human labeled rankings.
On all three tasks we find that our SVD user embeddings outperform the DeepWalk embeddings (Table 4).

TFW Interaction Matrix Factorization.
Before many browsers are used to sign up for Twitter, they have already interacted with Twitter on websites with embedded Twitter content, known as Twitter for Websites (TFW) domains. Similar to Consumer-Producer engagement embeddings, we can learn TFW embeddings by factorizing the browser-TFW interaction matrix. Since this data is available during the NUX, TFW domain embeddings can be particularly useful for the NUX Follow Recommendation task, where few other strong signals exist.
An interesting facet of TFW data is that it's extremely skewed: over 80% of browser instances interact with the top 5 or so domains, but the distribution drops off quickly so that less than half a percent of browser instances interact with the 100 th most popular domain. We find that these most popular TFW domains (e.g. www.google.com) are mostly uninformative, so we remove them. This leads to extreme sparsity, so we use the Alternating Least Squares (ALS) approach from [9] to downweight the impact of 0s on the matrix factorization objective. Our algorithm consists of the following steps: (1) Select the 1 million most popular TFW domains and gather the interactions between browser instances and these domains to form the matrix A of browser-TFW interactions. Normalize this matrix similarly to how we normalize the Consumer-Producer matrix.
(2) Apply the Alternating Least Squares algorithm to factorize this matrix into the browser and domain matrices U and V such that A ≈ UV . As we can see in Table 3, the ALS TFW domain embeddings provide a significant performance improvement for the NUX task.

Co-Embeddings
Most product teams at Twitter deal with the basic underlying problem of selecting a small subset of entities (Tweets, users, events, etc) from a possible large set and presenting a ranked list of these entities to clients such that they deliver the desired customer experience.
A few examples are: (1) The home timeline presents a ranked list of Tweets from a host of possible Tweets by first narrowing them down to Tweets engaged or authored by other users in your network or from out-of-network authors based on your interests and past engagements. (2) Ads selects a small ranked list of line items that the customer is most likely to engage with from a possible large set, eligible to be displayed to the customer based on advertiser's chosen targeting criteria.
Although it would require a great deal of work for each team to develop their candidate recommendation systems in isolation, if we have embeddings for users and entities such that a similarity metric like dot product uv, cosine similarity uv ∥u ∥ ∥v ∥ or euclidian similarity 1 − ∥u − v ∥ is indicative of user-item affinity, then this reduces to an approximate nearest neighbor problem. As such, an important effort we have made at Twitter is developing reliable user-item co-embeddings, and we are currently in the process of developing a large scale nearest neighbor system to use these co-embeddings for candidate recommendation. In the meantime, we have seen strong results by using co-embeddings directly in Machine Learning models.
Note that the Consumer-Producer matrix factorization algorithm that we discussed above is an example of a co-embedding algorithm, where the Consumer and Producer embeddings are engineered such that the dot product of some Consumer's embedding and some Producer's embedding will be as close as possible to the number of engagements between that Consumer and that Producer. This framework works well when we are interested in a fully collaborative co-embedding algorithm without user or item metadata 1 and we have a concrete measure of "affinity" between a user and an item that we want dot products to represent.
In order to generate user-item co-embeddings from arbitrary features, we are developing a generic co-embedding network system (similar to [2]). Our system consists of two embedding networks, a user network and an item network, which accept feature representations of users and items respectively. The networks produce embeddings of the same length such that the dot product (or other similarity metric) between a user's and item's embeddings is indicative of the affinity between that user and item (See Figure 5 for an example). This approach works well when we are interested in generating co-embeddings from complex nonlinear combinations of 1 Certain matrix factorization approaches can incorporate user/item metadata, but we omit them for this discussion user and item features and we need generate realtime embeddings for new users and items based on these features.
In both of the above methods, our goal is to co-embed entities such that the similarity between two entities' embeddings is as close as possible to some measure of affinity between the entities. However, it's often more convenient to frame the interaction between two entities in terms of "co-occurrences". For example, a co-occurrence between a user and a Producer could be an instance of a user liking that Producer's content. Then the objective is to generate embeddings such that the similarity between two entities' co-embeddings is indicative of the entities' co-occurrence likelihood.
At Twitter Cortex, we have developed a generic "Co-Occurrence Embedding" system (similar to [26]) that can generate co-embeddings for entity types e 1 and e 2 from a set of (e 1i , e 2j ) co-occurrence pairs. The pipeline integrates with Airflow, so engineers can implement workflows to regularly generate new co-occurrence pairs and retrain the embeddings (such as the word vector embedding workflow described in "Workflows"). The system performs the following algorithm to pull the embeddings for entities that tend to co-occur closer together, and push embeddings for entities that rarely cooccur apart: (1) Construct the embedding matrices E 1 and E 2 , where the i th row of E 1 (E 1 i ) and the j th row of E 2 (E 2 j ) correspond to the embeddings for e 1i and e 2j respectively. (2) For each pair of entities (e 1i , e 2j ), select a group of "negative samples" S e 2 from the set of e 2 entities and perform an SGD step to maximize the function loдσ ( There are three ways that we can use this pipeline to generate entity embeddings: (1) We can co-embed two entity types based on a co-occurrence criteria between them, such as the Consumer-Producer example above.
(2) We can co-embed entity types e 1 and e 2 by representing e 1 as a "a bag of features", defining a co-occurrence criteria between e 1 's features and e 2 , and assigning e 1 's embeddings to be the weighted average of it's feature embeddings. (3) We can embed a single entity type according to a co-occurrence criteria. For example, in [16], Mikolov et al used this strategy (known as skipgram in this context) to generate word embeddings based on the co-occurrence criteria that two words appear near each other in a document.
Use case (2) is particularly robust in situations where we need to model new items in realtime, since we can compute new embeddings with just a table lookup and a vector average. For example, we can use (2) to co-embed users and Tweets by representing Tweets as "bags of words, " and defining the user-word co-occurrence criterion as "word appears in Tweet that user likes. " This strategy allows us to quickly compute new Tweet embeddings that we can directly match with existing user embeddings.
We can also use (2) to generate embeddings for new users based on the TFW domain interactions of corresponding browsers. If we define a (TFW domain, Producer) co-occurrence event between domain r and Producer p as an instance of a user who follows p and whose corresponding browser visits r , we can use this to generate  embeddings for new users that we can easily match with existing Producers. We find that we can use this strategy to improve the performance of the NUX recommendation model. Just adding the dot product between 300 element TFW domain embedding and the Producer's embedding to the feature set improves the RCE and ROC-AUC of the NUX model by 0.14 and 0.001 respectively. We can also see that these "TFW Co-Occurrence" embeddings perform well on the embedding benchmarking tasks (Table 1).

Folding-In New Entities
One of the primary downsides of some of the embedding techniques that we have discussed (such as Matrix Factorization and Direct Co-Occurrence) is that all of the embeddings are generated and saved at the same time. This makes it difficult to assign embeddings to new entities without retraining the model from scratch and can even decrease model performance. For example, consider the problem of generating Consumer and Producer user embeddings with a matrix factorization approach. The model uses the recent interactions between Consumers and Producers to quantify Consumers' affinities for Producers. For relatively mature and active users this is a good approximation. However, new and inactive users have significantly fewer interactions with Producers, so their Producer interactions are noisier approximations of their Producer affinities. Therefore, we may see better overall performance by omitting these noisy users from the model training.
To address these problems, we use "Folding-In" strategies to assign static embeddings to new entities without affecting the original embedding model. To illustrate how this works, consider a matrix factorization model where we approximate the user-item interaction matrix X with the product of the low rank user matrix U and the low rank item matrix V . Then for some new user with interaction vector x, we want to assign to them the embedding u such that ∥uV − x ∥ is minimized. If our matrix factorization model is a vanilla SVD, this is equivalent to the problem of projecting the vector x onto the user embedding vector space [21]. If we write our SVD such that then we can project x onto the row space of U with If our matrix factorization model is a more general least squares model along the lines of [9] or [12], then we don't have the orthonormality guarantees that SVD provides, so it's not quite as easy to perform this projection. However, we can still apply a least squares solution method or use an approximation of V −1 .
Since we can express the "Folding-In" procedure as the product of a sparse user-item interaction vector and a dense "fold-in" matrix, folding a new user in is as simple as querying Feature Registry for the rows of the dense matrix corresponding to the items that user interacted with and computing their sum weighted by the strength of the user's interactions with those items. This is valuable for two reasons. First, we can perform this operation online without any modeling architecture, making it an attractive approach for assigning embeddings in low latency settings. Second, in an offline setting we can express these operations in a Map-Reduce framework (such as Twitter's Scalding library), which allows us to easily fold hundreds of millions of users into our matrix factorization models.
During the map phase, the algorithm converts each item vector to a set of (item, index, value) tuples and joins them to the set of (user, item, interaction) tuples to form a set of (user, index, value * interaction) tuples. During the reduce phase, the algorithm sums along the user and index dimensions to produce the user embeddings. This structure allows the algorithm to easily parallelize across multiple machines and quickly assign embeddings to hundreds of millions of users.
Folding-In Experiment. In this experiment we collected a set of Twitter users and popular Twitter Producers, formed the sparse Consumer-Producer engagement matrix and explored how removing users with fewer engagements affected the performance of an Alternating Least Squares model [9].
To begin, we split our Consumer-Producer engagements into training and testing sets for each user. Then, we repeated the following algorithm for different values of N : (1) Select the top N percent of users and use their training set engagements to train the Alternating Least Squares algorithm.
(2) Assign user embeddings to the remaining users by multiplying their training set engagements with an approximation of V −1 . (3) Evaluate the model performance over the testing set engagements with the NDCG metric. We found that the model's performance initially increases as we remove noisier users from the training set, but it eventually peaks and begins to decrease after the training set becomes too small ( Figure 6). Importantly, this effect holds over both the users who we fit the model on and the users who we fold into the model. That is, our predictions of noisy users' future engagements is more accurate when we leave them out of the model fitting stage than when we include them. Figure 6: An Alternating Least Squares model trained on Consumer-Producer interactions performs best when we remove the noisiest users from the training set and fold them into the model after.
"Lookalike" Folding-In. In certain situations we may want to use a co-embedding to predict the affinity between a user with no interaction data whatsoever and an entity. For example, we may want to determine the affinity between a new user and a Producer based on the Consumer-Producer SVD embedding. In these situations we can't use traditional Folding-In strategies, so we utilize a technique that we call "Lookalike Folding-In".
First, we look up user embeddings for existing users that are similar to the new user, e.g. users in the new user's address book, users who selected the same interest categories when they signed up, and users who are in the same geographical area 2 . Next, we compute the similarity (dot product in this case) of each user embedding with the candidates' embeddings and we compute the quantiles (e.g. max/median/min) of these similarity vectors to generate a set of user features that we can use in a model (Figure 7). We find that incorporating these features into the NUX model improves the RCE and ROC by 0.47 and 0.004 respectively.

Democratized Embeddings
Although multiple teams may be interested in the same embedding, it's not uncommon for different teams to have different efficiency and quality requirements and therefore be interested in embedding vectors of different lengths. For example, the analytics team at Twitter performs realtime interactive user segment analysis, which requires low latency modeling but is relatively robust to the lack of fine grained information about each user. Therefore, they would be most interested in very low dimensional user embedding vectors . In contrast, since the Email Recommendation team's   models run offline latency is less of a concern, but their standards for performance are higher. Therefore, it would make sense for the Email Recommendation team to use higher dimensional user embedding vectors (100-1000).
Rather than resort to training separate embedding models for each team, we apply a variation on the Deep AutoEncoder model [8] to easily supply multi-length embeddings to teams throughout Twitter. The Deep AutoEncoder is composed of two symmetrical deep-belief networks. One network performs an encoding operation f (·) while the other one performs a decoding operation д(·) (Figure 8). The model accepts an original high-dimensional embedding as input, which it sequentially encodes into smaller and smaller embedding vectors, the final of which is decoded by the decoding network. We train the model to minimize the difference between the original input embedding and the decoded output: arg min f ,д ∥x − д(f (x))∥. In our construction, we monotonically decrease the number of neurons from the input layer to the bottleneck layer, and we found that we achieve better performance by replacing the RBM's sigmoid activation function with the relu [17] activation function and training the model in an end-to-end fashion.
Once this model is trained, each layer in the encoder can serve as a user representation of different dimensionality. As we demonstrate in Figure 8, each team can select the layer with the efficiencyquality tradeoff that best suits them. This decision is made particularly easy by the available of our Embedding Benchmarking System. We refer to this technique as "Embedding Democratization," and we demonstrate in Table 2 and Table 1 that using this technique to nonlinearly reduce the size of Consumer-Producer SVDs from 1000 elements to 50 elements does not dramatically impact the performance of the Email Recommendation pipeline (whereas simply taking the top 50 elements of the SVD does dramatically reduce Email Recommendation performance).

DISCUSSION
In this paper we described the tools and algorithms that we have constructed at Twitter to facilitate generating and sharing embeddings. We also detail a variety of embedding methods, such as Matrix Factorization, Co-Occurrence, Folding-In and Democratization, and demonstrate the results of applying them to real world problems at Twitter.
There are few consistent guidelines and best practices for developing reusable Machine Learning systems, but we believe that tools and algorithms which facilitate modularity and collaboration -such as Workflows, Feature Registry, and the Embedding Benchmarking System -help mitigate Machine Learning's inherent pitfalls. By abstracting away the complexities of model building, these tools can allow Machine Learning to scale.