From a35dd70b4b735888cd39ac030ea9ec45cab7ae6e Mon Sep 17 00:00:00 2001 From: Alex Co Date: Fri, 6 Sep 2024 16:29:20 +0800 Subject: [PATCH 1/6] remove some models to save memory during build Signed-off-by: Alex Co --- .../workflows/gar-build-push-model-server-container-on-tag.yml | 3 +++ backend/Dockerfile.model_server | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gar-build-push-model-server-container-on-tag.yml b/.github/workflows/gar-build-push-model-server-container-on-tag.yml index 50792288b0d..951a34eed12 100644 --- a/.github/workflows/gar-build-push-model-server-container-on-tag.yml +++ b/.github/workflows/gar-build-push-model-server-container-on-tag.yml @@ -4,6 +4,9 @@ on: push: tags: - "*" + pull_request: + branches: + - main env: GarProjectID: mv-auxiliary diff --git a/backend/Dockerfile.model_server b/backend/Dockerfile.model_server index f2fb1ca44d0..4b6fa2c48a9 100644 --- a/backend/Dockerfile.model_server +++ b/backend/Dockerfile.model_server @@ -22,12 +22,9 @@ RUN apt-get remove -y --allow-remove-essential perl-base && \ # Download model weights # Run Nomic to pull in the custom architecture and have it cached locally RUN python -c "from transformers import AutoTokenizer; \ -AutoTokenizer.from_pretrained('distilbert-base-uncased'); \ -AutoTokenizer.from_pretrained('mixedbread-ai/mxbai-rerank-xsmall-v1'); \ from huggingface_hub import snapshot_download; \ snapshot_download(repo_id='danswer/hybrid-intent-token-classifier', revision='v1.0.3'); \ snapshot_download('nomic-ai/nomic-embed-text-v1'); \ -snapshot_download('mixedbread-ai/mxbai-rerank-xsmall-v1'); \ from sentence_transformers import SentenceTransformer; \ SentenceTransformer(model_name_or_path='nomic-ai/nomic-embed-text-v1', trust_remote_code=True);" From 94ecac5a72cae6d92aa50926a7533a07b542c834 Mon Sep 17 00:00:00 2001 From: Alex Co Date: Fri, 6 Sep 2024 16:30:54 +0800 Subject: [PATCH 2/6] use github.sha Signed-off-by: Alex Co --- .../gar-build-push-model-server-container-on-tag.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gar-build-push-model-server-container-on-tag.yml b/.github/workflows/gar-build-push-model-server-container-on-tag.yml index 951a34eed12..2d17537c409 100644 --- a/.github/workflows/gar-build-push-model-server-container-on-tag.yml +++ b/.github/workflows/gar-build-push-model-server-container-on-tag.yml @@ -48,7 +48,7 @@ jobs: id: metadata with: images: | - us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:${{ github.ref_name }} + us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:${{ github.sha }} - name: Model Server Image Docker Build and Push uses: int128/kaniko-action@v1 @@ -63,7 +63,7 @@ jobs: --snapshot-mode=redo --cache-ttl=730h tags: | - us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:${{ github.ref_name }} + us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:${{ ggithub.sha }} us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:latest build-args: | - DANSWER_VERSION=${{ github.ref_name }} + DANSWER_VERSION=${{ github.sha }} From ef82c116d762632beedf5357f4d31f413b235a0d Mon Sep 17 00:00:00 2001 From: Alex Co Date: Fri, 6 Sep 2024 16:31:09 +0800 Subject: [PATCH 3/6] Fix typo Signed-off-by: Alex Co --- .../workflows/gar-build-push-model-server-container-on-tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gar-build-push-model-server-container-on-tag.yml b/.github/workflows/gar-build-push-model-server-container-on-tag.yml index 2d17537c409..4b50253e522 100644 --- a/.github/workflows/gar-build-push-model-server-container-on-tag.yml +++ b/.github/workflows/gar-build-push-model-server-container-on-tag.yml @@ -63,7 +63,7 @@ jobs: --snapshot-mode=redo --cache-ttl=730h tags: | - us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:${{ ggithub.sha }} + us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:${{ github.sha }} us-docker.pkg.dev/${{ env.GarProjectID }}/${{ env.GarRepo }}/${{ env.GarImageName }}:latest build-args: | DANSWER_VERSION=${{ github.sha }} From 0e2ef0cd6344aea590e5b5003a40e978efb6869b Mon Sep 17 00:00:00 2001 From: Alex Co Date: Fri, 6 Sep 2024 16:38:37 +0800 Subject: [PATCH 4/6] Dont download any models Signed-off-by: Alex Co --- backend/Dockerfile.model_server | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/Dockerfile.model_server b/backend/Dockerfile.model_server index 4b6fa2c48a9..f032f423621 100644 --- a/backend/Dockerfile.model_server +++ b/backend/Dockerfile.model_server @@ -21,12 +21,12 @@ RUN apt-get remove -y --allow-remove-essential perl-base && \ # Download tokenizers, distilbert for the Danswer model # Download model weights # Run Nomic to pull in the custom architecture and have it cached locally -RUN python -c "from transformers import AutoTokenizer; \ -from huggingface_hub import snapshot_download; \ -snapshot_download(repo_id='danswer/hybrid-intent-token-classifier', revision='v1.0.3'); \ -snapshot_download('nomic-ai/nomic-embed-text-v1'); \ -from sentence_transformers import SentenceTransformer; \ -SentenceTransformer(model_name_or_path='nomic-ai/nomic-embed-text-v1', trust_remote_code=True);" +# RUN python -c "from transformers import AutoTokenizer; \ +# from huggingface_hub import snapshot_download; \ +# snapshot_download(repo_id='danswer/hybrid-intent-token-classifier', revision='v1.0.3'); \ +# snapshot_download('nomic-ai/nomic-embed-text-v1'); \ +# from sentence_transformers import SentenceTransformer; \ +# SentenceTransformer(model_name_or_path='nomic-ai/nomic-embed-text-v1', trust_remote_code=True);" # In case the user has volumes mounted to /root/.cache/huggingface that they've downloaded while # running Danswer, don't overwrite it with the built in cache folder From d8da92c46d5185666d7207df1554b55193d2e554 Mon Sep 17 00:00:00 2001 From: Alex Co Date: Fri, 6 Sep 2024 18:35:13 +0800 Subject: [PATCH 5/6] Commented 1 line Signed-off-by: Alex Co --- backend/Dockerfile.model_server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Dockerfile.model_server b/backend/Dockerfile.model_server index f032f423621..c915dc688c4 100644 --- a/backend/Dockerfile.model_server +++ b/backend/Dockerfile.model_server @@ -30,7 +30,7 @@ RUN apt-get remove -y --allow-remove-essential perl-base && \ # In case the user has volumes mounted to /root/.cache/huggingface that they've downloaded while # running Danswer, don't overwrite it with the built in cache folder -RUN mv /root/.cache/huggingface /root/.cache/temp_huggingface +# RUN mv /root/.cache/huggingface /root/.cache/temp_huggingface WORKDIR /app From 9c2d2d4706a3e68b58bc4067899c6741afac447b Mon Sep 17 00:00:00 2001 From: Alex Co Date: Fri, 6 Sep 2024 20:31:04 +0800 Subject: [PATCH 6/6] Build on tag only Signed-off-by: Alex Co --- .../workflows/gar-build-push-model-server-container-on-tag.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/gar-build-push-model-server-container-on-tag.yml b/.github/workflows/gar-build-push-model-server-container-on-tag.yml index 4b50253e522..d4788b25310 100644 --- a/.github/workflows/gar-build-push-model-server-container-on-tag.yml +++ b/.github/workflows/gar-build-push-model-server-container-on-tag.yml @@ -4,9 +4,6 @@ on: push: tags: - "*" - pull_request: - branches: - - main env: GarProjectID: mv-auxiliary