Spaces:
Running
Running
Add cache directory to Dockerfile and update embeddings model to use cache folder
Browse files- .gitignore +1 -0
- Dockerfile +3 -0
- app/models/db/__init__.py +1 -5
- app/models/llm/__init__.py +1 -1
.gitignore
CHANGED
@@ -182,3 +182,4 @@ app/models/chroma/data/chroma.sqlite3
|
|
182 |
models/chroma/data/*.bin
|
183 |
models/chroma/_data/chroma.sqlite3
|
184 |
models/chroma/data/chroma.sqlite3
|
|
|
|
182 |
models/chroma/data/*.bin
|
183 |
models/chroma/_data/chroma.sqlite3
|
184 |
models/chroma/data/chroma.sqlite3
|
185 |
+
cache
|
Dockerfile
CHANGED
@@ -7,6 +7,9 @@ COPY . .
|
|
7 |
# Set the working directory to /app
|
8 |
WORKDIR /app
|
9 |
|
|
|
|
|
|
|
10 |
# Install requirements.txt
|
11 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
12 |
|
|
|
7 |
# Set the working directory to /app
|
8 |
WORKDIR /app
|
9 |
|
10 |
+
# Create a cache directory and set permissions
|
11 |
+
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
|
12 |
+
|
13 |
# Install requirements.txt
|
14 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
15 |
|
app/models/db/__init__.py
CHANGED
@@ -2,17 +2,13 @@
|
|
2 |
import faiss
|
3 |
from langchain_community.vectorstores import FAISS
|
4 |
from langchain_community.docstore.in_memory import InMemoryDocstore
|
5 |
-
# from langchain_chroma import Chroma
|
6 |
from models.llm import EmbeddingsModel
|
7 |
|
8 |
embeddings = EmbeddingsModel("all-MiniLM-L6-v2")
|
9 |
|
10 |
-
index = faiss.IndexFlatL2(len(embeddings.embed_query("hello world")))
|
11 |
-
print(index)
|
12 |
-
|
13 |
vectorstore = FAISS(
|
14 |
embedding_function=embeddings,
|
15 |
-
index=
|
16 |
docstore=InMemoryDocstore(),
|
17 |
index_to_docstore_id={}
|
18 |
)
|
|
|
2 |
import faiss
|
3 |
from langchain_community.vectorstores import FAISS
|
4 |
from langchain_community.docstore.in_memory import InMemoryDocstore
|
|
|
5 |
from models.llm import EmbeddingsModel
|
6 |
|
7 |
embeddings = EmbeddingsModel("all-MiniLM-L6-v2")
|
8 |
|
|
|
|
|
|
|
9 |
vectorstore = FAISS(
|
10 |
embedding_function=embeddings,
|
11 |
+
index=faiss.IndexFlatL2(len(embeddings.embed_query("hello world"))),
|
12 |
docstore=InMemoryDocstore(),
|
13 |
index_to_docstore_id={}
|
14 |
)
|
app/models/llm/__init__.py
CHANGED
@@ -115,7 +115,7 @@ class EmbeddingsModel(Embeddings):
|
|
115 |
Args:
|
116 |
model_name (str): The name of the model to be used for sentence transformation.
|
117 |
"""
|
118 |
-
self.model = SentenceTransformer(model_name)
|
119 |
|
120 |
def embed_documents(self, documents: List[str]) -> List[List[float]]:
|
121 |
"""
|
|
|
115 |
Args:
|
116 |
model_name (str): The name of the model to be used for sentence transformation.
|
117 |
"""
|
118 |
+
self.model = SentenceTransformer(model_name, cache_folder="/app/cache")
|
119 |
|
120 |
def embed_documents(self, documents: List[str]) -> List[List[float]]:
|
121 |
"""
|