Downloads · 30 days
0
vltruong01/TechQA-Adaptive-Hybrid-RAG
TechQA-Adaptive-Hybrid-RAG is a question answering model from vltruong01. Use it when the input is a question plus a passage. The card lists the license as apache-2.0.
A reproducible technical-support Retrieval-Augmented Generation (RAG) system built on the reduced nvidia/TechQA-RAG-Eval corpus.
Downloads · 30 days
0
Access
Public
Updated Sep 8, 2026
Repo size
19.7 MB
Likes
0
Public
Click a slice to open those files.
.npy7.8 MB · 35%
From the Hugging Face model README
A reproducible technical-support Retrieval-Augmented Generation (RAG) system built on the reduced nvidia/TechQA-RAG-Eval corpus.
This repository packages the Adaptive Hybrid RRF system selected by the controlled five-system comparison published in:
vltruong01/TechQA-Hybrid-RAG-System-Comparison
Selection result: Adaptive Hybrid RRF achieved the strongest overall held-out document-ranking performance in the controlled comparison and was selected as the primary retrieval strategy.
System behavior: the generation stage is deliberately conservative. When the provided evidence does not directly support the requested technical answer, the system is instructed to abstain rather than invent unsupported troubleshooting guidance.
Important distinction: this repository is the reusable implementation of the selected system. The companion comparison repository remains the source of the controlled five-system experimental comparison.
| Item | Setting |
|---|---|
| Upstream dataset | nvidia/TechQA-RAG-Eval |
| Experimental corpus | 496 unique Technotes |
| QA rows | 910 |
| TRAIN | 600 questions: 450 answerable + 150 impossible |
| DEV | 310 questions: 160 answerable + 150 impossible |
| Primary retriever | Adaptive Hybrid RRF |
| Lexical retriever | BM25 |
| Dense retriever | BAAI/bge-base-en-v1.5 |
| Router | StandardScaler + LogisticRegression(class_weight="balanced") |
| Adaptive specialist boost | 3.0 |
| Chunk size / overlap | 384 / 64 tokens |
| Generator | Qwen/Qwen2.5-7B-Instruct |
| Generator precision | 4-bit NF4 |
| Evidence budget | 5 chunks, max 2 per document |
| Maximum prompt length | 4096 tokens |
| Maximum new tokens | 256 |
| Evidence-sufficiency threshold | 0.535 |
| Fine-tuning | None |
| Seed | 42 |
| Reference / usage notebook | TechQA_Adaptive_Hybrid_RAG_Reference_Guide.ipynb |
| Comparison repository | TechQA-Hybrid-RAG-System-Comparison |
This is a complete RAG system repository, not a standalone fine-tuned language-model checkpoint.
It packages:
The pretrained models are loaded from their original Hugging Face repositories when the notebook runs.
The project is split into two repositories with different roles:
| Repository | Purpose |
|---|---|
TechQA-Hybrid-RAG-System-Comparison | Controlled comparison of BM25, Dense BGE, Static Hybrid RRF, Static RRF + Neural Reranker, and Adaptive Hybrid RRF |
TechQA-Adaptive-Hybrid-RAG | Complete implementation and reusable artifacts for the selected Adaptive Hybrid RRF RAG system |
The research flow is:
Reduced TechQA-RAG-Eval corpus
|
v
Controlled five-system retrieval comparison
|
v
Adaptive Hybrid RRF selected
|
v
This repository:
Adaptive retrieval + evidence selection + grounded Qwen generation
The selection of Adaptive Hybrid RRF is based on the controlled comparison, not on a claim that it dominates every downstream generation metric.
Question
|
+----------------------+
| |
v v
BM25 ranking Dense BGE ranking
| |
+----------+-----------+
|
v
Query feature extraction
|
v
TRAIN-learned router
|
v
Query-specific BM25/Dense weights
|
v
Weighted Reciprocal Rank Fusion
|
v
Adaptive Hybrid RRF
|
v
Diverse evidence selection
top 5 chunks, max 2/doc
|
v
Evidence-sufficiency classifier
|
+-----+------+
| |
v v
abstain answer path
|
v
Qwen2.5-7B-Instruct
4-bit NF4
|
v
Grounded answer + citations
The controlled 30-question answerable generation evaluation bypasses the calibrated evidence-sufficiency gate so it remains comparable with the generation experiment in the companion comparison repository. The user-facing ask_techqa() helper applies the calibrated gate by default.
The system loads:
nvidia/TechQA-RAG-Eval
from its published train split and recovers the benchmark partitions from question IDs:
| Split | Total | Answerable | Impossible |
|---|---|---|---|
| TRAIN | 600 | 450 | 150 |
| DEV | 310 | 160 | 150 |
| Total | 910 | 610 | 300 |
The reduced corpus contains 496 unique Technotes.
Title: line is present;chunk size = 384 tokens
chunk overlap = 64 tokens
minimum tail = 40 tokens
Chunk IDs follow:
<filename>::chunk_0000
<filename>::chunk_0001
...
The lexical branch uses technical-token-aware tokenization and BM25 retrieval.
BM25_TOP_K = 50
Dense retrieval uses:
Queries are encoded with:
Represent this sentence for searching relevant passages:
Embeddings are normalized and searched with FAISS inner-product similarity.
DENSE_TOP_K = 50
The two ranked lists are combined using weighted RRF:
score(d) =
w_bm25 / (60 + rank_bm25(d))
+ w_dense / (60 + rank_dense(d))
Static Hybrid RRF uses equal weights. Adaptive Hybrid RRF changes the weights for each query.
The router is trained only on 450 answerable TRAIN questions.
It predicts one of:
BM25-heavy
Balanced
Dense-heavy
TRAIN target distribution:
| Router class | Samples |
|---|---|
| BM25-heavy | 17 |
| Balanced | 371 |
| Dense-heavy | 62 |
| Total | 450 |
The router uses 14 lightweight features:
query_terms
query_avg_token_length
technical_token_ratio
digit_token_ratio
uppercase_token_ratio
bm25_top1
bm25_margin
bm25_relative_margin
dense_top1
dense_margin
dense_relative_margin
bm25_dense_top1_agree
top5_document_overlap
top5_document_jaccard
Model:
StandardScaler
+
LogisticRegression(
class_weight="balanced",
max_iter=3000,
random_state=42
)
| Metric | Value |
|---|---|
| Accuracy | 0.7311 |
| Balanced accuracy | 0.5182 |
| Macro F1 | 0.4762 |
The Adaptive specialist boost is selected using TRAIN out-of-fold retrieval evaluation:
ADAPTIVE_HEAVY_WEIGHT = 3.0
DEV labels are not used to select this value.
Adaptive Hybrid RRF is evaluated on all 160 answerable DEV questions.
| Metric | Adaptive Hybrid RRF |
|---|---|
| Recall@1 | 0.8500 |
| Recall@5 | 0.94375 |
| Recall@10 | 0.96875 |
| MRR@10 | 0.889105 |
| nDCG@10 | 0.908251 |
The standalone notebook reproduces the selected retrieval metrics from the controlled comparison.
Latency is hardware- and runtime-dependent and should not be compared across independent executions without controlling the environment.
In the companion five-system comparison:
| System | R@1 | R@5 | R@10 | MRR@10 | nDCG@10 |
|---|---|---|---|---|---|
| Adaptive Hybrid RRF | 0.8500 | 0.9438 | 0.9688 | 0.8891 | 0.9083 |
| Static Hybrid RRF | 0.8500 | 0.9313 | 0.9688 | 0.8884 | 0.9076 |
| Dense BGE | 0.7938 | 0.9625 | 0.9750 | 0.8617 | 0.8899 |
| BM25 | 0.8000 | 0.9063 | 0.9250 | 0.8473 | 0.8664 |
| Static RRF + Neural Reranker | 0.7438 | 0.9313 | 0.9688 | 0.8213 | 0.8572 |
Adaptive was selected for its strongest overall top-rank document-ranking performance, while Dense BGE remained strongest at deeper recall and Static Hybrid RRF remained extremely competitive.
For the complete controlled comparison and its interpretation, see the companion repository.
A separate lightweight classifier estimates whether the retrieved evidence is sufficient to answer the question.
Model:
StandardScaler
+
LogisticRegression(
class_weight="balanced",
max_iter=3000,
random_state=42
)
The classifier uses 14 features derived from the question and retrieval evidence.
The threshold is selected on TRAIN out-of-fold predictions:
threshold = 0.535
TRAIN OOF ROC-AUC = 0.7806
The gate is evaluated on all 310 DEV questions:
| Metric | Value |
|---|---|
| Answerable answer rate | 0.6750 |
| Impossible abstention rate | 0.8133 |
| False-answer rate on impossible questions | 0.1867 |
| Balanced accuracy | 0.7442 |
| Overall accuracy | 0.7419 |
| ROC-AUC | 0.8095 |
This classifier is an auxiliary safety / evidence-sufficiency component. It is separate from the primary Adaptive retrieval contribution.
The generator is:
loaded with 4-bit NF4 quantization.
max prompt tokens = 4096
max new tokens = 256
sampling = disabled
evidence chunks = 5
max chunks/doc = 2
The prompt requires Qwen to:
[1], [2], etc.;Exact abstention text:
The available documentation does not contain enough information to answer this question.
Citation retry is enabled when the first answer does not satisfy the notebook's citation-format checker.
The model repository contains a standalone Adaptive-only generation run on the same seeded 30 answerable DEV questions used by the comparison experiment.
The calibrated evidence-sufficiency gate is not applied to this 30-question evaluation because the controlled comparison evaluates the generator directly on answerable questions.
| Metric | Value |
|---|---|
| Questions | 30 |
| Answer rate | 0.6333 |
| Exact false-abstention rate | 0.3667 |
| Gold-document retrieval rate | 1.0000 |
| Mean gold chunks in prompt | 1.6333 |
| Mean unique documents in prompt | 3.5667 |
| Mean best reference-chunk cosine | 0.7634 |
| Mean top-3 reference-chunk cosine | 0.7105 |
| ROUGE-L F1 | 0.2313 |
| BGE answer cosine | 0.6921 |
| Citation presence among detected answers | 1.0000 |
| Citation-format validity among detected answers | 1.0000 |
The standalone run should not replace the controlled cross-system generation table in the comparison repository.
Independent executions can differ modestly because of environment, package, model-revision, and low-level kernel differences. Cross-system claims should therefore be taken from the companion comparison repository, where all five systems were evaluated in the same experiment.
The standalone run is useful for verifying that the packaged Adaptive system behaves consistently and that its retrieval results reproduce exactly.
The system intentionally prefers abstention to unsupported technical guidance.
On the 30-question answerable sample, the notebook's exact abstention detector marks 11/30 outputs as abstentions. This metric is based on normalization of the configured exact abstention sentence; longer refusal-like answers may not always be counted as abstentions. Manual inspection is therefore recommended when studying answer coverage.
Citation-format validity also does not prove factual entailment. It verifies citation presence and source-index formatting, not whether every cited claim is technically correct.
TechQA-Adaptive-Hybrid-RAG/
|
|-- README.md
|-- TechQA_Adaptive_Hybrid_RAG.ipynb
|-- TechQA_Adaptive_Hybrid_RAG_Reference_Guide.ipynb
|-- system_config.json
|-- requirements.txt
|-- artifact_manifest.json
|
`-- artifacts/
|-- models/
| |-- router_pipeline.joblib
| `-- abstention_pipeline.joblib
|
|-- index/
| |-- techqa_bge_embeddings.npy
| |-- techqa_bge_faiss.index
| |-- techqa_chunks.parquet
| |-- techqa_unique_documents.parquet
| `-- techqa_qa.parquet
|
|-- retrieval/
| |-- retrieval_metrics.csv
| `-- retrieval_detail.csv
|
|-- router/
| |-- router_oof_metrics.csv
| |-- router_train_oof.csv
| `-- adaptive_weight_search.csv
|
|-- abstention/
| |-- abstention_metrics.csv
| |-- abstention_train_oof_scores.csv
| |-- abstention_threshold_tuning.csv
| |-- abstention_dev_outputs.csv
| |-- abstention_feature_weights.csv
| `-- abstention_errors.csv
|
|-- generation/
| |-- generation_metrics.csv
| |-- generation_eval_questions.csv
| |-- generation_eval_outputs.csv
| `-- manual_generation_review.csv
|
`-- examples/
|-- answerable_example_output.json
|-- impossible_example_output.json
`-- custom_question_output.json
artifact_manifest.json records the released files with their byte sizes and SHA-256 hashes.
| Notebook | Best for |
|---|---|
TechQA_Adaptive_Hybrid_RAG_Reference_Guide.ipynb | Recommended starting point for new users. Downloads the released artifacts, verifies checksums, restores the Adaptive retriever and evidence-sufficiency gate, and optionally runs Qwen generation without retraining the full experiment. |
TechQA_Adaptive_Hybrid_RAG.ipynb | Full end-to-end reproduction: rebuild corpus/indexes, train/select the router, calibrate the gate, evaluate DEV, run generation, and export artifacts. |
This repository is notebook-first rather than a conventional transformers checkpoint.
Do not expect the following to load the complete RAG system:
AutoModelForCausalLM.from_pretrained(
"vltruong01/TechQA-Adaptive-Hybrid-RAG"
)
The repository does not contain a replacement Qwen checkpoint. Instead, it combines released retrieval artifacts, lightweight scikit-learn models, frozen BGE embeddings/indexes, and the original Qwen generator.
This is the recommended path for most users.
Open:
TechQA_Adaptive_Hybrid_RAG_Reference_Guide.ipynb
The reference guide:
snapshot_download();artifact_manifest.json;router_pipeline.joblib and abstention_pipeline.joblib;Qwen/Qwen2.5-7B-Instruct in 4-bit NF4;ask_techqa() helper.A T4-class GPU or better is recommended if you want to run Qwen generation. Repository inspection and retrieval can also be performed without loading Qwen.
Example after initialization:
output = ask_techqa(
"Your technical-support question here",
use_calibrated_gate=True,
show_sources=True,
)
If you want to rebuild and study the entire experiment, open:
TechQA_Adaptive_Hybrid_RAG.ipynb
This notebook reconstructs the reduced corpus, regenerates chunks and embeddings, rebuilds the FAISS index, trains/selects the Adaptive router from TRAIN, calibrates the evidence-sufficiency model, evaluates DEV, loads Qwen, and exports the released artifacts.
You can also clone the repository:
git clone https://huggingface.co/vltruong01/TechQA-Adaptive-Hybrid-RAG
cd TechQA-Adaptive-Hybrid-RAG
pip install -r requirements.txt
Then choose either the Reference Guide for artifact-based usage or the full notebook for complete reproduction.
The following sequence refers to TechQA_Adaptive_Hybrid_RAG.ipynb, not the lightweight Reference Guide.
The full notebook rebuilds the pipeline in the following order:
nvidia/TechQA-RAG-Eval;datasetstransformersacceleratebitsandbytessentence-transformersfaiss-cpurank-bm25rouge-scorepandasscikit-learnjoblibSee requirements.txt for the released environment specification.
The selected system follows the same leakage controls as the comparison experiment:
The notebook includes integrity checks for the expected router target distribution and selected Adaptive specialist boost.
This repository is intended for:
It can also serve as a reference implementation for a lightweight query-adaptive retriever that does not require fine-tuning the embedding model or generator.
Reduced corpus
The system uses the reduced TechQA-RAG-Eval corpus, not the original full TechQA / full IBM Technotes collection.
Generation evaluation size
End-to-end generation is evaluated on a seeded subset of 30 answerable DEV questions rather than all 160 answerable DEV questions.
Conservative generation can abstain on answerable questions
Successful document retrieval does not guarantee that the generator will use the evidence correctly. The grounded prompt intentionally abstains when the evidence appears insufficiently explicit.
Gold-document retrieval is not answer-span retrieval
A gold Technote appearing in the evidence set does not guarantee that the exact answer-bearing passage is optimally positioned in the limited 5-chunk prompt.
Automated answer metrics are incomplete
ROUGE-L and embedding similarity measure similarity to references but do not guarantee technical correctness, completeness, or absence of misleading details.
Citation checks are format checks
A valid [n] citation means the source index is syntactically valid. It does not prove that the cited source entails every claim.
Exact abstention detection can undercount semantic refusals
Evaluation normalization is centered on the configured abstention sentence. Longer refusal-style generations can require manual inspection.
Frozen generator
Qwen2.5-7B-Instruct is not fine-tuned for TechQA. Some failures occur after successful retrieval because evidence utilization remains a downstream bottleneck.
Router class imbalance
Most TRAIN router targets are Balanced; BM25-heavy examples are rare. Balanced accuracy and macro F1 should be considered alongside raw router accuracy.
Not authoritative support guidance
Generated outputs are research artifacts. Technical-support answers should be checked against the cited documentation before operational use.
Latency is environment-dependent
Retrieval and generation times vary with GPU, CPU, package versions, model revisions, and runtime configuration.
The upstream dataset is:
The companion comparison repository is:
vltruong01/TechQA-Hybrid-RAG-System-Comparison
Processed QA, document, chunk, embedding, and FAISS artifacts in this repository are derived from the reduced TechQA-RAG-Eval corpus and are included for system reproducibility.
This repository does not redistribute the pretrained Qwen or BGE model weights.
Users should also follow the license and attribution requirements of the upstream dataset and model repositories.
Original TechQA resource:
For users who want to try the packaged system rather than reproduce training and evaluation, start with TechQA_Adaptive_Hybrid_RAG_Reference_Guide.ipynb.
The selected system preserves the main finding of the controlled comparison:
Adaptive Hybrid RRF achieved the strongest overall held-out document-ranking performance and was therefore selected as the primary retrieval strategy.
The standalone model reproduction exactly matches the selected full-DEV retrieval metrics while retaining a conservative grounded-generation policy.
The broader project also shows that:
Strong document retrieval does not automatically guarantee strong downstream generation. Evidence selection, limited context budgets, abstention behavior, and generator evidence utilization remain important bottlenecks.
For cross-system claims, use the controlled comparison repository rather than the standalone reproduction in this model repository.
If you use the packaged selected system, please cite this repository:
@misc{vltruong01_techqa_adaptive_hybrid_rag_2026,
author = {vltruong01},
title = {TechQA Adaptive Hybrid RAG},
year = {2026},
howpublished = {Hugging Face},
url = {https://huggingface.co/vltruong01/TechQA-Adaptive-Hybrid-RAG}
}
For the controlled five-system experiment, please also cite:
@misc{vltruong01_techqa_hybrid_rag_2026,
author = {vltruong01},
title = {TechQA Hybrid RAG System Comparison},
year = {2026},
howpublished = {Hugging Face},
url = {https://huggingface.co/datasets/vltruong01/TechQA-Hybrid-RAG-System-Comparison}
}
Please also follow the citation / attribution guidance of the upstream TechQA and TechQA-RAG-Eval resources.
nvidia/TechQA-RAG-Evalvltruong01/TechQA-Hybrid-RAG-System-ComparisonBAAI/bge-base-en-v1.5Qwen/Qwen2.5-7B-InstructHugging Face Model:
https://huggingface.co/vltruong01/TechQA-Adaptive-Hybrid-RAG