towhee.models.collaborative_experts.collaborative_experts.sharded_single_view_inner_product

towhee.models.collaborative_experts.collaborative_experts.sharded_single_view_inner_product(embds, subspaces, text_weights=None, l2renorm=True)[source]

Compute a similarity matrix from sharded vectors.

Parameters:
  • (dict[str (embds) – torch.Tensor]): the set of sub-embeddings that, when concatenated, form the whole. The ith shard has shape B x K x F_i (i.e. they can differ in the last dimension), or shape B x F_i

  • l2norm (bool::True) – whether to l2 normalize the full embedding.

Returns:

similarity matrix of size BK x BK.

Return type:

(torch.tensor)