ARTIFACT // CHECK-RAG-EMBEDDING-HEALTH.SH (SHELL)
Local RAG Embedding Dimension, Bilingual Recall & Zombie VRAM Diagnostic Script (check-rag-embedding-health.sh)
Probes exact output vector dimensions (e.g. 1024 for bge-m3 vs 768 for nomic-embed-text), checks dual-model VRAM residency, and verifies non-empty embeddings.
[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Local RAG Embedding Dimension, Bilingual Recall & Zombie VRAM Diagnostic Script" (check-rag-embedding-health.sh, SHELL) is paired with Tinker AI Lab's hardware-verified guide "embedding-dimension-mismatch-and-zombie-vram". It exposes 3 customizable browser variables (EMBED_MODEL=bge-m3:latest, EXPECTED_DIM=1024, OLLAMA_ENDPOINT=http://127.0.0.1:11434) with loopback-first security defaults.
04 // DIAGNOSISAPI & Deployment Troubleshooting· Verified: 2026-10-26
Browse All 42 Artifacts →check-rag-embedding-health.sh
View Paired Guide →Local RAG Embedding Dimension, Bilingual Recall & Zombie VRAM Diagnostic Script
Probes exact output vector dimensions (e.g. 1024 for bge-m3 vs 768 for nomic-embed-text), checks dual-model VRAM residency, and verifies non-empty embeddings.
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
#!/usr/bin/env bash
# Tinker AI — RAG Embedding Dimension & Multi-Model VRAM Healthcheck (Guide #20)
set -euo pipefail
EMBED="bge-m3:latest"
EXP_DIM="1024"
API="http://127.0.0.1:11434/api/embed"
echo "=== [1/3] Probing Vector Dimension for $EMBED ==="
RESP=$(curl -sS "$API" -d "{
\"model\": \"$EMBED\",
\"input\": [\"Tinker AI Lab bilingual RAG verification\", \"本地知识库跨语言向量检索测试\"],
\"keep_alive\": \"5m\"
}")
echo "$RESP" | python3 -c "
import sys, json, math
data = json.load(sys.stdin)
vecs = data.get('embeddings', [])
if not vecs:
print('[FAIL] Empty embeddings array returned! Check model tag.')
sys.exit(1)
dim = len(vecs[0])
exp = int('$EXP_DIM')
status = 'OK' if dim == exp else f'MISMATCH (Expected {exp}, Got {dim} -> Must re-index Vector DB!)'
dot = sum(a*b for a, b in zip(vecs[0], vecs[1]))
norm0 = math.sqrt(sum(a*a for a in vecs[0]))
norm1 = math.sqrt(sum(b*b for b in vecs[1]))
cos = dot / (norm0 * norm1) if (norm0 and norm1) else 0.0
print(f'Vector Dimension : {dim} [{status}]')
print(f'EN-ZH Cosine Sim : {cos:.4f} (Expect > 0.55 for multilingual models like bge-m3)')
"
echo "=== [2/3] Inspecting Co-Loaded Models & VRAM Split ==="
ollama ps
echo "=== [3/3] Checking OLLAMA_MAX_LOADED_MODELS Policy ==="
echo "Tip: Ensure OLLAMA_MAX_LOADED_MODELS>=2 so $EMBED and your Chat LLM do not thrash disk on every RAG query."
PARAMETER SPECIFICATION // 参数化变量规范说明表
Customizable Parameter Reference for check-rag-embedding-health.sh
This SHELL artifact exposes 3 template variables compiled client-side in your browser.
| Template Token | Parameter Description | Verified Default | Example Format |
|---|---|---|---|
{{EMBED_MODEL}} | Embedding Model Tag | bge-m3:latest | bge-m3:latest | nomic-embed-text |
{{EXPECTED_DIM}} | Expected Vector DB Dimension | 1024 | 1024 (bge-m3) | 768 (nomic) | 384 (MiniLM) |
{{OLLAMA_ENDPOINT}} | Ollama Endpoint | http://127.0.0.1:11434 | http://127.0.0.1:11434 |
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录
Verified Environment for "Troubleshooting RAG Embedding Dimension Mismatch (1024 vs 768) & Zombie VRAM Allocation"
Tested Hardware & OS
Linux / macOS / Windows WSL2 · Ollama 0.5.7 · Open WebUI / Dify / Continue (ChromaDB, Qdrant, PGVector)
Pinned Stack & Model Versions
Ollama 0.5.7bge-m3 (1024-dim)nomic-embed-text (768-dim)mxbai-embed-large (1024-dim)
Offline Boundary (100% Local Vector DB & GPU Process Diagnostics)
All vector dimension probes and GPU process checks run locally via curl and nvidia-smi.
Known Operational Limits & Failure Modes
- Vector spaces are mathematically incompatible across models: even if two models share the same dimension (`bge-m3` is 1024-dim and `mxbai-embed-large` is 1024-dim), querying an index built with model A using model B returns pure random noise!
- In WSL2 on Windows, freeing CUDA memory inside Linux does not always immediately shrink `vmmemWSL` on Windows Task Manager without `OLLAMA_KEEP_ALIVE=0` or `wsl --shutdown`.
DEPLOYMENT CHECKLIST // 配置落地核验步骤
3-Step Verification Checklist After Deploying check-rag-embedding-health.sh
- Verified `jq ".embedding | length"` matches the vector collection dimension (`1024` for `bge-m3`, `768` for `nomic-embed-text`).
- Re-indexed existing knowledge collections after changing the embedding model (even if dimensions were equal).
- Configured `OLLAMA_MAX_LOADED_MODELS=2` so `bge-m3` and the main Chat LLM do not evict each other during RAG turns.