merlin.models.tf.MatrixFactorizationBlock

merlin.models.tf.MatrixFactorizationBlock(schema: merlin.schema.schema.Schema, dim: int, query_id_tag=<Tags.USER_ID: 'user_id'>, item_id_tag=<Tags.ITEM_ID: 'item_id'>, embeddings_initializers: Optional[Union[Dict[str, Callable[[Any], None]], Callable[[Any], None]]] = None, embeddings_l2_reg: float = 0.0, aggregation=CosineSimilarity(), **kwargs)[source]

Returns a block for Matrix Factorization, which created the user and item embeddings based on the schema and computes the dot product between user and item L2-norm embeddings

Parameters
  • schema (Schema) – The Schema with the input features

  • dim (int) – Dimension of the user and item embeddings

  • query_id_tag (_type_, optional) – The tag to select the user id feature, by default Tags.USER_ID

  • item_id_tag (_type_, optional) – The tag to select the item id feature, by default Tags.ITEM_ID

  • embeddings_initializers (Optional[Dict[str, Callable[[Any], None]]] = None) – An initializer function or a dict where keys are feature names and values are callable to initialize embedding tables

  • embeddings_l2_reg (float = 0.0) – Factor for L2 regularization of the embeddings vectors (from the current batch only)

  • aggregation (_type_, optional) – Aggregation of the user and item embeddings, by default CosineSimilarity()

Returns

A block that encodes user ids and item ids into embeddings and computes their dot product

Return type

QueryItemIdsEmbeddingsBlock