Flashcards
Rec sys

Flashcards do conjunto (61)
- 1What is an embedding?A mapping from a discrete set (queries, items etc) to a vector space called an embedding space.
- 2What is candidate generation?Starting from a huge corpus and generating a much smaller subset of candidates
- 3What is scoring?Scoring and ranking candidates to select the set of items (usually the order of 10) for a given user
- 4What is re-ranking?Taking into account additional constraints for the final ranking. For example the system removes items that the user dislikes, or boosts the score of fresher content.
- 5What is content-based filteringSimilarity between items to recommend items similar to what the user likes. Maps each item and query to an embedding vector in a common embedding space
- 6What is collaborative filteringUses similarities between queries and items simultaneously to provide recommendations. Maps each item and query to an embedding vector in a common embedding space
- 7What is an embedding spaceA low-dimensional space that captures some latent structure of the item or query set. Similar items will be closer together, although it may be hard to understand what the exact relationship is between close items
- 8At a high level, what is a similarity measureA function E x E -> R that takes a pair of embeddings and returns a scalar measuring their similarity. For candidate generation we can do as follows: given a query embedding, the system looks for item embeddings that are close to q - embeddings with a high similarity.
- 9Give 3 examples of similarity metricsCosine, dot product, euclidean distance
- 10What is the cosine similarityThe cosine of the angle between the two vectors
- 11What is the dot productThe cosine of the angle multiplied by the product of norms. If the embeddings are normalised then the dot product and cosine coincide.
- 12What is the euclidean distanceDistance in euclidean space. Smaller distance means high similarity. Note that when the embeddings are normalized, the squared Euclidean distance coincides with dot-product (and cosine) up to a constant
- 13Which item will be chosen for each similarity measure?


- 14How to choose which similarity measure ?Items that appear frequently in a training set can have embeddings with large norms, if popularity is important then use dot product.
- 15What is a two tower model?Is a system that uses two separate neural networks - a query tower which represents users and a candidate tower which represents items. latent vector representation. The item and query embeddings are mapped to the same embedding space and similarity can be calculated using the dot product.
- 16What is a cascade ranking system?A multi-stage ranking system. In this system, simpler and faster algorithms that focus on recall metrics are employed at earlier steps (Recall and Pre-Ranking). Whereas the large-scale deep neural networks are employed at the later steps (Ranking and Re-Ranking). Keeping latency expectations and accuracy tradeoffs in mind, an appropriate algorithm is used at each step. Each algorithm calculates some form of relevance or similarity value for every single candidate and passes the most relevant candidate set onto the next step.

- 17How is inference performed with respect to each tower in a two tower model?Item embeddings can be calculated and stored before inference time, and then called for inference using the query tower, which can make use of real-time features for the user. We can also calculate the user vectors offline as well.

