Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

huggingface[patch]: hide client field in HuggingFaceEmbeddings #27522

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings):
)
"""

client: Any = None #: :meta private:
model_name: str = DEFAULT_MODEL_NAME
"""Model name to use."""
cache_folder: Optional[str] = None
Expand Down Expand Up @@ -57,7 +56,7 @@ def __init__(self, **kwargs: Any):
"Please install it with `pip install sentence-transformers`."
) from exc

self.client = sentence_transformers.SentenceTransformer(
self._client = sentence_transformers.SentenceTransformer(
self.model_name, cache_folder=self.cache_folder, **self.model_kwargs
)

Expand All @@ -79,11 +78,11 @@ def embed_documents(self, texts: List[str]) -> List[List[float]]:

texts = list(map(lambda x: x.replace("\n", " "), texts))
if self.multi_process:
pool = self.client.start_multi_process_pool()
embeddings = self.client.encode_multi_process(texts, pool)
pool = self._client.start_multi_process_pool()
embeddings = self._client.encode_multi_process(texts, pool)
sentence_transformers.SentenceTransformer.stop_multi_process_pool(pool)
else:
embeddings = self.client.encode(
embeddings = self._client.encode(
texts, show_progress_bar=self.show_progress, **self.encode_kwargs
)

Expand Down
Loading