A latent space represents users or items with features inferred from data rather than recorded as explicit attributes. In personalized search, these features help identify shared interests, recommend products, and boost results for a particular user. section 9.0 section 9.3.1
One way to learn this space is matrix factorization. Start with a user–item matrix whose entries reflect interactions such as purchases or ratings. Factor it into a user matrix and an item matrix, both using the same smaller set of latent features. Multiplying a user’s feature values by an item’s corresponding values and summing them predicts that user’s preference—even for an item with no recorded interaction. This is especially useful when the original matrix is too sparse for direct comparisons between users. section 4.2.3 section 9.3.1
Finding a pattern without product descriptions
Suppose several shoppers buy stainless-steel microwaves, refrigerators, and dishwashers, while others buy black versions of those appliances. Their interaction patterns can reveal a latent feature that separates the products by color, even if the model receives only product IDs. The learned feature need not come with a readable label. section 9.3.1 section 9.4.1
Figure 9.7 Matrix factorization. The user-item matrix R is decomposed into two matrices, a user matrix U and an item matrix I. The product of these two matrices (U . I) should be as close as possible to the original user-item matrix R.
The diagram shows how a user–item matrix is represented by smaller user and item matrices whose product approximates the observed preferences. section 9.3.1
Latent spaces can also come from document content. A language model maps each product’s text to an embedding: each dimension is a latent feature, and its value indicates how strongly that feature appears. Product embeddings and user interactions can then form an evolving profile for personalizing search results. Unlike illustrative dimensions labeled “color” or “cost,” real embedding dimensions are generally unlabeled and more complex. section 9.4.1
Listing 9.12 Generating product embeddings
from sentence_transformers import SentenceTransformer #1
transformer = SentenceTransformer("all-mpnet-base-v2") #1
... #2
def get_embeddings(texts, model, cache_name, ignore_cache=False):
... #2
embeddings = model.encode(texts) #3
... #2
return embeddings
product_embeddings = get_embeddings(product_names,
transformer, cache_name="all_product_embeddings")
The Python listing generates product embeddings with SentenceTransformer and its encode method, making the content-based route concrete. section 9.4.1
Latent features extend limited signals into predicted preferences; they do not eliminate the need for signals. Collaborative filtering can miss a new item that has never attracted an interaction—the cold-start problem. Content-derived embeddings offer a different way to represent items using their text. section 4.2.3 section 9.4.1

















