thanhtung09t2 commited on
Commit
f67c3aa
1 Parent(s): 1a418ef

Create baai_bge embeeding

Browse files
Files changed (1) hide show
  1. api/embedding_models/baai_bge_m3.py +17 -0
api/embedding_models/baai_bge_m3.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from llama_index.embeddings.huggingface import HuggingFaceEmbedding
3
+ from api.embedding_models.embedding_config import EmbeddingConfig
4
+ from llama_index.core import Settings
5
+
6
+ root_path = os.environ['ROOT_PATH']
7
+ MODEL_DIRECTORY = os.path.join(root_path,"model")
8
+
9
+ def EmbeddingModel():
10
+ current_file_path = os.path.abspath(__file__)
11
+ embedding_model_dir = os.path.dirname(current_file_path)
12
+ api_dir = os.path.dirname(embedding_model_dir)
13
+ model_dir = os.path.join(api_dir,MODEL_DIRECTORY)
14
+ Settings.embed_model = HuggingFaceEmbedding(model_name = "BAAI/bge-m3",
15
+ cache_folder = model_dir)
16
+ return EmbeddingConfig()
17
+