TinkerLab
ARTIFACT // TINKER-RAG-EVAL-SAMPLE.SH (SHELL)

Local Document Q&A (RAG) Downloadable Sample Corpus & Citation Verifier (tinker-rag-eval-sample.sh)

Generates a ground-truth technical document sample with trap clauses and tests whether your local RAG setup cites exact sections or hallucinates.

[KEY VERIFIED TAKEAWAY / TL;DR]This reproducible configuration artifact "Local Document Q&A (RAG) Downloadable Sample Corpus & Citation Verifier" (tinker-rag-eval-sample.sh, SHELL) is paired with Tinker AI Lab's hardware-verified guide "local-rag-citation-and-failure-cases". It exposes 3 customizable browser variables (RAG_CHAT_MODEL=qwen2.5:14b-instruct-q4_K_M, EMBED_MODEL=bge-m3, RAG_NUM_CTX=8192) with loopback-first security defaults.
01 // HOMELABLocal AI / HomeLab· Verified: 2026-10-23
Browse All 42 Artifacts →
tinker-rag-eval-sample.sh

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.

View Paired Guide →
Customizable Variables (Saved in Browser)
UTF-8 Encoded · Live Client-Side Compilation
#!/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",""))'
PARAMETER SPECIFICATION // 参数化变量规范说明表

Customizable Parameter Reference for tinker-rag-eval-sample.sh

This SHELL artifact exposes 3 template variables compiled client-side in your browser.

Template TokenParameter DescriptionVerified DefaultExample Format
{{RAG_CHAT_MODEL}}RAG Chat Model Tagqwen2.5:14b-instruct-q4_K_Mqwen2.5:14b-instruct-q4_K_M
{{EMBED_MODEL}}Local Embedding Modelbge-m3bge-m3
{{RAG_NUM_CTX}}RAG Context Window (num_ctx)81928192
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录

Verified Environment for "Local Document Q&A (RAG): Downloadable Sample Corpus, Citation Check & Failure Cases"

Tested Hardware & OS

Mac M3 Pro 36GB & RTX 4070 12GB · Local Ollama + Open WebUI Hybrid RAG

Pinned Stack & Model Versions
Ollama 0.5.7Open WebUI v0.5.10bge-m3:567mqwen2.5:14b-instruct-q4_K_M
Offline Boundary (100% Local Embedding + Local Generation)

Both `bge-m3` embeddings and `qwen2.5:14b` synthesis run strictly on local hardware.

Known Operational Limits & Failure Modes
  • 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.
DEPLOYMENT CHECKLIST // 配置落地核验步骤

3-Step Verification Checklist After Deploying tinker-rag-eval-sample.sh

  1. Ran the downloadable RAG sample verification script and checked exact Section 3.2 & 4.4 citations.
  2. Set RAG chat model `num_ctx >= 8192` and `temperature = 0` to eliminate silent chunk truncation.
  3. Enabled Hybrid Search (`BM25 + Vector`) for exact error codes and part numbers.