<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Abuzar Zulfiqar: Notes on Production AI]]></title><description><![CDATA[Abuzar Zulfiqar: Notes on Production AI]]></description><link>https://abuzar18.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 02:00:37 GMT</lastBuildDate><atom:link href="https://abuzar18.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Three Years of Shipping Production AI: What I Built, What Got Hard, What I Learned]]></title><description><![CDATA[I have spent about three years building AI systems that real people depend on, and I have never written about it as a whole. This is that post: what I…]]></description><link>https://abuzar18.hashnode.dev/three-years-of-shipping-production-ai-what-i-built-what-got-hard-what-i-learned</link><guid isPermaLink="true">https://abuzar18.hashnode.dev/three-years-of-shipping-production-ai-what-i-built-what-got-hard-what-i-learned</guid><category><![CDATA[Career]]></category><category><![CDATA[llm]]></category><category><![CDATA[Machine Learning]]></category><dc:creator><![CDATA[Abuzar Zulfiqar]]></dc:creator><pubDate>Fri, 27 Nov 2026 10:46:53 GMT</pubDate><content:encoded><![CDATA[<p>I have spent about three years building AI systems that real people depend on, and I have never written about it as a whole. This is that post: what I worked on, what went wrong or got hard, and what I would tell a team starting today.</p>
<p>No client names, and no code that isn't mine to share. The numbers are the ones I can stand behind.</p>
<h2>Before industry: a research lab</h2>
<p>At FAST-NUCES I led COLAB, a 30-member applied AI research team, while finishing my CS degree. We worked across NLP and machine learning. One project used an RNN on Wi-Fi signals to recognise human activity, running on a Raspberry Pi.</p>
<p>The main thing research taught me was discipline about experiments: write down what you're testing, keep it reproducible, and don't trust a result you can't rerun. That habit turned out to matter more in production than any model.</p>
<h2>OptimusFox: from intern to shipping at scale (2023 to 2025)</h2>
<p>I joined OptimusFox as an AI intern in June 2023 and became an Associate AI Engineer about two months later. Part of my role was R&amp;D: research a new GenAI approach, prototype it, and hand what worked to the delivery team.</p>
<p><strong>25+ policy RAG assistants.</strong> The hard part was not answering questions. It was keeping answers current. Policy documents change, and a stale index gives a confident wrong answer. We automated ingestion end to end (ETL, chunking, embedding and index sync on Kubernetes), which cut manual refresh work by about 90%. Prompt routing and Redis caching brought inference latency down about 40% and API cost down 35%. We reused one delivery pattern, so each new assistant became configuration instead of a new build.</p>
<p><strong>An agentic insurance-appeal workflow.</strong> Appeals are long, rule-heavy documents, and every unsupported claim weakens them. I modelled the process as a LangGraph state machine: ingest documents, extract facts, retrieve policy clauses, then draft with citations. In a regulated domain, the controls were half the work: PHI/PII redaction, audit logs, and prompt and model versioning. Drafting time fell by 60 to 70%.</p>
<p><strong>SAM BOT, a conversational BI assistant.</strong> Text-to-SQL is easy to demo and hard to get right, because "revenue" or "active customer" means something specific in every business. What made it useful was encoding those business rules into the prompts. Manual analysis time dropped by about 60%.</p>
<h2>Rolustech: when the bottleneck isn't the model (2025 to 2026)</h2>
<p>At Rolustech I worked on LLM research and enrichment pipelines, meeting intelligence and backend performance.</p>
<p><strong>126 seconds to 4.</strong> A matching feature took about two minutes at the median, across 1.24 million records. Nothing about it was an AI problem. The code scanned records one by one. Indexed PostgreSQL queries, an event-driven path on Lambda and SQS, PgBouncer and safe retries brought the median to 4 seconds at 100 concurrent requests.</p>
<p><strong>Meeting notes into Salesforce.</strong> Meeting bots, recording and transcript webhooks into S3, Azure OpenAI summaries and action items, synced to the CRM. Webhooks arrive twice and calls fail, so idempotency, deduplication, signed requests and replay-safe recovery had to be designed in from the start.</p>
<p><strong>Watching the meter.</strong> I added per-request token, cost and latency telemetry, and found and fixed a billing calculation for reasoning tokens. If you can't see cost per request, you find out about cost problems from the invoice.</p>
<h2>Now: independent</h2>
<p>Since August 2026 I've worked independently with startups and SMBs. I also packaged the patterns I kept repeating into open-source references: a self-correcting, citation-grounded RAG system with an evaluation harness, an agent control plane with policy gates and human approval, and an AWS MLOps reference with release gates. I run my own small e-commerce store too, with an automated repricing system. It's a good reminder of what it's like to live with your own automation.</p>
<h2>What three years taught me</h2>
<p><strong>Most "AI problems" are data and systems problems.</strong> The biggest wins I've had came from indexes, queues, caching and ingestion, not from a bigger model.</p>
<p><strong>Controls aren't extra work, they're the product.</strong> Redaction, audit trails, approval steps and idempotency are what let a business trust an AI system with real work.</p>
<p><strong>Measure before you change anything.</strong> A p50 number, a cost per request or a fixed eval set turns arguments into decisions.</p>
<p><strong>Prefer refusals to confident wrong answers.</strong> A system that says "I don't know" when the evidence isn't there is worth more than one that always answers.</p>
<p><strong>Design for the team that owns it next.</strong> Clear contracts, logs and runbooks outlast any clever prompt.</p>
<p><em>Also on</em> <a href="https://dev.to/abuzar18"><em>DEV</em></a> <em>and</em> <a href="https://medium.com/@abuzarzulfiqar18"><em>Medium</em></a><em>. More case studies at</em> <a href="http://abuzar18.github.io"><em>abuzar18.github.io</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Five Ways an Unreviewed AI Architecture Breaks in Production]]></title><description><![CDATA[AI projects rarely fail at the demo. The demo works. They fail three or six months later, when the agent has more tools, more users and more data than…]]></description><link>https://abuzar18.hashnode.dev/five-ways-an-unreviewed-ai-architecture-breaks-in-production</link><guid isPermaLink="true">https://abuzar18.hashnode.dev/five-ways-an-unreviewed-ai-architecture-breaks-in-production</guid><category><![CDATA[AIArchitecture]]></category><category><![CDATA[llm]]></category><dc:creator><![CDATA[Abuzar Zulfiqar]]></dc:creator><pubDate>Fri, 27 Nov 2026 09:56:13 GMT</pubDate><content:encoded><![CDATA[<p>AI projects rarely fail at the demo. The demo works. They fail three or six months later, when the agent has more tools, more users and more data than anyone planned for, and nobody ever sat down and reviewed the architecture as a whole.</p>
<p>That is going to get more common, not less. Agent tooling moved fast this year. Google added a /swarm mode to Antigravity, where a coordinator model hands work to parallel agents. The MCP spec moved to a stateless core with stricter auth in July. It has never been easier to wire a model to real systems. It is just as easy to wire it in a way that breaks quietly.</p>
<p>Here are the five failure modes I would look for first in any AI architecture review, and what to check for each.</p>
<h2>1. Cost that grows faster than usage</h2>
<p>Agent loops usually re-send the whole conversation on every step: the system prompt, the tool definitions and every tool result so far. That makes input tokens grow roughly with the square of the number of steps, not in a straight line.</p>
<p>I worked it out with a small script. Assume a 2,000-token system prompt plus tools, and 1,500 tokens of tool output added per step. Here is the total input the model reads across a whole run:</p>
<table>
<thead>
<tr>
<th>Steps</th>
<th>Full history re-sent</th>
<th>Avg per step</th>
<th>Last 4 results + summary</th>
<th>Saving</th>
</tr>
</thead>
<tbody><tr>
<td>5</td>
<td>32,500</td>
<td>6,500</td>
<td>32,500</td>
<td>0%</td>
</tr>
<tr>
<td>10</td>
<td>102,500</td>
<td>10,250</td>
<td>80,000</td>
<td>22%</td>
</tr>
<tr>
<td>20</td>
<td>355,000</td>
<td>17,750</td>
<td>175,000</td>
<td>51%</td>
</tr>
<tr>
<td>40</td>
<td>1,310,000</td>
<td>32,750</td>
<td>365,000</td>
<td>72%</td>
</tr>
</tbody></table>
<p>Going from 20 steps to 40 doesn't double the tokens. It multiplies them by about 3.7. A task that cost cents in testing can cost dollars per run once real users ask harder questions.</p>
<p><strong>What to check:</strong> a hard cap on steps per task, a context policy (windowing or summarising old tool output), and cost per task tracked as a metric, not just monthly spend.</p>
<pre><code class="language-python">S, T, WINDOW = 2_000, 1_500, 4  # system prompt, tokens per tool result, results kept

