Compare commits

...

1 Commits

Author SHA1 Message Date
Weves
7e41bb8c3a Testing 2024-04-26 11:51:49 -07:00
7 changed files with 3732 additions and 23 deletions

View File

@@ -31,14 +31,5 @@ jobs:
push: true
tags: |
danswer/danswer-backend:${{ github.ref_name }}
danswer/danswer-backend:latest
build-args: |
DANSWER_VERSION=${{ github.ref_name }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
# To run locally: trivy image --severity HIGH,CRITICAL danswer/danswer-backend
image-ref: docker.io/danswer/danswer-backend:${{ github.ref_name }}
severity: 'CRITICAL,HIGH'
trivyignores: ./backend/.trivyignore

View File

@@ -31,12 +31,5 @@ jobs:
push: true
tags: |
danswer/danswer-model-server:${{ github.ref_name }}
danswer/danswer-model-server:latest
build-args: |
DANSWER_VERSION=${{ github.ref_name }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: docker.io/danswer/danswer-model-server:${{ github.ref_name }}
severity: 'CRITICAL,HIGH'

View File

@@ -31,12 +31,5 @@ jobs:
push: true
tags: |
danswer/danswer-web-server:${{ github.ref_name }}
danswer/danswer-web-server:latest
build-args: |
DANSWER_VERSION=${{ github.ref_name }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: docker.io/danswer/danswer-web-server:${{ github.ref_name }}
severity: 'CRITICAL,HIGH'

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,9 @@ from typing import Optional
from typing import TYPE_CHECKING
import requests
from huggingface_hub.constants import HF_HOME
from transformers import logging as transformer_logging # type:ignore
from transformers.utils import TRANSFORMERS_CACHE
from danswer.configs.model_configs import DOC_EMBEDDING_CONTEXT_SIZE
from danswer.configs.model_configs import DOCUMENT_ENCODER_MODEL
@@ -58,6 +60,17 @@ def get_default_tokenizer(model_name: str | None = None) -> "AutoTokenizer":
# This could be inaccurate
model_name = DOCUMENT_ENCODER_MODEL
print(f"HF Home: {HF_HOME}")
print(f"Cache dir: {TRANSFORMERS_CACHE}")
from danswer.search.hf_test import hf_hub_download
from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE
hf_file_path = hf_hub_download(
model_name, TOKENIZER_CONFIG_FILE, local_files_only=True
)
print("hf_file_path", hf_file_path)
_TOKENIZER = (AutoTokenizer.from_pretrained(model_name), model_name)
if hasattr(_TOKENIZER[0], "is_fast") and _TOKENIZER[0].is_fast:

View File

@@ -3,8 +3,10 @@ from typing import Optional
import numpy as np
import tensorflow as tf # type: ignore
from fastapi import APIRouter
from huggingface_hub.constants import HF_HOME
from transformers import AutoTokenizer # type: ignore
from transformers import TFDistilBertForSequenceClassification
from transformers.utils import TRANSFORMERS_CACHE
from model_server.constants import MODEL_WARM_UP_STRING
from model_server.utils import simple_log_function_time
@@ -24,6 +26,17 @@ _INTENT_MODEL: Optional[TFDistilBertForSequenceClassification] = None
def get_intent_model_tokenizer(
model_name: str = INTENT_MODEL_VERSION,
) -> "AutoTokenizer":
print(f"HF Home: {HF_HOME}")
print(f"Cache dir: {TRANSFORMERS_CACHE}")
from model_server.hf import hf_hub_download
from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE
hf_file_path = hf_hub_download(
model_name, TOKENIZER_CONFIG_FILE, local_files_only=True
)
print("hf_file_path", hf_file_path)
global _INTENT_TOKENIZER
if _INTENT_TOKENIZER is None:
_INTENT_TOKENIZER = AutoTokenizer.from_pretrained(model_name)
@@ -36,6 +49,8 @@ def get_local_intent_model(
) -> TFDistilBertForSequenceClassification:
global _INTENT_MODEL
if _INTENT_MODEL is None or max_context_length != _INTENT_MODEL.max_seq_length:
print(f"HF Home: {HF_HOME}")
print(f"Cache dir: {TRANSFORMERS_CACHE}")
_INTENT_MODEL = TFDistilBertForSequenceClassification.from_pretrained(
model_name
)

1852
backend/model_server/hf.py Normal file

File diff suppressed because it is too large Load Diff