Repository navigation
Description
Update 2026-11-26 (infra move): the TEI manifests and the gateway entry go to dan-petty/homelab.
This issue keeps the ADR in docs/adr/ and the rerank call in the gateway smoke check of k8s/README.md (#4885). deploy-stack lists the llm files in MANIFESTS_BY_STACK, so a new manifest file also needs a line there. The environment checks of devops ci for these files are gone.
Follow-up: dan-petty/homelab#283.
Problem or Motivation
The LiteLLM gateway has no rerank route, and no manifest names a reranker. Ollama has no rerank endpoint (ollama#3368, open since 2024-03).
On the 62-query project eval set of #4961, the cross-encoder BAAI/bge-reranker-v2-m3 lifts nDCG@10 from 0.386 (current path) to 0.514 over the current pool (B1, p 0.002) and to 0.567 over the hybrid pool (B2, p < 0.001). Over the hybrid pool alone, its gain is +0.105 on the 42 natural-language queries (p 0.017) and +0.224 on census questions (p 0.002), but only +0.053 over all queries (p 0.10). The trial #4968 confirms this with the scores that TEI serves before this route is built.
A cross-encoder of this size needs a GPU. One rerank of 50 candidates of about 190 tokens is about 5.8 TFLOP (303M non-embedding parameters x 2 x 9,500 tokens). On a workstation CPU, it took 1,730 to 1,890 CPU-seconds. On TEI 1.9.4 on an RTX 3090, it took p50 220 ms and p95 245 ms, with 1.4 GiB VRAM at idle and 1.9 GiB at peak.
TEI does not support the Pascal embed GPUs (cc 6.1) or the Volta GPUs (cc 7.0), so it shares an Ampere GPU with the 48 GiB chat tier.
Proposed Solution & Architectural Design
Add a TEI 1.9.4 Deployment in namespace llm, managed by Argo CD from k8s/llm:
- image
ghcr.io/huggingface/text-embeddings-inference:86-1.9.4, pinned by digest; BAAI/bge-reranker-v2-m3at revision 953dc6f6, float16,--max-batch-tokens 16384, and the truncation length that test(k8s): trial TEI quality and load on a cluster GPU #4968 sets;- one replica on
<ampere-node>, on the GPU with the larger 7-day headroom, with the GPU selection that the 48 GiB tier uses; - the restricted Pod Security level and uid 1000 (the trial showed that this works), a PVC for the model cache (warm start 2 to 3 s, cold start 77 to 112 s),
HF_HUB_DISABLE_TELEMETRY=1; - a NetworkPolicy that admits only the gateway and Prometheus, and a PodMonitor for the
te_*metrics; - an alert on the GPU memory of the shared GPU.
Add a LiteLLM model_list entry: model_name: bge-reranker-v2-m3, model: huggingface/BAAI/bge-reranker-v2-m3, api_base the TEI Service, model_info.mode: rerank. LiteLLM posts {query, texts, raw_scores} to <api_base>/rerank. Clients call POST /v1/rerank with the Cohere shape {model, query, documents, top_n} and read results[].index and results[].relevance_score.
Add one rerank call to the gateway smoke calls (#4885).
Record the choice in an ADR: TEI, and why not Infinity (v3 license fails; v2 cannot load Qwen3 and counts characters as tokens), Ollama (no rerank endpoint) or llama.cpp llama-server (the latency that #4968 measured on a P6000).
Stop rule: if the stop test of #4968 fails (the reranked arm does not beat the fused arm on the natural-language queries with p < 0.05), do not build this route. Return this issue to New with the evidence.
Target Subsystem
docs/adr/ and the gateway smoke check in devops-cli. The TEI manifests, the gateway entry and the alerts are in dan-petty/homelab.
Existing Tool Considered
Hugging Face Text Embeddings Inference 1.9.4 (Apache-2.0), with the reranker model BAAI/bge-reranker-v2-m3 (Apache-2.0). LiteLLM's huggingface/ rerank provider. Argo CD, DCGM and Prometheus. No code is added to the CLI. Estimated cost: about 0.25M tokens and 4 hours.
Acceptance criteria
- Argo CD shows the TEI application Synced and Healthy. The image is pinned by digest and the model by revision.
POST <gateway>/v1/rerankwith modelbge-reranker-v2-m3and 50 documents returns 50 results withrelevance_score.- Over 100 gateway calls with 50 candidates of at most 2,400 characters, p95 <= 500 ms.
- The TEI pod VRAM peak is at most 2.5 GiB, and the 48 GiB chat tier has 0 OOM restarts in the 7 days after rollout (DCGM, kubectl).
- Prometheus has
te_request_countfor the pod. - The gateway smoke calls include one rerank call.
- The ADR is merged.
Dependencies
#4968 (the GPU trial and its stop test).
Source: #4961
Alternatives check of 2026-11-27: in-use.
The item already names this tool.
Tool: huggingface/text-embeddings-inference (https://github.com/huggingface/text-embeddings-inference), Apache-2.0, last activity 2026-11-25, maintained.
Reason: Web searches were unhelpful, but the tool facts confirm TEI is an open, maintained server that already serves cross-encoder rerank scores and te_* metrics; the issue itself names it as the tool in use, so only the ADR and smoke call remain.
Covers:
- Serves cross-encoder rerank scores over HTTP for a reranker model
- Loads BAAI/bge-reranker-v2-m3, pinned by revision and dtype
- Exposes te_* Prometheus metrics for request and batch counts
- Ships a CUDA image that a Deployment can pin by digest
Lacks:
- No gateway route; needs the LiteLLM model_list rerank entry
- No Cohere /v1/rerank shape; serves /rerank with raw_scores
- No GPU node placement, model-cache PVC, NetworkPolicy or PodMonitor
- No support for Pascal or Volta GPUs, so an Ampere GPU is shared
Proposed design
Problem statement
The LiteLLM gateway has no rerank route, and retrieval cannot use a cross-encoder. The infra move puts the TEI manifests and the gateway entry in dan-petty/homelab#283. This issue keeps the ADR in docs/adr/ and the rerank call in the gateway smoke check of k8s/README.md.
Acceptance criteria
Requirement: ADR records reranker choice
The change SHALL add an accepted MADR record that chooses TEI and rejects Infinity, Ollama and llama.cpp.
Scenario: ADR record check
- WHEN
uv run devops docs generateanduv run devops ci test tests/invariants/test_adr_records.pyrun on the change branch. - THEN The index of
docs/adr/README.mdholds the new row. The test exits 0 for the new record withstatus: acceptedandissue: 4970.
Requirement: Gateway smoke rerank call
The gateway smoke calls in k8s/README.md SHALL include one POST /rerank call with 50 documents and SHALL list six calls in total.
Scenario: Documented smoke calls
- WHEN
uv run devops ci --check --only docsruns on the change branch, andrg -n "POST /rerank" k8s/README.mdreads the smoke section. - THEN The command exits 0. The smoke section lists six calls, and one call is
POST /rerankwith modelbge-reranker-v2-m3and 50 documents.
Requirement: Pending a person after the merge
The pull request SHALL merge only after its required checks pass and a person approves it.
Scenario: Person merge
- WHEN The pull request is ready and its required checks pass.
- THEN A person merges it, and the ADR and smoke call are on the default branch.
Existing Tool Considered
Hugging Face Text Embeddings Inference (TEI) 1.9.4, Apache-2.0, maintained. The alternatives check of 2026-11-21 in the issue body records verdict in-use and lists what TEI covers and lacks. This change adds the ADR and the gateway smoke rerank call. The TEI manifests and the LiteLLM entry are in dan-petty/homelab#283. The estimated cost is about 0.25M tokens and 4 hours.
Key questions
- Which reranker server and model does the ADR record?: Use Hugging Face Text Embeddings Inference 1.9.4 with
BAAI/bge-reranker-v2-m3at revision 953dc6f6. The alternatives check of 2026-11-21 in the issue body records TEI asin-useand lists what it covers and lacks. This change adds the ADR and the smoke call; the manifests and gateway entry are indan-petty/homelab#283. (best practice) [sources: docs/adr/README.md, k8s/README.md:186]- Chosen: Text Embeddings Inference 1.9.4. Open, Apache-2.0 and maintained; serves cross-encoder rerank scores and Prometheus metrics; the alternatives check records it in-use.
- Rejected: Infinity. Its v3 license fails, and v2 cannot load Qwen3 or count tokens correctly.
- Rejected: Ollama. It has no rerank endpoint (ollama#3368).
- Rejected: llama.cpp llama-server. The trial measured too much latency on a P6000.
- Where do the TEI manifests and the LiteLLM gateway entry live after the infra move?: They go to
dan-petty/homelab#283. This issue keeps only the ADR indocs/adr/and the rerank call in the gateway smoke check ofk8s/README.md. [sources: k8s/README.md:1, CONTEXT.md] - Where do the gateway smoke calls live, and what does the change add?: They live in the "Smoke check after a gateway upgrade" section of
k8s/README.md, which lists five calls. The change adds onePOST /rerankcall with modelbge-reranker-v2-m3and 50 documents, and changes the count to six. [sources: k8s/README.md:186, k8s/README.md:188, k8s/README.md:210] - Which command proves the ADR record?:
uv run devops docs generatewrites the index row indocs/adr/README.md, anduv run devops ci test tests/invariants/test_adr_records.pychecks the record. The ADR is accepted and names issue 4970. [sources: docs/adr/README.md, tests/invariants/test_adr_records.py] - What does the issue body say about the
MANIFESTS_BY_STACKline for the new TEI manifest?: The issue body says that a newllmmanifest file also needs a line inMANIFESTS_BY_STACK. The TEI manifest file is indan-petty/homelab#283. This issue keeps the ADR and the smoke call. [sources: src/devops_cli/commands/k8s/stack_lifecycle.py, k8s/README.md:1]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 12, 2026
Both add a new inference model type to the LiteLLM gateway, but #481 serves embeddings while this serves rerank scores.devops-cli-service commentedon Nov 15, 2026
Alternatives check: in-use
Reason: Searches found no tool that covers the rerank need better than the one the issue already names: Hugging Face Text Embeddings Inference, an open (Apache-2.0), maintained server whose rerank endpoint serves cross-encoder scores such as BAAI/bge-reranker-v2-m3, at exactly the 1.9.4 release the issue pins. What remains is project glue (Kubernetes manifests, LiteLLM model_list entry, alert, smoke call, ADR), not a missing tool, so the issue is already built on the right existing tool.
The item already names this tool.
Tool: huggingface/text-embeddings-inference (https://github.com/huggingface/text-embeddings-inference)
Covers:
/rerank) for reranker models such as BAAI/bge-reranker-v2-m3, which the trial test(k8s): trial TEI quality and load on a cluster GPU #4968 already ran against TEIte_*metrics, so the PodMonitor and alert in the issue can read themLacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 16, 2026
Owner question: Who accepts and merges the ADR? (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 21, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 21, 2026
Answer (a documented fact, not a decision for a person):
docs/adr/README.md, section Approval, lines 36-40, gives the steps.status: proposedanddecision-makers: [owner]in a draft pull request.status: acceptedandbody-hash, and marks the pull request ready.The record goes in the pull request of this item, with the TEI manifests. This question does not hold the item from Ready. The item still waits on #4968 and its stop test.
devops-cli-service commentedon Nov 21, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.