- Python 98.6%
- Shell 0.7%
- Makefile 0.3%
- Mako 0.3%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Chnobli github release See merge request library/adl/Machine_learning_platform/embeddings-backend!32 |
||
| .tests | ||
| alembic | ||
| models | ||
| scripts | ||
| src/embeddings_backend | ||
| tests | ||
| vm_setup | ||
| volumes | ||
| web | ||
| .dockerignore | ||
| .env.chnobli | ||
| .env.dev.example | ||
| .env.example | ||
| .env.gitlab | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .python-version | ||
| ACCESS.md | ||
| alembic.ini | ||
| API.md | ||
| docker-compose.chnobli.yml | ||
| docker-compose.dev.yml | ||
| docker-compose.gitlab.yml | ||
| docker-compose.staging.yml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| Dockerfile.fastapi | ||
| Dockerfile.ocr | ||
| Dockerfile.test-runner | ||
| Dockerfile.worker | ||
| embeddings_service.png | ||
| Makefile | ||
| pyproject.toml | ||
| README.md | ||
| server_entrypoint.sh | ||
| uv.lock | ||
Embeddings Service
How to run (dev)
- Create your local dev env file:
cp .env.dev.example .env.dev
# edit .env.dev and fill in required values
- Start the stack (Compose uses
.env.devfor${...}interpolation via--env-file):
docker compose -f docker-compose.dev.yml --env-file .env.dev up -d
Rebuild images only when you change dependencies / Dockerfiles (e.g. pyproject.toml, uv.lock, private Git deps):
docker compose -f docker-compose.dev.yml --env-file .env.dev build fastapi-app embeddings-worker ocr-worker
Notes:
- Source code is mounted into the containers (no rebuild needed for Python code changes). Usually restarting
fastapi-appis enough:
docker compose -f docker-compose.dev.yml --env-file .env.dev restart fastapi-app
- Run tests on the workstation:
pytest
GitLab CI
The CI pipeline runs integration tests from the tests/ folder.
- Non-secret runtime configuration is committed in
.env.gitlaband is sourced by.gitlab-ci.yml. - Secrets must be configured as GitLab CI/CD variables (Settings → CI/CD → Variables).
Service Architecture
Simple install with docker
git clone --recurse-submodules git@gitlab.ethz.ch:library/adl/embeddings-service/embeddings-backend.git
cd embeddings-backend
# Checkout different branch if necessary
git submodule update
# Copy .env.dev.example to .env.dev and fill in values
cp .env.dev.example .env.dev
# Start (use --env-file so compose-time `${...}` values are resolved from .env.dev)
docker compose -f docker-compose.dev.yml --env-file .env.dev up -d
Staging (pre-built image)
docker-compose.staging.yml uses a pre-built Docker image for the FastAPI app (and the Celery workers), so you don't need to rebuild containers when deploying.
By default it pulls:
registry.ethz.ch/embeddings-service/embeddings/embeddings-image:latest
Override the image/tag via FASTAPI_IMAGE:
FASTAPI_IMAGE=registry.ethz.ch/embeddings-service/embeddings/embeddings-image:<tag> \
docker compose -f docker-compose.staging.yml up -d
Quick start
- To access the Fast API documentation go to
http://localhost:8000/docs
On this page one can try out the different API calls.
- To visually inspect the Milvus database go to
http://localhost:8080
-
In order to query the embedding api run the following command:
- Single text embedding
curl -X POST "http://localhost:8000/embeddings/single" -H "Content-Type: application/json" -d '{
"text_id": "test-id-1",
"text": "Hello, this is a test.",
"model": "ollama",
"model_name": "jina/jina-embeddings-v2-base-de",
"store": false
}' > out.json
- Bulk text embeddings
curl -X POST "http://localhost:8001/embeddings/single" -H "Content-Type: application/json" -d '{
"text_ids": ["test-id-1", "test-id-2"],
"texts": ["Hello, this is a test.", "Hello, this is also a test."],
"model": "ollama",
"model_name": "jina/jina-embeddings-v2-base-de",
"store": false
}' > out.json
The recipe for doing tasks such as installing the environment, creating a docker image and pushing it to a registry are listed in the Makefile. These can be executed as follows:
Installing the environment locally
make install-env
- Run locally
make run
- Format
make format
- Updating the environment
make update-env
