06Team Member
StatLens
AI-Powered Statistical Data Query Engine
- Role
- Backend Developer / Full-Stack Data Engineer – Team Member
- Stack
- PythonFastAPIPostgreSQLpgvectorReactNext.jsOpenAI GPT
- Links
- Private / internal
Overview
A natural-language query engine for government statistics: users ask questions like “GDP by state” and receive structured, cited answers backed by hybrid search and an LLM query pipeline.
Problem
Government statistics are spread across many sources; users should be able to ask a question like “GDP by state” and get a structured, cited answer.
Solution
A natural-language query engine: a 10-phase ingestion pipeline normalizes datasets from 10+ sources, hybrid search (pgvector + BM25) finds relevant datasets, and an LLM pipeline decomposes the question, fetches data and writes a cited answer.
Architecture
- Next.js / React UI
- FastAPI
- Query pipeline — decompose → select datasets → fetch → answer (OpenAI GPT)
- hybrid search
- PostgreSQL + pgvector
- BM25 keyword search
- Precomputed query slices
- 10-phase ingestion
- 10+ sources — Census, WHO, World Bank, …
Features
- Natural-language statistical queries
- Multi-stage data ingestion
- 10+ global data sources
- Hybrid search
- pgvector
- BM25
- LLM-powered query pipeline
- Dataset discovery
- Query decomposition
- Real-time data retrieval
- Precomputed query slices
- OpenTelemetry monitoring
Engineering work
- Architected a natural language query engine for government statistics, returning structured, cited answers.
- Built a multi-stage data ingestion pipeline (10 phases) to collect and normalize datasets from 10+ global data sources (Census, WHO, World Bank, etc.).
- Implemented hybrid search (semantic + keyword) using pgvector + BM25 for fast and accurate dataset discovery across millions of records.
- Developed an LLM-powered query pipeline that decomposes user queries, selects relevant datasets, fetches real-time data, and generates human-readable insights.
- Designed precomputed query “slices” to reduce latency for frequently asked statistical queries.
- Integrated OpenTelemetry and monitoring tools for tracking LLM usage, latency, and system performance.
Engineering decisions
- 1Hybrid search — semantic (pgvector) plus keyword (BM25) — for dataset discovery.
- 2Precomputed query “slices” to cut latency on frequently asked questions.
- 3OpenTelemetry for tracking LLM usage, latency and system performance.
Code
search/hybrid.pypython
def find_datasets(question: str, k: int = 20): semantic = vector_search(embed(question), limit=50) # pgvector keyword = bm25_search(question, limit=50) # BM25 # combine both rankings into one ordered list return merge_rankings(semantic, keyword)[:k]Screens
Challenges
- Fast, accurate dataset discovery across millions of records.