Repository navigation
Description
Update 2026-11-26 (infra move): the LiteLLM gateway and k8s/llm are now in dan-petty/homelab.
Gateway config, TEI manifests, NetworkPolicy and alerts change in homelab. Retrieval code in src/devops_cli/ai/rag/ stays here. The route item #4970 is split: its manifests go to homelab.
Problem or Motivation
RAG search and the project brain read through one retrieval path. Today it has these parts:
- Embeddings: Ollama serves
qwen3-embedding:0.6b(DEFAULT_RAG_EMBEDDING_MODEL) on the two embed podsollama-24gib-embed-gpu0and-gpu1(Pascal P6000, cc 6.1), through the LiteLLM gateway. - Store: Qdrant 1.19.1 with the two collections
devops_codeanddevops_docs. Each point has one unnamed dense vector. - Ranking:
SearchReranker(src/devops_cli/ai/rag/reranker.py:149) sorts the hits by a weighted score: 0.5 vector, 0.2 token overlap and fixed bonuses (src/devops_cli/config/defaults.py:414-416and509-510). A client BM25 runs over the dense pool only. There is no cross-encoder.
The brain plan (#4624: ADR 0023, #4665, #4671, #4676) and the content freshness plan (#4880) read through this path.
The owner asked on 2026-11-11, word for word: "Investigate adding infinity or a text embeddings inference tool to enhance qdrant and project brain content retrieval". "Infinity" is the embedding and reranking server michaelfeil/infinity, not the Grafana Infinity data source (#4597). The owner set these rules:
- Decide with measured evidence on the project's own content: retrieval quality on an eval set built from the project, throughput and latency on the cluster GPUs, VRAM and operations cost. Compare at least Hugging Face Text Embeddings Inference (TEI) and Infinity with the current Ollama path. Consider a cross-encoder reranker, sparse or hybrid search in Qdrant, and one server for embeddings and reranking.
- Use permissive licenses for the server and the models. Check each at the release tag or the model card. Avoid non-commercial model licenses.
- Connect through standard interfaces: OpenAI-compatible endpoints through the LiteLLM gateway, and the Qdrant APIs. No custom glue. Use the newest versions that the tools support.
- Investigate first: recommend, file the work as issues and report. Do not build yet.
Later on 2026-11-11 the owner wrote: "I authorize use of my homelab cluster for live testing and verification". The cluster trial of 2026-11-11 ran in a temporary namespace under that authorization, and the namespace was deleted at the end.
The study found that the current ranking lowers quality. Dense search alone ranks better than the current path (nDCG@10 0.468 against 0.386, p 0.036).
Goal
One Qdrant Query API call fuses a dense vector and a server-side BM25 sparse vector with RRF. A cross-encoder (BAAI/bge-reranker-v2-m3) on TEI 1.9.4 orders the fused top 50 through a new LiteLLM /v1/rerank route. When the rerank call fails, the query returns the fused order. The weighted SearchReranker and the client BM25 and RRF code go away. Embeddings stay on the two Ollama pods with the same model. They move to TEI only after a GPU trial shows that the shared Ampere GPU keeps the chat tier safe.
Measured results
Eval set: 62 queries built from the project (24 issue_fix, 18 census_question, 20 exact_identifier; 119 relevant files), 16,737 chunks at commit 9208717, file-level scores. Dense vectors come from qwen3-embedding:0.6b through the gateway. The cross-encoder is bge-reranker-v2-m3 in float32 with max_length 512.
| Arm | What | recall@5 | recall@10 | MRR@10 | nDCG@10 | nDCG@10 issue_fix / census / identifier |
|---|---|---|---|---|---|---|
| D0 | dense top 100 | 0.516 | 0.591 | 0.557 | 0.468 | 0.593 / 0.259 / 0.507 |
| B0 | dense + weighted SearchReranker (current) | 0.415 | 0.565 | 0.423 | 0.386 | 0.438 / 0.202 / 0.489 |
| B0prod | production shape: 15 per collection, cosine >= 0.35, weighted | 0.457 | 0.575 | 0.435 | 0.393 | 0.481 / 0.209 / 0.452 |
| BM25 | BM25 over all chunks (CPU) | 0.554 | 0.653 | 0.624 | 0.526 | 0.546 / 0.324 / 0.683 |
| B1 | B0 top 50 + cross-encoder | 0.583 | 0.632 | 0.601 | 0.514 | 0.615 / 0.337 / 0.551 |
| B1d | D0 top 50 + cross-encoder | 0.562 | 0.632 | 0.612 | 0.525 | 0.661 / 0.324 / 0.544 |
| B2f | RRF of dense and BM25 | 0.575 | 0.656 | 0.595 | 0.514 | 0.595 / 0.229 / 0.673 |
| B2w | B2f + weighted SearchReranker | 0.476 | 0.636 | 0.469 | 0.430 | 0.484 / 0.204 / 0.570 |
| B2 | B2f top 50 + cross-encoder (this plan) | 0.609 | 0.714 | 0.652 | 0.567 | 0.611 / 0.453 / 0.617 |
Paired contrasts of nDCG@10 (B minus A; 95% bootstrap interval, 10,000 samples, seed 13; p from a paired sign-flip test, 20,000 samples). "Natural language" is the 42 issue_fix and census queries.
| Contrast | What it measures | All 62 | Natural language | issue_fix | census | identifier |
|---|---|---|---|---|---|---|
| B2 - B0 | the whole plan | +0.181 [+0.097, +0.264], p < 0.001 | +0.207, p 0.001 | +0.173, p 0.053 | +0.252, p 0.001 | +0.128, p 0.038 |
| D0 - B0 | delete the weighted reranker (no GPU) | +0.082 [+0.005, +0.159], p 0.043 | +0.113, p 0.024 | +0.155, p 0.068 | +0.057, p 0.11 | +0.018, p 0.79 |
| B2f - D0 | Qdrant hybrid (no GPU) | +0.046 [+0.004, +0.088], p 0.040 | -0.012 [-0.051, +0.026], p 0.57 | +0.002, p 0.96 | -0.029, p 0.20 | +0.166, p 0.001 |
| B2 - B2f | the cross-encoder on the hybrid pool | +0.053 [-0.007, +0.119], p 0.10 | +0.105 [+0.027, +0.192], p 0.017 | +0.016, p 0.73 | +0.224, p 0.002 | -0.056, p 0.071 |
| B2 - BM25 | the plan against BM25 alone on CPU | +0.042 [-0.020, +0.102], p 0.19 | +0.093, p 0.025 | +0.065, p 0.30 | +0.130, p 0.010 | -0.066, p 0.13 |
| B2 - B1d | hybrid pool against dense pool, both reranked | +0.042 [-0.002, +0.095], p 0.10 | +0.027, p 0.47 | -0.050, p 0.004 | +0.130, p 0.050 | +0.073, p 0.017 |
What these numbers say:
- The gain of +0.181 belongs to the whole plan. Most of it comes from two parts that need no GPU: the deletion of the weighted reranker (+0.082) and BM25 (+0.046, on identifiers only).
- On the 42 natural-language queries, the hybrid step gives no gain (-0.012, p 0.57). Its only measured gain is on exact identifiers. The relevance of an identifier query is an exact string match, so this gain is lexical by construction, and
git grepalso serves it. - The cross-encoder is the only GPU part. Over all queries, its gain over the hybrid pool is not larger than the noise (+0.053, p 0.10). On the natural-language queries it is (+0.105, p 0.017), and on census questions it is large (+0.224, p 0.002). On exact identifiers it ranks lower than fusion alone (-0.056, p 0.071).
- On issue_fix, the whole plan gains with p about 0.05 (bootstrap p 0.037, sign-flip p 0.053).
- A re-check with chunk-level scores gives the same direction: B2 - B0 +0.203 (p 0.0001), D0 - B0 +0.109 (p 0.020). The file-level merge does not cause the gain.
- The eval set has limits. One third of the queries are identifiers. The corpus holds 69% docs chunks, against about 51% in production. Before a change of reranker or embedder, add natural-language questions about code behaviour.
Serving, cluster trial of 2026-11-11: one RTX 3090 (cc 8.6), client pod on the same node, 2,000 docs chunks, one run for each point.
| Server and model | Single query p50 / p95 | Bulk embed | Rerank of 50 p50 / p95 | VRAM idle / peak MiB | Warm restart |
|---|---|---|---|---|---|
| TEI 1.9.4, Qwen3-Embedding-0.6B fp16 | 4.0 / 4.5 ms | 114 to 153 texts/s, up to 40,971 tokens/s | - | 1,522 / 2,258 | 3 s |
| TEI 1.9.4, bge-m3 fp16 | 3.0 / 3.4 ms | 140 to 208 texts/s | - | 1,458 / 1,874 | 3 s |
| TEI 1.9.4, bge-reranker-v2-m3 fp16 | - | - | 220 / 245 ms; 239.5 pairs/s at 4 in flight | 1,426 / 1,874 | 2 s |
| Infinity 0.0.80, Qwen3-Embedding-0.6B | failed at start: its transformers pin (below 4.48) has no qwen3 | - | - | - | - |
| Infinity 0.0.80, bge-m3 | 17.0 / 33.8 ms | 106 to 208 texts/s | - | 1,986 / 6,296 | 13 s |
| Infinity 0.0.80, bge-reranker-v2-m3 | - | - | 226 / 256 ms; 233 pairs/s | 2,370 / 2,378 | 13 s |
| Infinity 0.0.80, bge-m3 + reranker in one process | 14.0 / 15.4 ms | 152 to 210 texts/s | 221 / 252 ms | 3,460 / 6,594 | 14 s |
| Ollama 0.40.16, qwen3-embedding:0.6b Q8_0, 2 x P6000 (production, through the gateway; not like-for-like) | 139 / 213 ms | 45 texts/s, 6,626 tokens/s on both pods | no rerank endpoint | max 1.41 GiB per GPU (DCGM, 7 d) | - |
Other measurements:
- The same model on another runtime gives the same vectors: TEI against the Ollama route, cosine min 0.9984 (20 queries). A different model pair gives 0.37 to 0.48.
- Production embedding load (7 days): 31,696 gateway requests; each batch request has p50 8.4 s and p95 28.6 s; 745 took over 30 s; 529 calls ended with status 499 in 30 days. Each Ollama pod is busy about 42% of the day.
- Interactive RAG query (30 days, n 11): total p50 164 ms, p95 737 ms.
- The cross-encoder on a workstation CPU took 1,730 to 1,890 CPU-seconds for one rerank of 50. One rerank of 50 candidates of about 190 tokens is about 5.8 TFLOP (303M non-embedding parameters x 2 x 9,500 tokens). A CPU cannot do this in the 0.5 s budget.
- BM25 (bm25s): index 18.2 s for 16,737 chunks, query p50 17 ms. RRF p50 0.4 ms. The weighted SearchReranker p50 145 ms for 100 candidates.
- VRAM headroom: the trial RTX 3090 had 5,270 MiB of 7-day headroom beside the 48 GiB chat tier.
Decisions
- Server: TEI 1.9.4 (Apache-2.0). It serves the reranker now and can serve Qwen3-Embedding-0.6B later. It has the lowest single-query latency and VRAM of the candidates, a warm restart of 2 to 3 s, and correct token counts through LiteLLM. Hugging Face maintains it (32 commit authors in 6 months).
- Not Infinity. Infinity v3 has the "Infinity Restricted MIT License 1.0": it is source-available, names 38 providers (Cloudflare included) whose capacity it may not use, and ends the permission on a breach. This fails the license rule. The MIT v2 (
infinity-emb0.0.80) cannot load Qwen3, and its LiteLLM usage counts characters as tokens (3 to 4 times too high). It has one maintainer. - Not Ollama for rerank. Ollama has no rerank endpoint (ollama#3368, open since 2024-03).
- llama.cpp
llama-server(MIT) is an alternative, not chosen. It has a/v1/rerankendpoint (--reranking), and its CUDA build supports cc 6.1. It is the only candidate that can rerank on the Pascal embed GPUs, so it puts no new tenant on the GPU of the chat tier. The study did not measure it. A FLOP estimate gives about 1 s for each rerank of 50 on a P6000 (5.8 TFLOP against 12.6 TFLOPS fp32 peak, no fast fp16 on GP102). That is over the 0.5 s budget. The GPU trial measures it with fewer candidates and withgte-reranker-modernbert-base. - Reranker:
BAAI/bge-reranker-v2-m3(Apache-2.0, rev 953dc6f6). It is the only cross-encoder with a project score. The smallerAlibaba-NLP/gte-reranker-modernbert-base(Apache-2.0) goes to the trial. - Embedder: keep Qwen3-Embedding-0.6B (Apache-2.0, rev 97b0c614) on Ollama. No candidate embedder has a project score. TEI gives the same vectors, so a move changes speed, not quality.
- Hybrid in Qdrant, no learned sparse model. Qdrant computes BM25 on the server (in core for self-hosted servers since 1.15.3) with the IDF modifier, and sets the RRF k since 1.16. The bge-m3 sparse output has no server among the candidates, and the SPLADE example model of TEI is CC-BY-NC-SA-4.0.
- RRF k: set it explicitly. The study used 1/(60 + rank) with rank from 1. Qdrant counts positions from 0, and its default k is 2. Set k 61 to give the study's fusion, and check the formula in the Qdrant source of the live version.
- One collection behind an alias (
devops_rag) replacesdevops_codeanddevops_docs. This matches the measured single pool, removes the client merge and gives a rollback. - Delete the weighted reranker first. It lowers quality in every measured pool, and it needs no cluster change.
- Stop rule for the GPU part. The trial must show that the cross-encoder beats the fused order on the natural-language queries with TEI float16 scores (p < 0.05). If not, the rerank route and the retriever rerank stop and return to New with the evidence.
Owner step: approve the GPU trial
The trial of 2026-11-11 measured TEI and Infinity alone on one RTX 3090. A second trial must measure the candidate embedders and rerankers, the latency and VRAM while the 48 GiB chat tier generates on the same GPU, one call of each kind through the live gateway, mixed bulk and single-query load, the score agreement of float16 and float32, and llama.cpp on a P6000.
In a later run, the auto mode check refused to make temporary cluster resources. Thus the trial waits for the owner's explicit approval on #4968 (child 4) before any namespace, pod or Qdrant collection is made. The guards stay: the restricted Pod Security level, a VRAM watchdog, images by digest, models by revision, and deletion of the namespace at the end.
Ordered child list
Each line gives the issue, its title, its child number and the issues to merge first. "Start now" marks a child with no unmet dependency.
- test(ai): a gold set measures retrieval of knowledge base facts #3902 test(ai): a gold set measures retrieval of knowledge base facts (child 1; new scope: the project eval set, in a scope comment). Depends on: refactor(ai): rank the benchmark with numpy and pytrec-eval #1928.
- fix(ai): rank RAG hits by fusion, not by the weighted score #4965 fix(ai): rank RAG hits by fusion, not by the weighted score (child 2). Depends on: test(ai): a gold set measures retrieval of knowledge base facts #3902.
- fix(ai): RAG chunks cover module code and use a token size #4967 fix(ai): RAG chunks cover module code and use a token size (child 3, start now). Depends on: none.
- test(k8s): trial TEI quality and load on a cluster GPU #4968 test(k8s): trial TEI quality and load on a cluster GPU (child 4). Depends on: test(ai): a gold set measures retrieval of knowledge base facts #3902; owner step: approval on test(k8s): trial TEI quality and load on a cluster GPU #4968.
- feat(k8s): serve a cross-encoder rerank route on TEI #4970 feat(k8s): serve a cross-encoder rerank route on TEI (child 5). Depends on: test(k8s): trial TEI quality and load on a cluster GPU #4968 and its stop test.
- feat(ai): search RAG with Qdrant dense and BM25 fusion #4971 feat(ai): search RAG with Qdrant dense and BM25 fusion (child 6). Depends on: test(ai): a gold set measures retrieval of knowledge base facts #3902, fix(ai): rank RAG hits by fusion, not by the weighted score #4965, fix(ai): RAG chunks cover module code and use a token size #4967.
- feat(ai): rerank RAG hits with the gateway cross-encoder #4972 feat(ai): rerank RAG hits with the gateway cross-encoder (child 7). Depends on: feat(k8s): serve a cross-encoder rerank route on TEI #4970, feat(ai): search RAG with Qdrant dense and BM25 fusion #4971.
- feat(ai): give every agent brain tools through MCP, CLI and skill #4671 feat(ai): give every agent brain tools through MCP, CLI and skill (child 8; new scope: brain search ranks its sources with the reranker, in a scope comment; it stays child 18 of feat(roadmap): track the project brain #4624). Depends on: feat(ai): rerank RAG hits with the gateway cross-encoder #4972.
- perf(k8s): serve Qwen3 embeddings on TEI with Ollama fallback #4975 perf(k8s): serve Qwen3 embeddings on TEI with Ollama fallback (child 9). Depends on: test(k8s): trial TEI quality and load on a cluster GPU #4968, feat(k8s): serve a cross-encoder rerank route on TEI #4970.
Related open items
#4624 (the brain tracker) is the parent of this tracker. #4671 (brain tools) is child 18 of #4624 and takes the scope of child 8. #3902 (gold set) takes the scope of child 1. #1928 brings pytrec_eval. #4921 adds the payload fields commit and doc_class that the re-index of child 6 carries. #4566 runs the cluster ingest that the re-index needs. #4885 (gateway smoke calls) takes one rerank call from child 5. #4406 (LiteLLM upgrade) can change the rerank provider mapping. #4665, #4676 and #4808 keep their plan: the embedding model and the vectors do not change. #4569 owns the Valkey embedding key fix.
Measure of the whole
| Measure | Today | Target |
|---|---|---|
| nDCG@10 on the project eval set | 0.386 | 0.54 or more |
| recall@10 | 0.565 | 0.68 or more |
| MRR@10 | 0.423 | 0.60 or more |
| census nDCG@10 (proxy for brain questions) | 0.202 | 0.45 or more |
| exact_identifier nDCG@10 | 0.489 | 0.60 or more |
| natural-language nDCG@10, reranked minus fused | no rerank | larger than 0, p < 0.05 |
| rerank of 50, p95 | no rerank | 500 ms or less |
| interactive RAG query, p95 | 737 ms | 1.5 s or less |
| gateway embedding batch, p95 (after child 9 only) | 28.6 s | 5 s or less |
| OOM restarts of the chat tier caused by a new tenant | 0 | 0 |
Risks
- GPU sharing: TEI does not run on the Pascal embed GPUs (cc 6.1) or the Volta GPUs (cc 7.0). It shares an RTX 3090 with the 48 GiB chat tier, with no device plugin accounting. The 7-day headroom is 5,270 MiB. TEI rerank peaks at 1,874 MiB and TEI Qwen3 at 2,258 MiB; both together leave about 1.1 GiB. Mitigation: bound
--max-batch-tokens, alert on GPU memory, run the trial under chat load first, and move embeddings only after that. - Exact identifiers: the cross-encoder ranks exact identifiers lower than fusion alone. Agents keep
git grep, thefile_pathfilter and the ADR index for exact lookups. Each eval reports the score for each query kind. - Small eval set: 62 queries, 18 to 24 for each kind, on a docs-heavy corpus. Published tables show
bge-reranker-v2-m3below Qwen3-Embedding-0.6B alone on MTEB-Code (41.38 against 75.41). - Settings drift: the measured cross-encoder used float32 and max_length 512. TEI serves float16 and can take a longer input. The trial and child 7 measure the score through the live route.
- LiteLLM rerank: the
huggingface/provider mapping comes from the LiteLLM v1.103.10 source and a direct TEI call, not from a gateway call. The gateway smoke calls must include one rerank call. - Qdrant server-side BM25: qdrant-client must send the document text to the server. If the client runs local inference, it loads fastembed in the client process. The first test checks this. The Qdrant tokenizer and stemmer can differ from bm25s, so the eval decides.
- Re-index: the index is 5 days stale, and the cluster ingest has never run (feat(k8s): let Argo Workflows run roadmap pods in devops #4566). The new collection needs a working ingest path. The alias switch and 7 days of the old collections give a rollback.
- Model download: a cold start takes 77 to 112 s from Hugging Face. Pin the revision, keep a PVC cache and set Hugging Face telemetry off.
- Pascal end of life: PyTorch CUDA 12.6 wheels, the last with sm_61 and sm_70, stop at PyTorch 2.15. TEI and Infinity v3 already exclude these GPUs. Ollama and llama.cpp still run on them. Child 9 decides their future.
- Private text: TEI runs in the cluster, so private repository text stays in the cluster. No Qdrant point carries
visibilitytoday. Child 6 writes it on every point before brain search reads Qdrant for a public answer.
Target Subsystem
AI and RAG (src/devops_cli/ai/rag/: retriever, reranker, chunker, Qdrant store), the LiteLLM gateway and Kubernetes manifests in k8s/llm of dan-petty/homelab, monitoring there, and the brain search of #4671.
Existing Tool Considered
Hugging Face Text Embeddings Inference 1.9.4 (Apache-2.0), Qdrant 1.19.1 (named sparse vectors, server-side BM25, the Query API with prefetch and RRF), LiteLLM v1.103.10 (huggingface/ rerank and openai/ embedding providers), pytrec_eval (#1928), scipy.stats.bootstrap, Argo CD, DCGM and Prometheus. No new dependency in the CLI.
Rejected with reasons in the decisions: Infinity v3 (license), infinity-emb 0.0.80 (no Qwen3, character token counts, one maintainer), Ollama for rerank (no endpoint), llama.cpp llama-server (estimated latency on Pascal over the budget; the trial measures it), a learned sparse model (no server for bge-m3 sparse; the SPLADE models are non-commercial), the jina models (CC-BY-NC-4.0), google/embeddinggemma-300m (gated, Gemma terms), and a cross-encoder on CPU.
Written cost of the children (estimates): child 1 about 0.30M tokens and 5 hours; child 2 about 0.12M tokens and 2 hours; child 3 about 0.20M tokens and 3 hours; child 4 about 0.25M tokens and 4 hours, with about 1 hour of GPU time; child 5 about 0.25M tokens and 4 hours; child 6 about 0.40M tokens and 6 hours, plus a re-index of about 26 minutes; child 7 about 0.20M tokens and 3 hours; child 8 about 0.10M tokens and 2 hours; child 9 about 0.20M tokens and 3 hours. Sum: about 2.0M tokens and 32 hours of agent time, plus reviews and live checks. To keep: about 30,000 tokens a month for eval runs, and about 50,000 tokens for each fix. Run cost: about 2 GiB of VRAM on one RTX 3090 for the reranker.
Acceptance Criteria
- Each child is merged, or closed with evidence.
- The measures of the whole meet their targets over 7 days after child 7 merges.
git grepfinds noSearchReranker, noDEFAULT_RERANKER_constant and no client BM25 or RRF in the retriever path.
Dependencies
None for the tracker. The children carry their own.
Source: #4624
Alternatives check of 2026-11-21: partly.
Tool: huggingface/text-embeddings-inference (https://github.com/huggingface/text-embeddings-inference), Apache-2.0, last activity 2026-11-17, maintained.
Reason: Searches returned little and the repository page confirms TEI serves both a cross-encoder rerank API and Qwen3 embeddings, so it covers the serving part only; the Qdrant fusion, gateway route, eval set and GPU trial remain project work.
Covers:
- Serves cross-encoder rerankers over an HTTP rerank API
- Serves Qwen3-Embedding-0.6B with vectors matching the Ollama route
- Lowest single-query latency and VRAM of the trial candidates
Lacks:
- No dense plus sparse fusion or RRF; that stays in the Qdrant Query API
- No LiteLLM /v1/rerank route; the project configures the gateway
- No Pascal cc 6.1 or Volta cc 7.0 support, so it shares the RTX 3090
- No project eval set, alias migration or GPU trial
Proposed design
Problem statement
The retrieval path of RAG search and the project brain ranks worse than dense search alone. The weighted SearchReranker gives nDCG@10 0.386 against 0.468 for dense search on the project eval set. This tracker holds the study that measured the options and the nine child issues that deliver the new path: Qdrant dense plus server-side BM25 fused by RRF, and a TEI cross-encoder rerank through the LiteLLM gateway. Embeddings stay on the two Ollama pods until a GPU trial shows that the shared RTX 3090 keeps the chat tier safe.
Acceptance criteria
Requirement: Weighted reranker removed
The RAG retrieval path SHALL contain no SearchReranker class and no DEFAULT_RERANKER_ setting after child 2 and child 7 merge.
Scenario: Grep of the retrieval path
- WHEN A test greps
src/devops_cli/ai/rag/andsrc/devops_cli/config/defaults.pyat the merged head. - THEN The grep returns no match for
SearchRerankerorDEFAULT_RERANKER_.
Requirement: One fused Qdrant query
The retriever SHALL send one Qdrant Query API request that prefetches a dense query and a server-side BM25 sparse query and fuses them with RRF.
Scenario: Request shape on the fake Qdrant client
- WHEN A test runs a retrieval against the fake Qdrant client.
- THEN The client receives one query request with a dense prefetch, a sparse prefetch with the IDF modifier, and the fusion
rrfwith k 61.
Requirement: Rerank through the gateway
The retriever SHALL send the fused top 50 to the LiteLLM /v1/rerank route and SHALL order the hits by the returned scores.
Scenario: Rerank request on the fake gateway
- WHEN A test runs a retrieval against a fake gateway that answers the rerank call.
- THEN The gateway receives one
/v1/rerankrequest with the modelbge-reranker-v2-m3and 50 documents, and the hits return in the answered order.
Requirement: Fused order on rerank failure
The retriever MUST return the fused order when the rerank call fails.
Scenario: Rerank call error
- WHEN The fake gateway answers the rerank call with a 500 error.
- THEN The retrieval returns the fused order, raises no exception and records the failure.
Requirement: One collection behind an alias
The indexer SHALL write every point to one collection that the alias devops_rag names, in place of devops_code and devops_docs.
Scenario: Index and alias on the fake Qdrant client
- WHEN A test indexes a small corpus against the fake Qdrant client.
- THEN The points go to one collection and the alias
devops_ragpoints to that collection.
Requirement: Eval targets enforced
The eval command SHALL fail when nDCG@10 is below 0.54, recall@10 below 0.68 or MRR@10 below 0.60 on the project eval set.
Scenario: Eval run on the project set
- WHEN A test runs the eval command on the project eval set with recorded embedding and rerank answers.
- THEN The command reports each measure for each query kind and exits non-zero for a measure under its target.
Existing Tool Considered
huggingface/text-embeddings-inference (TEI) 1.9.4, Apache-2.0, maintained (last activity 2026-11-15; page fetched 2026-11-16 shows Qwen3 embedding support and XLM-RoBERTa sequence-classification rerankers). The alternatives check of 2026-11-15 returns covers for this tool, and the item adopts it. It serves the cross-encoder BAAI/bge-reranker-v2-m3 over its HTTP rerank API. It also serves Qwen3-Embedding-0.6B with the same vectors as the Ollama route, inside the cluster, so private text stays in the cluster. It lacks dense and sparse fusion and RRF; the Qdrant Query API and its server-side BM25 give these. It lacks a LiteLLM /v1/rerank route; the project configures the gateway. It lacks support for the Pascal cc 6.1 and Volta cc 7.0 GPUs, so it shares the RTX 3090 with the chat tier. It lacks an eval set; the project measures its own content. The CLI takes no new dependency. The remaining glue has a written cost of about 2.0M tokens and 32 hours of agent time across the nine children. To keep: about 30,000 tokens a month for eval runs, and about 50,000 tokens for each fix.
Key questions
- The alternatives check found that Hugging Face Text Embeddings Inference covers this item. Adopt the tool, or keep the item and give the reason?: Adopt TEI as the serving tool and keep the item. TEI covers the serving need of the plan: it serves cross-encoder rerankers and Qwen3 embeddings, and the repository holds no serving code for either. The rest of the plan, the Qdrant dense and BM25 fusion with RRF, the LiteLLM
/v1/rerankroute and the project eval set, is configuration of tools that the plan already names, so work remains and the item does not close. Checked on 2026-11-16. (best practice) [sources: https://github.com/huggingface/text-embeddings-inference]- Chosen: Adopt TEI as the existing tool. The alternatives check returns
covers, and the page fetched on 2026-11-16 shows both needs: embedding models (Qwen3) and XLM-RoBERTa sequence-classification rerankers over one HTTP server. - Rejected: Keep the item with no serving tool. Ollama has no rerank endpoint and a cross-encoder on CPU takes 1,730 to 1,890 CPU-seconds for one rerank of 50, so the rerank part would have no server.
- Rejected: Build a serving server in the project. It rebuilds batching, token counting and an HTTP rerank API that TEI gives under Apache-2.0, at the written cost of about 2.0M tokens and 32 hours that the children already spend on glue.
- Chosen: Adopt TEI as the existing tool. The alternatives check returns
- Which server serves the cross-encoder and, later, the embeddings?: Hugging Face Text Embeddings Inference (TEI) 1.9.4, Apache-2.0. It serves the reranker now and can serve Qwen3-Embedding-0.6B later, and it is the lowest-latency and lowest-VRAM candidate of the trial. The project configures one LiteLLM route to it. Checked on 2026-11-16: the project page lists Qwen3 embedding models and XLM-RoBERTa rerankers among the supported models. (best practice) [sources: https://github.com/huggingface/text-embeddings-inference]
- Chosen: TEI 1.9.4. Apache-2.0 and maintained. It has the lowest single-query latency and VRAM of the trial, a warm restart of 2 to 3 s and correct token counts through LiteLLM.
- Rejected: Infinity v3 or
infinity-emb0.0.80. v3 has the restricted MIT license and fails the license rule. 0.0.80 cannot load Qwen3 and counts characters as tokens. - Rejected: Ollama for rerank. It has no rerank endpoint (ollama#3368, open since 2024-03).
- Rejected: llama.cpp
llama-server. It is MIT and runs on the Pascal GPUs. The estimate of about 1 s for a rerank of 50 is over the 0.5 s budget, and the trial measures it.
- Which cross-encoder does the rerank route serve?:
BAAI/bge-reranker-v2-m3, Apache-2.0, revision 953dc6f6. It is the only cross-encoder with a project score. Its model card documents the query and passage input and the 512-token truncation that the study used. The smallerAlibaba-NLP/gte-reranker-modernbert-basegoes to the trial. Checked on 2026-11-16. (best practice) [sources: https://huggingface.co/BAAI/bge-reranker-v2-m3, https://huggingface.co/BAAI/bge-reranker-v2-m3/discussions/59]- Chosen:
BAAI/bge-reranker-v2-m3. It is the only cross-encoder with a score on the project eval set, and its license is Apache-2.0. - Rejected:
Alibaba-NLP/gte-reranker-modernbert-base. It is smaller and Apache-2.0, but it has no project score. The GPU trial measures it. - Rejected: A cross-encoder on CPU. One rerank of 50 took 1,730 to 1,890 CPU-seconds, over the 0.5 s budget.
- Chosen:
- What RRF k does the fused Qdrant query use?: Set k 61 explicitly, and do not rely on the server default. The study's fusion is 1/(60 + rank) with rank from 1, which is the formula of the current client RRF:
hybrid_search_resultsdefaults to k 60 andreciprocal_rank_fusionadds 1 to the 0-based position (1.0 / (k + rank + 1)). Qdrant counts positions from 0, so k 61 gives the same weight for the same position. Child 6 checks the formula and the default of the live Qdrant version in its source before it sets the value. (best practice) [sources: src/devops_cli/ai/rag/retriever.py:208, src/devops_cli/ai/rag/retriever.py:228, src/devops_cli/ai/rag/retriever.py:233]- Chosen: k 61. It reproduces the measured B2 fusion: the study and the client RRF use 1/(60 + rank) from 1, and Qdrant's positions start at 0.
- Rejected: The Qdrant default k. The default is not the k the study measured, so the measured gain does not carry; the query sets the value instead of inheriting it.
- Rejected: A weighted sum of the two prefetches. The study measured RRF only. A weighted sum needs its own tuning.
- How does the store move from two collections to one?: Write one collection
devops_ragbehind an alias of the same name. Switch the alias, and keep the old collections for 7 days as the rollback. The re-index writescommit,doc_class(feat(ai): RAG points carry the commit and the document class #4921) andvisibilityon every point. (best practice) [sources: src/devops_cli/config/defaults.py:233, src/devops_cli/ai/rag/qdrant.py]- Chosen: One collection behind the alias
devops_rag. It matches the single pool that the study measured. It removes the client merge and gives a rollback. - Rejected: Keep
devops_codeanddevops_docs. It keeps the client merge and splits the pool that the study measured as one.
- Chosen: One collection behind the alias
- Do the embeddings move to TEI with the reranker?: No. Embeddings stay on the two Ollama pods with
qwen3-embedding:0.6b, revision 97b0c614. They move only after a GPU trial shows that the shared RTX 3090 keeps the chat tier safe. TEI gives the same vectors (cosine minimum 0.9984), so a move changes speed, not quality. (best practice) [sources: src/devops_cli/config/defaults.py:237, src/devops_cli/ai/rag/embeddings.py]- Chosen: Keep Qwen3-Embedding-0.6B on Ollama. No candidate embedder has a project score. TEI gives the same vectors, and the move waits for the GPU trial.
- Rejected: Move the embeddings to TEI now. It adds about 2,258 MiB to the GPU of the chat tier before the trial measures the headroom.
- What must the trial show before the rerank route stays?: The trial must show that the cross-encoder beats the fused order on the 42 natural-language queries, with TEI float16 scores, at p < 0.05. If it does not, child 5 and child 7 stop and return to New with the evidence. The gate sits on the natural-language stratum because over all 62 queries the cross-encoder gain is inside the noise (+0.053, p 0.10), while the natural-language gain is +0.105 at p 0.017; the eval harness of refactor(ai): rank the benchmark with numpy and pytrec-eval #1928 already scores recall, MRR and nDCG with pytrec_eval, so the trial reuses it. (best practice) [sources: openspec/changes/1928-rank-the-benchmark-with-numpy-and/specs/ai-benchmark-ranking/spec.md]
- Chosen: Keep the route only on a measured gain at p < 0.05. Over all queries the cross-encoder gain is not larger than the noise (+0.053, p 0.10). The natural-language gain is (+0.105, p 0.017), and the route costs about 2 GiB of VRAM on the GPU of the chat tier.
- Rejected: Keep the route on the whole-plan gain alone. Most of the +0.181 belongs to the two parts with no GPU. It does not show that the rerank earns its VRAM.
- Rejected: Decide after the trial from the numbers. A threshold set after the measurement lets the result pick the rule. The trial needs its gate before it runs.
Open questions
- The alternatives check found that https://github.com/huggingface/text-embeddings-inference covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
Fit
Needs splitting into 9 items:
- test(ai): a gold set measures retrieval of knowledge base facts #3902 test(ai): a gold set measures retrieval of knowledge base facts - needs refactor(ai): rank the benchmark with numpy and pytrec-eval #1928 first.
- fix(ai): rank RAG hits by fusion, not by the weighted score #4965 fix(ai): rank RAG hits by fusion, not by the weighted score - after test(ai): a gold set measures retrieval of knowledge base facts #3902.
- fix(ai): RAG chunks cover module code and use a token size #4967 fix(ai): RAG chunks cover module code and use a token size - start now.
- test(k8s): trial TEI quality and load on a cluster GPU #4968 test(k8s): trial TEI quality and load on a cluster GPU - after test(ai): a gold set measures retrieval of knowledge base facts #3902, with the owner approval.
- feat(k8s): serve a cross-encoder rerank route on TEI #4970 feat(k8s): serve a cross-encoder rerank route on TEI - after test(k8s): trial TEI quality and load on a cluster GPU #4968 and its stop test.
- feat(ai): search RAG with Qdrant dense and BM25 fusion #4971 feat(ai): search RAG with Qdrant dense and BM25 fusion - after test(ai): a gold set measures retrieval of knowledge base facts #3902, fix(ai): rank RAG hits by fusion, not by the weighted score #4965 and fix(ai): RAG chunks cover module code and use a token size #4967.
- feat(ai): rerank RAG hits with the gateway cross-encoder #4972 feat(ai): rerank RAG hits with the gateway cross-encoder - after feat(k8s): serve a cross-encoder rerank route on TEI #4970 and feat(ai): search RAG with Qdrant dense and BM25 fusion #4971.
- feat(ai): give every agent brain tools through MCP, CLI and skill #4671 feat(ai): give every agent brain tools through MCP, CLI and skill - after feat(ai): rerank RAG hits with the gateway cross-encoder #4972.
- perf(k8s): serve Qwen3 embeddings on TEI with Ollama fallback #4975 perf(k8s): serve Qwen3 embeddings on TEI with Ollama fallback - after test(k8s): trial TEI quality and load on a cluster GPU #4968 and feat(k8s): serve a cross-encoder rerank route on TEI #4970.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(ai)scope of the title gives the scope.The owner explicitly requested this work on 2026-11-11 and measured results show a 36 percent nDCG@10 gain over the current path.It directly improves retrieval quality for RAG search and the project brain, which are core user-facing features.It requires deploying TEI, adding a new LiteLLM route, rewriting the Qdrant query to use the Query API with RRF, integrating a cross-encoder, and removing the old weighted reranker and client BM25 code.Both use hybrid dense plus sparse BM25 search in Qdrant, but the candidate adds a cross-encoder reranker via TEI and a new LiteLLM /v1/rerank route that #313 did not deliver.devops-cli-service commentedon Nov 15, 2026
Alternatives check: covers
Reason: Searches found that Huging Face Text Embddings Inference (TEI) is an open, actively maintained Apache-2.0 inference server that serves both embdding models and cross-encoder rerankers over standard HTTP APIs, which is exactly the serving piece the issue needs; the issue itself names TEI 1.9.4 as the chosen server and rejects Infinity (license) and Ollama (no rerank endpoint). The remaining parts of the plan (Qdrant-side dense + BM25 fusion with RRF, the LteLLM rerank route, the eval set) are configuration of other tools that the issue already names, not another tool.
Tool: huggingface/text-embeddings-inference (https://github.com/huggingface/text-embeddings-inference)
Covers:
BAAI/bge-reranker-v2-m3).Qwen3-Embddding-0.6B), with the same vectors as the current Ollama route.Lacks:
/v1/rerankroute or gateway configuration; that is project glue on top of the standard API.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: The alternatives check found that https://github.com/huggingface/text-embeddings-inference covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 21, 2026
Answer to the open question: adopt Text Embeddings Inference (TEI) as the server of the cross-encoder. Keep this tracker open. It is the adoption plan, and its nine children deliver it.
infinity-emb0.0.80 cannot load Qwen3./v1/rerankroute. If TEI cannot share the RTX 3090 with the chat tier, llama.cppllama-server(MIT) on the Pascal GPUs replaces it behind the same route.devops-cli-service commentedon Nov 21, 2026
The result in the alternatives block of the issue body changed. Before this check:
covers, tool https://github.com/huggingface/text-embeddings-inference. A person decides what the new result means for the item.Searches (7)
Tools considered:
Searches run:
Sources:
dan-petty commentedon Nov 24, 2026
Adopt the tool: text-embeddings-inference. AGENTS.md rule 3 requires using an open tool before building.