• This function implements the Maximal Marginal Relevance algorithm to select a set of embeddings that maximizes the diversity and relevance to a query embedding.

    Parameters

    • queryEmbedding: number[] | number[][]

      The query embedding.

    • embeddingList: number[][]

      The list of embeddings to select from.

    • Optionallambda: number

      The trade-off parameter between relevance and diversity.

    • Optionalk: number

      The maximum number of embeddings to select.

    Returns number[]

    The indexes of the selected embeddings in the embeddingList.