<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Faizan</title>
    <description>The latest articles on DEV Community by Muhammad Faizan (@faizzyhon).</description>
    <link>https://dev.to/faizzyhon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F617870%2F021fcdaf-0f1b-4751-85d4-b35b632a6872.JPG</url>
      <title>DEV Community: Muhammad Faizan</title>
      <link>https://dev.to/faizzyhon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/faizzyhon"/>
    <language>en</language>
    <item>
      <title>FastAPI vs Flask for ML APIs: Two Years of Production Lessons</title>
      <dc:creator>Muhammad Faizan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 20:46:23 +0000</pubDate>
      <link>https://dev.to/faizzyhon/fastapi-vs-flask-for-ml-apis-two-years-of-production-lessons-5gn4</link>
      <guid>https://dev.to/faizzyhon/fastapi-vs-flask-for-ml-apis-two-years-of-production-lessons-5gn4</guid>
      <description>&lt;p&gt;Every ML engineer eventually faces the same unglamorous question: the model works in a notebook — now how do I serve it? For two years at Systems Limited, I built NLP pipelines and the APIs that exposed them, using both Flask and FastAPI in production. This is what I learned about choosing between them, beyond the benchmark charts.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short answer
&lt;/h2&gt;

&lt;p&gt;If you are serving machine learning models today, start with FastAPI. It gives you request validation, automatic documentation, and async support out of the box, and those three things prevent the exact class of bugs that waste the most production time. Flask remains excellent for small, simple services and for teams who want total control with minimal magic. But for ML APIs specifically, FastAPI's defaults align with what model serving actually needs.&lt;/p&gt;

&lt;p&gt;Here is why, in production terms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Ffastapi-vs-flask-for-ml-apis%2Ffastapi-vs-flask-table.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Ffastapi-vs-flask-for-ml-apis%2Ffastapi-vs-flask-table.png" alt="FastAPI vs Flask for ML APIs, from two years of production use." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;FastAPI vs Flask for ML APIs, from two years of production use.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Validation is not bureaucracy — it is uptime
&lt;/h2&gt;

&lt;p&gt;ML APIs fail in a characteristic way: a client sends malformed input, the model code throws an exception deep in a preprocessing step, and you get a 500 with a useless stack trace. With Flask, input validation is your job — you write it by hand, endpoint by endpoint, and sooner or later you forget a field.&lt;/p&gt;

&lt;p&gt;FastAPI uses Pydantic models to validate requests before your code runs. Bad input gets a clear 422 response describing exactly what is wrong. In production, this turned entire categories of "the API is broken" tickets into "the client fixed their payload." That is not a framework nicety. That is hours of debugging you never spend.&lt;/p&gt;

&lt;p&gt;For ML work specifically, typed request models also document your feature schema. When a model's expected inputs change, the schema change is explicit and reviewable, not buried in a preprocessing function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Async matters when models are slow
&lt;/h2&gt;

&lt;p&gt;Model inference is not instant. An NLP pipeline might take 200 milliseconds on a good day and two seconds on a bad one. In a synchronous Flask worker, that request blocks a thread the whole time. Under load, threads pile up, and latency collapses for everyone.&lt;/p&gt;

&lt;p&gt;FastAPI's async support lets a single process handle many concurrent requests while inference runs, especially when combined with async database and HTTP calls around the model. You still need to be careful — CPU-bound inference should run in a thread pool or separate workers so it does not block the event loop — but the framework gives you the tools instead of making you bolt them on.&lt;/p&gt;

&lt;p&gt;My production pattern became: FastAPI for the API layer, model inference dispatched to a worker pool, and results cached for repeated inputs. Simple, and it held up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Ffastapi-vs-flask-for-ml-apis%2Fsync-vs-async-timeline.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Ffastapi-vs-flask-for-ml-apis%2Fsync-vs-async-timeline.png" alt="Slow predictions block synchronous workers; async keeps one process useful." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Slow predictions block synchronous workers; async keeps one process useful.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Documentation your future self will thank you for
&lt;/h2&gt;

&lt;p&gt;FastAPI generates interactive OpenAPI documentation from your code automatically. When a frontend developer or a client asks "what does this endpoint accept?", the answer is a URL, not a meeting. With Flask, documentation is a separate artifact that drifts out of date the week after you write it.&lt;/p&gt;

