RAG

401(k) RAG Advisor

Hybrid RAG + text-to-SQL system for querying retirement plan documents and fund data in plain English.

Overview

A RAG pipeline that answers natural language questions about 401(k) plans. It classifies queries into plan rules (searches PDF documents), fund data (SQL translation), or hybrid approaches. Built using ChromaDB for vector storage and lightweight local LLMs via LM Studio.

The Problem

401(k) plans are complex. Between the Summary Plan Description, fee disclosures, and fund prospectuses, understanding your options requires reading hundreds of pages of dense legal and financial text. Most people don’t, and end up making suboptimal decisions about one of their largest financial assets.

Architecture

The system handles three types of questions:

TypeWhat it answersHow it works
Plan RulesVesting, contributions, withdrawals, eligibilitySearches plan documents (PDFs)
Fund DataFees, returns, fund comparisonsQueries structured fund data (SQL)
Combined”I’m 30, which target-date fund should I pick?”Uses both, merges the answer

Two-tier classification

Instead of calling the LLM for every query, the classifier first checks against 70+ keyword patterns. This handles ~80% of questions instantly. The LLM only kicks in for ambiguous cases.

Domain term injection

Before searching the vector database, the system adds relevant 401(k) vocabulary to the query. This bridges the gap between how users ask questions (“Can I buy stocks directly?”) and how plan documents are written (“self-directed brokerage window”).

Graceful fallbacks

If SQL generation fails, the system falls back to RAG search. If classification is uncertain, it defaults to RAG. The user always gets an answer.

Highlights

  • Two-tier classification handles 80% of queries instantly via keyword patterns
  • Hybrid retrieval combining PDF search and SQL translation for fund data
  • Domain term injection enhances search with 401(k) vocabulary
  • Graceful fallbacks when SQL generation fails

Interested in learning more?

Check out my other projects or get in touch.