A retrieval-augmented generation system for IBM technical support. Ask a question, inspect the selected passages, and get a verified, cited answer. The pipeline asks for clarification or withholds an answer when the evidence is incomplete.
The indexed snapshot contains 28,482 support articles and 99,697 chunks. The application uses FastAPI, Qdrant, EmbeddingGemma, a BGE cross-encoder, and a Next.js workspace with OpenUI.
Benchmarks · Architecture · Evaluation · Run locally · Operate the index
The project-maintained 133-question TechQA comparison reported these aggregate results.
| Metric | Baseline | Updated |
|---|---|---|
| RAGAS Context Precision | 72.0% | 84.0% |
| RAGAS Answer Relevancy | 66.0% | 88.5% |
| RAGAS Context Recall | 100% | 100% |
| Answer Correctness | — | 89% |
These figures are transcribed from the project owner's evaluation records. Per-question scores and the correctness judging method were not supplied with the aggregate. The repository's historical RAGAS runs have their own samples and judge configurations. Recorded benchmarks · Historical RAGAS audit.
The development holdout contains 259 questions after filtering overlap with training. The quality scores below use the 113 questions with annotated answers.
| Metric | Result |
|---|---|
| Article Recall@10, dense search | 84.1% (95/113) |
| Article Recall@10, reranking and rank fusion | 85.8% (97/113) |
| Annotated article present in the final context | 81.4% (92/113) |
| Audited Evidence Coverage | 82.3% (93/113) |
| Citation contract pass rate on a separate 24-case V8 generation sample | 100% (12/12 released answers) |
Audited Evidence Coverage combines 85 deterministic reference-text matches with eight additional cases confirmed by reviewing the selected excerpts. The citation contract checks citation format and valid source IDs. Citation support is evaluated separately during answer review. Recorded benchmarks.
| Benchmark | Baseline | Updated |
|---|---|---|
| p95 retrieval latency with Apple GPU reranking on 259 held-out questions | 2.74 s | 1.66 s (39.4% lower) |
| End-to-end latency in an exact-repeat smoke test | 42.5 s | 3.0 s |
| Model calls in the same smoke test | 4 | 1 |
The GPU benchmark used warm models and empty per-query caches, preserved Recall@10, and changed one final evidence payload on this cohort. The default local serving setup uses CPU reranking. The end-to-end test compared one fresh request, including provider quota waits, with its cached repeat.
IBM HTML → structured chunks and source coordinates → Gemma vectors → Qdrant
Question → exact answer cache → dense search → BGE reranking → reciprocal rank fusion
→ evidence selection → writer → citation check → verifier → workspace
- Ingestion and retrieval. The parser preserves article headings, tables, product metadata, and source coordinates where available. Exact Qdrant search and BGE reranking are fused before a bounded context is selected. BM25 and hybrid retrieval are available in offline benchmarks.
- Answering and UI. The writer cites excerpt IDs. Python validates the citation contract, then a separate verifier checks support, applicability, and completeness. The workspace streams progress and evidence, then renders the approved answer with optional validated OpenUI components.
- Caching and memory. Query vectors and reranker scores are stored locally. Exact answers are cached with session and version context. Users can regenerate to bypass the answer cache, and follow-up rewriting uses the current session.
- Versioned index. Document updates are staged separately and reuse unchanged vectors. Activation switches the serving index. A previous build can be reactivated for rollback.
| Layer | Coverage |
|---|---|
| Component | Article Recall@K, MRR, nDCG, and generation with supplied evidence |
| Pipeline | Annotated-article inclusion, reference-text coverage, citation contracts, and optional RAGAS metrics |
| Workflow | Follow-up resolution, exact-repeat caching, and response outcomes |
| Regression | Paired runs on fixed cases, saved artifacts, and review of changed outcomes |
| Observability | LangSmith traces and session threads, timing and usage, and user feedback for reviewed regression cases |
The deterministic suite compares saved runs without calling a model. RAGAS scores selected cases with a request budget. Human review can assess correctness, completeness, citation support, and appropriate withholding. Historical evaluation artifacts.
After installing the test requirements, use the synthetic fixture to see the report format and paired comparison.
python -m scripts.eval_suite report \
--cases evaluations/fixtures/offline_demo.json --output /tmp/eval-demo.json
python -m scripts.eval_suite compare \
--baseline /tmp/eval-demo.json --candidate /tmp/eval-demo.json \
--output /tmp/eval-diff.jsonFor a saved real run, pass matching case and judge artifacts to the suite. To score cases with RAGAS, install its separate environment and select the metrics explicitly.
uv venv --python 3.13 .venv-ragas
uv pip install --python .venv-ragas/bin/python -r requirements-ragas.txt
.venv-ragas/bin/python -m scripts.eval_ragas run \
--cases data/ragas/review/completed.json \
--metrics context_precision context_recall --limit 5 --max-requests 20The request cap includes retries. --max-requests 0 reuses cached judgments. Failed, skipped, and budget-exhausted cases are tracked separately. See the RAGAS runner and the evaluation CLI for collection and comparison options.
Set LANGSMITH_API_KEY and LANGSMITH_TRACING=true in the backend environment. Expand Pipeline / Question to inspect each retrieval and generation step. Use Threads to review related turns. Trace content includes source excerpts and private drafts, so use a private project.
Pipeline / Question
├── Follow-up resolution and exact answer cache
├── Retrieval
│ ├── Query embedding and exact vector search
│ ├── Cross-encoder reranking and rank fusion
│ └── Evidence selection and token count
├── Generation
│ ├── Writer and citation contract
│ └── Verifier decision
└── Optional OpenUI presentation
Publish saved cases with python -m scripts.publish_langsmith --cases PATH. Add --ragas PATH to attach existing scores without re-judging. The app records Helpful and Not helpful feedback. Feedback tooling supports approving and exporting cases for regression tests.
Use Python 3.13, Node.js 22, uv, and Docker Compose. Live answers require a Groq or TokenHarbor API key plus the prepared artifacts listed below. CI runs offline Python and frontend checks with synthetic inputs.
uv venv --python 3.13 .venv-test
uv pip install --python .venv-test/bin/python -r requirements-test.txt
.venv-test/bin/python -m pytest -q
cd frontend
npm ci
npm run test:genui
npm run typecheck
npm run lintFrom the repository root, set up the serving environment.
uv venv --python 3.13 .venv-ingest
uv pip install --python .venv-ingest/bin/python -r requirements-app.txt
cp .env.example .envSet GROQ_API_KEY in .env for the default provider. To use TokenHarbor, set RAG_LLM_PROVIDER=tokenharbor and TOKENHARBOR_API_KEY. Model and runtime settings are documented in the example environment.
This is a code-only checkout, not a bundled dataset or one-command model download. Restore the matching prepared artifacts before serving:
| Location | Purpose |
|---|---|
data/runs/html_v1/documents.json |
Prepared document text and metadata |
data/runs/html_v1/structured_512/chunks.jsonl |
Ordered document chunks |
data/retrieval_runs/gemma2_structured_512_html_v1/config.json |
Source hashes, vector-cache identity and query membership |
data/embedding_cache/<cache_key>/state.json and vectors.npy |
Complete, verified document/query vector cache |
data/tokenizers/bge_wordpiece/ |
Pinned reference tokenizer and its source.json hash record |
data/models/hub/models--google--embeddinggemma-2/snapshots/<revision>/ |
Local Gemma snapshot matching models-embeddings.json |
data/models/hub/models--BAAI--bge-reranker-base/snapshots/2cfc18c9415c912f9d8155881c133215df768a70/ |
Local BGE reranker snapshot |
RAG_RERANKER_DIR can override the reranker location with an absolute path or a path relative to the project root. Serving validates local assets and does not silently download missing weights.
The current importer deliberately targets the audited snapshot: 28,482 articles, 99,697 document chunks and 120 trailing query vectors. Query vectors are excluded from the Qdrant collection. Use the versioned update workflow below for subsequent document changes. Changes to the embedding or chunking policy require a separately prepared index.
Preparation code is included in scripts/audit_techqa.py, baseline.py, chunking.py, ingest_html.py and eval_embeddings.py. Rebuilding requires the original release, tokenizer manifests and the pinned model access; embedding preparation uses a CUDA runtime. It is separate from the local serving setup.
Obtain TechQA from the PrimeQA release, pinned revision 60437bc79ab217679682217598a3693cab78365b. Check the release's bundled data terms; the local audit identified CDLA Permissive 1.0 despite different hosting metadata. Dataset/model licenses are separate from this code repository. No dataset text or model weights are redistributed here.
docker compose up -d
.venv-ingest/bin/python -m scripts.import_qdrant --dry-run
.venv-ingest/bin/python -m scripts.import_qdrantOn a Mac using Colima, start Colima first. If Compose is installed as a standalone executable, use docker-compose instead of docker compose.
The importer verifies manifests, dimensions, finite/unit vectors and row identities before writing. It builds data/source.sqlite3 and the techqa_html_v1_gemma2 collection. Keep source/index backups together. Do not use docker compose down -v unless you intend to delete the database volume.
In one terminal:
.venv-ingest/bin/python -m uvicorn rag_app.api:app --host 127.0.0.1 --port 8000In another:
cd frontend
npm ci
npm run dev -- --hostname 127.0.0.1Open http://127.0.0.1:3000. The example APP_ORIGIN matches that address. For another origin, update it explicitly. The frontend proxies to http://127.0.0.1:8000; set the full /ask URL in RAG_API_URL inside frontend/.env.local to change the upstream.
GET /health/live checks the API process. GET /health/ready checks the key, pinned model assets, source hash and active index identity/count. The first request loads local models, so cold-start latency differs from subsequent requests.
The acceptance drill added, updated and deleted documents, reused 99,695 vectors, embedded two changed chunks, and verified rollback.
After the initial import, register the existing index once. Adoption validates source membership, payload versions, vector dimensions and norms.
.venv-ingest/bin/python -m scripts.manage_index adopt
.venv-ingest/bin/python -m scripts.manage_index statusAn update file maps document IDs to records with title, text and metadata. Optional content supplies original HTML for the existing Docling parser. Keep the original body in text when providing HTML so exact source matches can be mapped. Changed documents retain their raw input in the source store.
{
"your-document-id": {
"title": "Updated support article",
"text": "The updated article body.",
"metadata": {"productName": "Your product"}
}
}Stage changes into a separate collection, then activate the returned build ID. An unchanged input reuses its existing version. Deletion can be run with --delete alone. Policy fingerprints prevent mixing a changed model/parser/chunker configuration with old vectors.
.venv-ingest/bin/python -m scripts.manage_index stage --updates /path/to/updates.json
.venv-ingest/bin/python -m scripts.manage_index stage --delete document-id-to-remove
.venv-ingest/bin/python -m scripts.manage_index activate BUILD_ID
.venv-ingest/bin/python -m scripts.manage_index validate
.venv-ingest/bin/python -m scripts.manage_index activate PREVIOUS_BUILD_IDStaging copies unchanged vectors to preserve an isolated, recoverable version. It embeds the changed documents only. The serving process picks up activation on its next request. Keep version directories and their Qdrant collections together. Stage each batch from the currently active version. If the activation pointer is lost, serving stops until you explicitly activate a validated build.
.venv-ingest/bin/python -m scripts.manage_index backup /path/to/new-backup-directory
.venv-ingest/bin/python -m scripts.manage_index restore /path/to/backup-directory
.venv-ingest/bin/python -m scripts.manage_index activate RESTORE_IDThe backup contains a native Qdrant snapshot, matching SQLite sources and checksums. Restore creates a separate collection and returns restore_id. Activation validates the pair before changing the local pointer. This workflow is tested on a single-node Docker Qdrant. See the Qdrant snapshot documentation for the underlying snapshot operations.
The app is designed for a controlled local rollout. It runs with a single API worker and local Qdrant. Public authentication and sustained traffic capacity are outside the measured release scope. Latency varies with cache state and provider quota. Raw data, model files, conversation traces, and API keys are stored locally.