Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow swapping ST models #863

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@
if ext:
INSTALLED_APPS.append("ethicalads_ext.support")

ADSERVER_ANALYZER_MODEL = env(
"ADSERVER_ANALYZER_MODEL", default="multi-qa-MiniLM-L6-cos-v1"
)
ADSERVER_ANALYZER_MODEL_HOME = env("ADSERVER_ANALYZER_MODEL_HOME", default="/tmp")
ADSERVER_ANALYZER_MODEL_NORMALIZE = env(
"ADSERVER_ANALYZER_MODEL_NORMALIZE", default=False
)

# Whether Do Not Track is enabled for the ad server
ADSERVER_DO_NOT_TRACK = False

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
build:
context: .
dockerfile: ./docker-compose/django/Dockerfile
args:
- SENTENCE_TRANSFORMERS_HOME=${SENTENCE_TRANSFORMERS_HOME:-/app}
- SENTENCE_TRANSFORMERS_MODEL=${SENTENCE_TRANSFORMERS_MODEL:-multi-qa-MiniLM-L6-cos-v1}
image: ethicaladserver_local_django
depends_on:
- postgres
Expand Down
6 changes: 5 additions & 1 deletion docker-compose/django/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM ubuntu:22.04

ARG SENTENCE_TRANSFORMERS_HOME
ARG SENTENCE_TRANSFORMERS_MODEL


ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
Expand Down Expand Up @@ -55,7 +59,7 @@ RUN chmod +x /start-celerybeat
RUN ln -s /usr/bin/python3 /usr/bin/python

# Load model
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('multi-qa-MiniLM-L6-cos-v1', cache_folder='/tmp/sentence_transformers')"
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('$SENTENCE_TRANSFORMERS_MODEL', cache_folder='$SENTENCE_TRANSFORMERS_HOME', trust_remote_code=True)"

# Setup the locale
RUN locale-gen en_US.UTF-8
Expand Down
Loading