import { ... } from "@langchain/core/utils/math";This function calculates the row-wise cosine similarity between two matrices with the same number of columns.
Apply a row-wise function between two matrices with the same number of columns.
This function implements the Maximal Marginal Relevance algorithm to select a set of embeddings that maximizes the diversity and relevance to a query embedding.