Local Document Q&A (RAG): Downloadable Sample Corpus, Citation Check & Failure Cases
Test your local RAG pipeline with our downloadable ground-truth policy document—exposing silent num_ctx truncation, two-column PDF bleed, and hallucinated citations.
Mac M3 Pro 36GB & RTX 4070 12GB · Local Ollama + Open WebUI Hybrid RAG
Both `bge-m3` embeddings and `qwen2.5:14b` synthesis run strictly on local hardware.
- Failure Case #1 (Silent Context Truncation): If 5 retrieved chunks (~3,800 tokens) are injected into a model left at Ollama default `num_ctx=2048`, Ollama silently drops the top chunks and the model claims the fact is missing.
- Failure Case #2 (Two-Column PDF Bleed): Standard PDF text extractors read across left and right columns on the same horizontal line, corrupting tables and numeric clauses.
- Failure Case #3 (Small 3B/7B Citation Drift): Models under 7B frequently invent plausible section numbers (e.g. citing "Section 2.4" when the text is in "Section 3.2") unless temperature is locked to 0.
1. Reproducing & Fixing the 3 Classic Local RAG Failures
| Failure Mode | Observable Symptom | Root Cause | Verified Fix |
|---|---|---|---|
| Silent Head Truncation | UI shows chunk retrieved, but LLM says "Not mentioned" | Top-K chunks exceed default num_ctx=2048 | Set chat model num_ctx >= 8192 |
| Exact Error Code Miss | Searching "ERR_SSL_904" returns unrelated prose | Pure dense vector search blurs rare tokens | Enable Hybrid Search (BM25 + bge-m3) |
| Two-Column PDF Bleed | Numbers from column B get attached to column A | Naive PDF line scanner ignores column bounding boxes | Convert complex PDFs to Markdown via Marker/Docling first |
2. Enforcing Grounded Citations & "Abstain When Unsure" System Prompt
You are a strict document verification assistant.
Rules:
1. Answer ONLY using facts explicitly stated in the <context> blocks below.
2. Every factual statement MUST end with an exact section citation like [Section 3.2].
3. Pay strict attention to negative exclusions ("EXCLUDED", "NOT supported", "EXCEPT").
4. If the answer is not explicitly present in <context>, reply verbatim: "INSUFFICIENT_EVIDENCE_IN_DOCUMENT".3. Chunk Size, Overlap & Markdown Header Splitting Benchmarks
Frequently Asked Questions & Edge Cases
Q: Why does Open WebUI show the right document chunk in Citations, yet the LLM says the information is not found?
Because the UI displays retrieved chunks before sending the prompt to Ollama. If the combined system prompt + 5 chunks + user question exceeds Ollama default `num_ctx=2048`, Ollama silently truncates the top chunks from the prompt head. Set `num_ctx` to `8192` or `16384` in Model Settings.
Q: Should I use `bge-m3` or `nomic-embed-text` for bilingual Chinese/English documents?
Use `bge-m3` (567M parameters, ~1.2 GB VRAM). In our bilingual technical corpus tests, `bge-m3` achieved 94% Top-3 recall on cross-language queries (Chinese question matching English config keys), whereas English-centric embedding models dropped below 62%.
Local Document Q&A (RAG) Downloadable Sample Corpus & Citation Verifier
Generates a ground-truth technical document sample with trap clauses and tests whether your local RAG setup cites exact sections or hallucinates.
#!/usr/bin/env bash
# Tinker AI — Local Document Q&A (RAG) Sample Corpus & Citation Check (Guide #4)
set -euo pipefail
CHAT_MODEL="qwen2.5:14b-instruct-q4_K_M"
EMBED_MODEL="bge-m3"
CTX="8192"
cat << 'EOF' > ./sample-homelab-sla-policy.md
# Tinker HomeLab Storage & Backup Policy (Rev 2026.10)
## Section 3.1: RPO & Snapshot Frequency
All SQLite application databases (webui.db, n8n.sqlite) MUST be snapshotted every 6 hours using zstd compression. Maximum Recovery Point Objective (RPO) is strictly 6 hours.
## Section 3.2: Cold Storage Retention Trap
Daily archives are retained on local NVMe for 14 days, and replicated to offline NAS cold storage for 90 days. NOTE: Temporary cache directories (/root/.ollama/models/blobs) are EXCLUDED from daily tar snapshots.
## Section 4.4: Emergency Rollback Threshold
If post-upgrade p95 token latency degrades by more than 28% at num_ctx=8192, operators must revert to the previous pinned container digest within 15 minutes.
EOF
echo "=== Generated ./sample-homelab-sla-policy.md ==="
echo "=== Testing Citation Accuracy & Context Retention on $CHAT_MODEL (num_ctx=$CTX) ==="
DOC_CONTENT=$(cat ./sample-homelab-sla-policy.md)
curl -sS http://127.0.0.1:11434/api/generate -d "{
\"model\": \"$CHAT_MODEL\",
\"stream\": false,
\"options\": { \"num_ctx\": $CTX, \"temperature\": 0 },
\"prompt\": $(python3 -c 'import json,sys; print(json.dumps("Answer ONLY using the document below and cite the exact Section number. Question: Are Ollama model blobs included in daily tar snapshots, and what is the p95 latency rollback threshold?
Document:
" + sys.stdin.read()))' < ./sample-homelab-sla-policy.md)
}" | python3 -c 'import sys,json; print(json.load(sys.stdin).get("response",""))'