CFA2 Helper
A lightweight end-to-end RAG study assistant for CFA Level II preparation — built from scratch: PDF ingestion, hybrid retrieval with reranking, grounded answer generation with citations, and a web UI. Answers in Chinese or English, at ~2 seconds per query, entirely on local models except the LLM call.
Answers You Can Check
CFA Level II spans thousands of pages of curriculum. Off-the-shelf assistants hallucinate and cite nothing. This project builds the retrieval pipeline from scratch so every answer is grounded in the study corpus and cites its source down to the passage level — with an optional "genetic" mode that explains how each concept was discovered historically.
From PDF to Cited Answer
PDFs converted to retrieval-friendly Markdown with YAML metadata (pymupdf4llm); corpus chunked by paragraph with sentence-boundary fallback for long blocks.
BM25-style keyword search (IDF-weighted unigrams + bigrams) fused with multilingual dense embeddings (bge-m3) via reciprocal rank fusion — ~1s per query.
Top-20 candidates precision-reranked by a cross-encoder (bge-reranker-v2-m3).
DeepSeek API (OpenAI-compatible) with strict anti-hallucination prompting, passage-level citations [P1234], and a notes-first / web-supplements rule; optional live web search.
Streamlit web UI or CLI; filter by topic or corpus and boost a preferred source (e.g. official curriculum over prep notes).
Measured Retrieval Quality
40-Question Golden Set · 10 CFA Topics
Evaluation is built into the pipeline: 40 golden questions with expected sources labeled, hit@k and MRR metrics, and rerank ablation. Multilingual retrieval handles questions in either language across three corpora (English prep notes, English official curriculum, Chinese textbook).
The copyrighted study corpora are intentionally not included; the repo ships a small original demo corpus so the pipeline runs out of the box. The project deck (7 slides) covers design decisions, pitfalls found and fixed, and measured results.