__init__() — langchain Function Reference
Architecture documentation for the __init__() function in huggingface.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6f8d5d0a_4a99_c3be_d269_1921338dc479["__init__()"] bc29a19b_53a3_8e06_ab58_d933298d898b["HuggingFaceEmbeddings"] 6f8d5d0a_4a99_c3be_d269_1921338dc479 -->|defined in| bc29a19b_53a3_8e06_ab58_d933298d898b style 6f8d5d0a_4a99_c3be_d269_1921338dc479 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py lines 64–99
def __init__(self, **kwargs: Any):
"""Initialize the sentence_transformer."""
super().__init__(**kwargs)
try:
import sentence_transformers # type: ignore[import]
except ImportError as exc:
msg = (
"Could not import sentence_transformers python package. "
"Please install it with `pip install sentence-transformers`."
)
raise ImportError(msg) from exc
if self.model_kwargs.get("backend", "torch") == "ipex":
if not is_optimum_intel_available() or not is_ipex_available():
msg = f"Backend: ipex {IMPORT_ERROR.format('optimum[ipex]')}"
raise ImportError(msg)
if is_optimum_intel_version("<", _MIN_OPTIMUM_VERSION):
msg = (
f"Backend: ipex requires optimum-intel>="
f"{_MIN_OPTIMUM_VERSION}. You can install it with pip: "
"`pip install --upgrade --upgrade-strategy eager "
"`optimum[ipex]`."
)
raise ImportError(msg)
from optimum.intel import IPEXSentenceTransformer # type: ignore[import]
model_cls = IPEXSentenceTransformer
else:
model_cls = sentence_transformers.SentenceTransformer
self._client = model_cls(
self.model_name, cache_folder=self.cache_folder, **self.model_kwargs
)
Domain
Subdomains
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py.
Where is __init__() defined?
__init__() is defined in libs/partners/huggingface/langchain_huggingface/embeddings/huggingface.py at line 64.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free