From ed2f37da60ced53f2cce18118a1188175861334b Mon Sep 17 00:00:00 2001 From: ArzelaAscoIi <37148029+ArzelaAscoIi@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:13:30 +0100 Subject: [PATCH] fix: docstring for normalization (#8604) * fix: docstring for normalization * chore: add reno * fixing docstrings and adding pylint disable too many args --------- Co-authored-by: David S. Batista --- .../embedders/sentence_transformers_document_embedder.py | 4 ++-- .../embedders/sentence_transformers_text_embedder.py | 4 ++-- .../fix-docstrings-normalize-embedding-fd2dba50ba9e51a1.yaml | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-docstrings-normalize-embedding-fd2dba50ba9e51a1.yaml diff --git a/haystack/components/embedders/sentence_transformers_document_embedder.py b/haystack/components/embedders/sentence_transformers_document_embedder.py index 195c5d10c8..a5eaa9ae8b 100644 --- a/haystack/components/embedders/sentence_transformers_document_embedder.py +++ b/haystack/components/embedders/sentence_transformers_document_embedder.py @@ -38,7 +38,7 @@ class SentenceTransformersDocumentEmbedder: ``` """ - def __init__( # noqa: PLR0913 + def __init__( # noqa: PLR0913 # pylint: disable=too-many-positional-arguments self, model: str = "sentence-transformers/all-mpnet-base-v2", device: Optional[ComponentDevice] = None, @@ -79,7 +79,7 @@ def __init__( # noqa: PLR0913 :param progress_bar: If `True`, shows a progress bar when embedding documents. :param normalize_embeddings: - If `True`, returns vectors with length 1. + If `True`, the embeddings are normalized using L2 normalization, so that each embedding has a norm of 1. :param meta_fields_to_embed: List of metadata fields to embed along with the document text. :param embedding_separator: diff --git a/haystack/components/embedders/sentence_transformers_text_embedder.py b/haystack/components/embedders/sentence_transformers_text_embedder.py index f8b959495f..0785caddbd 100644 --- a/haystack/components/embedders/sentence_transformers_text_embedder.py +++ b/haystack/components/embedders/sentence_transformers_text_embedder.py @@ -34,7 +34,7 @@ class SentenceTransformersTextEmbedder: ``` """ - def __init__( # noqa: PLR0913 + def __init__( # noqa: PLR0913 # pylint: disable=too-many-positional-arguments self, model: str = "sentence-transformers/all-mpnet-base-v2", device: Optional[ComponentDevice] = None, @@ -73,7 +73,7 @@ def __init__( # noqa: PLR0913 If `True`, shows a progress bar for calculating embeddings. If `False`, disables the progress bar. :param normalize_embeddings: - If `True`, returned vectors have a length of 1. + If `True`, the embeddings are normalized using L2 normalization, so that the embeddings have a norm of 1. :param trust_remote_code: If `False`, permits only Hugging Face verified model architectures. If `True`, permits custom models and scripts. diff --git a/releasenotes/notes/fix-docstrings-normalize-embedding-fd2dba50ba9e51a1.yaml b/releasenotes/notes/fix-docstrings-normalize-embedding-fd2dba50ba9e51a1.yaml new file mode 100644 index 0000000000..4c76845f48 --- /dev/null +++ b/releasenotes/notes/fix-docstrings-normalize-embedding-fd2dba50ba9e51a1.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - fix docstrings for normalize_embeddings in sentence_transformers_text_embedder and sentence_transformers_document_embedder