&lt;p&gt;In client work, this mattered commercially. A live, accurate API reference made integrations faster and made the system look — and be — professional.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Flask still wins
&lt;/h2&gt;

&lt;p&gt;Honesty requires the other side. Flask is smaller, older, and battle-tested. Its ecosystem of extensions is vast, its mental model is simple, and for a tiny internal service — a webhook receiver, a health-check endpoint, a quick prototype — Flask gets out of your way. If your team already knows Flask deeply and your service is simple, switching costs may outweigh FastAPI's benefits.&lt;/p&gt;

&lt;p&gt;Flask also has fewer surprises. FastAPI's dependency injection and Pydantic magic occasionally confuse newcomers, and debugging a validation error can mean reading framework internals. That is a real cost for junior teams.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Ffastapi-vs-flask-for-ml-apis%2Fvalidation-flow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Ffastapi-vs-flask-for-ml-apis%2Fvalidation-flow.png" alt="Validation is uptime: the model never sees malformed payloads." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Validation is uptime: the model never sees malformed payloads.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The production checklist either way
&lt;/h2&gt;

&lt;p&gt;Whichever framework you choose, ML serving has non-negotiables I learned the hard way:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Load the model once, at startup.&lt;/strong&gt; Loading per-request is the classic beginner mistake that turns a 200ms inference into a 5-second one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version your endpoints.&lt;/strong&gt; Models change. &lt;code&gt;/v1/predict&lt;/code&gt; today saves you when v2 ships.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log inputs and outputs (safely).&lt;/strong&gt; When a client reports a bad prediction, you need to reproduce it. Log request IDs and payloads with privacy in mind.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Health and readiness endpoints.&lt;/strong&gt; Orchestrators and load balancers need to know when the model is actually loaded, not just when the process started.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timeouts and payload limits.&lt;/strong&gt; A 50MB text payload should be rejected politely, not processed heroically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure latency percentiles.&lt;/strong&gt; Average latency hides the p99 pain your users actually feel.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  My verdict
&lt;/h2&gt;

&lt;p&gt;For new ML APIs: FastAPI, with inference in a worker pool and Pydantic schemas as your contract. For tiny utilities and prototypes: Flask is still a pleasure. The framework matters less than the discipline around it — validation, versioning, logging, and honest latency measurement. Get those right, and either choice will serve you well. Get them wrong, and no framework will save you.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Muhammad Faizan is an AI engineer and full-stack developer based in Saudi Arabia. He built ML pipelines and model APIs at Systems Limited and now builds AI products including PocketBot and Gale Download Manager. More at faizzyhon.com.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://faizzyhon.com/blog/posts/fastapi-vs-flask-for-ml-apis.html" rel="noopener noreferrer"&gt;faizzyhon.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>fastapi</category>
      <category>flask</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Building Arabic AI That Understands Real People: Lessons From rihla-llm</title>
      <dc:creator>Muhammad Faizan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 20:46:13 +0000</pubDate>
      <link>https://dev.to/faizzyhon/building-arabic-ai-that-understands-real-people-lessons-from-rihla-llm-2m1f</link>
      <guid>https://dev.to/faizzyhon/building-arabic-ai-that-understands-real-people-lessons-from-rihla-llm-2m1f</guid>
      <description>&lt;p&gt;Arabic is one of the most spoken languages on Earth, and one of the worst served by AI. The problem is not a lack of speakers or text. The problem is that "Arabic" is not one language in practice. A user in Riyadh, a user in Cairo, and a user in Karachi typing Urdu in Arabic script all write differently — and most models handle that reality poorly.&lt;/p&gt;

&lt;p&gt;rihla-llm is my attempt to build a multilingual model pipeline for Arabic, Urdu, and English that respects how people actually write. This article shares the lessons that mattered most, because they generalize to anyone building AI for under-served languages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 1: Script is not language
&lt;/h2&gt;

