Read-only mirror of https://github.com/eth-library/CHNOBLi-embedding-backend — ETH Library. Issues & pull requests at the source.
  • Python 98.6%
  • Shell 0.7%
  • Makefile 0.3%
  • Mako 0.3%
  • Dockerfile 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
apelloni ffe7024f89 Merge branch 'apelloni/chnobli-github' into 'main'
Chnobli github release

See merge request library/adl/Machine_learning_platform/embeddings-backend!32
2026-08-11 12:53:09 +00:00
.tests Work on pdf processing 2026-04-28 15:24:32 +00:00
alembic persistence and integration of segmentation field (kraken, paddle) 2026-06-19 15:59:30 +02:00
models add english embeddings 2024-09-11 16:25:31 +02:00
scripts Added API usage script 2025-12-12 16:07:15 +01:00
src/embeddings_backend allow to allow for a range of IPs. This is used when deploying chnobli locally otherwise it falls back to the usuall behaviour 2026-08-11 14:24:48 +02:00
tests Support hugging_face_model property and disallow non-image files as ORC pipeline input. 2026-07-06 13:13:32 +02:00
vm_setup fixed ports for vm and force GPU 2025-07-09 12:27:08 +02:00
volumes Added init postgres script 2025-12-16 17:18:19 +01:00
web Finished dev docker compose 2025-12-16 16:25:59 +01:00
.dockerignore Fixing tag and pipeline ownership. Once we have groups, looks unreasonable only the owning user to have access to pipelines. 2026-01-12 15:10:27 +01:00
.env.chnobli Apelloni/chnobli 2026-07-21 06:50:29 +00:00
.env.dev.example Chnobli integration 2026-08-07 14:19:20 +02:00
.env.example removed vectordb operations from repo and import them from external repos 2026-01-19 13:58:24 +01:00
.env.gitlab Run full backend test suite in GitLab after build 2026-02-17 12:06:23 +00:00
.gitignore Work on pdf processing 2026-04-28 15:24:32 +00:00
.gitlab-ci.yml Adjust docker build to have CPU and GPU paddle versions separately. 2026-06-19 17:45:04 +02:00
.python-version Started combining both API servers 2025-11-19 08:31:24 +01:00
ACCESS.md Documenting in ACCESS.md who can do who. 2026-01-12 18:07:30 +01:00
alembic.ini added alembic 2025-12-05 10:19:09 +01:00
API.md Progress with tag handling. 2026-01-13 17:17:49 +01:00
docker-compose.chnobli.yml Apelloni/chnobli 2026-07-21 06:50:29 +00:00
docker-compose.dev.yml Chnobli integration 2026-08-07 14:19:20 +02:00
docker-compose.gitlab.yml Adjust docker build to have CPU and GPU paddle versions separately. 2026-06-19 17:45:04 +02:00
docker-compose.staging.yml Adjust docker build to have CPU and GPU paddle versions separately. 2026-06-19 17:45:04 +02:00
docker-compose.yml include new version of ocr worker, and configured prod default to use paddleocr for segmentation + better trocr model for transcription 2026-05-26 17:01:17 +02:00
Dockerfile removed vectordb operations from repo and import them from external repos 2026-01-19 13:58:24 +01:00
Dockerfile.fastapi Apelloni/chnobli 2026-07-21 06:50:29 +00:00
Dockerfile.ocr Adjust docker build to have CPU and GPU paddle versions separately. 2026-06-19 17:45:04 +02:00
Dockerfile.test-runner Run full backend test suite in GitLab after build 2026-02-17 12:06:23 +00:00
Dockerfile.worker use github when no GITLAB_TOKEN is given for embeddings-backend 2026-08-11 14:26:10 +02:00
embeddings_service.png Service diagram 2025-05-14 14:22:22 +02:00
Makefile cleaned first version 2024-09-06 16:41:53 +02:00
pyproject.toml Work on pdf processing 2026-04-28 15:24:32 +00:00
README.md Work on pdf processing 2026-04-28 15:24:32 +00:00
server_entrypoint.sh Working on ci 2026-02-13 14:18:55 +01:00
uv.lock Work on pdf processing 2026-04-28 15:24:32 +00:00

Embeddings Service

How to run (dev)

  1. Create your local dev env file:
cp .env.dev.example .env.dev
# edit .env.dev and fill in required values 
  1. Start the stack (Compose uses .env.dev for ${...} 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-app is 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.gitlab and is sourced by .gitlab-ci.yml.
  • Secrets must be configured as GitLab CI/CD variables (Settings → CI/CD → Variables).

Service Architecture

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