download embedding model on build time
Browse files- Dockerfile +3 -0
- src/conversation.py +2 -3
- src/vector_index.py +3 -3
Dockerfile
CHANGED
@@ -14,6 +14,9 @@ WORKDIR $HOME/src/app
|
|
14 |
COPY --chown=user requirements.txt ./
|
15 |
RUN pip install -r requirements.txt
|
16 |
|
|
|
|
|
|
|
17 |
# Copy the rest of your application's code
|
18 |
COPY --chown=user ./src .
|
19 |
|
|
|
14 |
COPY --chown=user requirements.txt ./
|
15 |
RUN pip install -r requirements.txt
|
16 |
|
17 |
+
RUN huggingface-cli download sentence-transformers/all-mpnet-base-v2 \
|
18 |
+
--local-dir /model/all-mpnet-base-v2 --local-dir-use-symlinks False
|
19 |
+
|
20 |
# Copy the rest of your application's code
|
21 |
COPY --chown=user ./src .
|
22 |
|
src/conversation.py
CHANGED
@@ -8,6 +8,7 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
8 |
import os
|
9 |
|
10 |
openai_api_key = os.environ.get("OPENAI_API_KEY")
|
|
|
11 |
|
12 |
class Conversation_RAG:
|
13 |
def __init__(self, model_name="gpt-3.5-turbo"):
|
@@ -15,9 +16,7 @@ class Conversation_RAG:
|
|
15 |
|
16 |
def get_vectordb(self):
|
17 |
index = pinecone.Index(os.environ.get("PINECONE_INDEX"))
|
18 |
-
embeddings = HuggingFaceEmbeddings(
|
19 |
-
model_name="sentence-transformers/all-mpnet-base-v2",
|
20 |
-
)
|
21 |
vectordb = Pinecone(index, embeddings, "text")
|
22 |
|
23 |
return vectordb
|
|
|
8 |
import os
|
9 |
|
10 |
openai_api_key = os.environ.get("OPENAI_API_KEY")
|
11 |
+
model_name = os.environ.get('MODEL_NAME', 'all-MiniLM-L6-v2')
|
12 |
|
13 |
class Conversation_RAG:
|
14 |
def __init__(self, model_name="gpt-3.5-turbo"):
|
|
|
16 |
|
17 |
def get_vectordb(self):
|
18 |
index = pinecone.Index(os.environ.get("PINECONE_INDEX"))
|
19 |
+
embeddings = HuggingFaceEmbeddings(model_name=f"model/{model_name}")
|
|
|
|
|
20 |
vectordb = Pinecone(index, embeddings, "text")
|
21 |
|
22 |
return vectordb
|
src/vector_index.py
CHANGED
@@ -4,6 +4,8 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
4 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
5 |
import os, uuid
|
6 |
|
|
|
|
|
7 |
def create_vector_store_index(file_path):
|
8 |
|
9 |
file_path_split = file_path.split(".")
|
@@ -29,9 +31,7 @@ def create_vector_store_index(file_path):
|
|
29 |
|
30 |
index = pc.Index(os.environ.get("PINECONE_INDEX"))
|
31 |
|
32 |
-
embeddings = HuggingFaceEmbeddings(
|
33 |
-
model_name="sentence-transformers/all-mpnet-base-v2",
|
34 |
-
)
|
35 |
|
36 |
batch_size = 32
|
37 |
|
|
|
4 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
5 |
import os, uuid
|
6 |
|
7 |
+
model_name = os.environ.get('MODEL_NAME', 'all-MiniLM-L6-v2')
|
8 |
+
|
9 |
def create_vector_store_index(file_path):
|
10 |
|
11 |
file_path_split = file_path.split(".")
|
|
|
31 |
|
32 |
index = pc.Index(os.environ.get("PINECONE_INDEX"))
|
33 |
|
34 |
+
embeddings = HuggingFaceEmbeddings(model_name=f"model/{model_name}")
|
|
|
|
|
35 |
|
36 |
batch_size = 32
|
37 |
|