FinBrief RAG — Source-Grounded Financial News Q&A Prototype
An applied RAG prototype featuring multi-URL ingestion, recursive chunking, FAISS retrieval and source attribution—presented here as a curated, read-only inspection sandbox with live LLM queries and URL fetching disabled.

Financial News Overload & Generative Hallucinations
Financial analysts spend hours cross-referencing multi-source press releases, earnings reports, and macroeconomic commentary. When teams consult generic LLMs, they encounter uncalibrated hallucinations—models fabricating quarterly figures and misattributing executive commentary. FinBrief RAG constrains responses strictly to retrieved passages, enforcing transparent URL source attribution on every synthesized claim.
Deterministic 5-Stage Retrieval Pipeline
To provide verifiable financial analysis, I built an end-to-end question-answering prototype organized into 5 sequential processing phases:
- Concurrent Source Ingestion: Ingests up to 3 article URLs, stripping boilerplate HTML, navigation elements, and scripts.
- Recursive Text Chunking: Segments unstructured text into 1,000-character windows with 200-character overlap to preserve semantic boundaries.
- Dense Vector Retrieval: Embeds chunks into dense vectors and builds an in-memory FAISS similarity index for low-latency matching.
- Source-Attributed Synthesis: Formulates retrieval-augmented prompts that map synthesized answers directly to source URLs.
Tools & Frameworks
Strict Grounding & Hallucination Suppression
Evaluating the prototype across financial news articles demonstrated strong grounding performance:
Zero Uncited Claims
Every factual assertion in the synthesized answer is grounded directly in retrieved chunks with clickable source URLs.
Strict Context Bounding
When user questions cannot be answered from ingested articles, the system explicitly reports insufficient information.
Audit Disclosures & Security Boundaries
- !Prototype Status & Security Remediation: Public demo operates in curated read-only mode; Live LLM question answering, unrestricted URL ingestion, and paid OpenAI execution remain disabled.
- !Local In-Memory Scope: The FAISS index is serialized in-memory per session rather than a managed distributed vector database.
Pipeline Implementation & Security Remediation
Click below to review the 5-step pipeline architecture, LangChain Python implementation, and security remediation findings.
ArchitectureThe 5-Step RAG Execution WorkflowDetails
Multi-URL Ingestion
Accepts up to 3 concurrent financial article URLs, validating protocol schemes and stripping extraneous quote formatting.
HTML DOM Extraction
Fetches remote web pages, strips navigation scripts, headers, and CSS stylesheets, isolating raw article body paragraphs.
Recursive Chunking
Segments unstructured text into 1,000-character windows using hierarchical separators (\n\n, \n, '.', ',') to preserve semantic sentences.
Vector Embedding & FAISS Index
Generates dense vector embeddings for all text chunks and builds a local FAISS similarity index persisted to vector_index_data/.
Source-Attributed Synthesis
Queries the vector index for top similarity matches, constructs an augmented prompt, and outputs an answer with explicit URL citations.
# 1. Ingest up to 3 financial article URLs
loader = UnstructuredURLLoader(urls=urls)
data = loader.load()
# 2. Split into 1,000-character overlapping chunks
text_splitter = RecursiveCharacterTextSplitter(
separators=['\n\n', '\n', '.', ','],
chunk_size=1000
)
docs = text_splitter.split_documents(data)
# 3. Vectorize and build local FAISS similarity index
embeddings = OpenAIEmbeddings()
vectorstore_openai = FAISS.from_documents(docs, embeddings)
vectorstore_openai.save_local("vector_index_data")
# 4. Query vector index with RetrievalQAWithSourcesChain
chain = RetrievalQAWithSourcesChain.from_llm(
llm=OpenAI(temperature=0.9, max_tokens=500),
retriever=vectorstore.as_retriever()
)
result = chain({"question": query}, return_only_outputs=True)
answer = result["answer"]
sources = result.get("sources", "")AuditSecurity Remediation & Public Demo StatusDetails
Security Remediation & Public Demo Status
Our technical audit identified critical security vulnerabilities in the legacy prototype that prevent hosting an un-sandboxed public demo:
Line 27 wrote st.write(f"API Key Retrieved: {api_key}") directly to the user-facing DOM for debugging purposes, leaking active credentials to client browsers.
FAISS loaded pickled index files with allow_dangerous_deserialization=True, opening remote code execution vulnerabilities if malicious index artifacts were processed.
Proposed Future Direction (Phase 4 Roadmap Concept)
Full production hardening mandates removing debug statements, strictly managing API credentials via server-side environment variables, replacing local pickle files with managed vector databases (Pinecone or pgvector), and sandboxing remote web loaders against SSRF attacks. The prototype currently requires multi-issue remediation covering credential handling, unsafe deserialization, unrestricted URL fetching, and rate/abuse controls before public reactivation.
Explore FinBrief RAG in the Curated Sandbox
The curated, read-only RAG inspection sandbox is available for examining verified source documents, stored chunks, and the audited retrieval architecture. Features 10 verified document chunks (FAISS index vector count unavailable for offline serialized index).