An intelligent full-stack insurance claim decision-making system that combines FastAPI backend with React TypeScript frontend, powered by Hugging Face Transformers and Gemma LLM. This AI agent analyzes insurance clauses and customer queries to predict whether a claim should be Approved or Rejected, along with justification and estimated amounts.
- β¨ Uses llama-3.3-70b-versatile large language model
- π Parses PDF policy documents using
PyMuPDF - π€ Uses NLP to analyze user queries against insurance clauses
- π FAISS vector search with Sentence Transformers for efficient clause retrieval
- π₯ Supports both local inference and Hugging Face Inference API and Groq API
- β‘ Fast API backend with clean REST endpoints
- π¨ Modern React UI built with TypeScript, Tailwind CSS, and ShadCN UI
- π€ Drag-and-drop PDF upload functionality
- π¬ Interactive query interface for claim analysis
- π Visual display of matched clauses and AI reasoning
- π― Real-time claim decision results with justification
-
PDF Document Upload & Processing:
- Users upload insurance policy documents via the React frontend
- The backend parses PDFs using
PyMuPDFand extracts relevant clauses - Clauses are indexed using FAISS for efficient similarity search
-
User Query Processing:
- Users submit natural language queries like: "I underwent surgery after 14 months of policy"
- The system retrieves the most relevant clauses using vector similarity
-
AI-Powered Decision Making:
- Query and matched clauses are processed by the llama-3.3-70b-versatile using Groq
- The model returns structured JSON output with decision, amount, and justification
-
Results Display:
- Frontend displays the AI decision with matched clauses and reasoning
- Users can review the complete analysis workflow
- FastAPI - High-performance web framework
- Hugging Face Transformers - LLM integration
- PyMuPDF - PDF parsing
- FAISS - Vector similarity search
- Sentence Transformers - Text embeddings
- Llama-3.3-70B-Versatile - Language model for reasoning via Groq API
- Groq - Ultra-fast LLM inference platform
- React with TypeScript - Component-based UI
- Tailwind CSS - Utility-first styling
- ShadCN UI - Modern component library
- Vite - Fast build tool
- Node.js (v16+) and npm
- Python (3.8+)
- Git
- Clone the repository:
git clone
cd insurance-ai-agent- Install Python dependencies:
pip install -r requirements.txt**********Step 3 & 4 to run Gemma 1B/2B Locally**********
- For GPU users (CUDA 12.1):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121- For CPU-only users:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu- Start the FastAPI server:
uvicorn main:app --reloadThe backend will be available at http://localhost:8000
- Navigate to frontend directory:
cd frontend # or wherever your React app is located- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will be available at http://localhost:8080
fastapi==0.104.1
uvicorn==0.24.0
pydantic==2.5.0
huggingface_hub==0.19.0
transformers==4.35.0
torch==2.1.0
PyMuPDF==1.23.0
sentence-transformers==2.2.2
faiss-cpu==1.7.4
numpy==1.24.0
groq==0.4.1
- React 18+
- TypeScript
- Tailwind CSS
- ShadCN UI components
- Vite
Upload and process insurance policy PDF documents.
Request: Multipart form data with PDF file Response: Confirmation of successful processing
Analyze insurance claims against uploaded policies.
Request:
{
"user_query": "I was hospitalized 10 months after starting the policy."
}Response:
{
"result": {
"decision": "Rejected",
"amount": "N/A",
"justification": "Hospitalization occurred before the 12-month waiting period.",
"matched_clauses": ["Policy allows hospitalization claims only after 12 months..."]
}
}Interactive API documentation (Swagger UI)
-
Upload Policy Document:
- Open the React frontend at
http://localhost:8080 - Drag and drop your insurance policy PDF
- Wait for processing confirmation
- Open the React frontend at
-
Submit Claim Query:
- Enter your claim details in natural language
- Example: "I need surgery coverage after 15 months of active policy"
-
Review AI Decision:
- See the AI's decision (Approved/Rejected)
- Review matched policy clauses
- Read the detailed justification
You can also test the backend directly:
# Test the API with curl
curl -X POST "http://localhost:8000/query" \
-H "Content-Type: application/json" \
-d '{"user_query": "I underwent surgery after 14 months of policy"}'HackRX/
βββ Backend-ai/
β βββ main.py # FastAPI application
β βββ logic.py # Claim processing logic
β βββ requirements.txt # Python dependencies
β βββ policy_clause.pdf # Sample policy document
βββ Frontend/
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Main application pages
β β βββ App.tsx # Root component
β β βββ main.tsx # Application entry point
β βββ package.json # Node.js dependencies
β βββ tailwind.config.js # Tailwind configuration
βββ README.md # This file
βββ .gitignore # Git ignore rules
Create a .env file in the backend directory:
HUGGINGFACE_TOKEN=
GROQ_API_KEY=Update API base URL in src/config.ts if needed:
export const API_BASE_URL = 'http://localhost:8000';For production deployment, consider:
- Docker containerization:
FROM python:3.9
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]- Cloud platforms: Railway, Heroku, AWS, or Google Cloud
- Build for production:
npm run build- Deploy static files to Vercel, Netlify, or any static hosting service
- Primary Model:
google/gemma-1.1-2borgoogle/gemma-1.1-1b - Embeddings:
sentence-transformers/all-MiniLM-L6-v2 - Vector Search: FAISS with cosine similarity
- Local Inference: No internet required for basic functionality
- Fallback: Hugging Face Inference API support
- Enhanced PDF parsing for complex documents
- Multi-language support
- Improved error handling and validation
- User authentication system
- Multi-agent system for complex claims
- Integration with external insurance APIs
- Advanced fraud detection capabilities
- Mobile application support
- Real-time collaboration features
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page for existing solutions
- Create a new issue with detailed information
- Join our Discussions for community support
- Faster Processing: Reduce claim processing time from days to minutes[1][6]
- Improved Accuracy: AI-powered analysis reduces human error in claim decisions[8][12]
- Cost Effective: Automate up to 50% of claims processing tasks[6]
- Scalable: Handle increasing claim volumes without proportional staff increases[8]
- Transparent: Clear justifications for every AI decision[10]
- User-Friendly: Intuitive interface for both technical and non-technical users[2]
Built with β€οΈ for the future of insurance technology
[1] https://huggingface.co/spaces/anoopreddyyeddula/Automated-Insurance-Claim-Validation-System/tree/main [2] https://www.kdnuggets.com/a-simple-to-implement-end-to-end-project-with-huggingface [3] https://huggingface.co/harshita23sh/setfit-model-intent-classification-insurance [4] https://towardsdatascience.com/building-nlp-powered-applications-with-hugging-face-transformers-9f561effc84f/ [5] https://railway.com/deploy/z52Exi [6] https://www.lyzr.ai/blog/ai-agents-for-insurance-claims/ [7] https://intellisqr.com/consulting-services/ai-solution-development [8] https://intellias.com/ai-agents-for-insurance/ [9] https://github.com/Michael95-m/API-for-insurance-claim-model [10] https://www.domo.com/glossary/insurance-ai-agents [11] https://5ly.co/blog/ai-tech-stack/ [12] https://www.rapidinnovation.io/post/ai-agents-for-claims-workflow [13] https://www.damcogroup.com/blogs/ai-agents-in-insurance-intelligent-leap-beyond-traditional-chatbots [14] https://markovate.com/intelligent-agents-for-insurance/ [15] https://huggingface.co/datasets/OpenLeecher/lmsys_chat_1m_clean/viewer/default/train [16] https://www.tcs.com/what-we-do/industries/insurance/white-paper/ai-agents-insurance-claims-function [17] https://developers.cloudflare.com/developer-platform/llms-full.txt [18] https://huggingface.co/datasets/shalabh05/shalabh_most_updated/viewer