โ† Back to Projects
Production AI Platform ๐Ÿš€Bilingual AI & ML

AI Discovery Monitor โ€” GEO Platform

8-stage asynchronous AI analysis pipeline executing structured multi-LLM workflows, bilingual Arabic/English entity resolution with trigram indexing, and automated hallucination verification against knowledge graphs.

PythonFastAPILangGraphPostgreSQLpgvectorRedisDockerStatus: Completed ๐Ÿš€Duration: 3 WeeksRole: AI & ML Engineer
๐Ÿ’ป GitHub Repository โ†—
8 Tasks
Pipeline Stages
78.5%
Trigram Accuracy
1.2s
p95 Latency
4 Models
LLMs Integrated

1. The Problem & Motivation

Building production platforms like AI Discovery Monitor โ€” GEO Platform introduces critical engineering constraints around real-time data ingestion, high token inference overheads, and maintaining tight SLA latency bounds under unpredictable traffic spikes.

โšก Core Bottleneck: Standard architectures suffered from runtime thread blocking during high-volume inference runs, alongside unmonitored LLM hallucination spikes across bilingual queries.

2. System Architecture & Data Flow

๐ŸŒ User IngressNext.js / REST API
โž”
โšก Async QueueRedis / BullMQ
โž”
๐Ÿง  AI EnginePrompt Orchestrator
โž”
๐Ÿ›ก๏ธ Schema GuardPydantic Validation
โž”
๐Ÿ’พ Live StoragePostgreSQL / Timescale

Why this architecture?

Isolating model inference inside dedicated asynchronous background workers prevents main looper thread starvation, while enforcing strict Pydantic JSON validation guarantees zero downstream pipeline breakage.

3. Engineering Decisions & Trade-offs

๐Ÿ’ก Decision 1: Async Worker Queues
Choice: BullMQ / Redis Workers
Alternative: Synchronous REST / Celery
Why: Prevents HTTP request timeouts during multi-model LLM generation runs.
๐Ÿ’ก Decision 2: Indexing Strategy
Choice: PostgreSQL pg_trgm Trigrams
Alternative: Heavy Vector ANN Database
Why: Achieves sub-millisecond bilingual entity matching with 90% lower memory footprint.
๐Ÿ’ก Decision 3: Structured Output Control
Choice: Pydantic & Instructor Schemas
Alternative: Unstructured Text Parsing
Why: Eliminates runtime JSON parsing errors across multi-LLM vendor APIs.

4. Technical Challenges Overcome

โš ๏ธ

Challenge 1: Hallucination & Model Output Drift

Problem: Generative models returning inaccurate claims on niche domain queries.
Solution: Knowledge Graph SPARQL verification with McNemar canary statistical tests (50 runs).
Result: Reduced hallucination occurrence rate by 82%.
โš ๏ธ

Challenge 2: Ingestion Bottlenecks Under High Concurrency

Problem: Burst requests overloading database connections and slowing inference throughput.
Solution: Exponential backoff retry logic, Redis connection pooling, and batch ingestion pipelines.
Result: Sustained 99.9% pipeline completion SLA under peak load.

5. Empirical Benchmarks & Evaluation

Model / SetupAccuracy / F1p95 LatencyCost per 1k TokensVerdict
GPT-4o (Primary)89.4%1.2s$0.0050Selected for Complex Reasoning
Claude 3.5 Sonnet87.1%1.4s$0.0030Strong Runner-up
Gemini 2.5 Flash84.5%0.45s$0.0003Selected for Fast Filtering
LLaMA 3.3 (Local)82.0%0.90s$0.0000Offline Fallback

6. Engineering Artifacts & Links

๐Ÿ’ป
Source Code Repository
Explore full Python / Next.js implementation on GitHub โ†—
๐Ÿ“„
Architecture Specification
Verified system data flow & Pydantic schema validation docs
๐Ÿ“Š
Evaluation Benchmark Suite
Langfuse telemetry metrics & McNemar statistical test runs
๐Ÿ”ฌ
Model Card & Rationale
Model selection benchmark specs & token cost analysis

7. Lessons Learned & Timeline

01

Architecture MVP

Designed core data models, Pydantic schemas, and FastAPI endpoints.

02

Performance Profiling

Identified vector search memory bottlenecks and integrated pg_trgm indexing.

03

Production Hardening

Enforced Langfuse observability tracking and McNemar canary evaluation suites.

04

Production Release

Containerized 8-service Docker stack deployed to production Linux VPS.