&lt;p&gt;Urdu and Arabic share a script, so naive pipelines lump them together. That is a mistake. The same characters carry different vocabularies, different grammar, and different cultural context. A model trained on mixed data without language awareness produces answers that drift mid-sentence — Arabic words in Urdu grammar, or formal Modern Standard Arabic where the user wrote casual dialect.&lt;/p&gt;

&lt;p&gt;In rihla-llm, language identification happens early and explicitly. Every training example is tagged, and the model learns to stay in the language the user chose. It sounds obvious. Almost nobody does it carefully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fbuilding-arabic-ai-that-understands-real-people-rihla-llm%2Farabic-language-layers.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fbuilding-arabic-ai-that-understands-real-people-rihla-llm%2Farabic-language-layers.png" alt="Script is not language: dialect, script, numerals and morphology all sit between text and understanding." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Script is not language: dialect, script, numerals and morphology all sit between text and understanding.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 2: Dialect is the product
&lt;/h2&gt;

&lt;p&gt;Most Arabic training data is Modern Standard Arabic — news, books, formal writing. But people do not chat in Modern Standard Arabic. They write Gulf dialect, Egyptian dialect, Levantine slang, and Roman Urdu mixed with English words. A model that only understands formal Arabic feels foreign to the very users it claims to serve.&lt;/p&gt;

&lt;p&gt;The practical fix is unglamorous: collect and clean real conversational data, normalize the wild spelling variation of dialect text (the same word can be spelled five ways), and evaluate on dialect test sets, not just formal benchmarks. My rule became simple: if a native speaker would not write it that way in a WhatsApp message, the model should still understand it — and reply naturally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 3: Tokenization quietly decides your budget
&lt;/h2&gt;

&lt;p&gt;Tokenizers trained mostly on English split Arabic words into many small pieces. That means Arabic text costs more tokens, fills context windows faster, and gives the model less room to think. It is an invisible tax on every Arabic user.&lt;/p&gt;

&lt;p&gt;When building rihla-llm, measuring tokens-per-word for Arabic and Urdu versus English was one of the first diagnostics. If your tokenizer needs three tokens for a common Arabic word, your effective context and your inference bill both suffer. Choosing a base model and vocabulary with decent Arabic coverage is not a detail — it is a budget decision that compounds with every request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fbuilding-arabic-ai-that-understands-real-people-rihla-llm%2Ftokenization-cost.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fbuilding-arabic-ai-that-understands-real-people-rihla-llm%2Ftokenization-cost.png" alt="Tokenization decides the budget: sequence length, cost and quality all follow." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Tokenization decides the budget: sequence length, cost and quality all follow.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lesson 4: Fine-tuning beats scale for domain work
&lt;/h2&gt;

&lt;p&gt;I did not train a foundation model. I fine-tuned one, using QLoRA so the work fits on modest hardware, then applied preference tuning (DPO) to push outputs toward helpful, in-language, culturally appropriate responses. For a domain assistant — travel, local services, everyday questions in Arabic and Urdu — a well-tuned smaller model beats a giant general model that answers in stiff formal Arabic.&lt;/p&gt;

&lt;p&gt;The pipeline matters more than the parameter count:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Curate&lt;/strong&gt; domain data in all three languages, with dialect coverage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fine-tune&lt;/strong&gt; with QLoRA for efficiency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Align&lt;/strong&gt; with DPO using preference pairs that reward staying in-language and answering directly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ground&lt;/strong&gt; with retrieval (RAG) so factual answers come from documents, not memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lesson 5: Evaluation must be native
&lt;/h2&gt;

&lt;p&gt;Benchmarks translated from English do not tell you whether Arabic users will be satisfied. I evaluate with native-speaker-style test prompts: dialect questions, code-switched Urdu-English messages, and requests where the correct answer requires local context. A model can score well on translated benchmarks and still fail every one of these.&lt;/p&gt;

&lt;p&gt;If you build for a language, test in that language, the way its speakers actually write. Everything else is theater.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fbuilding-arabic-ai-that-understands-real-people-rihla-llm%2Frihla-pipeline.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fbuilding-arabic-ai-that-understands-real-people-rihla-llm%2Frihla-pipeline.png" alt="The rihla-llm pipeline: real text, QLoRA fine-tuning, DPO, retrieval with native-speaker evaluation." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The rihla-llm pipeline: real text, QLoRA fine-tuning, DPO, retrieval with native-speaker evaluation.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this work matters
&lt;/h2&gt;

