Spaces:
Sleeping
Sleeping
File size: 543 Bytes
a6e92fe b99886d a6e92fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Databricks notebook source
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_community.vectorstores.utils import DistanceStrategy
def init_embedding_model(EMBEDDING_MODEL_NAME: str):
embedding_model = HuggingFaceEmbeddings(
model_name=EMBEDDING_MODEL_NAME,
multi_process=True,
model_kwargs={"device": "cuda"},
# model_kwargs={"device": "cpu"},
# Set `True` for cosine similarity
encode_kwargs={"normalize_embeddings": True},
)
return embedding_model |