thanhtung09t2's picture
Create baai_bge embeeding
f67c3aa verified
raw
history blame contribute delete
676 Bytes
import os
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from api.embedding_models.embedding_config import EmbeddingConfig
from llama_index.core import Settings
root_path = os.environ['ROOT_PATH']
MODEL_DIRECTORY = os.path.join(root_path,"model")
def EmbeddingModel():
current_file_path = os.path.abspath(__file__)
embedding_model_dir = os.path.dirname(current_file_path)
api_dir = os.path.dirname(embedding_model_dir)
model_dir = os.path.join(api_dir,MODEL_DIRECTORY)
Settings.embed_model = HuggingFaceEmbedding(model_name = "BAAI/bge-m3",
cache_folder = model_dir)
return EmbeddingConfig()