&lt;p&gt;Hundreds of millions of people speak Arabic and Urdu. Their AI tools should understand them as they are — dialect, code-switching, script and all. rihla-llm is a small step, built with open techniques: QLoRA fine-tuning, DPO alignment, and retrieval grounding. The larger lesson is for every builder working in an under-served language: respect the language's real usage, measure honestly, and tune for your users instead of for a leaderboard.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Muhammad Faizan is an AI engineer and full-stack developer based in Saudi Arabia. He builds ML systems and developer tools including PocketBot and Gale Download Manager. More at faizzyhon.com.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://faizzyhon.com/blog/posts/building-arabic-ai-that-understands-real-people-rihla-llm.html" rel="noopener noreferrer"&gt;faizzyhon.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>nlp</category>
      <category>arabic</category>
    </item>
    <item>
      <title>Quantization-Aware Training, Explained With a Real 89 MB Browser Model</title>
      <dc:creator>Muhammad Faizan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 20:45:41 +0000</pubDate>
      <link>https://dev.to/faizzyhon/quantization-aware-training-explained-with-a-real-89-mb-browser-model-2d1i</link>
      <guid>https://dev.to/faizzyhon/quantization-aware-training-explained-with-a-real-89-mb-browser-model-2d1i</guid>
      <description>&lt;p&gt;When I built PocketBot, I had a simple goal: a chatbot that answers questions from a business's own FAQ, runs entirely in the browser, and never sends data to a server. No API keys, no per-request costs, no privacy worries. The hard part was size. A useful language model is usually measured in gigabytes. A browser tab is not.&lt;/p&gt;

&lt;p&gt;This article explains the technique that made it possible — quantization-aware training (QAT) — using real numbers from the PocketBot build, and why the naive approach quietly destroys accuracy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: big models, small tabs
&lt;/h2&gt;

&lt;p&gt;PocketBot starts from SmolLM2-135M, a 135-million-parameter language model. In full precision (FP32), 135 million parameters take roughly 540 MB. Even in FP16, you are around 270 MB. Browsers can technically load that, but "can" and "should" are different words. Download time, memory pressure on cheap laptops, and mobile data costs all say no.&lt;/p&gt;

&lt;p&gt;Quantization shrinks the model by storing weights in fewer bits. At 4 bits per weight, 135 million parameters need only about 68 MB plus overhead — PocketBot ships at roughly 89 MB. That is the difference between a demo and a deployable product.&lt;/p&gt;

&lt;p&gt;But there is a catch, and it is the whole story of this article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fquantization-aware-training-explained-pocketbot%2Fweight-rounding-levels.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fquantization-aware-training-explained-pocketbot%2Fweight-rounding-levels.png" alt="A 4-bit weight can hold only 16 values. Naive rounding snaps and hopes; QAT trains with the snapping on." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A 4-bit weight can hold only 16 values. Naive rounding snaps and hopes; QAT trains with the snapping on.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why naive 4-bit rounding hurts
&lt;/h2&gt;

&lt;p&gt;The simplest quantization is post-training quantization (PTQ): take a trained model, round every weight to the nearest 4-bit value, ship it. It is fast and easy. It is also lossy in a way that matters.&lt;/p&gt;

&lt;p&gt;Neural network weights are not evenly distributed. A small number of outlier weights carry outsized importance, and rounding them coarsely shifts the model's behavior. In my PocketBot experiments, plain 4-bit rounding dropped next-token accuracy to &lt;strong&gt;88.8%&lt;/strong&gt; (from the full-precision fine-tuned baseline). For a chatbot answering customer questions, that accuracy loss shows up as subtly wrong, less reliable answers — exactly what a business FAQ bot cannot afford.&lt;/p&gt;

&lt;p&gt;The model still "works." It just works worse, in ways that are hard to notice in a quick demo and painful in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  What quantization-aware training does differently
&lt;/h2&gt;

&lt;p&gt;Quantization-aware training flips the order. Instead of quantizing after training, you simulate quantization &lt;em&gt;during&lt;/em&gt; training. The model experiences the rounding noise while it is still learning, so it adapts: weights settle into values that survive 4-bit rounding with minimal damage.&lt;/p&gt;