- 18What is a drawback of the two tower model?There is lack of information interaction between the two towers. The latent embeddings are trained independently without using any enriching information. This can hinder the models performance
- 19What is data sparsity in recommender systems?. A common technique for using these categorical variables in machine learning algorithms is to convert them to a set of binary vectors via one-hot encoding. This means that for a system with a large (millions, or even billions) userbase and item catalog, the resultant feature input is highly sparse as the actual engagement data is comparatively smaller.
This highly sparse data makes it difficult to learn effective feature interactions because often there isn’t any observed data for a lot of combinations of feature values. - 20What is approximate nearest neighbour search (ANN)Algorithms that find a data point in a dataset that is close to a query point but not necessarily the absolute closest one. NN algorithms are brute force/ exhaustive searches, but ANN is good enough and makes the trade-off for speed over accuracy
- 21What 3 concepts are key to ANN search algorithms?1. Dimensionality reduction - simplify the data while preserving its characteristics
2. Metric spaces - distances between data points are defined according to rules (euclidian distance, cosine similarity)
3. Indexing structures - such as KD-trees, locality sensitive hashing (LSH) and HNSW - 22When should we use ANN search?1. Large datasets 2. High dimensional data, 3. Realtime applications 4. Acceptable approximation
- 23What are KD-treesA space partitioning data structure for organising points in a k-dimensional space. It recursively subdivides a multidimensional space into regions associated with specific data points. They are useful for traversing a high dimensional search space. Logarithmic time complexity for various search operations in average cases.
- 24What is locality-sensitive hashing (LSH)Hashes data points into lower dimensional spaces while preserving similarity relationships. Fast and scalable but may produce false positives
- 25What is hierarchical navigable small world (HNSW)Builds a graph-based index that facilitates quick searches in large scale datasets. Logarithmic search complexity
- 26What is FAISSFacebook AI similarity search, used for high-dimensional vectors. It is a library that provides search methods:
1. IndexFlatL2 - brute force exact search
2. Inverted file index - 27What is re-rankingIn the final phase of a recommendation system, the system has the capability to re-rank candidates by taking into account additional criteria or constraints that were not initially considered. This re-ranking stage allows the system to assess factors beyond the initial scoring, such as the diversity of items within the recommended set. For instance, the system may choose to penalize items that are too similar to one another, thereby fostering a more varied set of recommendations.
- 28What are methods that can be applied at the re-ranking stage?Freshness/novelty, Diversity, serendipity, popularity, seasonality, bias/fairness
- 29What are some solutions to freshness in reranking?1. Re-run training as often as possible for new items (can use warm start)
2. Create an average user to represent new users in matrix factorisation models. You can create clusters of users for this
3. Use DNN search such as softmax or two tower. Feature vectors are an input so can be used on items that were not seen during training
4. Age as a feature - 30What are some solutions to diversity in reranking?When using similarity search you often get similar items to the query embedding.
1. Train multiple candidate generators using different sources
2. Train multiple rankers using different objective functions
3. Re-rank items based on genre or metadata - 31Simply - what is the exploration/ exploitation trade-off?Exploitation involves choosing the best option based on current knowledge of the system (which may be incomplete or misleading), while exploration involves trying out new options that may lead to better outcomes in the future at the expense of an exploitation opportunity. Finding the optimal balance between these two strategies is a crucial challenge in many decision-making problems whose goal is to maximize long-term benefits.
- 32What is exploitation?Exploitation is a strategy of using the accumulated knowledge to make decisions that maximize the expected reward based on the present information. The focus of exploitation is on utilizing what is already known about the environment and achieving the best outcome using that information
- 33What are 3 key aspects of exploitation?1. Reward maximization - This is choosing courses of action based on learned values or rewards that the model predicts will yield the highest expected payoff.
2. Decision efficiency - Exploitation can often make more efficient decisions by concentrating on known high-reward actions
3. Risk aversion - Exploitation inherently involves a lower level of risk as it relies on tried and tested actions, avoiding the uncertainty associated with less familiar options. - 34What are some exploitation strategies?1. Greedy algorithms - Greedy algorithms tend to choose the locally optimal solutions at each step without consideration of the potential impact on the overall solution. They are often efficient in terms of computation time
2. Exploitation of learned policies - Reinforcement learning algorithms tend to base their pursuits on previously learned policies as a way of leveraging on old gains
3. Model-based methods - Model-based approaches take advantage of underlying models that make decisions based on their predictive capabilities. - 35What is exploration?Exploration is used to increase knowledge about an environment or model. The exploration process selects actions with uncertain outcomes to gather information about the possible states and rewards that the performed actions will result.
- 36What are the three key aspects of exploration?1. Information gain - The main objective of exploration is to gather fresh data that can improve the model's comprehension of the surroundings. This involves exploring distinct regions of the state space or experimenting with different actions whose outcomes are unknown.
2. Uncertainty reduction - Reducing uncertainty in the model's estimates of the environment guides the actions that are selected. For example, activities that are rarely selected in the past are ranked in order of possible rewards.
3. State space coverage - In certain models, especially those with large or continuous state spaces, exploration makes sure that enough different areas of the state space are visited to prevent learning that is biased toward a small number of experiences. - 37What are some exploration strategies1. Epsilon greedy exploration - Epsilon-greedy algorithms manage to unify those two characteristics (exploitation and exploration) by sometimes choosing completely random actions with probability epsilon while continuing to use the current best-known action with probability (1 - epsilon).
2. Thompson sampling - Thompson sampling exploits the Bayesian method to explore and exploit services simultaneously - 38What is dynamic parameter tuning?t makes the algorithm dynamically set the exploration and exploitation parameters according to how the model performs and the environment changes characteristics, thus the algorithm can be changed in a way that better adapts to the changing environment and is learning efficiently.
- 39What is Multi-armed bandit frameworks?The multi-armed bandit theory has got a formal basis for balancing the exploration and exploitation in the decision problems that are sequential in nature. They provide algorithms that make the analysis of this trade-off between exploration and exploitation depending on different reward systems and conditions.
- 40What are hierarchical approaches?Hierarchical reinforcement learning (RL) approaches can maintain a balance at different levels of architecture between exploration and exploitation. Classifying actions and policies in the hierarchical order makes efficient search for a combination of methods while using known answers at all level as in exploitation method.
- 41What is bag of words retrieval?BoW isa model which uses an unordered collection (a bag of words) and returns counts for how often each word appears ignoring the order
- 42What is TF-IDFTerm frequency inverse document frequency. How important is a word to a document in relation to a larger collection of documents
1. TF - measures of often a word appears in a document out of all terms
2. IDF - reduces the weight of common words across documents and increases weight of rare words. = total n docs/ n docs containing the term
3. calculate TF * IDF - 43What is BM25Best matching 25 is a ranking algorithm used in information retrieval systems to determine how relevant a document is to a given search query
It measures term frequency and document relevance more accurately.
It accounts for document length normalization, giving fair weight to all documents.
It is widely used in tools like Elasticsearch, Whoosh and Lucene.
It helps to deliver more relevant search results based on keyword matching and context. - 44Compare BM25 and embedding based retrieval

