|
Download PROJECT_SPEC.md from h-murai/FedInsight: direct link, hf CLI and curl.
- Browser
- Download file 5.73 kB
-
https://huggingface.co/h-murai/FedInsight/resolve/main/PROJECT_SPEC.md
- Command line
-
hf download hf://h-murai/FedInsight/PROJECT_SPEC.md
-
curl -L -o PROJECT_SPEC.md https://huggingface.co/h-murai/FedInsight/resolve/main/PROJECT_SPEC.md
5.73 kB
| # FedInsight β Project Specification & Architecture | |
| ## 1. Project Goal | |
| A RAG (Retrieval-Augmented Generation) system for working with U.S. Federal | |
| Reserve communications. It: | |
| - Collects Fed documents (FOMC Minutes today; Beige Book, speeches, SEP planned) | |
| - Turns them into a searchable vector knowledge base | |
| - Answers natural-language questions with accurate quotes and source attribution | |
| - Runs fully locally (no mandatory API keys), or switches to a hosted LLM | |
| **Target audience**: quants, economists, traders, students, and monetary-policy | |
| researchers. | |
| ## 2. High-level Architecture | |
| ``` | |
| Raw PDFs (federalreserve.gov) | |
| β src/scraper/ requests + BeautifulSoup | |
| Scraper Layer | |
| β src/parser/ PyMuPDF (column-aware), pdfplumber fallback | |
| Parser + Cleaner | |
| β src/chunker/ RecursiveCharacterTextSplitter | |
| Chunker | |
| β src/embeddings/ sentence-transformers (CUDA / Apple MPS / CPU) | |
| Embedder | |
| β src/vectorstore/ pgvector (default) | ChromaDB | |
| Vector Store | |
| β src/rag/retriever cosine top-k + metadata filter | |
| Retriever | |
| β src/rag/rag_pipeline grounded prompt β LLM, cited sources | |
| RAG Pipeline | |
| β app.py Streamlit chat UI | |
| UI | |
| ``` | |
| ### Components & status | |
| | Layer | Technology | Status | Location | | |
| |-------------------|-------------------------------------|--------|-----------------------| | |
| | Scraper | requests + BeautifulSoup | β FOMC Minutes | `src/scraper/` | | |
| | Parser | PyMuPDF (+ pdfplumber fallback) | β | `src/parser/` | | |
| | Chunker | langchain-text-splitters | β | `src/chunker/` | | |
| | Embeddings | sentence-transformers `all-MiniLM-L6-v2` | β | `src/embeddings/` | | |
| | Vector DB | pgvector (default) / ChromaDB | β | `src/vectorstore/` | | |
| | Retriever | cosine top-k + metadata filter | β | `src/rag/retriever.py`| | |
| | RAG pipeline | OpenAI / Ollama / offline fallback | β | `src/rag/` | | |
| | UI | Streamlit | β | `app.py` | | |
| | Deployment | Docker β Hugging Face Spaces | β | `Dockerfile` | | |
| | Evaluation | retrieval metrics + RAGAS (optional)| β¬ planned | `eval/` (planned) | | |
| | Test suite | pytest | β¬ planned | `tests/` (planned)| | |
| ## 3. Data | |
| ### Sources (priority order) | |
| 1. **FOMC Minutes** β implemented (8 regular meetings/year + extraordinary) | |
| 2. **Beige Book** β planned | |
| 3. **FOMC Speeches** β planned | |
| 4. **Summary of Economic Projections (SEP)** β planned | |
| 5. **Monetary Policy Report**, **Financial Stability Report** β later | |
| ### Storage layout | |
| - `data/raw/fomc_minutes/YYYY-MM-DD_fomc_minutes.pdf` β downloaded PDFs | |
| - `data/processed/β¦` β scraper metadata + logs | |
| - Vectors: PostgreSQL/pgvector table `fed_chunks` (default), or on-disk Chroma | |
| at `data/chroma/` (used by the shipped/Hugging Face build) | |
| **Chunk metadata** (carried end-to-end into search results): `meeting_date`, | |
| `release_date`, `document_type`, `pdf_url`, `chunk_index`, `total_chunks`. | |
| > **Note:** the repo ships a prebuilt Chroma store (~4,075 FOMC chunks) but no | |
| > source PDFs. `scripts/migrate_chroma_to_pgvector.py` copies those vectors into | |
| > pgvector, so you get the full knowledge base without re-scraping. | |
| ## 4. Vector backends | |
| Two interchangeable backends implement one interface (`src/vectorstore/base.py`), | |
| selected by `VECTOR_BACKEND`: | |
| - **pgvector (default)** β PostgreSQL + pgvector. Strong metadata filtering | |
| (JSONB `@>`), SQL power, production-ready. Start locally with | |
| `docker compose up -d` (see `docker-compose.yml`). | |
| - **ChromaDB** β server-less, on-disk. Zero setup; used by the Hugging Face | |
| Space, which pins `VECTOR_BACKEND=chroma` in the `Dockerfile`. | |
| ## 5. Technical decisions | |
| - **Embeddings**: `all-MiniLM-L6-v2` (384-dim, fast). The embedder auto-selects | |
| the fastest device β **CUDA β Apple MPS β CPU** β and normalizes vectors for | |
| cosine similarity. Upgrade path: `bge-*` / `e5-*` (re-ingest required). | |
| - **LLM**: provider is `auto` β OpenAI if `OPENAI_API_KEY` is set, else a local | |
| Ollama server if reachable, else `none` (returns retrieved excerpts, fully | |
| offline). See `src/rag/llm.py`. | |
| - **Chunking**: 800-char chunks, 150-char overlap (tunable via ingest flags). | |
| ## 6. Development Roadmap | |
| - **Phase 0 β Initialization** β structure, scraper, requirements, docs | |
| - **Phase 1 β End-to-end skeleton** β parse β chunk β embed β store β retrieve β generate, both backends, Streamlit UI, Docker deploy | |
| - **Phase 2 β Retrieval quality** β¬ eval harness, hybrid (dense+BM25) search, reranking, better chunking *(see `plan.md`)* | |
| - **Phase 3 β UX & trust** β¬ source links/snippets, metadata filters in UI, faithfulness guardrails *(see `plan.md`)* | |
| - **Phase 4 β Coverage & hardening** β¬ more document types, incremental ingest, test suite, input/SQL hardening *(see `plan.md`)* | |
| ## 7. Project principles | |
| - **Skeleton first**: a working end-to-end flow before polishing parts (done). | |
| - **Observable**: good logging and progress bars (loguru + tqdm). | |
| - **Resumable**: scrapers and pipelines support resuming. | |
| - **Interchangeable backends**: nothing above the vector store knows which DB is in use. | |
| - **Clean & educational**: readable, well-documented code; English only. | |
| --- | |
| **Current status**: Phase 1 complete (end-to-end RAG on pgvector by default). | |
| Next: Phase 2 retrieval quality. See [plan.md](plan.md) for the detailed, | |
| prioritized next steps. | |