&lt;p&gt;Think of it like training an athlete with a weighted vest. The constraint is present during practice, so performance under the constraint becomes the thing being optimized.&lt;/p&gt;

&lt;p&gt;In practice, QAT adds "fake quantization" operations in the forward pass: weights are rounded to 4-bit precision and immediately dequantized back, so gradients still flow, but the model learns under realistic rounding error. At export time, the weights convert cleanly to true 4-bit storage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fquantization-aware-training-explained-pocketbot%2Fqat-pipeline.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fquantization-aware-training-explained-pocketbot%2Fqat-pipeline.png" alt="The QAT pipeline: fine-tune, simulate 4-bit rounding, adapt, export an 89 MB ONNX model." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The QAT pipeline: fine-tune, simulate 4-bit rounding, adapt, export an 89 MB ONNX model.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The PocketBot numbers
&lt;/h2&gt;

&lt;p&gt;Here is what this meant in the actual build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Base model:&lt;/strong&gt; SmolLM2-135M, fine-tuned on FAQ-style data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plain 4-bit rounding (PTQ):&lt;/strong&gt; next-token accuracy fell to 88.8%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;With quantization-aware training:&lt;/strong&gt; accuracy recovered to &lt;strong&gt;97.0%&lt;/strong&gt; at the same 4-bit size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Final size:&lt;/strong&gt; ~89 MB, running in the browser via ONNX Runtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An 8-point accuracy recovery at identical size is the difference between "interesting experiment" and "I would put this on a client's website." That is the entire argument for QAT in one line: same bytes, much better brain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fquantization-aware-training-explained-pocketbot%2Fqat-accuracy-comparison.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fquantization-aware-training-explained-pocketbot%2Fqat-accuracy-comparison.png" alt="Same 89 MB file: 88.8% accuracy with naive rounding versus 97.0% with quantization-aware training." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Same 89 MB file: 88.8% accuracy with naive rounding versus 97.0% with quantization-aware training.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When QAT is worth it — and when it is not
&lt;/h2&gt;

&lt;p&gt;QAT is not free. It makes training slower and more complex, and you need training infrastructure that supports fake-quantization ops. So when should you bother?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use QAT when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The model must run on constrained hardware (browsers, phones, edge devices).&lt;/li&gt;
&lt;li&gt;Accuracy at low precision is a product requirement, not a nice-to-have.&lt;/li&gt;
&lt;li&gt;You control the training pipeline end to end.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;PTQ is probably fine when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are quantizing to 8 bits (losses are usually small).&lt;/li&gt;
&lt;li&gt;The model is large enough that redundancy absorbs rounding error.&lt;/li&gt;
&lt;li&gt;You need a quick deployment and can tolerate a small quality drop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For small models at 4 bits — exactly the browser/edge scenario — QAT earns its keep. Small models have less redundancy to spare, so every point of accuracy matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical tips from the build
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fine-tune first, then QAT.&lt;/strong&gt; Get the model good at your task in full precision, then run a QAT phase so it adapts to rounding without relearning the task from scratch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure the right thing.&lt;/strong&gt; I tracked next-token accuracy on held-out FAQ data, not just perplexity. Task metrics tell you what users will feel.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export and test in the real runtime.&lt;/strong&gt; Accuracy in PyTorch is a promise; accuracy in ONNX Runtime in an actual browser tab is the truth. Test where users live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch memory, not just file size.&lt;/strong&gt; The downloaded model is ~89 MB, but runtime memory during inference is what crashes tabs. Budget for both.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why this matters beyond one chatbot
&lt;/h2&gt;

&lt;p&gt;Small, private, offline-capable models are becoming a real product category: support bots that never leak customer data, assistants on factory floors with no connectivity, tools for regions where bandwidth is expensive. Quantization-aware training is one of the key techniques that makes that category viable. It turns "the model is too big" from a dead end into an engineering problem with a known solution.&lt;/p&gt;

