Inspiration

The inspiration for FinancialAI Agent came from witnessing the inefficiency in traditional financial document management. Financial professionals often spend hours searching through lengthy reports, handbooks, and compliance documents to find specific information. I wanted to create an intelligent system that could instantly understand and respond to financial questions by leveraging the power of vector search and AI, making financial knowledge more accessible and actionable.

What it does

FinancialAI Agent is a multi-step AI system that transforms static financial documents into an intelligent Q&A platform. It automatically processes financial documents (like Guide.docx), vectorizes them using OpenAI embeddings, and stores them in TiDB Serverless. When users ask financial questions, the system performs vector similarity search to find relevant document chunks, then uses OpenAI GPT-4 to generate contextual, accurate responses. Every interaction is logged in TiDB for audit trails and analytics.

How we built it

Built a 4-step agentic workflow using Python, TiDB Serverless, and OpenAI APIs. Created TiDB connection manager with SSL support, built document chunking pipeline using RecursiveCharacterTextSplitter, implemented custom cosine similarity search for TiDB vectors, developed RAG chain with financial-specific prompts, added comprehensive session management and logging, and created interactive terminal interface for user interaction.

Challenges we ran into

Vector Search in TiDB: Initially struggled with TiDB's vector storage format. Solved by storing vectors as JSON and implementing cosine similarity in Python. Document Chunking: Financial documents have complex structures with tables and cross-references. Had to experiment with chunk sizes and overlap to preserve context. Performance Optimization: Ensuring sub-second search while maintaining accuracy required careful optimization of vector storage and retrieval algorithms. Error Handling: Coordinating multiple systems (TiDB, OpenAI, LangChain) required robust error recovery and comprehensive logging.

Accomplishments that we're proud of

  • Complete Agentic Workflow: Successfully built a true multi-step AI agent that chains data ingestion, search, AI processing, and logging
  • TiDB Vector Search Integration: Implemented efficient vector similarity search using TiDB's capabilities
  • Real-time Performance: Achieved sub-second search performance with high accuracy
  • Comprehensive Logging: Built complete audit trails for all system interactions
  • Production-Ready Code: Created robust error handling and user feedback mechanisms
  • Hackathon Compliance: Met all required building blocks for the TiDB AgentX Hackathon

What we learned

  • Vector Search Optimization: Mastered cosine similarity implementation and vector storage strategies
  • Document Processing: Learned advanced techniques for chunking complex financial documents
  • AI Orchestration: Gained expertise in chaining multiple AI operations seamlessly
  • Database Design: Designed comprehensive schemas for tracking interactions and analytics
  • TiDB Integration: Deep understanding of TiDB Serverless vector capabilities and connection management

What's next for FinancialAI Agent - Intelligent Document Processing System

Short-term: Add support for multiple document formats (PDF, Excel, PowerPoint), implement user authentication and role-based access, create a web interface for better user experience, add real-time document updates and re-vectorization.

Medium-term: Integrate with external financial data sources (APIs, databases), add advanced analytics dashboard for usage patterns, implement multi-language support for global financial teams, add voice interface for hands-free financial queries.

Long-term: Deploy as a cloud service for enterprise customers, integrate with popular financial software (QuickBooks, SAP), add predictive analytics for financial trend analysis, develop mobile app for on-the-go financial insights.

Built With

  • docx2txt
  • git
  • gpt-4
  • langchain
  • openai
  • recursivecharactertextsplitter
  • tidb
Share this project:

Updates