AI/ML2025

Investment Research Assistant

Investment Research Assistant
Investment Research Assistant is a production-ready RAG (Retrieval Augmented Generation) system that enables portfolio managers and investors to quickly query financial documents using natural language.

Built with FastAPI, Next.js, Pinecone, OpenAI, and Cohere, the system features:
- Hybrid Search: Combines semantic search (conceptual understanding) with keyword search (exact term matching) for more accurate results
- Cohere Reranking: Optional reranking improves result quality by reordering search results by relevance before generating answers
- Query Analysis: Automatically detects multi-part questions and comparison queries, improving answer quality for complex questions
- Smart Source Filtering: Only displays sources with relevance scores above 30% to reduce noise and improve answer quality
- Source Citations: Every answer includes citations with document names, page numbers, relevance scores, and search method indicators (semantic/keyword/hybrid)
- Multi-Company Support: Query documents from multiple companies (Apple, Microsoft, etc.) and compare results across companies
- Document Management: View and download uploaded financial documents
- Production Security: API key authentication, rate limiting, cost tracking, and prompt injection protection

The system demonstrates practical RAG implementation for financial document analysis, making it easy for investors to extract insights from lengthy SEC filings and earnings reports.

Business Case

Portfolio managers and investment analysts spend countless hours reading through SEC filings, earnings reports, and other financial documents to extract key insights. A single 10-K filing can be hundreds of pages long, making it time-consuming to find specific information about revenue, risks, cash positions, or other critical metrics.

Investment Research Assistant addresses this challenge by using RAG (Retrieval Augmented Generation) to enable natural language queries across financial documents. Analysts can ask questions like "What is Apple's revenue?" or "What are the main risks?" and get instant answers with source citations, dramatically reducing research time.

Key Business Value:
- Time Savings: Reduces research time from hours to minutes for common questions
- Accuracy: Citations ensure transparency and enable fact-checking
- Scalability: Can process thousands of documents without performance degradation
- Accessibility: Natural language interface makes complex financial data accessible to all team members
- Cost Efficiency: Enables smaller teams to compete with larger firms' research capabilities

Who Should Use This?

Portfolio Managers: Investment professionals who need to quickly extract insights from financial documents to make informed investment decisions.

Investment Analysts: Research analysts who spend significant time reading SEC filings and earnings reports, looking for ways to accelerate their workflow.

Investment Research Teams: Teams at asset management firms, hedge funds, and investment banks who need efficient tools for document analysis.

Financial Advisors: Advisors who need to quickly understand company fundamentals when advising clients on investment decisions.

FinTech Companies: Companies building tools for financial professionals who want to integrate RAG capabilities into their platforms.

Technologies Used

PythonFastAPINext.jsTypeScriptPineconeOpenAICohereTailwind CSSRailwayVercel

Challenges & Solutions

Pinecone Dimension Mismatch: Initially encountered a dimension mismatch error when switching embedding models. The Pinecone index was created with 1536 dimensions but the new model (text-embedding-3-large) requires 3072 dimensions. Solution: Implemented dynamic dimension detection based on embedding model and added force_recreate option to rebuild the index with correct dimensions.

Document Listing Reliability: The initial implementation used a zero vector query to fetch documents, which wasn't reliable. Solution: Changed to use a meaningful query ("financial document company") embedded through the embedding service to get diverse results from Pinecone.

CORS Configuration: Needed to coordinate CORS between Railway backend and Vercel frontend with proper domain configuration. Solution: Implemented dynamic CORS configuration that reads from environment variables, allowing easy updates for new deployments.

Document Status Display: Documents found in Pinecone were showing as "missing" because files don't exist on Railway's filesystem. Solution: Updated logic to always mark documents found in Pinecone as "available" since they're accessible via the vector database.

Environment Variable Build-Time Embedding: Next.js embeds NEXT_PUBLIC_* variables at build time, requiring rebuilds when environment variables change. Solution: Documented the need for redeployment after environment variable changes in Vercel.

Future Buildouts & Next Steps

Query Decomposition: Implement query decomposition for complex questions, breaking them into sub-queries and combining results for more comprehensive answers. Current query analysis detects multi-part questions, but full decomposition would execute separate queries and merge results.

Document Upload UI: Build a document upload interface allowing users to add new financial documents directly through the web interface (currently requires running setup script).

Conversation History: Add persistent conversation history so users can refer back to previous queries and build on previous insights.

Advanced Filtering: Add filters for document type (10-K, 10-Q, 8-K), date ranges, and company names to narrow search scope.

Export Functionality: Allow users to export conversations and citations to PDF or CSV for reporting and documentation.

User Authentication: Add user accounts to enable personalized document collections and saved searches.

Streaming Responses: Implement streaming responses for real-time answer generation, improving perceived performance.

Cost Analytics Dashboard: Add a dashboard showing usage statistics, cost breakdowns, and query analytics for administrators.

Screenshots

Investment Research Assistant screenshot 1
Investment Research Assistant screenshot 2