&lt;p&gt;PocketBot is open source, and the approach generalizes: fine-tune small, quantize with awareness, ship where the users are. The browser, it turns out, is a perfectly good inference server — if you respect its limits.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Muhammad Faizan is an AI engineer and full-stack developer based in Saudi Arabia. He builds ML systems and developer tools including PocketBot and Gale Download Manager. More at faizzyhon.com.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://faizzyhon.com/blog/posts/quantization-aware-training-explained-pocketbot.html" rel="noopener noreferrer"&gt;faizzyhon.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I Built a Hotel Finance System in Makkah — What Real Businesses Taught Me About Software</title>
      <dc:creator>Muhammad Faizan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 20:45:13 +0000</pubDate>
      <link>https://dev.to/faizzyhon/i-built-a-hotel-finance-system-in-makkah-what-real-businesses-taught-me-about-software-1dai</link>
      <guid>https://dev.to/faizzyhon/i-built-a-hotel-finance-system-in-makkah-what-real-businesses-taught-me-about-software-1dai</guid>
      <description>&lt;p&gt;Most software advice online assumes your users are tech-savvy, your internet is fast, and your data is clean. Then you build software for a hotel in Makkah during Ramadan, and reality teaches you a different curriculum.&lt;/p&gt;

&lt;p&gt;Over the past few years, alongside my machine learning work, I have built finance and booking systems for hotels in Makkah and Madinah as a freelance developer. These are not demo projects. They run real front desks, real invoices, and real end-of-day reconciliations for businesses that cannot afford downtime when pilgrims are checking in at 2 a.m. This article is about what that work taught me — lessons I now apply to every system I build, including AI products.&lt;/p&gt;

&lt;h2&gt;
  
  
  The night the spreadsheet died
&lt;/h2&gt;

&lt;p&gt;Every hotel I have worked with started the same way: a heroic Excel file. One workbook for bookings, another for payments, a third for the night audit. It worked until it didn't — usually at the worst possible moment. A formula overwritten by a tired receptionist. Two staff members editing copies of the same file. A guest disputing a charge, and nobody able to prove what was actually paid.&lt;/p&gt;

&lt;p&gt;The breaking point is never the software. It is trust. When a manager cannot answer "how much did we collect today, and from whom?" in under a minute, the system has failed, no matter how clever the spreadsheet is.&lt;/p&gt;

&lt;p&gt;So the first design rule I learned: &lt;strong&gt;every money movement must be traceable to a person, a time, and a reason.&lt;/strong&gt; In the systems I built, every payment, refund, and adjustment writes an immutable record. You cannot edit history; you can only add a correcting entry. That single decision eliminated most disputes, because the answer to any question was one search away.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fi-built-a-hotel-finance-system-in-makkah%2Fmoney-traceability-flow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fi-built-a-hotel-finance-system-in-makkah%2Fmoney-traceability-flow.png" alt="Append-only money records: every payment becomes an immutable entry, mistakes are fixed by correcting entries, and disputes are answered with one search." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Append-only money records: every payment becomes an immutable entry, mistakes are fixed by correcting entries, and disputes are answered with one search.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Design for the person at 2 a.m.
&lt;/h2&gt;

&lt;p&gt;Hotel front desks run around the clock, often with staff whose first language is not English and who have never used anything more complex than WhatsApp. If your interface needs a training manual, it will fail.&lt;/p&gt;

&lt;p&gt;I learned to design for the tiredest user on the worst shift:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One obvious action per screen.&lt;/strong&gt; Check-in is one big button, not a menu tree.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Numbers before words.&lt;/strong&gt; Room numbers, amounts, and dates are large and unmissable; labels are short.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bilingual where it matters.&lt;/strong&gt; In Saudi hotels, staff switch between Arabic and English constantly. Key actions and receipts work in both, with proper right-to-left layout for Arabic — not just translated text pasted into a left-to-right page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgiving input.&lt;/strong&gt; Phone numbers get typed with spaces, country codes, and Arabic-Indic numerals. The system normalizes them instead of rejecting them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this is glamorous. All of it decides whether software survives contact with reality.&lt;/p&gt;

&lt;h2&gt;
  
  
  The end-of-day problem nobody warns you about
&lt;/h2&gt;

