Skip to content

Add local Qwen3 embedding benchmark matrix - #3

Open
CompleteDotTech wants to merge 5 commits into
mainfrom
feat/local-qwen3-embeddings
Open

Add local Qwen3 embedding benchmark matrix#3
CompleteDotTech wants to merge 5 commits into
mainfrom
feat/local-qwen3-embeddings

Conversation

@CompleteDotTech

Copy link
Copy Markdown

What

  • Add three local Qwen3 embedding services (A/B/C): 0.6B, 4B, and 8B.
  • Run every model in separate CPU and GPU TEI containers.
  • Add CPU, GPU, and BOTH Compose profiles, persistent per-model caches, loopback ports, pinned model revisions, and configurable TEI image/throughput settings.
  • Extend the OpenAI Compatible Embedding adapter with query and passage prefixes required by asymmetric retrieval models.
  • Add a standard-library benchmark harness with latency, throughput, dimension validation, and fixture retrieval metrics.

Why

Unstract already supports local vector databases and OpenAI-compatible embedding endpoints, but it did not provide local model-serving containers or a repeatable CPU/GPU comparison matrix. This keeps all six variants available for the benchmark review; unselected variants are intentionally not removed in this PR.

How

The Compose include is profile-gated, so the normal development stack does not download model weights. The services expose TEI's OpenAI-compatible endpoint and share the existing Unstract network.

  • CPU: qwen3-embedding-06b-cpu:8101, qwen3-embedding-4b-cpu:8102, qwen3-embedding-8b-cpu:8103
  • GPU: qwen3-embedding-06b-gpu:8201, qwen3-embedding-4b-gpu:8202, qwen3-embedding-8b-gpu:8203
  • Dimensions: 1024, 2560, and 4096 respectively
  • The adapter configuration source is docker/local-embeddings.config.json.
  • The smoke fixture is deliberately small; replace it with representative documents and labeled queries before using quality scores for a production decision.

Published benchmark snapshot

The following is the published MTEB comparison shown in the Qwen model cards, not a measurement from this checkout. The card labels this as an MTEB online snapshot dated 2025-05-24.

Candidate Parameters Dimensions Multilingual MTEB mean / retrieval English MTEB v2 mean / retrieval
A: Qwen3-Embedding-0.6B 0.6B 1024 64.33 / 64.64 70.70 / 61.83
B: Qwen3-Embedding-4B 4B 2560 69.45 / 69.60 74.60 / 68.46
C: Qwen3-Embedding-8B 8B 4096 70.58 / 70.88 75.22 / 69.44

Sources: Qwen3-Embedding-0.6B, Qwen3-Embedding-4B, and Qwen3-Embedding-8B model cards. The official MTEB page for 4B lists approximately 7.5 GB model memory and the 8B page lists approximately 14.1 GB; actual service memory also depends on runtime, batch limits, and sequence lengths.

Can this PR break any existing features. If yes, please list possible items. If no, please explain why.

The default stack behavior is unchanged because all six embedding services are profile-gated. The OpenAI-compatible adapter keeps its existing defaults when prefixes are blank. A model change still requires a separate vector collection and full reindex when dimensions differ.

Potential operational impact: starting embeddings-both can exceed one GPU's memory, and first startup downloads large model artifacts into persistent volumes.

Database Migrations

  • None.

Env Config

  • Optional HF_TOKEN for private model access.
  • QWEN3_TEI_CPU_IMAGE and QWEN3_TEI_GPU_IMAGE override the default TEI images for host architecture.
  • QWEN3_06B_CPU_PORT, QWEN3_4B_CPU_PORT, QWEN3_8B_CPU_PORT and corresponding GPU variables override host ports.
  • QWEN3_*_REVISION variables default to the pinned model commits.
  • QWEN3_MAX_BATCH_TOKENS, QWEN3_MAX_CLIENT_BATCH_SIZE, QWEN3_MAX_CONCURRENT_REQUESTS, and QWEN3_TOKENIZATION_WORKERS tune serving behavior.
  • OpenAI Compatible Embedding instances should use the service's internal API base and configure the Qwen query prefix; Passage Prefix remains empty.

Relevant Docs

  • docker/README.md
  • docker/local-embeddings.config.json
  • docker/benchmarks/embedding_benchmark.py

Related Issues or PRs

  • None.

Dependencies Versions

  • TEI CPU image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.9
  • TEI GPU image: ghcr.io/huggingface/text-embeddings-inference:cuda-1.9
  • Qwen model revisions are pinned in Compose and local-embeddings.config.json.

Notes on Testing

  • PASS: 64 SDK adapter tests.
  • PASS: Python compilation for changed Python files.
  • PASS: JSON parsing and Compose YAML structural validation for six services, six volumes, profiles, healthchecks, GPU reservations, and pinned revisions.
  • PASS: benchmark harness fake HTTP endpoint, including TEI's empty-body HTTP 200 health response, dimensions, and retrieval metrics.
  • PASS: relevant Ruff lint rules and formatting.
  • LIMITATION: the full SDK suite reports 558 passed and 11 unrelated environment failures: botocore is not installed for existing Bedrock Mantle tests, and pytest-asyncio is not installed for existing async compatibility tests.
  • NOT RUN: live model benchmark. This execution host has no Docker CLI/daemon and no nvidia-smi, so no CPU/GPU model weights were downloaded and no runtime performance numbers are claimed.

Screenshots

Not applicable.

Checklist

I have read and understood the Contribution Guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant