Spaces:
Running
Running
seanpedrickcase
commited on
Commit
·
51ba1cb
1
Parent(s):
cd6a3e0
Removed some requirements from Dockerfile for AWS deployment to reduce container size
Browse files- Dockerfile +4 -5
- funcs/representation_model.py +4 -1
- requirements_aws.txt +14 -0
Dockerfile
CHANGED
@@ -15,9 +15,9 @@ RUN mkdir /model && mkdir /model/rep && mkdir /model/embed
|
|
15 |
|
16 |
WORKDIR /src
|
17 |
|
18 |
-
COPY
|
19 |
|
20 |
-
RUN pip install --no-cache-dir -r
|
21 |
|
22 |
# Gradio needs to be installed after due to conflict with spacy in requirements
|
23 |
RUN pip install --no-cache-dir gradio==4.41.0
|
@@ -46,7 +46,7 @@ RUN mkdir -p /home/user/app/cache && chown -R user:user /home/user/app/cache
|
|
46 |
#RUN git clone https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1 /home/user/app/model/embed
|
47 |
#RUN rm -rf /home/user/app/model/embed/.git
|
48 |
|
49 |
-
# Download the
|
50 |
COPY download_model.py /src/download_model.py
|
51 |
RUN python /src/download_model.py
|
52 |
|
@@ -56,7 +56,7 @@ USER user
|
|
56 |
# Set home to the user's home directory
|
57 |
ENV HOME=/home/user \
|
58 |
PATH=/home/user/.local/bin:$PATH \
|
59 |
-
PYTHONPATH
|
60 |
PYTHONUNBUFFERED=1 \
|
61 |
PYTHONDONTWRITEBYTECODE=1 \
|
62 |
GRADIO_ALLOW_FLAGGING=never \
|
@@ -66,7 +66,6 @@ ENV HOME=/home/user \
|
|
66 |
GRADIO_THEME=huggingface \
|
67 |
AWS_STS_REGIONAL_ENDPOINT=regional \
|
68 |
GRADIO_OUTPUT_FOLDER='output/' \
|
69 |
-
#GRADIO_ROOT_PATH=/data-text-search \
|
70 |
NUMBA_CACHE_DIR=/home/user/app/cache \
|
71 |
SYSTEM=spaces
|
72 |
|
|
|
15 |
|
16 |
WORKDIR /src
|
17 |
|
18 |
+
COPY requirements_aws.txt .
|
19 |
|
20 |
+
RUN pip install --no-cache-dir -r requirements_aws.txt
|
21 |
|
22 |
# Gradio needs to be installed after due to conflict with spacy in requirements
|
23 |
RUN pip install --no-cache-dir gradio==4.41.0
|
|
|
46 |
#RUN git clone https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1 /home/user/app/model/embed
|
47 |
#RUN rm -rf /home/user/app/model/embed/.git
|
48 |
|
49 |
+
# Download the embedding model - Create a directory for the model and download specific files using huggingface_hub
|
50 |
COPY download_model.py /src/download_model.py
|
51 |
RUN python /src/download_model.py
|
52 |
|
|
|
56 |
# Set home to the user's home directory
|
57 |
ENV HOME=/home/user \
|
58 |
PATH=/home/user/.local/bin:$PATH \
|
59 |
+
PYTHONPATH=/home/user/app \
|
60 |
PYTHONUNBUFFERED=1 \
|
61 |
PYTHONDONTWRITEBYTECODE=1 \
|
62 |
GRADIO_ALLOW_FLAGGING=never \
|
|
|
66 |
GRADIO_THEME=huggingface \
|
67 |
AWS_STS_REGIONAL_ENDPOINT=regional \
|
68 |
GRADIO_OUTPUT_FOLDER='output/' \
|
|
|
69 |
NUMBA_CACHE_DIR=/home/user/app/cache \
|
70 |
SYSTEM=spaces
|
71 |
|
funcs/representation_model.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import os
|
2 |
from bertopic.representation import LlamaCPP
|
3 |
-
|
4 |
from pydantic import BaseModel
|
5 |
import torch.cuda
|
6 |
from huggingface_hub import hf_hub_download
|
@@ -152,6 +152,9 @@ def create_representation_model(representation_type: str, llm_config: dict, hf_m
|
|
152 |
print(error_message)
|
153 |
representation_model = {"LLM":base_rep}
|
154 |
return representation_model
|
|
|
|
|
|
|
155 |
|
156 |
print("Generating LLM representation")
|
157 |
# Use llama.cpp to load in model
|
|
|
1 |
import os
|
2 |
from bertopic.representation import LlamaCPP
|
3 |
+
|
4 |
from pydantic import BaseModel
|
5 |
import torch.cuda
|
6 |
from huggingface_hub import hf_hub_download
|
|
|
152 |
print(error_message)
|
153 |
representation_model = {"LLM":base_rep}
|
154 |
return representation_model
|
155 |
+
# Else import Llama
|
156 |
+
else:
|
157 |
+
from llama_cpp import Llama
|
158 |
|
159 |
print("Generating LLM representation")
|
160 |
# Use llama.cpp to load in model
|
requirements_aws.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
boto3==1.34.158
|
2 |
+
bertopic==0.16.2
|
3 |
+
spacy
|
4 |
+
en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1.tar.gz
|
5 |
+
gradio # Not specified version due to interaction with spacy - reinstall latest version after requirements.txt load
|
6 |
+
pyarrow==14.0.2
|
7 |
+
openpyxl==3.1.2
|
8 |
+
Faker==22.2.0
|
9 |
+
presidio_analyzer==2.2.354
|
10 |
+
presidio_anonymizer==2.2.354
|
11 |
+
scipy==1.11.4
|
12 |
+
polars==0.20.6
|
13 |
+
sentence-transformers==3.0.1
|
14 |
+
numpy==1.26.4
|