- 45For LTR (learning to rank) algorithm there are challenges of using typical ranking evaluation metrics - why?NDCG, MAP, MRR measure the quality of the entire ranked list, they depend on the relative order of items and are often non-differentiable - so optimisation using standard gradient descent is problematic
- 46How are gradient boosting approaches better for ranking evaluation metrics?GBMs can optimise loss functions that implicitly improve the target ranking metrics.
Using a pointwise approach, pairwise approach, or listwise approach - 47With respect to LTR what is a pointwise approachTreats each item independently, reframes LTR as a regression or classification problem. Predict a relevance score for each item based on its features relative to the query. The final ranking is obtained by sorting items based on these predicted scores. Limitations are it ignores the relative ordering during training. The model doesn't explicitly learn that item A being ranked higher than item B is preferable for a given query. Standard loss functions like MSE or LogLoss are used. While simple, this often yields suboptimal ranking performance compared to methods that directly evaluate item pairs or lists.
- 48With respect to LTR what is a pairwise approach?Instead of evaluating items individually, the pairwise approach focuses on the relative order of pairs of items within the same query context. The goal is to learn a scoring function f(q,d) where f(q, di) > f(q, dj)
- Training data is constructed from pairs for each query, if di is more relevant than dj the pair forms a positive training instance for the relative ordering - 49With respect to LTR what is a listwise approach?These methods attempt to directly optimize a loss function defined over the entire list of items for a query. They try to capture the complex interdependencies among all items in the ranked list and directly approximate the target ranking metric. Examples include ListNet, ListMLE, and variations that build upon LambdaMART principles but examine the full list structure more explicitly. While theoretically appealing, they can be computationally more demanding and complex to implement effectively. Often, well-tuned LambdaMART (technically pairwise with Lambda gradients, but behaving list-wise) provides a strong practical baseline.
- 50What are the three main approaches for LTR algorithms?

