Rxrohans/PayLens-Dev
<div align="center">
π³ PayLens
AI-powered payment fee explainer
    
"Why did PayPal deduct 7% from my payment?" β PayLens tells you exactly why, and what to do about it.
[β Try the live demo](https://huggingface.co/spaces/Rxrohans/paylens)
</div>
π― The Problem
You see USD 500 in your PayPal. Quick mental math β that's around βΉ41,500 at today's rate. You're happy. Then the money actually arrives. βΉ38,200. You got βΉ3,300 less and you have no idea why. Transaction fee? Currency conversion markup? Some hidden platform charge? The app doesn't explain it clearly. The terms are a bit complex. You're just... sad. PayLens tells you exactly what happened β how much each platform deducted, why, and what you can do differently next time.
PayLens solves this. Just Ask, get a clear answer
Example questions it answers:
- "Why did PayPal charge me 7-8% when I received money from Outlier?"
- "What is the difference between NEFT and IMPS?"
- "Do I need to pay GST on my freelance income from abroad?"
- "How does currency conversion spread work?"
- "Is UPI free for merchants in India?"
ποΈ System Architecture
User Question
β
βββββββββββββββββββββββββββββββ
β INPUT GUARDRAILS β
β β’ PII detection β
β β’ Prompt injection check β
β β’ Topic relevance filter β
β β’ Length validation β
βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββ
β FAISS SEMANTIC RETRIEVAL β
β β’ all-MiniLM-L6-v2 embeds β
β β’ Top-7 chunk retrieval β
β β’ Cosine similarity search β
βββββββββββββββββββββββββββββββ
β
Confidence score >= 0.60?
β β
YES NO
β β
β βββββββββββββββββββββββ
β β DUCKDUCKGO SEARCH β
β β Live web results β
β βββββββββββββββββββββββ
β β
ββββββββββ¬ββββββββββββ
β
βββββββββββββββββββββββββββββββ
β LLM SYNTHESIS β
β β’ Llama 3.1 via Groq β
β β’ Two prompt variants β
β (RAG-only / Hybrid) β
β β’ temperature=0 β
βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββ
β OUTPUT GUARDRAILS β
β β’ Hallucination detection β
β β’ PII redaction from logs β
β β’ Confidence classificationβ
βββββββββββββββββββββββββββββββ
β
Structured Answer
+ Source badges
+ Confidence badge
+ Official links
+ JSONL audit log⨠Features
Core
Safety & Compliance
Evaluation
π§ Knowledge Base
6 curated domain files totalling 150+ indexed chunks:
All sources documented in `data/SOURCES.md`.
Live web search (DuckDuckGo) handles questions outside the KB β no API key required.
π οΈ Tech Stack
π Evaluation Results
First eval run β 20 questions, March 2026
Note: Faithfulness and Relevancy use keyword overlap scoring which underreports paraphrasing LLMs. A human evaluation of the same answers would score significantly higher. Context Coverage is the most reliable metric for this system.
Run your own evaluation:
python eval/ragas_eval.pyπ Project Structure
paylens/
β
βββ src/ β Python source
β βββ app.py β Streamlit UI (tabs: Ask / Eval Dashboard)
β βββ chain.py β Hybrid RAG + web search logic
β βββ retriever.py β FAISS semantic search
β βββ embedder.py β Builds vector store from chunks
β βββ chunker.py β Splits raw docs into chunks with metadata
β βββ ingestor.py β Fetches/loads raw documents
β βββ guardrails.py β PII detection + injection prevention
β
βββ eval/ β Evaluation pipeline
β βββ ragas_eval.py β Runs eval, saves scores
β βββ metrics_dashboard.py β Dashboard UI (embedded as app tab)
β βββ golden_dataset.json β 20 verified Q&A pairs
β βββ scores_history.json β Score history (auto-generated)
β
βββ data/
β βββ raw/ β Knowledge base source files
β βββ processed/ β Auto-generated, gitignored
β β βββ chunks.json β Chunked documents with metadata
β β βββ faiss_index.bin β FAISS vector index
β β βββ chunk_metadata.pkl β Chunk source/score metadata
β βββ SOURCES.md β Data lineage registry
β
βββ logs/ β Auto-generated, gitignored
β βββ answers.jsonl β Full audit log of every query
β βββ chain.log β System logs
β
βββ .gitignore β Excludes venv, .env, index, logs
βββ .env β API keys (gitignored)
βββ env.example β Safe template for .env
βββ requirements.txt β Python dependencies
βββ packages.txt β HuggingFace Linux deps (libgomp1)
βββ README.md β This file (also HuggingFace Space config)π Run Locally
# 1. Clone
git clone https://github.com/Rxrohans/paylens
cd paylens
# 2. Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Mac/Linux
# 3. Install dependencies
pip install -r requirements.txt
# 4. Add your free Groq API key
# Get one at: console.groq.com (free, no credit card)
cp env.example .env
# Edit .env: GROQ_API_KEY=your_key_here
# 5. Build knowledge base index
python src/chunker.py
python src/embedder.py
# 6. Launch
streamlit run src/app.py
# Opens at http://localhost:8501π Adding New Knowledge
No code changes needed:
# 1. Add your .txt file
nano data/raw/new_topic.txt
# 2. Document it
nano data/SOURCES.md
# 3. Rebuild index (2 commands)
python src/chunker.py
python src/embedder.py
# New knowledge is live immediatelyπ§ Swapping the LLM
One line change in src/chain.py:
# Current (fastest, 14,400 req/day free)
model="llama-3.1-8b-instant"
# Smarter answers (1,000 req/day free)
model="llama-3.3-70b-versatile"
# Latest Llama 4 (1,000 req/day free)
model="meta-llama/llama-4-scout-17b-16e-instruct"πΊοΈ Roadmap
- [ ] Section-header based chunking (better than fixed-size for structured docs)
- [ ] Embedding similarity eval (more accurate than keyword overlap)
- [ ] Paytm, CCAvenue, PayU fee structures
- [ ] Southeast Asia + Middle East payment systems (Pine Labs markets)
- [ ] Conversation memory for multi-turn questions
- [ ] Query latency optimisation (cache frequent questions)
- [ ] Cost tracking per query
π€ Author
Rohan Singh
 
π License
MIT β see LICENSE for details.