def full_history(n):
    return sum(S + k * T for k in range(1, n + 1))

def windowed(n):
    return sum(S + min(k, WINDOW) * T + (T if k &gt; WINDOW else 0) for k in range(1, n + 1))

for n in (5, 10, 20, 40):
    print(n, full_history(n), windowed(n))
</code></pre>
<p>These are assumptions, not a benchmark. Plug in your own numbers. The shape of the curve is the point.</p>
<h2>2. Tools with more power than the task needs</h2>
<p>OWASP's Top 10 for LLM applications calls this "excessive agency": giving an agent tools or permissions it doesn't need. In a lot of agent setups, one set of credentials can read, write and delete, because that was the quickest thing to wire up.</p>
<p><strong>What to check:</strong> separate read and write tools, scoped credentials per tool, and a human approval step for anything irreversible (payments, deletes, outbound email). Approval should be a state in the workflow with an audit record, not a checkbox in the UI.</p>
<h2>3. Retries that do the work twice</h2>
<p>Queues deliver messages more than once. Webhooks get replayed. Agents retry failed tool calls. Without idempotency, a retry means a second CRM update, a second email or a second charge.</p>
<p>When I built a meeting-to-CRM pipeline, handling duplicate webhooks was part of the design from the start. The fix is boring and it works: idempotency keys, deduplication on receive and replay-safe recovery.</p>
<p><strong>What to check:</strong> can every write step run twice safely? If nobody can answer that quickly, it can't.</p>
<h2>4. No way to tell when answers get worse</h2>
<p>Prompts change, models get upgraded and documents go stale. Without an evaluation set, quality drifts and the first signal is a customer complaint.</p>
<p><strong>What to check:</strong> a fixed set of representative questions, including ones the system should refuse. Run it on every prompt or model change. Measure the false-refusal rate as well as accuracy, because tightening one usually moves the other.</p>
<h2>5. Tail latency nobody planned for</h2>
<p>Parallel agents feel fast in a demo. In production, a coordinator that waits for every worker finishes when the slowest one does. In a simulation I ran with 10 parallel workers, the median wait was about 2.5 times a single worker's, and 80% of runs had at least one worker slower than 15 seconds.</p>
<p><strong>What to check:</strong> per-tool and per-worker timeouts, a fallback answer, and p95 latency as an explicit target, not just the average.</p>
<h2>Why a review, and why early</h2>
<p>None of these are exotic. They are the ordinary data, permissions and reliability problems of any distributed system, showing up again around a model. The difference is that AI systems hide them well: the output still looks fluent while the cost, the risk or the error rate climbs.</p>
<p>A review before scaling is cheap. Usually it's a few days to map the data flow, the failure modes, the security boundaries, the eval plan and the cost per task. Rebuilding after an incident is not cheap, especially when the agent has already written to production systems.</p>
<p>If you only do one thing this quarter: pick your most-used AI workflow and write down its worst-case cost per task, what it can change without a human, and how you'd know if its answers got worse last week. If any of the three is "not sure", that's where to start.</p>
<hr />
<p><em>Sources:</em> <a href="https://www.infoworld.com/article/4248403/google-adds-multi-model-orchestrator-gemini-4-hydrogen-to-antigravity.html"><em>Google Antigravity /swarm (InfoWorld)</em></a><em>,</em> <a href="https://claude.com/blog/bringing-mcp-2026-07-28-to-claude"><em>MCP 2026-07-28 spec (Anthropic)</em></a><em>,</em> <a href="https://genai.owasp.org/llm-top-10/"><em>OWASP Top 10 for LLM Applications</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[From 126 Seconds to 4: The Unglamorous Fix Behind a 30x Speedup]]></title><description><![CDATA[A matching feature I worked on took about 126 seconds to answer a single request at the median. After the fix it took 4. Nothing about the fix was clever…]]></description><link>https://abuzar18.hashnode.dev/from-126-seconds-to-4-the-unglamorous-fix-behind-a-30x-speedup</link><guid isPermaLink="true">https://abuzar18.hashnode.dev/from-126-seconds-to-4-the-unglamorous-fix-behind-a-30x-speedup</guid><category><![CDATA[PostgreSQL]]></category><category><![CDATA[AWS]]></category><category><![CDATA[performance]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Abuzar Zulfiqar]]></dc:creator><pubDate>Thu, 26 Nov 2026 08:18:56 GMT</pubDate><content:encoded><![CDATA[<p>A matching feature I worked on took about 126 seconds to answer a single request at the median. After the fix it took 4. Nothing about the fix was clever, and I think that is the useful part of the story.</p>
<p>The feature matched people against a table of about 1.24 million account records. It had to keep working with 100 requests in flight at once. When I started, the median response was a little over two minutes.</p>
<h2>Where the time went</h2>
<p>The code walked through records one after another and checked each one. With a few thousand rows that is fine. With 1.24 million rows and many users at once, every request paid for a full pass over the data, and the requests queued up behind each other.</p>
<p>There was no hidden bug. The design simply didn't match the size of the data any more.</p>
<h2>What I changed</h2>
<p><strong>1. Let the database do the searching.</strong> I normalized the data the matching logic needed into proper tables and added indexes for the fields it filtered on. The application stopped scanning rows itself and asked PostgreSQL a precise question instead. This was the biggest single win.</p>
<p><strong>2. Take heavy work off the request path.</strong> Work that didn't need to finish before the user got an answer moved to an event-driven path: API Gateway receives the request, a message goes onto SQS, and Lambda workers process it. Large payloads go to S3, and only a reference travels through the queue, so messages stay small.</p>
<p><strong>3. Protect the database from the fix.</strong> Once work runs in parallel, the database becomes the bottleneck you created. I put PgBouncer in front of PostgreSQL for connection pooling and set concurrency limits on the workers, so a spike in traffic can't open hundreds of connections at once.</p>
<p><strong>4. Make retries safe.</strong> Queues deliver messages more than once, and networks fail. Every step became idempotent, so processing the same message twice does no harm, and failed calls retry with exponential backoff instead of hammering the service that just failed.</p>
<h2>The result</h2>
<p>Median response time went from about 126 seconds to 4 seconds, across 1.24 million records at 100 concurrent requests. That is roughly 30 times faster.</p>
<h2>What I took from it</h2>
<ul>
<li><strong>Measure first.</strong> The p50 number told me this was a design problem, not a tuning problem. Tweaking timeouts would have hidden it.</li>
<li><strong>Indexes beat cleverness.</strong> Most "slow AI feature" problems I've seen are ordinary data access problems wearing an AI label.</li>
<li><strong>Async is not free.</strong> Moving work to queues helps only if you also handle duplicates, retries and database load. Otherwise you trade a slow system for a flaky one.</li>
<li><strong>Keep the boring parts boring.</strong> PgBouncer, SQS and an index are not exciting. They are why the system still behaves at 100 concurrent requests.</li>
</ul>
<p>If you are looking at a feature that got slow as your data grew, start with the query plan before you reach for a bigger instance.</p>
<p><em>Abuzar Zulfiqar is an AI/ML engineer who builds production AI agents, RAG assistants and the backends behind them. More case studies at</em> <a href="http://abuzar18.github.io"><em>abuzar18.github.io</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Building a RAG System That Says "I Don't Know": Self-Correcting RAG with Llama 3.1 and LangGraph]]></title><description><![CDATA[Most RAG demos have the same flaw: ask them something the documents never mention, and they answer anyway, confidently and wrongly. In a demo that is a…]]></description><link>https://abuzar18.hashnode.dev/building-a-rag-system-that-says-i-don-t-know-self-correcting-rag-with-llama-3-1-and-langgraph</link><guid isPermaLink="true">https://abuzar18.hashnode.dev/building-a-rag-system-that-says-i-don-t-know-self-correcting-rag-with-llama-3-1-and-langgraph</guid><category><![CDATA[RAG ]]></category><category><![CDATA[llm]]></category><category><![CDATA[Python]]></category><category><![CDATA[langchain]]></category><dc:creator><![CDATA[Abuzar Zulfiqar]]></dc:creator><pubDate>Thu, 26 Nov 2026 08:14:55 GMT</pubDate><content:encoded><![CDATA[<p>Most RAG demos have the same flaw: ask them something the documents never mention, and they answer anyway, confidently and wrongly. In a demo that is a curiosity. In production it is how a support bot invents a refund policy.</p>
<p>I built <a href="https://github.com/abuzar18/llama-agentic-rag">Llama Agentic RAG</a> around the opposite rule: <strong>an answer must be supported by cited sources, or the system says "I don't know."</strong> It runs fully locally on Llama 3.1 8B through Ollama, which fits in 8 GB of VRAM, so private documents never leave the machine.</p>
<p>This post walks through the design and the choices that made it work on a small model.</p>
<h2>The workflow</h2>
<p>The pipeline is a LangGraph state machine with five stages:</p>
<ol>
<li><strong>Retrieve</strong> the top-k chunks from a vector index. Every chunk has a stable id such as <a href="http://handbook.md"><code>handbook.md</code></a><code>#3</code>, so citations stay traceable.</li>
<li><strong>Grade</strong> each chunk for relevance with the LLM before anything is generated. Off-topic context never reaches the answer.</li>
<li><strong>Rewrite</strong> the query once if no chunk is relevant. Vague questions often recover here; if they don't, the graph refuses.</li>
<li><strong>Generate</strong> an answer only from the numbered context, citing <code>[n]</code> after each claim.</li>
<li><strong>Check groundedness</strong>: a judge prompt verifies the answer against the context. An unsupported answer is replaced by a refusal.</li>
</ol>
<p>The key idea is that hallucinations become refusals, not wrong answers. A refusal is annoying; a confident wrong answer is expensive.</p>
<h2>Making it work on an 8B model</h2>
<p>Large models forgive sloppy prompts. Small models don't, so a few details mattered more than any framework choice:</p>
<ul>
<li><strong>One-word verdicts.</strong> Llama 3.1 8B is unreliable with complex JSON schemas, so the grading and groundedness prompts ask for <code>yes</code> or <code>no</code>, and parsing is tolerant of extra words.</li>
<li><strong>Strip reasoning tags.</strong> If you swap in a reasoning model, its <code>&lt;think&gt;</code> blocks are removed before parsing.</li>
<li><strong>Citations are enforced, not requested.</strong> An answer without valid <code>[n]</code> citations is treated as ungrounded, even if it sounds right.</li>
<li><strong>Config over code.</strong> Every model, path and threshold is an environment variable, so trying another Ollama model is a one-line change.</li>
</ul>
<h2>Measure the refusals</h2>
<p>A RAG system that never says "I don't know" isn't production-ready, so the evaluation set deliberately includes unanswerable questions. The harness reports:</p>
<table>
<thead>
<tr>
<th>Metric</th>
<th>What it tells you</th>
</tr>
</thead>
<tbody><tr>
<td>Retrieval hit rate</td>
<td>Did we retrieve an expected source for answerable questions?</td>
</tr>
<tr>
<td>Citation precision</td>
<td>Do cited chunks come from expected sources?</td>
</tr>
<tr>
<td>Refusal accuracy</td>
<td>Were unanswerable questions correctly refused?</td>
</tr>
<tr>
<td>False-refusal rate</td>
<td>Were answerable questions wrongly refused?</td>
</tr>
<tr>
<td>Judge correctness</td>
<td>LLM-as-judge score against a reference answer</td>
</tr>
<tr>
<td>p50 / p95 latency</td>
<td>What does it cost the user in time?</td>
</tr>
</tbody></table>
<p>Refusal accuracy and false-refusal rate pull against each other, which is exactly why you need both. Tighten the groundedness check and refusals get safer while false refusals rise. The numbers make that trade-off visible instead of a matter of opinion.</p>
<p>Treat prompt and model changes like code changes: they ship only if the evals hold.</p>
<h2>Tests that don't need a GPU</h2>
<p>CI runs the full graph with scripted fake LLM replies and deterministic embeddings. That covers the happy path, query rewrite, refusal, ungrounded answers, missing citations and reasoning-tag stripping, all without a model or a GPU. It is the cheapest way to keep a graph's control flow honest as it grows.</p>
<h2>Use it from Claude with MCP</h2>
<p>The same graph is exposed as an MCP tool, <code>ask_documents</code>, so Claude Desktop, Claude Code or any MCP client can query your documents and get cited answers back. The FastAPI service exposes <code>/ask</code>, <code>/ingest</code> and <code>/health</code> for everything else.</p>
<h2>What's next</h2>
<p>The roadmap is the usual path from reference to production: hybrid retrieval with BM25 and a cross-encoder reranker, a persistent vector database such as pgvector or Qdrant, tracing with Langfuse, streaming, and PDF and DOCX ingestion.</p>
<p>The code is MIT-licensed: <a href="https://github.com/abuzar18/llama-agentic-rag">github.com/abuzar18/llama-agentic-rag</a>.</p>
<p><em>Abuzar Zulfiqar is an AI/ML engineer who builds production AI agents, RAG assistants and LLM automation. More at</em> <a href="http://abuzar18.github.io"><em>abuzar18.github.io</em></a><em>.</em></p>
]]></content:encoded></item></channel></rss>