&lt;p&gt;The hardest part of hotel finance is not taking payments. It is closing the day. Cash, cards, bank transfers, and payments through booking platforms all land in different places, and someone has to prove they agree.&lt;/p&gt;

&lt;p&gt;In spreadsheet-land, the night audit took hours and still produced arguments. In the system I built, the day closes with a reconciliation view: expected versus received, per payment method, with every mismatch listed as a clickable item that jumps straight to the offending transaction. Closing the day went from an evening of detective work to a short checklist.&lt;/p&gt;

&lt;p&gt;The lesson generalizes far beyond hotels: &lt;strong&gt;build the reconciliation screen first.&lt;/strong&gt; If your system cannot explain its own numbers, users will not trust it, and untrusted systems get abandoned — quietly, back to Excel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fi-built-a-hotel-finance-system-in-makkah%2Fend-of-day-reconciliation.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fi-built-a-hotel-finance-system-in-makkah%2Fend-of-day-reconciliation.png" alt="The end-of-day closing view: expected versus received per payment method." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The end-of-day closing view: expected versus received per payment method.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Offline is not an edge case
&lt;/h2&gt;

&lt;p&gt;Internet connections drop. Power flickers. During peak pilgrimage seasons, networks strain. A front desk cannot tell a guest "come back when the Wi-Fi works."&lt;/p&gt;

&lt;p&gt;So the systems I built treat offline as a normal state: work continues locally, and records sync when connectivity returns, with conflicts resolved by the immutable-entry rule above — nothing is overwritten, so nothing is lost. Designing for disconnection changed how I think about all software. "It works on my machine" means nothing; the question is whether it works on a bad night in a busy lobby.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fi-built-a-hotel-finance-system-in-makkah%2Foffline-first-sync.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffaizzyhon.com%2Fblog-images%2Fi-built-a-hotel-finance-system-in-makkah%2Foffline-first-sync.png" alt="Offline-first sync: work continues locally and records sync on reconnect." width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Offline-first sync: work continues locally and records sync on reconnect.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What this taught me about AI products
&lt;/h2&gt;

&lt;p&gt;You might wonder what hotel finance has to do with machine learning. More than I expected.&lt;/p&gt;

&lt;p&gt;When I later built PocketBot — a fine-tuned language model that runs entirely in the browser — the design constraints felt familiar. It had to work offline. It had to be small enough for modest hardware. It had to be trustworthy: answers grounded in the business's own FAQ, not invented. The hotel years taught me that &lt;strong&gt;constraints are the product.&lt;/strong&gt; A model that needs a perfect connection and a powerful server is a demo. A model that answers correctly on a cheap laptop with no internet is a tool.&lt;/p&gt;

&lt;p&gt;The same applies to data. Hotel records taught me to respect messy, real-world data: duplicate guest names spelled three ways, phone numbers in two numeral systems, dates in two calendars. Machine learning pipelines break on exactly this kind of mess, and cleaning it thoughtfully — without destroying information — is most of the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Five rules I now build by
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Traceability over cleverness.&lt;/strong&gt; If money or trust is involved, every action leaves an immutable record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design for the tiredest user.&lt;/strong&gt; If it works at 2 a.m. for a stressed beginner, it works for everyone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reconciliation is a feature, not a report.&lt;/strong&gt; Systems must explain their own numbers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offline is normal.&lt;/strong&gt; Connectivity is a bonus, not an assumption.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bilingual is structural.&lt;/strong&gt; Arabic support means RTL layout, numeral handling, and calendar awareness — not a translation file added at the end.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;Building for hotels in Makkah and Madinah made me a better engineer than any tutorial could. Real businesses do not care about your stack. They care whether the day closes cleanly, whether the guest at the desk gets served, and whether the numbers add up. Software that earns that trust is software that lasts — and that is the standard I now hold every project to, from finance systems to AI models.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Muhammad Faizan is an AI engineer and full-stack developer based in Saudi Arabia. He builds ML systems, web platforms, and developer tools including PocketBot and Gale Download Manager. More at faizzyhon.com.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://faizzyhon.com/blog/posts/i-built-a-hotel-finance-system-in-makkah.html" rel="noopener noreferrer"&gt;faizzyhon.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>career</category>
      <category>productivity</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>How I Built PocketBot: A Fine-Tuned Chatbot That Runs Entirely in the Browser</title>
      <dc:creator>Muhammad Faizan</dc:creator>
      <pubDate>Fri, 04 Dec 2026 16:31:57 +0000</pubDate>
      <link>https://dev.to/faizzyhon/how-i-built-pocketbot-a-fine-tuned-chatbot-that-runs-entirely-in-the-browser-3hnl</link>
      <guid>https://dev.to/faizzyhon/how-i-built-pocketbot-a-fine-tuned-chatbot-that-runs-entirely-in-the-browser-3hnl</guid>
      <description>&lt;p&gt;Most FAQ chatbots need a server and an API key. I wanted one that runs entirely in a browser tab — offline, private, and free to host. PocketBot is that experiment: fine-tune a small language model on a FAQ dataset, compress it aggressively, and serve it in the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  The model
