Add adaptive page-aware retrieval pipeline with graded evaluation #115
Draft
Shrey1306 wants to merge 4 commits into
Draft
Add adaptive page-aware retrieval pipeline with graded evaluation #115Shrey1306 wants to merge 4 commits into
Shrey1306 wants to merge 4 commits into
Conversation
Replace static chunk retrieval with adaptive query routing, hierarchical section-to-chunk retrieval, page-aware reranking, and a graded benchmark suite. Measured on 21 judged textbook questions: chunk nDCG@10 = 0.359, chunk Recall@10 = 0.698, page-hit@10 = 0.857. Key changes: - Manifest-backed artifact bundle with SHA256 validation (src/artifacts.py) - Adaptive query planner with 5-type routing (src/retrieval_pipeline.py) - Hierarchical section-to-chunk retrieval with section-prior boosting - Page-aware reranking (base score + lexical overlap + page specificity) - Multi-part query decomposition with coverage-aware result merging - Hardened GGUF embedder: single-input default, no zero-vector fallback - Hardened query enhancement: try-catch fallbacks on all LLM calls - build_index() decomposed into extract, embed, persist stages - get_answer() split into adaptive and legacy retrieval helpers - 21 graded benchmarks with 3-level chunk/page relevance labels - Ranked IR metrics: nDCG, Recall, MRR, MAP, page-hit variants - Benchmark runner with --mode baseline for fair comparison - Ruff lint, docstrings, 36 unit tests passing
Resolve conflicts keeping improved retrieval pipeline while incorporating main's new fields (embedding_model_context_window, enable_topic_extraction, uuid4, flash_attn, LlamaRAMCache). Fix duplicate numpy import and unused deepcopy import introduced during merge.
…rieval-quality # Conflicts: # Makefile # config/config.yaml # src/api_server.py # src/config.py # src/index_builder.py # src/main.py # tests/conftest.py
…rop duplicate files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace static chunk retrieval with adaptive query routing, hierarchical section-to-chunk retrieval, page-aware reranking, and a graded benchmark suite. Measured on 21 judged textbook questions: chunk nDCG@10 = 0.359, chunk Recall@10 = 0.698, page-hit@10 = 0.857.
Key changes:
This (update) 04/25/2026 (FINAL REPORT)
Consolidates adaptive routing policy, tightens the retrieval + artifact stack, and adds a reproducible local eval path—plus benchmarks and tests aligned to the current textbook index.
What changed
src/planning/rules.py(new)Single place for query-type classification, follow-up reference patterns, heuristic decomposition, and shared
QUERY_TYPE_*constants.HeuristicQueryPlanner,query_enhancement, andretrieval_pipelineall route through the same policy.src/retrieval_pipeline.py&src/query_enhancement.pyRefactor to use shared rules: named score weights, multi-part merge and anchor rerank behavior, confidence widening traced on
RetrievalTrace, and deterministic/consistent follow-up handling.src/retriever.py&src/config.pyStricter bundle loading (e.g. manifest / artifact version expectations), type and config cleanups in support of hierarchical + page-aware behavior.
scripts/run_evals.sh(new)One script to run preflight, optional index build, artifact validation, retrieval benchmark,
pytest, andmake lint, with timestamped logs undereval_runs/.Index metadata checked in
index/sections/textbook_index_manifest.jsonplus updatedtextbook_index_page_to_chunk_map.jsonfor the currenttextbook_indexbuild (large diff is the page map).tests/benchmarks.yamlGraded
retrieval_gold(chunks/pages + grades) and query-type fields updated for the current artifact set.Tests
tests/test_planning_rules.py(new), extendedtest_retrieval_pipeline,test_artifacts, and other suites for the above behavior.Tooling
MakefileRuff list includesrules.pyandtest_planning_rules.py..gitignore: local conda dirs,eval_runs/, generatedindex/sections/*.npyand*_info.json, and* 2.{py,yaml,ymlto avoid duplicate-file accidents.config/config.yamlDefault generator model path adjusted (e.g. smaller/faster local instruct model); teams should still align paths with their own
models/.How to verify