core[patch]: mmr util (#25689)

This commit is contained in:
Erick Friis 2024-08-22 21:31:17 -07:00 committed by GitHub
parent ba89933c2c
commit b28bc252c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 4 deletions

View File

@ -21,9 +21,7 @@ from langchain_core.embeddings import Embeddings
from langchain_core.load import dumpd, load
from langchain_core.vectorstores import VectorStore
from langchain_core.vectorstores.utils import _cosine_similarity as cosine_similarity
from langchain_core.vectorstores.utils import (
_maximal_marginal_relevance as maximal_marginal_relevance,
)
from langchain_core.vectorstores.utils import maximal_marginal_relevance
if TYPE_CHECKING:
from langchain_core.indexing import UpsertResponse

View File

@ -71,7 +71,7 @@ def _cosine_similarity(X: Matrix, Y: Matrix) -> np.ndarray:
return similarity
def _maximal_marginal_relevance(
def maximal_marginal_relevance(
query_embedding: np.ndarray,
embedding_list: list,
lambda_mult: float = 0.5,