Skip to content

Commit fa1d57d

Browse files
committed
feat(transformers): split in separate backend
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent caedb4e commit fa1d57d

23 files changed

+777
-28
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
sudo apt-get install -y libopencv-dev && sudo ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
7979
8080
sudo rm -rfv /usr/bin/conda || true
81-
PATH=$PATH:/opt/conda/bin make -C backend/python/huggingface
81+
PATH=$PATH:/opt/conda/bin make -C backend/python/sentencetransformers
8282
8383
# Pre-build piper before we start tests in order to have shared libraries in place
8484
make sources/go-piper && \

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ARG TARGETARCH
1212
ARG TARGETVARIANT
1313

1414
ENV BUILD_TYPE=${BUILD_TYPE}
15-
ENV EXTERNAL_GRPC_BACKENDS="huggingface-embeddings:/build/backend/python/huggingface/run.sh,autogptq:/build/backend/python/autogptq/run.sh,bark:/build/backend/python/bark/run.sh,diffusers:/build/backend/python/diffusers/run.sh,exllama:/build/backend/python/exllama/run.sh,vall-e-x:/build/backend/python/vall-e-x/run.sh,vllm:/build/backend/python/vllm/run.sh"
15+
ENV EXTERNAL_GRPC_BACKENDS="huggingface-embeddings:/build/backend/python/sentencetransformers/run.sh,transformers:/build/backend/python/transformers/run.sh,sentencetransformers:/build/backend/python/sentencetransformers/run.sh,autogptq:/build/backend/python/autogptq/run.sh,bark:/build/backend/python/bark/run.sh,diffusers:/build/backend/python/diffusers/run.sh,exllama:/build/backend/python/exllama/run.sh,vall-e-x:/build/backend/python/vall-e-x/run.sh,vllm:/build/backend/python/vllm/run.sh"
1616
ENV GALLERIES='[{"name":"model-gallery", "url":"github:go-skynet/model-gallery/index.yaml"}, {"url": "github:go-skynet/model-gallery/huggingface.yaml","name":"huggingface"}]'
1717
ARG GO_TAGS="stablediffusion tts"
1818

@@ -169,7 +169,10 @@ RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
169169
PATH=$PATH:/opt/conda/bin make -C backend/python/vllm \
170170
; fi
171171
RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
172-
PATH=$PATH:/opt/conda/bin make -C backend/python/huggingface \
172+
PATH=$PATH:/opt/conda/bin make -C backend/python/sentencetransformers \
173+
; fi
174+
RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
175+
PATH=$PATH:/opt/conda/bin make -C backend/python/transformers \
173176
; fi
174177
RUN if [ "${IMAGE_TYPE}" = "extras" ]; then \
175178
PATH=$PATH:/opt/conda/bin make -C backend/python/vall-e-x \

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ test: prepare test-models/testmodel grpcs
296296
@echo 'Running tests'
297297
export GO_TAGS="tts stablediffusion"
298298
$(MAKE) prepare-test
299-
HUGGINGFACE_GRPC=$(abspath ./)/backend/python/huggingface/run.sh TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models \
299+
HUGGINGFACE_GRPC=$(abspath ./)/backend/python/sentencetransformers/run.sh TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models \
300300
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!gpt4all && !llama && !llama-gguf" --flake-attempts 5 --fail-fast -v -r ./api ./pkg
301301
$(MAKE) test-gpt4all
302302
$(MAKE) test-llama
@@ -367,7 +367,8 @@ protogen-go:
367367
backend/backend.proto
368368

369369
protogen-python:
370-
python3 -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=backend/python/huggingface/ --grpc_python_out=backend/python/huggingface/ backend/backend.proto
370+
python3 -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=backend/python/sentencetransformers/ --grpc_python_out=backend/python/sentencetransformers/ backend/backend.proto
371+
python3 -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=backend/python/transformers/ --grpc_python_out=backend/python/transformers/ backend/backend.proto
371372
python3 -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=backend/python/autogptq/ --grpc_python_out=backend/python/autogptq/ backend/backend.proto
372373
python3 -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=backend/python/exllama/ --grpc_python_out=backend/python/exllama/ backend/backend.proto
373374
python3 -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=backend/python/bark/ --grpc_python_out=backend/python/bark/ backend/backend.proto
@@ -382,7 +383,8 @@ prepare-extra-conda-environments:
382383
$(MAKE) -C backend/python/bark
383384
$(MAKE) -C backend/python/diffusers
384385
$(MAKE) -C backend/python/vllm
385-
$(MAKE) -C backend/python/huggingface
386+
$(MAKE) -C backend/python/sentencetransformers
387+
$(MAKE) -C backend/python/transformers
386388
$(MAKE) -C backend/python/vall-e-x
387389
$(MAKE) -C backend/python/exllama
388390

api/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ var _ = Describe("API test", func() {
704704
})
705705

706706
Context("External gRPC calls", func() {
707-
It("calculate embeddings with huggingface", func() {
707+
It("calculate embeddings with sentencetransformers", func() {
708708
if runtime.GOOS != "linux" {
709709
Skip("test supported only on linux")
710710
}

backend/python/huggingface/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.PONY: sentencetransformers
2+
sentencetransformers:
3+
@echo "Creating virtual environment..."
4+
@conda env create --name sentencetransformers --file sentencetransformers.yml
5+
@echo "Virtual environment created."
6+
7+
.PONY: run
8+
run:
9+
@echo "Running sentencetransformers..."
10+
bash run.sh
11+
@echo "sentencetransformers run."
12+
13+
# It is not working well by using command line. It only6 works with IDE like VSCode.
14+
.PONY: test
15+
test:
16+
@echo "Testing sentencetransformers..."
17+
bash test.sh
18+
@echo "sentencetransformers tested."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Creating a separate environment for the sentencetransformers project
2+
3+
```
4+
make sentencetransformers
5+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
##
4+
## A bash script wrapper that runs the sentencetransformers server with conda
5+
6+
export PATH=$PATH:/opt/conda/bin
7+
8+
# Activate conda environment
9+
source activate sentencetransformers
10+
11+
# get the directory where the bash script is located
12+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
13+
14+
python $DIR/sentencetransformers.py $@

0 commit comments

Comments
 (0)