- 51Why might we prefer precision@k over recall@kuse precision@k when you care about the usefulness of the displayed results, and recall@k when you care about not missing relevant items
- 52Examples of covariate shiftMedical imaging: A model trained on X-rays from one hospital (older machines, different lighting) is deployed at another hospital with newer equipment. The images look different, but a tumour is still a tumour.
Spam detection: A model trained on emails from 2010 is applied to 2024 emails — the writing style and vocabulary shift, but spam is still spam.
Self-driving cars: A model trained on sunny California roads is deployed in rainy London. The scenery changes, but a stop sign still means stop. - 53Examples of label shiftDisease screening: A COVID test model trained during a peak wave (high prevalence) is used after restrictions ease (low prevalence). Positive cases look the same, but they're now much rarer.
Fraud detection: A model trained during the holiday season (high fraud rate) is used in January — fraud looks identical, but occurs less frequently.
Sentiment analysis: A product review model trained on a niche audiophile forum (mostly positive) is deployed on a general retail site with more mixed reviews. - 54Examples of concept driftCredit scoring: "Has a mortgage" used to signal financial stability, but after a housing crash, it signals risk. The input is the same; its meaning changed.
News topic classification: The word "tweet" once meant a bird sound; now it primarily means a social media post. The label for the same word flips.
Stock price prediction: A model trained pre-pandemic finds that patterns that once predicted growth now predict decline, because market dynamics fundamentally changed.
Recommendation systems: A user's taste in music evolves over years — the same listening history no longer predicts the same preferences. - 55Why normalised embeddings?Normalized embeddings make cosine similarity and dot product equivalent, which simplifies retrieval and ranking. However we use magnitude information
- 56How to pick the best similarity measure for embeddings?Use cosine similarity when vector length should not matter and you care about semantic alignment, which is common for text embeddings.
Use dot product when vector magnitude carries useful signal, such as popularity, confidence, or strength.
Use Euclidean distance when absolute geometric closeness in the embedding space matters, especially if the model or training objective was built around that notion. - 57Whats a rating matrix

- 58What is required for offline evaluationOffline evaluation consists in collecting user interaction data—most commonly from a working system—over a period of time and setting it aside for repeated experimentation. The offline data are usually divided into two disjoint subsets: the “training” subset is passed as input to the evaluated systems, and the “test” subset is taken as ground truth for metric computation.
- 59What is self selection biasWhen presented with an item, users are more prone to engage with some items than others (Marlin et al. 2007). Reasons include the perception by the user that one item will be more interesting to them than others, or will suit their needs better, or the item simply draws the user's attention or curiosity (e.g., a shocking video).
- 60What is external exposure biasxternal bias factors include, for instance, advertisement, fashion, mouth-to-mouth communication, or virality in social media, that boost the popularity of particular products, news, artists, brands, and so forth, outside the system. These biases may leak into offline data when users actively seek such popular items in the data logging system, or are influenced by their external environment in their choices in the system.
- 61What is internal exposure biasInternal exposure biases are generally stronger than external ones, and are produced by the algorithms (such as search, browsing and recommendation functionalities) that decide which items are presented when collecting offline data. The placement of retrieved items in the user interface is an additional major internal source of bias: items at prominent positions receive a disproportionately higher user attention. Of course, time is another major factor in item exposure: the longer an item exists, the more opportunity it gets to attract people's attention—in this respect, item cold start can be seen as a natural case of observation bias.
Informações
- Descrição
- Software Engineer ML Theory FlashCards sobre Rec sys, criado por Sophie Cooper em 18-03-2026.
- Criado por
- Sophie Cooper
- Visualizações
- 3
- Avaliação