&lt;/h2&gt;

&lt;p&gt;I started with SmolLM2-135M, a 135M-parameter model small enough to be practical in a browser. I fine-tuned it on FAQ-style question/answer data so it specializes in answering questions about one product or site, rather than trying to be a general assistant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compression: where it got interesting
&lt;/h2&gt;

&lt;p&gt;At full precision the fine-tuned model reached 97.2% next-token accuracy on my evaluation set. Plain 4-bit rounding shrank it to about 89 MB but dropped accuracy to 88.8% — a real quality loss. Quantization-aware training (QAT) fixed most of that: training with the 4-bit constraint in the loop recovered accuracy to 97.0%, nearly the full-precision result, at the same ~89 MB size.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running in the browser
&lt;/h2&gt;

&lt;p&gt;The compressed model is exported to ONNX and runs with ONNX Runtime Web / WebGPU. No server, no API key, no data leaving the device. The page downloads the model once and answers locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Honest results and limits
&lt;/h2&gt;

&lt;p&gt;On unseen questions, PocketBot answers roughly 8 of 12 correctly. The evaluation set is small, and the model is narrow by design — it knows its FAQ domain and little else. That trade-off is the point: a small, honest, deployable model beats a large one you cannot ship.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Compression, evaluation, and deployment constraints are one problem, not three. QAT only helps if you measure the right thing, and "runs in the browser" forces discipline on size, latency, and failure modes from day one.&lt;/p&gt;

&lt;p&gt;I wrote the full build log on my site: &lt;a href="https://faizzyhon.com/blog/posts/pocketbot-offline-chatbot-in-the-browser-4-bit-fine-tuned-model.html" rel="noopener noreferrer"&gt;How I Built PocketBot&lt;/a&gt;. The code is open source on my GitHub: &lt;a href="https://github.com/faizzyhon" rel="noopener noreferrer"&gt;https://github.com/faizzyhon&lt;/a&gt;. A follow-up project, rihla-llm, extends this work to Arabic, Urdu, and English pipelines — also on faizzyhon.com.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Darkside Termux – Tool Information Gathering &amp; Social Engineering</title>
      <dc:creator>Muhammad Faizan</dc:creator>
      <pubDate>Tue, 20 Apr 2021 13:16:15 +0000</pubDate>
      <link>https://dev.to/faizzyhon/darkside-termux-tool-information-gathering-social-engineering-545m</link>
      <guid>https://dev.to/faizzyhon/darkside-termux-tool-information-gathering-social-engineering-545m</guid>
      <description>&lt;p&gt;Social Engineering Trojan tools are installed on the victims’ computers and then use them to distribute other malicious payloads. After installation, the backdoor can listen on all network interfaces and is able to send out different indicators of compromise. KIS was first discovered on Friday and researchers note that their backdoor has already successfully been implemented in banking Trojans. This particular backdoor banking Trojan has a proof-of-concept available here. Rick Sanatorium attacks Anthem for Hacking .&lt;br&gt;
&lt;a href="https://cometolearnofficial.blogspot.com/2021/04/darkside-termux-tool-information.html" rel="noopener noreferrer"&gt;https://cometolearnofficial.blogspot.com/2021/04/darkside-termux-tool-information.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>darkside</category>
      <category>termux</category>
      <category>informationgathering</category>
    </item>
  </channel>
</rss>
