Multi_Pdf_Rag_chat / src /core /embeddings.py
Dinesh310's picture
Update src/core/embeddings.py
6ae5065 verified
raw
history blame contribute delete
543 Bytes
import torch
torch.set_default_device("cpu")
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}")