Offline reranker sidecar for the pattern MCP servers — Hugging Face TEI (CPU)
with Alibaba-NLP/gte-reranker-modernbert-base
(149M params, 8k context, English) baked into the image. No downloads, no API keys at runtime.
┌────────────────────────────────────────────────────────────────┐
│ architecture-pattern-mcp / agent-pattern-mcp │
│ ───────── HTTP /rerank ─────────► │
│ │
│ ┌───────────────────────────────┐ │
│ │ pattern-tei-rerank │ ◄── pattern-tei-infra │
│ │ gte-reranker-modernbert-base │ │
│ │ :8080 (TEI, CPU) │ │
│ └───────────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘
This image is the reranker only. It contains no MCP server, no embedder,
and no LLM client. The MCP servers (olk/architecture-pattern-mcp,
olk/agent-pattern-mcp) reach it via
the shared Docker network pattern-tei-shared at the DNS name
pattern-tei-rerank (see the pattern-tei-infra stack).
Runtime base is ghcr.io/huggingface/text-embeddings-inference:cpu-1.9,
but the router binary is not stock: it is self-built from TEI v1.9.4
plus unmerged upstream PR #884
(see Startup and --warmup-tokens below).
Pinned invariants: --model-id /data/reranker-model --dtype float32
(ORT backend; sequence-classification models take no --pooling flag).
Alibaba-NLP/gte-reranker-modernbert-base — English, 149M params, 8k context, Apache 2.0 (fp32 ONNX baked in, onnx/model.onnx)v1.9.4 + PR #884 on :8080 (ORT backend, float32)POST /rerank (raw TEI) · GET /health · GET /infoHF_HUB_OFFLINE=1MAX_CONCURRENT_REQUESTS=64, MAX_BATCH_TOKENS=16384, MAX_CLIENT_BATCH_SIZE=48, AUTO_TRUNCATE=true, WARMUP_TOKENS=0, PROMETHEUS_PORT=0 (metrics not exposed)No config.json patching is needed: max_position_embeddings=8192 is below
the default max_batch_tokens=16384, so TEI accepts the model config without
the warmup warning that affects larger-context models.
--warmup-tokensWhy this image carries a custom router build instead of stock cpu-1.9:
cpu-1.9 has no --warmup-tokens / WARMUP_TOKENS flag. On CPU
it always runs a synthetic warmup pass of min(max_input_length, max_batch_tokens)
tokens before serving. Measured cost for this 149M model: ~78 s of an ~81 s
cold start — warmup is the boot time.MAX_BATCH_TOKENS (upstream
issue #819),
which caps throughput to buy back startup time.--warmup-tokens / WARMUP_TOKENS.
This image builds the router from TEI v1.9.4 + PR #884 (pinned SHA 5806bdc)
and sets WARMUP_TOKENS=0 (skip the synthetic pass) by default, so the
container is ready in seconds (weight load only).Semantics of WARMUP_TOKENS (this image only — stock TEI ignores the variable):
| Value | Behaviour |
|---|---|
0 (default) | Skip the synthetic warmup pass |
N > 0 | Warm with N tokens instead of the full default |
N > MAX_BATCH_TOKENS | Rejected at startup |
Unlike the Qwen3 embedder sidecar (capped at MAX_BATCH_TOKENS=8192 for the
documented CPU warmup OOM, PR #634/#725), 16384 is safe here — the 149M
reranker never hit that failure mode.
All tunables are environment variables (clap fallbacks; CLI flags win).
Image defaults are overridable per container, e.g.
docker run -e WARMUP_TOKENS=512 … or the compose environment: block:
| Variable | Default | Notes |
|---|---|---|
WARMUP_TOKENS | 0 | Skip (0) / shrink (N) the warmup pass. Custom-build flag, see above |
MAX_CONCURRENT_REQUESTS | 64 | Must be ≥ texts per rerank request. TEI consumes one queue slot per text |
MAX_CLIENT_BATCH_SIZE | 48 | Must be ≥ the MCP client's RERANKER_MAX_BATCH_SIZE (default 48). Binding invariant: max_batch_size ≤ min(MAX_CLIENT_BATCH_SIZE, MAX_CONCURRENT_REQUESTS) |
MAX_BATCH_TOKENS | 16384 | Well above the 8k model context; safe for this model |
AUTO_TRUNCATE | true | Keep on: requirement strings can exceed model input length |
PORT | 8080 | If changed, update RERANKER_BASE_URL on the MCP side |
PROMETHEUS_PORT | 0 | Ephemeral port; /metrics never exposed |
HOSTNAME | 0.0.0.0 | Informational: Docker injects its own HOSTNAME at runtime, which TEI rejects as non-IP and falls back to 0.0.0.0 |
The MCP consumer chunks its fused candidate pool into requests of
RERANKER_MAX_BATCH_SIZE (default 48, config.json → RERANKER_MAX_BATCH_SIZE)
against http://pattern-tei-rerank:8080, with keep_retrieval_score preserving
the stage-1 fusion score alongside the cross-encoder logit.
docker compose version)Part of the pattern-tei-infra stack
(recommended — shared Docker network pattern-tei-shared, DNS name pattern-tei-rerank):
git clone https://github.com/olk/pattern-tei-infra.git && cd pattern-tei-infra
TEI_RERANK_IMAGE=olkowa/pattern-tei-rerank:latest docker compose up -d
Or standalone (no MCP consumer):
docker run -d --name pattern-tei-rerank -p 8080:8080 olkowa/pattern-tei-rerank:latest
curl -fsS http://localhost:8080/health
Mirrored on GHCR at
ghcr.io/olk/pattern-tei-rerank.
Nothing to configure — no env vars, no model download, no HF token.
Cold start is seconds (WARMUP_TOKENS=0); expect ~80 s only if you
explicitly set a large WARMUP_TOKENS.
# Update
docker compose -f pattern-tei-infra/docker-compose.yml pull
# Logs
docker compose -f pattern-tei-infra/docker-compose.yml logs -f pattern-tei-rerank
# Health
docker inspect --format '{{.State.Health.Status}}' pattern-tei-rerank
# Re-enable a warmup pass (e.g. to smooth first-request latency)
WARMUP_TOKENS=512 docker compose -f pattern-tei-infra/docker-compose.yml up -d pattern-tei-rerank
# Pin a version
TEI_RERANK_IMAGE=olkowa/pattern-tei-rerank:0.1.0 \
docker compose -f pattern-tei-infra/docker-compose.yml up -d
Content type
Image
Digest
sha256:e3d608691…
Size
619.6 MB
Last updated
10 days ago
docker pull olkowa/pattern-tei-rerank