Skip to content

feat(ai): track embedding and reranking serving for retrieval #4961

Open
1 of 8 issues completed
Open

Description

@dan-petty

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 pods ollama-24gib-embed-gpu0 and -gpu1 (Pascal P6000, cc 6.1), through the LiteLLM gateway.
  • Store: Qdrant 1.19.1 with the two collections devops_code and devops_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-416 and 509-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:

  1. 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.
  2. Use permissive licenses for the server and the models. Check each at the release tag or the model card. Avoid non-commercial model licenses.
  3. 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.
  4. 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 grep also 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-emb 0.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/rerank endpoint (--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 with gte-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 smaller Alibaba-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) replaces devops_code and devops_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.

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, the file_path filter 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-m3 below 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 visibility today. 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 grep finds no SearchReranker, no DEFAULT_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/ and src/devops_cli/config/defaults.py at the merged head.
  • THEN The grep returns no match for SearchReranker or DEFAULT_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 rrf with 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/rerank request with the model bge-reranker-v2-m3 and 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_rag points 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/rerank route 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.
  • 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-emb 0.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 smaller Alibaba-NLP/gte-reranker-modernbert-base goes 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.
  • 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_results defaults to k 60 and reciprocal_rank_fusion adds 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_rag behind an alias of the same name. Switch the alias, and keep the old collections for 7 days as the rollback. The re-index writes commit, doc_class (feat(ai): RAG points carry the commit and the document class #4921) and visibility on 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_code and devops_docs. It keeps the client merge and splits the pool that the study measured as one.
  • 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

Fit

Needs splitting into 9 items:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.

Sub-issues

Sub-issues

1 of 8 Issues completed
Loading 8 sub-issues

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/ai
    status/new
    value/high
    effort/high
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P1-High. The owner explicitly requested this work on 2026-11-11 and measured results show a 36 percent nDCG@10 gain over the current path.
    • Value: High. It directly improves retrieval quality for RAG search and the project brain, which are core user-facing features.
    • Effort: High. 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.
    • Related: feat(cli): qdrant vector engine async connection pooling, hybrid lexical-dense search & payload quantization research #313, which asks for a different change. 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.
  4. added
    priority/p1-high
    on Nov 12, 2026
  5. added
    priority/p2-medium
    and removed
    priority/p1-high
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    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)

    • License: Apache-2.0
    • Last activity: 2026-11-15
    • Maintained: yes

    Covers:

    • Serves a cross-encoder reranker over an HTTP rerank API (the plan's BAAI/bge-reranker-v2-m3).
    • Serves the embdding model as well (Qwen3-Embddding-0.6B), with the same vectors as the current Ollama route.
    • Runs in the cluster next to Qdrant, so private repository text stays inside the cluster.
    • Apache-2.0 and actively maintained, at release v1.9.4.

    Lacks:

    • No dense + sparse fusion or RRF of its own; the hybrid query stays with Qdrant's Query API and server-side BM25.
    • No LteLLM /v1/rerank route or gateway configuration; that is project glue on top of the standard API.
    • No support for the Pascal (cc 6.1) or Volta (cc 7.0) embdding GPUs, so the Ampre 3090 is shared with the chat tier.
    • No eval set or retrieval-quality measurement; the project must measure its own content.

    Tools considered:

    Searches run:

    • Text Embeddings Inference server embeddings and reranking OpenAI compatible endpoint, results: 5
    • huggingface text-embeddings-inference rerank API /rerank endpoint, results: 5
    • Qdrant Query API prefetch RRF fusion sparse BM25 server-side, results: 5
    • text embeddings inference TEI reranker, results: 5
    • text-embeddings-inference docs rerank endpoint bge-reranker, results: 5
    • Hugging Face Text Embeddings Inference supported models sequence classification reranker, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    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

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    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.

    • License: Apache-2.0 since 2024-04-08. Hugging Face maintains it: at least 38 commit authors since 2026-05-21, release v1.9.4.
    • Infinity stays rejected. v3 has a restricted license, and infinity-emb 0.0.80 cannot load Qwen3.
    • The project connects TEI only through the LiteLLM /v1/rerank route. If TEI cannot share the RTX 3090 with the chat tier, llama.cpp llama-server (MIT) on the Pascal GPUs replaces it behind the same route.
    • If the trial shows no rerank gain at p < 0.05, the stop rule removes the route, whatever the server.
    • The embeddings move to TEI only if perf(k8s): serve Qwen3 embeddings on TEI with Ollama fallback #4975 shows that the shared GPU keeps the chat tier safe.
    • The approval of the GPU trial is a separate question on test(k8s): trial TEI quality and load on a cluster GPU #4968.
  9. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    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:

    • Text Embeddings Inference TEI rerank endpoint cross-encoder server, results: 5
    • Qdrant Query API prefetch RRF server-side BM25 sparse vector fusion, results: 5
    • huggingface text-embeddings-inference /rerank API bge-reranker, results: 5
    • qdrant hybrid search query api prefetch rrf, results: 5
    • text-embeddings-inference github huggingface, results: 5
    • LiteLLM rerank API huggingface provider TEI, results: 5
    • qdrant documentation hybrid queries RRF, results: 5

    Sources:

  10. dan-petty commented on Nov 24, 2026

    @dan-petty
    OwnerAuthor

    Adopt the tool: text-embeddings-inference. AGENTS.md rule 3 requires using an open tool before building.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p2-mediumscope/aisource/agentstatus/newtype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions