Skip to content

Commit

Permalink
migration
Browse files Browse the repository at this point in the history
  • Loading branch information
guokan-shang committed Apr 12, 2023
1 parent d3db25c commit 61a8928
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .envdefault
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
APP_LANG=fr en
ASSETS_PATH_ON_HOST=./assets
ASSETS_PATH_IN_CONTAINER=/app/assets
LM_MAP = "{
'fr': 'sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2',
'en': 'sentence-transformers/all-MiniLM-L6-v2'
}"

# SERVING PARAMETERS
SERVICE_MODE=http
Expand Down
7 changes: 2 additions & 5 deletions kpe/processing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import ast
import sys
import spacy
from time import time
Expand All @@ -13,11 +14,7 @@
logger.info("Loading language model(s)...")
start = time()

# Supported languages and corresponding model names
LM_MAP = {
"fr": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
"en": "sentence-transformers/all-MiniLM-L6-v2"
}
LM_MAP = ast.literal_eval(os.environ["LM_MAP"])

try:
MODELS = {LM_MAP[lang]: SentenceTransformer(os.environ.get("ASSETS_PATH_IN_CONTAINER") + '/' + LM_MAP[lang]) for lang in os.environ.get("APP_LANG").split(" ")}
Expand Down

0 comments on commit 61a8928

Please sign in to comment.