From 1e0021cc5f45e93b75b1408c49cc443cc11dd81f Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Fri, 13 Jan 2023 09:30:19 +0100 Subject: [PATCH 1/7] Add support for sentence-t5-base model --- .travis.yml | 5 +++++ requirements.txt | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 81703ec..aab2d43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,11 @@ jobs: MODEL_TAG_NAME: sentence-transformers-gtr-t5-large if: tag IS present stage: buildanddeploy + - env: + MODEL_NAME: sentence-transformers/sentence-t5-base + MODEL_TAG_NAME: sentence-transformers-sentence-t5-base + if: tag IS present + stage: buildanddeploy - env: MODEL_NAME: vblagoje/dpr-ctx_encoder-single-lfqa-wiki MODEL_TAG_NAME: vblagoje-dpr-ctx_encoder-single-lfqa-wiki diff --git a/requirements.txt b/requirements.txt index 5585adb..e248219 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -tokenizers==0.13.1 -transformers==4.23.1 -fastapi==0.85.1 -uvicorn==0.19.0 -nltk==3.7 -torch==1.13.0 +tokenizers==0.13.2 +transformers==4.25.1 +fastapi==0.89.1 +uvicorn==0.20.0 +nltk==3.8.1 +torch==1.13.1 sentencepiece==0.1.97 -protobuf==4.21.9 +protobuf==4.21.12 From 926819cc8dc9f9a19e606b56987c5b81472f3df9 Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Fri, 13 Jan 2023 11:49:29 +0100 Subject: [PATCH 2/7] Switch to github actions --- .github/CODEOWNERS | 3 + .github/workflows/main.yaml | 95 +++++++++++++++++ .travis.yml | 207 ------------------------------------ smoke_test.py | 1 + 4 files changed, 99 insertions(+), 207 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/main.yaml delete mode 100644 .travis.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..ab95997 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# Ci related folders +/.github/ @semi-technologies/core +/ci/ @semi-technologies/core diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..9bc2ba7 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,95 @@ +name: Main + +on: + push: + branches: + - main + tags: + - '**' + paths-ignore: + - README.md + - LICENSE + pull_request: + +jobs: + build-image: + name: Build image + runs-on: ubuntu-latest + strategy: + matrix: + include: + - model_name: "distilbert-base-uncased" + model_tag_name: "distilbert-base-uncased" + # - model_name: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 + # model_tag_name: sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2 + # - model_name: sentence-transformers/multi-qa-MiniLM-L6-cos-v1 + # model_tag_name: sentence-transformers-multi-qa-MiniLM-L6-cos-v1 + # - model_name: sentence-transformers/multi-qa-mpnet-base-cos-v1 + # model_tag_name: sentence-transformers-multi-qa-mpnet-base-cos-v1 + # - model_name: sentence-transformers/all-mpnet-base-v2 + # model_tag_name: sentence-transformers-all-mpnet-base-v2 + # - model_name: sentence-transformers/all-MiniLM-L12-v2 + # model_tag_name: sentence-transformers-all-MiniLM-L12-v2 + # - model_name: sentence-transformers/paraphrase-multilingual-mpnet-base-v2 + # model_tag_name: sentence-transformers-paraphrase-multilingual-mpnet-base-v2 + # - model_name: sentence-transformers/gtr-t5-base + # model_tag_name: sentence-transformers-gtr-t5-base + # - model_name: sentence-transformers/gtr-t5-large + # model_tag_name: sentence-transformers-gtr-t5-large + # - model_name: sentence-transformers/sentence-t5-base + # model_tag_name: sentence-transformers-sentence-t5-base + # - model_name: vblagoje/dpr-ctx_encoder-single-lfqa-wiki + # model_tag_name: vblagoje-dpr-ctx_encoder-single-lfqa-wiki + # - model_name: vblagoje/dpr-question_encoder-single-lfqa-wiki + # model_tag_name: vblagoje-dpr-question_encoder-single-lfqa-wiki + # - model_name: facebook/dpr-ctx_encoder-single-nq-base + # model_tag_name: facebook-dpr-ctx_encoder-single-nq-base + # - model_name: facebook/dpr-question_encoder-single-nq-base + # model_tag_name: facebook-dpr-question_encoder-single-nq-base + env: + LOCAL_REPO: transformers-inference + REMOTE_REPO: semitechnologies/transformers-inference + MODEL_NAME: ${{matrix.model_name}} + MODEL_TAG_NAME: ${{matrix.model_tag_name}} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.9" + cache: 'pip' # caching pip dependencies + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKER_USERNAME}} + password: ${{secrets.DOCKER_PASSWORD}} + - name: Build and test + run: | + cicd/build.sh || exit 1 + cicd/test.sh || exit 1 + - name: Deploy + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + run: | + export GIT_TAG=$GITHUB_HEAD_REF + cicd/docker_push.sh || exit 1 + build-custom-image: + name: Build custom image + runs-on: ubuntu-latest + env: + LOCAL_REPO: transformers-inference + REMOTE_REPO: semitechnologies/transformers-inference + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.9" + cache: 'pip' # caching pip dependencies + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKER_USERNAME}} + password: ${{secrets.DOCKER_PASSWORD}} + - name: Deploy + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + run: | + export GIT_TAG=$GITHUB_HEAD_REF + cicd/build_custom_base.sh || exit 1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index aab2d43..0000000 --- a/.travis.yml +++ /dev/null @@ -1,207 +0,0 @@ -language: python -python: 3.9 - -env: - global: - - LOCAL_REPO: transformers-inference - - REMOTE_REPO: semitechnologies/transformers-inference - - secure: QLL5aAA41AjtgVeHPmgmtpp/nOup0R5FT/wIJwPEAjIWl2MuOCnqaHq5pE+XM80tkbAHhVz48IyLH6P5FkcYQO0dmRHO9M6n3jawrrsTvbQ1dIMqEarl69mO7+xQZJS/ggN6E8Q0Q5Y0Q8f/btC6osHr01OOyqd+Tb3Bcihv/zFmPydULSAu2pL4n89PkY52PjHgxkrsBBxiN3O95q/FwGCVWq+kH1bSkEAAl/miXA0wCss4I108cUmoY4RS1CYKAGzRk0fK6d+r+sIw08pX3Gvr/2KFQhCK0mJAPKnBZ/VBDFW1ilZ1LZseciYSX/RtHYvWgTb1xemAR3ewmXmJYP9mqvaBArleZARg4cWsz7Qz9Mj9oiC4EGgCxHrzXBV2d+SwIh1JFs3k87P+DUyDTmoR6rTTMMQ4lLPnPSRj0lQtvCAl861ojivkQG4jOKKYyJiKKDmTqGsJ6Ys53MNkzsHCUEZCZxJlSMqOLZGxr+U/A7F8LCUt/h2rgyL9QT1kCz2tNYyE3BMktAyKeLD4np7cHxkLUbPv59HkEffCfP/79B+1s2Gb3Bok9F/u1oiIXJ3pO3gaFXfN4/RxG7lROpNMhRin4yo7YU/kBNu432b4ufcJ1LPmqWAH+FN/0OidZPxitrHWPPklHga718/yhl+mkObWm9uJmt0zmK+ZzIM= - - secure: Kk1k4is7vziUkv6ZJqbIuY6zQCesWYILmI4x9MHQcwSzmrKas5fSvSFobQZHKp9IdpUQ6awR18+yJHmqU+I25LqCm3AjvSz2OmS3d/Fq/Q3U5C7mRrSprQT/zjCiTwjjrc7xO9RaaLKX92dHZkHvmYk2jf/1F3gMZGw1RpdTfj+pUbgIvw/AL8CaIPkNKZpR0tjpm3fOIO4MCgu0JpzscnCF00ANKc/Gy2jtmts8ee1lmnLRBeci1cRwbJOqzHh8AhJG3rrVCu9ISiqd62vOXlM+z7W2KUdTtVo5bNBa5iBuBa+kwd/uH95p9NVdMuISaO+cj5fT9sFMLPpLcAjnLjChGMBUIeT5pSedWwziYj48TZqIEgmza4iBwVyXIBx6Jblml+j8EobnDtQCtHbHU98FgBO5AdaNbt4laHlOQCSs2Kt2AFT6UAS8NqT842gHoG9jr6ovYpwb27TjE8ILCnCRnhy9e3VW0VCRHCrgotwCAV/gM4S0kVaO5IAa8vxDp0w+4ewdh60aysg4p6us21Iim746WNi4xXPzkeJ/ce/X1abDy2yMc6XP3el4OGIYe701/wDblcmjybNqq+RjphtwmNJUnk+BdykW+006+xkzAo58IcFZMqkeDFd/FOa5OEM6w1HA1rXM5IYGWwrQudx7lyFOzPAxPt938Gk33UE= - -install: echo skipping default travis install script - -jobs: - include: - # always run test, etc. for this model - - env: - MODEL_NAME: distilbert-base-uncased - stage: buildanddeploy - - # to prevent spamming the pipeline, only include most models if there is a tag - # - # TODO: should this be deprecated or not? - - env: - MODEL_NAME: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 - MODEL_TAG_NAME: sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2 - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/multi-qa-MiniLM-L6-cos-v1 - MODEL_TAG_NAME: sentence-transformers-multi-qa-MiniLM-L6-cos-v1 - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/multi-qa-mpnet-base-cos-v1 - MODEL_TAG_NAME: sentence-transformers-multi-qa-mpnet-base-cos-v1 - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/all-mpnet-base-v2 - MODEL_TAG_NAME: sentence-transformers-all-mpnet-base-v2 - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/all-MiniLM-L12-v2 - MODEL_TAG_NAME: sentence-transformers-all-MiniLM-L12-v2 - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/paraphrase-multilingual-mpnet-base-v2 - MODEL_TAG_NAME: sentence-transformers-paraphrase-multilingual-mpnet-base-v2 - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/gtr-t5-base - MODEL_TAG_NAME: sentence-transformers-gtr-t5-base - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/gtr-t5-large - MODEL_TAG_NAME: sentence-transformers-gtr-t5-large - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: sentence-transformers/sentence-t5-base - MODEL_TAG_NAME: sentence-transformers-sentence-t5-base - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: vblagoje/dpr-ctx_encoder-single-lfqa-wiki - MODEL_TAG_NAME: vblagoje-dpr-ctx_encoder-single-lfqa-wiki - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: vblagoje/dpr-question_encoder-single-lfqa-wiki - MODEL_TAG_NAME: vblagoje-dpr-question_encoder-single-lfqa-wiki - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: facebook/dpr-ctx_encoder-single-nq-base - MODEL_TAG_NAME: facebook-dpr-ctx_encoder-single-nq-base - if: tag IS present - stage: buildanddeploy - - env: - MODEL_NAME: facebook/dpr-question_encoder-single-nq-base - MODEL_TAG_NAME: facebook-dpr-question_encoder-single-nq-base - if: tag IS present - stage: buildanddeploy - # Disabled due to memory exaustion in Travis, configuration options can be found here: - # https://docs.travis-ci.com/user/enterprise/worker-configuration/ - # - env: - # MODEL_NAME: sentence-transformers/gtr-t5-xl - # MODEL_TAG_NAME: sentence-transformers-gtr-t5-xl - # if: tag IS present - # stage: buildanddeploy - - # no longer build the old models as the pipeline is already slow enough. - # They will still be accessible through Dockerhub, but will no longer be - # updated. - # - env: - # MODEL_NAME: sentence-transformers/paraphrase-mpnet-base-v2 - # MODEL_TAG_NAME: sentence-transformers-paraphrase-mpnet-base-v2 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/paraphrase-distilroberta-base-v2 - # MODEL_TAG_NAME: sentence-transformers-paraphrase-distilroberta-base-v2 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/stsb-mpnet-base-v2 - # MODEL_TAG_NAME: sentence-transformers-stsb-mpnet-base-v2 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/nli-mpnet-base-v2 - # MODEL_TAG_NAME: sentence-transformers-nli-mpnet-base-v2 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/msmarco-distilbert-base-v3 - # MODEL_TAG_NAME: sentence-transformers-msmarco-distilbert-base-v3 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/stsb-distilbert-base - # MODEL_TAG_NAME: sentence-transformers-stsb-distilbert-base - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/quora-distilbert-base - # MODEL_TAG_NAME: sentence-transformers-quora-distilbert-base - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/paraphrase-distilroberta-base-v1 - # MODEL_TAG_NAME: sentence-transformers-paraphrase-distilroberta-base-v1 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: kiri-ai/distiluse-base-multilingual-cased-et - # MODEL_TAG_NAME: kiri-ai-distiluse-base-multilingual-cased-et - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/msmarco-distilroberta-base-v2 - # MODEL_TAG_NAME: sentence-transformers-msmarco-distilroberta-base-v2 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/msmarco-distilbert-base-v2 - # MODEL_TAG_NAME: sentence-transformers-msmarco-distilbert-base-v2 - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/stsb-xlm-r-multilingual - # MODEL_TAG_NAME: sentence-transformers-stsb-xlm-r-multilingual - # if: tag IS present - # stage: buildanddeploy - # - env: - # MODEL_NAME: sentence-transformers/paraphrase-xlm-r-multilingual-v1 - # MODEL_TAG_NAME: sentence-transformers-paraphrase-xlm-r-multilingual-v1 - # if: tag IS present - # stage: buildanddeploy - - - name: Build the base for custom images - if: env(DOCKER_PASSWORD) IS present - script: GIT_BRANCH=$TRAVIS_BRANCH GIT_TAG=$TRAVIS_TAG GIT_PULL_REQUEST=$TRAVIS_PULL_REQUEST cicd/build_custom_base.sh - stage: postbuild - -script: -- cicd/build.sh || travis_terminate 1 -- cicd/test.sh || travis_terminate 1 -- |- - if [ -n "$DOCKER_PASSWORD" ] - then - # Push docker image - GIT_BRANCH=$TRAVIS_BRANCH \ - GIT_TAG=$TRAVIS_TAG \ - GIT_PULL_REQUEST=$TRAVIS_PULL_REQUEST \ - travis_wait 120 cicd/docker_push.sh || travis_terminate 1 - else - # Skip pushing docker image - echo "Skipping docker image push step. Tests passed." - travis_terminate 0 - fi - -before_install: - # install a newer docker version which supports buildx - - sudo rm -rf /var/lib/apt/lists/* - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) edge" - - sudo apt-get update - - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - - mkdir -vp ~/.docker/cli-plugins/ - - curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx - - chmod a+x ~/.docker/cli-plugins/docker-buildx - -before_script: - # if there is a password provided login to docker at the very beginning, so we don't run into rate-limiting -- |- - if [ -n "$DOCKER_PASSWORD" ] - then - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - fi - -# currently the latest available - so we can install the latest docker -dist: bionic diff --git a/smoke_test.py b/smoke_test.py index 0ffb534..d5572ac 100755 --- a/smoke_test.py +++ b/smoke_test.py @@ -11,6 +11,7 @@ def _waitForStartup(self): try: res = requests.get(url) if res.status_code == 204: + print("Weaviate is working starting tests") return else: raise Exception( From 2401a153d6f2eaa907cd0a75f839a4fa972243ea Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Sat, 14 Jan 2023 13:02:59 +0100 Subject: [PATCH 3/7] Fixed deploy step --- .github/workflows/main.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9bc2ba7..157d651 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -68,6 +68,9 @@ jobs: cicd/test.sh || exit 1 - name: Deploy if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + env: + DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} run: | export GIT_TAG=$GITHUB_HEAD_REF cicd/docker_push.sh || exit 1 @@ -82,7 +85,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.9" - cache: 'pip' # caching pip dependencies - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -90,6 +92,9 @@ jobs: password: ${{secrets.DOCKER_PASSWORD}} - name: Deploy if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + env: + DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} run: | export GIT_TAG=$GITHUB_HEAD_REF cicd/build_custom_base.sh || exit 1 From 909338e4065de0321dc3eb45ee45ddf85a8a8dad Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Sat, 14 Jan 2023 14:27:03 +0100 Subject: [PATCH 4/7] Fix GIT_TAG env variable in deploy step --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 157d651..6d01ba7 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -72,7 +72,7 @@ jobs: DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} run: | - export GIT_TAG=$GITHUB_HEAD_REF + export GIT_TAG=${GITHUB_REF##*/} cicd/docker_push.sh || exit 1 build-custom-image: name: Build custom image @@ -96,5 +96,5 @@ jobs: DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} run: | - export GIT_TAG=$GITHUB_HEAD_REF + export GIT_TAG=${GITHUB_REF##*/} cicd/build_custom_base.sh || exit 1 From fc7db0d963641c02ff36671f40095fde593793dd Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Sat, 14 Jan 2023 14:57:18 +0100 Subject: [PATCH 5/7] Enable all of the transformers models --- .github/workflows/main.yaml | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6d01ba7..16a2f38 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -20,32 +20,32 @@ jobs: include: - model_name: "distilbert-base-uncased" model_tag_name: "distilbert-base-uncased" - # - model_name: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 - # model_tag_name: sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2 - # - model_name: sentence-transformers/multi-qa-MiniLM-L6-cos-v1 - # model_tag_name: sentence-transformers-multi-qa-MiniLM-L6-cos-v1 - # - model_name: sentence-transformers/multi-qa-mpnet-base-cos-v1 - # model_tag_name: sentence-transformers-multi-qa-mpnet-base-cos-v1 - # - model_name: sentence-transformers/all-mpnet-base-v2 - # model_tag_name: sentence-transformers-all-mpnet-base-v2 - # - model_name: sentence-transformers/all-MiniLM-L12-v2 - # model_tag_name: sentence-transformers-all-MiniLM-L12-v2 - # - model_name: sentence-transformers/paraphrase-multilingual-mpnet-base-v2 - # model_tag_name: sentence-transformers-paraphrase-multilingual-mpnet-base-v2 - # - model_name: sentence-transformers/gtr-t5-base - # model_tag_name: sentence-transformers-gtr-t5-base - # - model_name: sentence-transformers/gtr-t5-large - # model_tag_name: sentence-transformers-gtr-t5-large - # - model_name: sentence-transformers/sentence-t5-base - # model_tag_name: sentence-transformers-sentence-t5-base - # - model_name: vblagoje/dpr-ctx_encoder-single-lfqa-wiki - # model_tag_name: vblagoje-dpr-ctx_encoder-single-lfqa-wiki - # - model_name: vblagoje/dpr-question_encoder-single-lfqa-wiki - # model_tag_name: vblagoje-dpr-question_encoder-single-lfqa-wiki - # - model_name: facebook/dpr-ctx_encoder-single-nq-base - # model_tag_name: facebook-dpr-ctx_encoder-single-nq-base - # - model_name: facebook/dpr-question_encoder-single-nq-base - # model_tag_name: facebook-dpr-question_encoder-single-nq-base + - model_name: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 + model_tag_name: sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2 + - model_name: sentence-transformers/multi-qa-MiniLM-L6-cos-v1 + model_tag_name: sentence-transformers-multi-qa-MiniLM-L6-cos-v1 + - model_name: sentence-transformers/multi-qa-mpnet-base-cos-v1 + model_tag_name: sentence-transformers-multi-qa-mpnet-base-cos-v1 + - model_name: sentence-transformers/all-mpnet-base-v2 + model_tag_name: sentence-transformers-all-mpnet-base-v2 + - model_name: sentence-transformers/all-MiniLM-L12-v2 + model_tag_name: sentence-transformers-all-MiniLM-L12-v2 + - model_name: sentence-transformers/paraphrase-multilingual-mpnet-base-v2 + model_tag_name: sentence-transformers-paraphrase-multilingual-mpnet-base-v2 + - model_name: sentence-transformers/gtr-t5-base + model_tag_name: sentence-transformers-gtr-t5-base + - model_name: sentence-transformers/gtr-t5-large + model_tag_name: sentence-transformers-gtr-t5-large + - model_name: sentence-transformers/sentence-t5-base + model_tag_name: sentence-transformers-sentence-t5-base + - model_name: vblagoje/dpr-ctx_encoder-single-lfqa-wiki + model_tag_name: vblagoje-dpr-ctx_encoder-single-lfqa-wiki + - model_name: vblagoje/dpr-question_encoder-single-lfqa-wiki + model_tag_name: vblagoje-dpr-question_encoder-single-lfqa-wiki + - model_name: facebook/dpr-ctx_encoder-single-nq-base + model_tag_name: facebook-dpr-ctx_encoder-single-nq-base + - model_name: facebook/dpr-question_encoder-single-nq-base + model_tag_name: facebook-dpr-question_encoder-single-nq-base env: LOCAL_REPO: transformers-inference REMOTE_REPO: semitechnologies/transformers-inference From 07b03955e59ea30fa97656b85b5390a1e264fcce Mon Sep 17 00:00:00 2001 From: John Trengrove Date: Mon, 16 Jan 2023 15:18:08 +1000 Subject: [PATCH 6/7] Add duplicate /vectors route to remove 307 redirects --- app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app.py b/app.py index a882eaa..2adf682 100644 --- a/app.py +++ b/app.py @@ -45,6 +45,7 @@ def meta(): return meta_config.get() +@app.post("/vectors") @app.post("/vectors/") async def read_item(item: VectorInput, response: Response): try: From 495dce810fee2d05bebac8d6ab1f637e12966bee Mon Sep 17 00:00:00 2001 From: Stefan Bogdan Date: Mon, 16 Jan 2023 13:37:04 +0100 Subject: [PATCH 7/7] remove un-used packages, remove installation of third party libs (#38) * remove un-used packages, remove instalation of third party libs * update requirements --- Dockerfile | 7 +++---- custom.Dockerfile | 7 +++---- download.py | 9 +++++++-- meta.py | 1 + requirements-test.txt | 16 +++++++--------- requirements.txt | 2 -- smoke_test.py | 4 ++-- test_app.py | 2 +- vectorizer.py | 12 +++++++++--- 9 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c634d2..b6e8c57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ -FROM python:3.9-slim-buster +FROM python:3.10-slim WORKDIR /app -RUN apt-get update && apt-get -y install curl build-essential -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -ENV PATH="$PATH:/root/.cargo/bin" +RUN apt-get update +RUN pip install --upgrade pip setuptools COPY requirements.txt . RUN pip3 install -r requirements.txt diff --git a/custom.Dockerfile b/custom.Dockerfile index 3ad0740..a020a4d 100644 --- a/custom.Dockerfile +++ b/custom.Dockerfile @@ -1,10 +1,9 @@ -FROM python:3.9-slim-buster +FROM python:3.10-slim WORKDIR /app -RUN apt-get update && apt-get -y install curl build-essential -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -ENV PATH="$PATH:/root/.cargo/bin" +RUN apt-get update +RUN pip install --upgrade pip setuptools COPY requirements.txt . RUN pip3 install -r requirements.txt diff --git a/download.py b/download.py index 1544f1d..c74d459 100755 --- a/download.py +++ b/download.py @@ -1,9 +1,14 @@ #!/usr/bin/env python3 -from transformers import AutoModel, AutoTokenizer, AutoConfig -import nltk import os import sys +import nltk +from transformers import ( + AutoModel, + AutoTokenizer, + AutoConfig, +) + model_name = os.getenv('MODEL_NAME', None) force_automodel = os.getenv('FORCE_AUTOMODEL', False) diff --git a/meta.py b/meta.py index 1f0a79b..3887d67 100644 --- a/meta.py +++ b/meta.py @@ -1,5 +1,6 @@ from transformers import AutoConfig + class Meta: config: AutoConfig diff --git a/requirements-test.txt b/requirements-test.txt index 9e9e478..aff6bc0 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,10 +1,8 @@ -requests==2.28.1 -tokenizers==0.11.6 -transformers==4.20.1 -fastapi==0.78.0 -uvicorn==0.18.2 -nltk==3.7 -torch==1.12.0 -sentencepiece==0.1.96 -protobuf==4.21.2 +requests==2.28.2 +transformers==4.25.1 +fastapi==0.89.1 +uvicorn==0.20.0 +nltk==3.8.1 +torch==1.13.1 +sentencepiece==0.1.97 pytest diff --git a/requirements.txt b/requirements.txt index e248219..f8cdd7b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,6 @@ -tokenizers==0.13.2 transformers==4.25.1 fastapi==0.89.1 uvicorn==0.20.0 nltk==3.8.1 torch==1.13.1 sentencepiece==0.1.97 -protobuf==4.21.12 diff --git a/smoke_test.py b/smoke_test.py index d5572ac..27d1ca6 100755 --- a/smoke_test.py +++ b/smoke_test.py @@ -1,6 +1,6 @@ +import time import unittest import requests -import time class SmokeTest(unittest.TestCase): @@ -18,7 +18,7 @@ def _waitForStartup(self): "status code is {}".format(res.status_code)) except Exception as e: print("Attempt {}: {}".format(i, e)) - time.sleep(1) + time.sleep(2) raise Exception("did not start up") diff --git a/test_app.py b/test_app.py index 69b4fc6..f088cb1 100644 --- a/test_app.py +++ b/test_app.py @@ -1,6 +1,6 @@ import os -import subprocess import time +import subprocess from multiprocessing import Process import pytest diff --git a/vectorizer.py b/vectorizer.py index 359747c..f52b242 100644 --- a/vectorizer.py +++ b/vectorizer.py @@ -1,11 +1,17 @@ import math from typing import Optional - import torch from nltk.tokenize import sent_tokenize from pydantic import BaseModel -from transformers import AutoModel, AutoTokenizer, T5ForConditionalGeneration, T5Tokenizer, DPRContextEncoder, \ - DPRQuestionEncoder +from transformers import ( + AutoModel, + AutoTokenizer, + T5ForConditionalGeneration, + T5Tokenizer, + DPRContextEncoder, + DPRQuestionEncoder, +) + # limit transformer batch size to limit parallel inference, otherwise we run # into memory problems