72 lines
2.5 KiB
YAML
72 lines
2.5 KiB
YAML
# Reranker — BAAI/bge-reranker-base, on CPU via HuggingFace TEI.
|
|||
|
|
#
|
||
|
|
# Second stage of retrieval: the embedding model fetches a coarse top-k by
|
||
|
|
# vector similarity, this cross-encoder re-scores those candidates against the
|
||
|
|
# query directly. That is what fixes the "semantic dilution" problem in Plan 1 —
|
||
|
|
# a single embedding vector cannot represent a large chunk faithfully, so
|
||
|
|
# ranking by cosine alone surfaces near-misses.
|
||
|
|
#
|
||
|
|
# CPU for the same reason as the embedding service: all 4 GPUs are claimed and
|
||
|
|
# the device plugin allocates whole cards. A 568M cross-encoder scoring ~20-50
|
||
|
|
# candidates per query is well within CPU budget.
|
||
|
|
#
|
||
|
|
# Arch is XLMRobertaForSequenceClassification, which TEI serves as /rerank.
|
||
|
|
# 278M params — smaller than v2-m3 (568M) and English/Chinese rather than
|
||
|
|
# multilingual, which suits code+docs retrieval and is faster on CPU.
|
||
|
|
apiVersion: serving.kserve.io/v1beta1
|
||
|
|
kind: InferenceService
|
||
|
|
metadata:
|
||
|
|
name: reranker
|
||
|
|
labels:
|
||
|
|
app.kubernetes.io/name: llm-reranker
|
||
|
|
app.kubernetes.io/part-of: llm-serving
|
||
|
|
spec:
|
||
|
|
predictor:
|
||
|
|
minReplicas: 1
|
||
|
|
maxReplicas: 1
|
||
|
|
# Same worker-1 pin as the embedding service, to share the RWO models PVC.
|
||
|
|
nodeSelector:
|
||
|
|
kubernetes.io/hostname: worker-1
|
||
|
|
containers:
|
||
|
|
- name: kserve-container
|
||
|
|
image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.8.2@sha256:4d632b76bd14cb57044a1ffb0ad48ab0ba4939e705a9a615ccc740658575c26e
|
||
|
|
args:
|
||
|
|
# bge-reranker-base, NOT v2-m3. TEI's CPU image starts the ONNX
|
||
|
|
# Runtime backend and v2-m3 ships no ONNX files, so it dies with
|
||
|
|
# "Model ONNX files not found in the repository". This build does.
|
||
|
|
- --model-id=BAAI/bge-reranker-base
|
||
|
|
- --port=8080
|
||
|
|
- --hostname=0.0.0.0
|
||
|
|
- --auto-truncate
|
||
|
|
env:
|
||
|
|
- name: HUGGINGFACE_HUB_CACHE
|
||
|
|
value: /mnt/models
|
||
|
|
ports:
|
||
|
|
- containerPort: 8080
|
||
|
|
protocol: TCP
|
||
|
|
resources:
|
||
|
|
requests:
|
||
|
|
cpu: "8"
|
||
|
|
memory: 4Gi
|
||
|
|
limits:
|
||
|
|
cpu: "16"
|
||
|
|
memory: 8Gi
|
||
|
|
volumeMounts:
|
||
|
|
- name: models
|
||
|
|
mountPath: /mnt/models
|
||
|
|
startupProbe:
|
||
|
|
httpGet:
|
||
|
|
path: /health
|
||
|
|
port: 8080
|
||
|
|
periodSeconds: 10
|
||
|
|
failureThreshold: 60
|
||
|
|
readinessProbe:
|
||
|
|
httpGet:
|
||
|
|
path: /health
|
||
|
|
port: 8080
|
||
|
|
periodSeconds: 10
|
||
|
|
volumes:
|
||
|
|
- name: models
|
||
|
|
persistentVolumeClaim:
|
||
|
|
claimName: llm-models
|