Demo_1 / src /core /embeddings.py
Dinesh310's picture
Update src/core/embeddings.py
e694569 verified
raw
history blame contribute delete
497 Bytes
from langchain_huggingface import HuggingFaceEmbeddings
from src.config.config import (
EMBEDDING_MODEL,
EMBEDDING_DEVICE,
NORMALIZE_EMBEDDINGS
)
def load_embeddings():
try:
return HuggingFaceEmbeddings(
model_name=EMBEDDING_MODEL,
model_kwargs={"device": EMBEDDING_DEVICE},
encode_kwargs={"normalize_embeddings": NORMALIZE_EMBEDDINGS}
)
except Exception as e:
raise RuntimeError(f"Failed to load embeddings: {e}")