Skip to content

feat: baseline RAG pipeline with FunSQL grounding, ingestion, and HuggingFace model support#42

Open
ParamThakkar123 wants to merge 11 commits into
mainfrom
baseline-rag-pipeline
Open

feat: baseline RAG pipeline with FunSQL grounding, ingestion, and HuggingFace model support#42
ParamThakkar123 wants to merge 11 commits into
mainfrom
baseline-rag-pipeline

Conversation

@ParamThakkar123

Copy link
Copy Markdown
Collaborator

Summary

This PR adds the baseline RAG pipeline for FunSQL.jl workflow support (Deliverable #1 from the GSoC proposal).

New Modules

  • src/ingestion.jl — Document loading, chunking via TextChunker, and ChunkEmbeddingsIndex building via RAGTools
  • src/grounding.jl — Registers :FunSQLQueryGeneration and :FunSQLQueryDirect templates with curated system prompts encoding FunSQL syntax, OMOP CDM schema, and response format rules
  • src/pipeline.jl — Orchestration layer: setup_grounding_index(), answer_question() (RAG), answer_question_direct() (no-RAG baseline)

Grounding Corpus (docs/grounding/)

  • funsql_reference.md — Complete FunSQL.jl syntax reference with 15 translation patterns
  • omop_cdm_schema.md — 16 OMOP CDM tables with key columns and common query patterns
  • sql_to_funsql_patterns.md — 15 SQL→FunSQL translation patterns with before/after examples

Enhancements

  • src/query.jl — Refactored to use template-based generation, supports both RAG and direct (no-context) modes
  • Project.toml — Bumped PromptingTools/RAGTools compat range to allow HuggingFaceSchema

Bug Fixes

  • Removed duplicate load_huggingface_model method from utils.jl
  • Fixed Base.convert import conflict in database.jl / pgvector.jl

Demo

demo/basic_rag_pipeline.jl — Runnable end-to-end demo showing index building → RAG query → generated FunSQL


All 5 existing tests pass. Feature complete for the baseline — ingestion, grounding, prompt construction, retrieval, and generation are all wired together in a modular, provider-agnostic pipeline.

…gingFace model schema support

- Add ingestion.jl: document loading, chunking, RAGTools index building
- Add grounding.jl: curated FunSQL prompt template + OMOP/CDM schema corpus
- Add pipeline.jl: high-level orchestration (setup index, answer questions)
- Update query.jl: template-based generation with grounded FunSQL context
- Create docs/grounding/: FunSQL ref, OMOP schema, SQL-to-FunSQL patterns
- Add demo/basic_rag_pipeline.jl: end-to-end runnable demo
- Fix pre-existing bugs: duplicate load_huggingface_model, Base.convert import conflict
- Bump PromptingTools/RAGTools compat range for HuggingFaceSchema support
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.45033% with 306 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.89%. Comparing base (8c40129) to head (b96c8b4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/benchmark.jl 46.84% 118 Missing ⚠️
src/local.jl 7.24% 64 Missing ⚠️
src/ingestion.jl 0.00% 42 Missing ⚠️
src/pipeline.jl 0.00% 39 Missing ⚠️
src/huggingface.jl 34.09% 29 Missing ⚠️
src/query.jl 0.00% 13 Missing ⚠️
src/grounding.jl 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
+ Coverage   27.27%   31.89%   +4.62%     
==========================================
  Files           4       11       +7     
  Lines          88      533     +445     
==========================================
+ Hits           24      170     +146     
- Misses         64      363     +299     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add src/benchmark.jl: Benchmark module with run_zeroshot() and run_rag()
- Add scripts/run_benchmark.jl: runnable script with CLI args
- Benchmark evaluates model-generated FunSQL by executing against DuckDB
- Tolerant DataFrame comparator for result validation
- Loads FunSQLQueries dataset and Synthea DuckDB automatically
…omparison runner

- compute_retrieval_stats: tracks chunk counts, unique sources, embedding score distributions
- compute_detailed_metrics: accuracy, parse/execution success rates, per-query-group breakdown, error type classification
- compute_comparison: side-by-side zero-shot vs RAG with accuracy delta and per-query agreement
- run_rag captures full RAGResult (sources, candidate scores) via return_all=true
- run_zeroshot updated to track parse_ok/exec_ok separately from final result match
- run_comparison convenience function runs both modes and compares
- CLI updated with comparison mode and rich metric display
- 28 new tests for all metric functions
Resolved merge conflicts:
- Keep all deps from both sides in Project.toml
- Keep all source includes in HealthLLM.jl (embedding.jl removed, build_index_rag moved to utils.jl)
- Keep pgvector.jl module, database.jl uses it
- Include both benchmark_metrics_test.jl and utils_tests.jl in runtests.jl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant