Just as a clinician can't diagnose a critical patient based on 'gut feeling' alone, AI engineers can't deploy models in production relying on manual 'vibe checks', especially when hallucinations could lead to compliance violations or user mistrust.
The tools have evolved, from stethoscope to tracing dashboards, but the mission remains: diagnose accurately, intervene precisely, and ensure system health.
My journey began in the ER, making life-or-death calls under pressure. Today, at a leading FinTech institution's Digital Factory, I apply the same clinical rigor to AI systems: building pipelines that don't just generate answers, but prove they're trustworthy.
One of my core contributions? Transforming subjective LLM evaluations into automated, scalable diagnostics using "LLM-as-a-Judge" architectures. This wasn't theoretical. I shipped production-grade systems evaluating HR agents handling sensitive employee queries in English and Arabic.
In medicine, misdiagnosis kills quietly.
In AI, hallucinations do the same, eroding trust before anyone notices.
The cure? Systematic, evidence-based evaluation.
Differential Diagnosis: Why Traditional Testing Fails Generative AI
Early in the project, we relied on manual reviews: analysts chatting with prototypes, debating if responses felt "correct." It was slow, biased, and unscalable, especially with datasets exceeding 22 million words curated from news, podcasts, and synthetic banking dialogues.
Classic metrics like BLEU or ROUGE? Useless for LLMs. They measure surface similarity, not grounded truthfulness. We needed something that could assess:
- • Faithfulness: Is the answer derived solely from reliable sources?
- • Relevance: Does it directly address the query without fluff?
- • Correctness: Holistic accuracy, including cultural nuance in Arabic dialects
- • Safety: Refusal of jailbreaks or out-of-scope requests
Enter LLM-as-a-Judge: Using a powerful LLM to score outputs automatically, with reasoning traces for auditability. But building it right required clinical precision.
# Simplified Judge Scoring Logic (Anonymized)
def score_response(query, context, response, expected):
prompt = f"""
Query: {query}
Context: {context[:2000]}...
Response: {response}
Expected Behavior: {expected}
Categorize: correct | partially_correct | incorrect
Score Faithfulness (0-1): ...
Reasoning: Step-by-step explanation
"""
result = await llm.generate(prompt)
return parse_judge_output(result)Vital Signs: Observability as the ICU Monitor
In the ICU, you don't wait for the patient to crash, but monitor vitals continuously. I applied the same to our agents using Langfuse: tracing every run, logging scores, latency, and token usage in real-time.

This turned opaque black-box evaluations into transparent dashboards: Compare runs side-by-side, spot regressions (e.g., vague query mishandling jumping from 10% to 25%), and iterate fast.
Golden Datasets → Clinical Benchmarks
I curated bilingual "golden" datasets on Langfuse: 100+ queries covering greetings, in-scope HR policies, vague topics, multi-turn conversations, and jailbreaks. Each with expected outputs and categories.
These served as our ECG strips, providing baseline health checks for every agent iteration.
Triage: Architecting the Evaluation Pipeline
The full pipeline integrated Dify workflows for the judge agent, Python scripts for orchestration, and Marimo notebooks for one-click evaluations.

Key innovations:
- Retry logic with backoff for flaky API calls
- Checkpointing to resume interrupted runs
- Multilingual NER preservation in judgments
- These served as our ECG strips, providing baseline health checks for every agent iteration, alongside latency tracking that reduced average response times from 30 seconds or more to under 10 seconds.
# Marimo One-Click Evaluator Snippet
async def run_evaluation(dataset_name, judge_workflow_url):
items = langfuse.get_dataset_items(dataset_name)
for item in tqdm(items):
response = await call_agent(item.query)
score = await call_judge(item.query, item.expected, response)
langfuse.score(trace_id=item.id, name="correctness", value=score)Result: Evaluations that once took days now ran in hours, with full traceability.
Preventative Medicine: Continuous Improvement as Immunity
The pipeline caught issues early: duplicate suggestions on vague queries, poor follow-up handling, infinite loops in reasoning.
Fixes applied: Query expansion only on vague inputs, reranking for better retrieval, model switches (e.g., GPT-OSS for efficiency).
Impact metrics:
- Correctness: 70% → 95% across iterations
- Latency: Reduced by 60% (tokens cut from 10k+ to under 4k per request)
- Cost: Halved through targeted optimizations
- Trust: Full audit trails for compliance teams

Final Diagnosis
I never stopped being a clinician. I simply shifted from human patients to AI systems that are complex, interconnected, and prone to silent failures.
They need monitors (Langfuse).
Benchmarks (Golden datasets).
Automated diagnostics (LLM-as-a-Judge).
And preventative engineering.
Trustworthy AI isn't built by accident.
It's engineered through rigorous, continuous evaluation.
Currently practicing clinical AI engineering at enterprise scale
Building evaluation pipelines, agent architectures, and observability systems for production HR and customer agents at Boubyan Digital Factory.
If your AI systems are suffering from hallucinations, latency arrhythmias, or evaluation blind spots, it's time for a check-up.
