Case Study · Applied LLM & RAG SystemsPrototypeLive API Remediation RequiredCurated Sandbox Available

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.

Source Ingestion
Up to 3 URLs
Concurrent financial web ingestion
Semantic Window
1,000 Chars
Recursive boundary segmentation
Vector Similarity
FAISS Index
Local dense vector retrieval
Original Live API Status
Remediation Req.
Offline sandbox active
FinBrief RAG InterfaceSource-Grounded Vector Q&A
FinBrief RAG financial Q&A interface with source citations and vector chunk inspector
Problem Addressed

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.

Architecture & Implementation

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.
Technology Stack

Tools & Frameworks

Python 3.10LangChainFAISS (Vector Search)OpenAI EmbeddingsStreamlitUnstructuredURLLoaderRecursiveCharacterTextSplitterRetrievalQAWithSourcesChain
Verified Results

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.

Limitations

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.
Technical Deep Dive

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 Workflow
01Stage

Multi-URL Ingestion

Streamlit Sidebar

Accepts up to 3 concurrent financial article URLs, validating protocol schemes and stripping extraneous quote formatting.

02Stage

HTML DOM Extraction

UnstructuredURLLoader

Fetches remote web pages, strips navigation scripts, headers, and CSS stylesheets, isolating raw article body paragraphs.

03Stage

Recursive Chunking

RecursiveCharacterTextSplitter

Segments unstructured text into 1,000-character windows using hierarchical separators (\n\n, \n, '.', ',') to preserve semantic sentences.

04Stage

Vector Embedding & FAISS Index

OpenAIEmbeddings + FAISS

Generates dense vector embeddings for all text chunks and builds a local FAISS similarity index persisted to vector_index_data/.

05Stage

Source-Attributed Synthesis

RetrievalQAWithSourcesChain

Queries the vector index for top similarity matches, constructs an augmented prompt, and outputs an answer with explicit URL citations.

LangChain Execution Core (app.py)Python 3.10 · FAISS · OpenAI
# 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 Status

Security Remediation & Public Demo Status

Our technical audit identified critical security vulnerabilities in the legacy prototype that prevent hosting an un-sandboxed public demo:

Plaintext API Key Output (Line 27)

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.

Unsafe Deserialization

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.

Interactive Playground Operational

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).

Explore Verifiable RAG Sandbox →