<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thuan Bui Huy on Medium]]></title>
        <description><![CDATA[Stories by Thuan Bui Huy on Medium]]></description>
        <link>https://medium.com/@testth02?source=rss-d3f81a6749d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*nIOaCLEw0CRHEiGQ</url>
            <title>Stories by Thuan Bui Huy on Medium</title>
            <link>https://medium.com/@testth02?source=rss-d3f81a6749d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 23:03:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@testth02/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mixture-of-Experts (MoE) — The Architecture Behind Fast, “Big-Brain” AI Models]]></title>
            <link>https://medium.com/@testth02/mixture-of-experts-moe-the-architecture-behind-fast-big-brain-ai-models-99cef166d487?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/99cef166d487</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[mixture-of-experts]]></category>
            <category><![CDATA[ai-architecture]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Fri, 02 Jan 2026 13:26:38 GMT</pubDate>
            <atom:updated>2026-01-02T13:26:38.336Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Mixture-of-Experts (MoE) — </strong>The Architecture Behind Fast, “Big-Brain” AI Models</h3><p><em>Why ERNIE-4.5 A3B, Qwen A-series, Kimi, and frontier models in 2025 rely on MoE — and how it really works.</em></p><h3>1. Why Dense Models Hit a Wall</h3><p>Traditional Transformer models scale intelligence by making <strong>everything bigger</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Bo4ZC1U2bnxFX75B9YEhA.png" /><figcaption>Flowchart Of Dense Models</figcaption></figure><p>Every token activates <strong>all parameters</strong>.</p><p><strong>Problem</strong></p><ul><li>Intelligence ↑</li><li>Compute cost ↑↑</li><li>Memory ↑↑</li><li>Latency ↑↑</li></ul><p>By 2024–2025, dense scaling became economically unsustainable.</p><h3>2. The Core Idea of Mixture-of-Experts (MoE)</h3><p><strong>Mixture-of-Experts (MoE)</strong> changes <em>how</em> computation happens.</p><blockquote><em>Instead of one monolithic network, MoE builds </em><strong><em>many specialist networks</em></strong><em> and activates </em><strong><em>only a few per token</em></strong><em>.</em></blockquote><h3>3. Dense vs MoE (Conceptual View)</h3><h4>Dense Transformer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9OiEwIWEnD89HiMVQwmew.png" /><figcaption>Dense Transformer</figcaption></figure><ul><li>All parameters active</li><li>Cost scales linearly with size</li></ul><h4>MoE Transformer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ki0RBCdehV60KFKTpMPAGw.png" /><figcaption>MoE Transformer</figcaption></figure><ul><li>Only <strong>top-k experts</strong> are active</li><li>Cost scales with <strong>k</strong>, not model size</li></ul><h3>4. Where MoE Fits in the Transformer</h3><p>The MoE does <strong>not</strong> replace the entire transformer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*JCLrwnyEvUFwtM9vBBmXCQ.png" /><figcaption>Flowchart of MoE</figcaption></figure><p>Only the <strong>Feed-Forward Network (FFN)</strong> becomes expert-based.<br>Self-attention remains dense.</p><h3>5. Inside the MoE Feed-Forward Network</h3><h4>5.1 Router (Gating Network)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7VFOFlf5ccBjG57hhYsyg.png" /><figcaption>Expert Router</figcaption></figure><ul><li>Small neural network</li><li>Computes expert scores</li><li>Selects <strong>top-k experts (usually k=1 or 2)</strong> per token</li></ul><h4>5.2 Experts</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-9lHz1syGelLn4vsqVb-Q.png" /><figcaption>Experts</figcaption></figure><p>Each expert:</p><ul><li>A full FFN</li><li>Has identical architecture</li><li>Learns <strong>specialization automatically</strong></li></ul><p>No manual labels. Specialization <em>emerges</em>.</p><h4>5.3 Sparse Activation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N4AkTrVYH8lcWGdWf29Q-g.png" /><figcaption>Sparse Activation</figcaption></figure><p>All other experts stay idle.</p><p>This is the source of MoE efficiency.</p><h3>6. Why MoE Feels Smarter Than Dense Models</h3><p>The MoE improves intelligence <strong>structurally</strong>, not just in terms of scale.</p><h4>Key reasons</h4><ul><li><strong>Specialization</strong>: Experts focus on narrow skills</li><li><strong>Conditional computation</strong>: Easy tokens → cheap experts</li><li><strong>Dynamic routing</strong>: Different reasoning paths per token</li></ul><p>This resembles <strong>human cognitive specialization</strong>.</p><h3>7. Training MoE: The Hard Part</h3><p>MoE is powerful — but fragile without the right techniques.</p><h4>7.1 Expert Collapse Problem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-Wrap2dN4fT2eDOMtXG9w.png" /><figcaption>Expert Collapse</figcaption></figure><p>Without constraints:</p><ul><li>The router sends everything to one expert</li><li>Other experts “die.”</li></ul><h4>7.2 Load-Balancing Loss (Critical)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zR1gLvn9BOb4-Ov_TXXU1g.png" /><figcaption>Load-Balancing Losss</figcaption></figure><p>An auxiliary loss:</p><ul><li>Encourages uniform expert usage</li><li>Prevents routing collapse</li><li>Essential for stable training</li></ul><h4>7.3 Capacity Constraints</h4><p>Each expert has a token limit per batch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43RqMCJhnBUiwdcs8bYdwA.png" /><figcaption>Expert Capacity Constraints</figcaption></figure><p>This prevents bottlenecks and memory blow-ups.</p><h3>8. MoE Inference: GPU Reality</h3><p>MoE saves compute — but adds <strong>system complexity</strong>.</p><h4>Expert Sharding Across GPUs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8IC3exNeXAyAI7AAgzxqrg.png" /></figure><h4>Costs shift from:</h4><ul><li>❌ Compute → ✅ Communication</li><li>❌ FLOPs → ✅ Memory bandwidth</li></ul><p>Well-optimized MoE still wins — poorly optimized MoE does not.</p><h3>9. Why MoE Dominates Frontier Models in 2025</h3><p>Dense scaling alone no longer works.</p><p>MoE provides:</p><ul><li>Massive parameter capacity</li><li>Affordable inference</li><li>Better reasoning specialization</li><li>Long-context scalability</li><li>Agent-ready architectures</li></ul><p>That’s why <strong>ERNIE-4.5 A3B, Qwen A-series, Kimi, and others all use MoE</strong>.</p><h3>10. When You Should Use MoE</h3><h4>Use MoE if:</h4><ul><li>You need a large reasoning capacity</li><li>Inference cost matters</li><li>Long context or agents are involved</li></ul><h4>Avoid MoE if:</h4><ul><li>Model &lt;10B</li><li>Infrastructure is simple</li><li>Latency must be perfectly predictable</li></ul><p>MoE is powerful — but not simple.</p><h3>11. Conclusion</h3><blockquote><strong><em>Dense models scale intelligence by doing more work.<br> MoE scales intelligence by doing the </em>right<em> work.</em></strong></blockquote><p>That shift defines modern AI architecture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99cef166d487" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Modern AI Customer Support Agents Are Built]]></title>
            <link>https://medium.com/@testth02/how-modern-ai-customer-support-agents-are-built-70a334b47f90?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/70a334b47f90</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[enterprise-ai-solutions]]></category>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[ai-architecture]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Thu, 18 Dec 2025 04:02:37 GMT</pubDate>
            <atom:updated>2025-12-18T04:02:37.222Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>AI-powered customer support has evolved far beyond chatbots and static FAQ systems. In modern SaaS platforms, cloud infrastructure, developer tools, fintech, and enterprise software, AI support agents are expected to behave like <strong>experienced human support engineers</strong>.</p><p>These systems must:</p><ul><li>Understand products with <strong>multiple versions and configurations</strong></li><li>Navigate large, fast-changing documentation and knowledge bases</li><li>Safely use internal tools such as ticket systems, logs, and release notes</li><li>Know when to escalate to humans instead of guessing</li></ul><p>The most important lesson from real-world deployments is simple:</p><blockquote><strong><em>Modern AI customer support agents are engineered systems with LLMs embedded inside — not autonomous chatbots.</em></strong></blockquote><h3>1. The Dominant Architecture: Planner–Executor</h3><h4>Why Planner–Executor Became the Standard</h4><p>Across nearly all production-grade AI customer support systems, the <strong>Planner–Executor architecture</strong> has emerged as the default design.</p><p>This architecture deliberately separates responsibilities:</p><ul><li><strong>Planning</strong>: deciding <em>what needs to be done</em></li><li><strong>Execution</strong>: performing those steps using tools and knowledge</li><li><strong>Validation</strong>: checking correctness, safety, and confidence</li></ul><p>This mirrors how senior human support engineers work and enables:</p><ul><li>Deterministic and debuggable workflows</li><li>Safer use of LLMs</li><li>Clear boundaries for human escalation</li><li>Better observability and cost control</li></ul><h4>Logical Architecture Overview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*llC59zYkb-Xf-rMTsnD-HA.png" /><figcaption>Logical Architecture</figcaption></figure><p>In this design, the LLM is <strong>not the system itself</strong>. It is a reasoning component operating inside a controlled workflow.</p><h3>2. Core System Design Layers</h3><h4>2.1 Entry &amp; Routing Layer</h4><p><strong>Purpose</strong></p><ul><li>Ingest tickets, chats, or emails</li><li>Extract structured metadata (product, version, platform, severity)</li><li>Route the request to the correct agent flow</li></ul><p>This layer prevents unnecessary reasoning over irrelevant context and significantly reduces hallucinations and cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6V3eAsKN_ZuIpiRCq5719w.png" /><figcaption>Entry &amp; Routing</figcaption></figure><p>Routing logic is typically deterministic, with optional lightweight LLM classification.</p><h4>2.2 Planning Layer (Task Decomposition)</h4><p>The Planner converts an unstructured problem into an <strong>explicit task plan</strong>.</p><p><strong>Example Output</strong></p><pre>{<br>  &quot;tasks&quot;: [<br>    &quot;identify_error&quot;,<br>    &quot;search_known_issues&quot;,<br>    &quot;check_version_compatibility&quot;,<br>    &quot;propose_fix_or_workaround&quot;  <br>  ]<br>}</pre><p>Design characteristics:</p><ul><li>Uses smaller or mid-sized models</li><li>Strong schema validation</li><li>Cached for common issues</li></ul><p>Planning is intentionally <strong>cheap, explainable, and repeatable</strong>.</p><h4>2.3 Execution Layer (Tool-Augmented Reasoning)</h4><p>The Executor performs each task by combining reasoning with verified tools and data sources.</p><p>Typical execution follows a reasoning–action–observation loop:</p><pre>Thought: This appears version-specific<br>Action: search_release_notes(version=3.2)<br>Observation: Breaking API change detected</pre><p>The loop continues until sufficient verified evidence is gathered.</p><h4>2.4 Tool Layer (Operational Backbone)</h4><p>Production AI agents rely heavily on tools to avoid guessing.</p><p><strong>Common Tools</strong></p><ul><li>Documentation and knowledge-base search</li><li>Ticket history retrieval (Zendesk, Jira)</li><li>Release notes and changelog lookup</li><li>Log analysis and diagnostics</li><li>Version compatibility services</li></ul><p>Tools are isolated and invoked via structured interfaces to ensure safety and auditability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6B4dWOitRlAjdbve3UXErA.png" /><figcaption>Tool Layer</figcaption></figure><h4>2.5 Knowledge &amp; Memory Layer</h4><p>Customer support requires <strong>hybrid knowledge access</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zH33Zr1Py3RIz4FcPrTt4w.png" /><figcaption>Knowledge &amp; Memory Layer</figcaption></figure><ul><li><strong>Vector databases</strong>: semantic retrieval over documentation and past tickets</li><li><strong>Structured databases</strong>: versions, error codes, known issues</li><li><strong>Object storage</strong>: logs, screenshots, user attachments</li></ul><p>Pure vector-based retrieval is insufficient without structured constraints.</p><h4>2.6 Validation &amp; Guardrails</h4><p>Before a response reaches the user, it passes through validation.</p><p><strong>Key Responsibilities</strong></p><ul><li>Enforce schema and format correctness</li><li>Verify version compatibility</li><li>Detect low-confidence or risky answers</li><li>Trigger human escalation when needed</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ddpW3eJai3Ub4kkAINpUdQ.png" /><figcaption>Validation &amp; Guardrails</figcaption></figure><p>This layer is critical for trust, safety, and enterprise adoption.</p><h3>3. Infrastructure &amp; Deployment Architecture</h3><p>Beyond logical design, modern AI support agents require robust infrastructure.</p><h4>Infrastructure Overview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7hg2CS1kC29epKURSWaT7A.png" /><figcaption>Infrastructure</figcaption></figure><h4>LLM Gateway</h4><p>The LLM Gateway decouples business logic from model providers.</p><p><strong>Responsibilities</strong></p><ul><li>Route requests between fast and strong models</li><li>Enforce rate limits and cost budgets</li><li>Log prompts and responses</li><li>Handle provider failover</li></ul><p>This abstraction allows systems to evolve independently of vendors.</p><h4>Tool Services</h4><p>Each tool runs as an independent service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8mpEio_4wrHHsYIjyBnCw.png" /><figcaption>Tool Services</figcaption></figure><p>Isolation improves security, scalability, and maintainability.</p><h4>Observability &amp; Operations</h4><p>Production systems rely on strong observability.</p><p><strong>Key Metrics</strong></p><ul><li>Tool invocation traces</li><li>Latency and cost per ticket</li><li>Escalation and fallback rates</li><li>Validation failure reasons</li></ul><p>These signals enable continuous improvement and safe iteration.</p><h3>Conclusion</h3><p>Modern AI customer support agents succeed because they are <strong>engineered systems</strong>, not autonomous reasoning engines.</p><p>By combining:</p><ul><li>Planner–Executor architecture</li><li>Tool-augmented execution</li><li>Hybrid knowledge retrieval</li><li>Strong validation and escalation</li><li>Robust infrastructure and observability</li></ul><p>Organizations can deploy AI agents that operate reliably alongside human support engineers.</p><blockquote><strong><em>The most effective AI support agents today are defined by structure, control, and system design — not by model size or theoretical complexity.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70a334b47f90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside a Personalized Neural TTS System: Architecture, Workflow & Infrastructure of Modern Voice…]]></title>
            <link>https://medium.com/@testth02/inside-a-personalized-neural-tts-system-architecture-workflow-infrastructure-of-modern-voice-778d748f8bf3?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/778d748f8bf3</guid>
            <category><![CDATA[ml-architecture]]></category>
            <category><![CDATA[text-to-speech]]></category>
            <category><![CDATA[audio-processing]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[multimodal-ai]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Sat, 06 Dec 2025 10:11:28 GMT</pubDate>
            <atom:updated>2025-12-06T10:11:28.080Z</atom:updated>
            <content:encoded><![CDATA[<h3>Inside a Personalized Neural TTS System: Architecture, Workflow &amp; Infrastructure of Modern Voice Cloning</h3><p>Creating natural and editable voice content used to require recording sessions, studio hardware, and countless retakes. Today, personalized neural Text-to-Speech (TTS) systems allow users to <em>clone</em> their voice from a few minutes of audio and generate new speech on demand. This technology powers modern tools where users type text and instantly hear it spoken in their own voice — perfectly integrated into a video or podcast timeline.</p><p>This article breaks down <strong>how such a system is architected</strong>, <strong>the data flows</strong>, and <strong>the infrastructure powering it</strong>, with a focus on multimodal processing of <strong>audio + text</strong> and the lifecycle from <strong>user samples → training → inference → timeline integration</strong>.</p><h3>1. High-Level System Architecture</h3><p>A modern personalized neural TTS system consists of five major components:</p><pre>User Input → Data Validation → Voice Clone Training → Neural TTS Inference →<br>Audio Post-Processing &amp; Timeline Integration</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-gsWquN2Fp92RhcaLperDQ.png" /><figcaption>Architecture Overview</figcaption></figure><h3>2. Data Collection &amp; Validation Pipeline</h3><p>Voice cloning begins when the user submits <strong>sample audio</strong> (usually 30 seconds to 5 minutes).</p><h4>Key Steps</h4><h4>2.1 Audio Upload Service</h4><ul><li>Built on GCS/S3 object storage.</li><li>Uses event-driven triggers (Cloud Pub/Sub, SQS, Kafka) to start preprocessing jobs.</li><li>Enforces allowed formats: WAV, FLAC, 48 kHz, mono.</li></ul><h4>2.2 Speech Quality Verification</h4><p>Purpose: ensure samples are clean enough to train a personalized voice.</p><p>Techniques:</p><ul><li><strong>VAD (Voice Activity Detection)</strong> to measure speech-only intervals.</li><li><strong>SNR estimation</strong> to check background noise.</li><li><strong>Phoneme coverage analysis</strong> via ASR.</li><li><strong>Speaker verification</strong> to ensure the person providing samples = user.</li></ul><p>If samples fail quality tests → user gets automatic feedback.</p><h4>2.3 Transcription (ASR Layer)</h4><p>The validated audio is transcribed using:</p><ul><li>Whisper</li><li>wav2vec2</li><li>Neural Transducer ASR</li></ul><p>Transcripts are aligned to audio using <strong>forced alignment</strong>, enabling the model to learn precise phoneme-to-sound mappings.</p><h3>3. Voice Model Training Pipeline</h3><p>Once audio is validated, the system generates a <strong>personalized voice embedding</strong> or a <strong>fine-tuned TTS model</strong>.</p><p>Two approaches exist:</p><h4>3.1 Embedding-Based Voice Cloning (Most popular today)</h4><p>This method does not train a new model for each user. Instead:</p><ol><li>A large pretrained multi-speaker TTS model (e.g., VITS, Tacotron2+StyleTokens, Grad-TTS)</li><li>A <strong>speaker encoder</strong> generates a <strong>speaker embedding vector</strong> from user audio.</li><li>The TTS model conditions on this embedding to generate speech in the user’s voice.</li></ol><p><strong>Advantages</strong></p><ul><li>Fast (minutes)</li><li>Cheap ($)</li><li>Scales for thousands of users</li><li>Highly consistent voice quality</li></ul><h4>3.2 Fine-Tuned TTS Model (Used for premium fidelity)</h4><p>The user audio is used to fine-tune further:</p><ul><li>Acoustic model</li><li>Vocoder (HiFi-GAN, WaveGlow)</li><li>Prosody &amp; style modules\</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qdWJtzy2y4gVoa9ykJpvyQ.png" /><figcaption>Fine-Tune Pipeline</figcaption></figure><p><strong>Training Infra</strong></p><ul><li>Containerized jobs (Kubernetes, Kubeflow, Ray)</li><li>GPUs: A100 / L40 / H100</li><li>Distributed training via DeepSpeed or PyTorch DDP</li><li>Checkpoints stored in a <strong>Model Artifact Registry</strong></li></ul><p>The training pipeline can take:</p><ul><li><strong>5–20 minutes</strong> for embedding-based systems</li><li><strong>1–6 hours</strong> for full fine-tuning</li></ul><h3>4. Real-Time Text → Speech Generation (Inference Layer)</h3><p>The user writes text inside the editor (video or podcast timeline). The system queries the <strong>Neural TTS Inference API</strong>.</p><h4>Inference Flow</h4><pre>Text Input → Text Normalization → Phoneme Conversion →<br>Acoustic Model → Vocoder → Waveform Output → Post-Processing</pre><h4>4.1 Text Normalization</h4><ul><li>Expands numbers, dates, and abbreviations</li><li>Cleans punctuation</li><li>Handles multilingual text</li></ul><h4>4.2 Linguistic / Phoneme Processing</h4><ul><li>Grapheme-to-phoneme (G2P)</li><li>Prosody estimation: pauses, emphasis, intonation</li><li>Styles (calm, excited, narrator)</li></ul><h4>4.3 Acoustic Model</h4><p>Examples:</p><ul><li>Tacotron 2</li><li>FastSpeech 2 / FastPitch</li><li>VITS</li><li>Grad-TTS</li></ul><p>Output: <strong>mel-spectrogram</strong></p><h4>4.4 Neural Vocoder</h4><p>Converts mel-spectrograms to final waveform:</p><ul><li>HiFi-GAN</li><li>WaveRNN</li><li>WaveGlow</li><li>StyleMelGAN</li></ul><h4>4.5 Post Processing</h4><ul><li>Loudness normalization to −16 LUFS</li><li>Breath/noise model</li><li>Smart prosody smoothing</li><li>Automatic lipsync alignment (for video)</li></ul><h3>5. Integration Into Editor &amp; Timeline</h3><p>The final speech must fit seamlessly into a video or podcast.</p><h4>5.1 Timeline Editor Embedding</h4><ul><li>Rendered audio is sent back as:</li><li>WAV</li><li>FLAC</li><li>low-latency streaming chunks (WebSockets)</li></ul><h4>5.2 Edit Controls</h4><p>Users can:</p><ul><li>Change speed</li><li>Insert pauses</li><li>Adjust pitch</li><li>Re-generate segments using new text</li><li>Auto-duck background music under speech</li></ul><p>This is possible because the system keeps a <strong>structured representation of utterances</strong>:</p><ul><li>phoneme timing</li><li>word alignment</li><li>metadata for replay</li></ul><h3>6. Infrastructure Overview</h3><h4>Backend Services</h4><ul><li><strong>API Gateway:</strong> handles user requests for training &amp; inference.</li><li><strong>Model Training Workers:</strong> GPU-backed compute nodes.</li><li><strong>Inference Servers:</strong> optimized for low latency.</li><li><strong>Job Scheduler:</strong> orchestrates training, validation, and ASR.</li><li><strong>Object Storage:</strong> for audio samples &amp; training sets.</li><li><strong>Model Registry:</strong> store embeddings or full checkpoints.</li><li><strong>Monitoring:</strong> Prometheus, Grafana, OpenTelemetry.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6gyOE2PpBixBOqWRySu-g.png" /><figcaption>Deployment Architecture</figcaption></figure><h3>Conclusion</h3><p>Personalized neural TTS systems represent a major shift in how creators produce voice content. By combining <strong>ASR</strong>, <strong>speaker modeling</strong>, <strong>neural TTS</strong>, and <strong>video/podcast editing tools</strong>, users can generate natural, editable speech that matches their own voice — without recording studios or retakes.</p><p>This synergy of <strong>audio + text multimodal processing</strong>, <strong>GPU-accelerated model training</strong>, and <strong>timeline-aware integration</strong> is what makes modern tools feel so seamless. As models improve, voice cloning will continue moving closer to perfect realism, real-time interaction, and multilingual fluency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=778d748f8bf3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside the Prompting & Script LLM: Architecture, Workflow, and Production Techniques]]></title>
            <link>https://medium.com/@testth02/inside-the-prompting-script-llm-architecture-workflow-and-production-techniques-bd8b46cc5d29?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd8b46cc5d29</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai-automation]]></category>
            <category><![CDATA[llm-architecture]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai-content-creation]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 04:11:24 GMT</pubDate>
            <atom:updated>2025-11-22T04:11:24.200Z</atom:updated>
            <content:encoded><![CDATA[<p>Automated document-to-video systems depend heavily on one core subsystem: the <strong>Prompting &amp; Script LLM</strong>. This component transforms raw input — product descriptions, long-form documents, book chapters, or structured metadata — into a coherent, video-ready script. It builds narrative flow, maintains audience-appropriate tone, and ensures the output aligns with production constraints (scene durations, visual requirements, pacing rules, etc.).</p><p>This article dives deep into how a production-grade Prompting &amp; Script LLM service works. You’ll see how the architecture scales, how it keeps latency predictable, how prompt construction works under the hood, and how to enforce structure and reliability in a generative model.</p><h3>1. Architectural Overview</h3><p>A production script-generation subsystem does much more than call a large language model. It handles content extraction, applies safety filters, constructs dynamic prompts, manages inference across GPU clusters (or vLLM nodes), enforces schema compliance, and evaluates output quality.</p><p>Here’s the high-level architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*yFGa9_ODd-1k_capz8FmZg.png" /><figcaption>High-level Architecture</figcaption></figure><h3>2. Workflow: How the System Generates Production-Ready Scripts</h3><h3>2.1 Document Pre-Processing</h3><p>The workflow begins by converting the input into structured semantic units:</p><ul><li><strong>OCR + Vision models:</strong> Extract text from scanned PDFs or photos.</li><li><strong>Layout parsers:</strong> Detect titles, sections, lists, diagrams.</li><li><strong>Topic segmentation:</strong> Split long documents into logical blocks for scene generation.</li><li><strong>NER and keyphrase extraction:</strong> Identify important entities to highlight in the video.</li></ul><p>This pre-processing ensures the LLM receives <strong>clean, interpretable input</strong>.</p><h3>2.2 Instruction-Optimized Prompt Building</h3><p>Prompt construction is the engine’s core intelligence.</p><p>A good prompt builder uses:</p><ul><li><strong>Dynamic template injection:</strong><br> Prompts change based on genre (product, education, marketing, book summary).</li><li><strong>Structural rules:<br></strong>Scene count<br>Scene length<br>Narration and visual description separation<br>No hallucinations beyond document content</li><li><strong>Style constraints:</strong><br> Tone: formal/friendly/promotional<br> Audience: consumer/expert/enterprise</li><li><strong>Context windows:</strong><br> Chunking large documents + using retrieval augmentation (RAG)</li></ul><p>A production system never hardcodes full prompts — it uses a <strong>templated, parameterized engine</strong> to keep output consistent.</p><h3>2.3 Inference Layer (vLLM + External APIs)</h3><p>The system uses a <strong>dual inference strategy</strong> for speed, flexibility, and cost control:</p><h4>vLLM cluster (primary path)</h4><ul><li>Runs optimized open-source LLMs.</li><li>Uses continuous batching for high throughput.</li><li>Supports parallel, multi-tenant workloads.</li><li>Works with GPU autoscalers (K8s + node autoscaling).</li></ul><h4>External APIs (fallback path)</h4><p>Used when:</p><ul><li>Workload spikes</li><li>Larger models are required</li><li>Customer requests premium quality</li></ul><p>The LLM Gateway decides dynamically which backend to use based on:</p><ul><li>Latency requirements</li><li>Model quality tier</li><li>API availability</li><li>Cost budgets</li></ul><h3>2.4 Script Validation &amp; Enforcement</h3><p>Raw LLM output rarely satisfies production constraints.<br> The system applies a structured validation layer:</p><ul><li><strong>JSON schema validation:</strong><br> Ensures scenes follow a strict format:</li></ul><pre>{<br>  &quot;scene_id&quot;: &quot;string&quot;,<br>  &quot;narration&quot;: &quot;string&quot;,<br>  &quot;visual_description&quot;: &quot;string&quot;,<br>  &quot;duration_seconds&quot;: &quot;number&quot;<br>}</pre><ul><li><strong>Timing rules:</strong><br> Prevent overly long or short scenes.</li><li><strong>Content sanity filters:<br></strong>No hallucinated facts<br>No disallowed language<br>No unsafe content</li><li><strong>Structural checks:</strong><br> Consistent ordering, coherent transitions.</li></ul><p>If validation fails, the system triggers a <strong>regeneration pass</strong>.</p><h3>2.5 Self-Critique &amp; Optimization</h3><p>The engine performs a refinement cycle using techniques such as:</p><ul><li><strong>LLM self-consistency checks</strong></li><li><strong>Chain-of-Verification</strong></li><li><strong>Semantic similarity checks</strong><br> Ensuring narration aligns with document facts.</li><li><strong>Tone harmonization</strong><br> Ensuring consistent style across scenes.</li></ul><p>This produces scripts that feel polished rather than raw.</p><h3>3. Infrastructure &amp; Deployment Design</h3><p>A robust Prompting &amp; Script LLM system must operate reliably even at high volume and under variable workloads.</p><h3>3.1 Core Infrastructure Components</h3><h3>3.1.1 Kubernetes Microservice Deployment</h3><p>Each subsystem runs as an independent K8s microservice:</p><ul><li>Content extraction</li><li>Prompt builder</li><li>LLM gateway</li><li>Validation service</li><li>Quality evaluation</li><li>Telemetry + observability</li></ul><p>This modularity enables independent scaling.</p><h3>3.1.2 vLLM GPU Cluster</h3><p>A production inference cluster includes:</p><ul><li><strong>GPU autoscaling nodes</strong><br> (A100/H100/L40S based on workload)</li><li><strong>Continuous batching</strong> for throughput</li><li><strong>KV caching</strong> for long prompts</li><li><strong>Token streaming</strong> for low latency</li><li><strong>Priority queueing</strong><br> (enterprise vs free-tier job separation)</li></ul><h3>3.1.3 High-Availability LLM Gateway</h3><p>The gateway acts as the “traffic controller”:</p><ul><li>Chooses between vLLM and external APIs</li><li>Retries failures</li><li>Logs token usage</li><li>Enforces model access rules</li><li>Applies rate limits per tenant</li></ul><p>This layer allows you to add or switch LLM vendors without changing your application logic.</p><h3>4. Techniques Behind the System</h3><p>Below are the key techniques that make the system robust, controllable, and production-ready.</p><h3>4.1 Instruction-Safe Prompt Engineering</h3><p>The system uses techniques such as:</p><ul><li>Constraint-based decomposition</li><li>Format-locking (“Respond only in JSON schema: …”)</li><li>Role separation (editor, narrator, fact-checker)</li><li>Step-by-step reasoning prompts</li><li>Guidance embeddings (e.g., “corporate tone”, “storytelling tone”)</li></ul><h3>4.2 RAG for Large Documents</h3><p>Large inputs exceed LLM context windows.<br> A RAG pipeline solves this by:</p><ol><li>Chunking the document</li><li>Embedding the sections</li><li>Retrieving the most relevant blocks</li><li>Feeding only relevant context to the LLM</li><li>Maintaining global structure via metadata</li></ol><p>This allows the system to process books, manuals, or long reports.</p><h3>4.3 Multi-Pass Refinement</h3><p>The engine improves the script with:</p><ul><li>Draft generation</li><li>Self-critique pass</li><li>Final refinement</li><li>Structural enforcement</li></ul><p>This reduces hallucinations and enhances clarity.</p><h3>4.4 Safety and Alignment</h3><p>Production text pipelines must filter for:</p><ul><li>Toxic content</li><li>Personal data</li><li>Unsafe instructions</li><li>Misleading claims</li></ul><p>A safety classifier runs before and after the LLLM call.</p><h3>5. Final Output</h3><p>The final script follows a precise structure:</p><ul><li>scene-level narration</li><li>visual description</li><li>duration estimate</li><li>video-production instructions</li><li>optional TTS markers</li><li>optional shot suggestions</li></ul><p>This structure allows downstream video engines (animation, slideshow, avatar TTS, or cinematic generators) to convert the script into a full video.</p><h3>6. Conclusion</h3><p>The Prompting &amp; Script LLM is far more than a text generator — it is the narrative engine that drives the entire document-to-video pipeline. By combining structured prompting, RAG-enhanced context assembly, schema validation, and multi-pass refinement, this subsystem ensures every script remains coherent, grounded, and production-ready at scale. Its architecture reflects the reality of modern AI systems: reliability requires engineering discipline, not just powerful models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd8b46cc5d29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accelerating Vision AI Inference with TensorRT: YOLOv8 and DINOv2 Optimization in Practice]]></title>
            <link>https://medium.com/@testth02/accelerating-vision-ai-inference-with-tensorrt-yolov8-and-dinov2-optimization-in-practice-287acd4c73e1?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/287acd4c73e1</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[tensorrt]]></category>
            <category><![CDATA[model-optimization]]></category>
            <category><![CDATA[ai-inferencing]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 04:06:55 GMT</pubDate>
            <atom:updated>2025-11-11T04:06:55.951Z</atom:updated>
            <content:encoded><![CDATA[<p>Deploying AI models efficiently in production has always been a delicate balance between <strong>accuracy</strong> and <strong>latency</strong>.<br>Modern deep learning models like <strong>YOLOv8</strong> and <strong>DINOv2</strong> deliver impressive accuracy — but their computational cost makes them less suitable for real-time applications without optimization.</p><p>Enter <strong>NVIDIA TensorRT</strong> — a powerful inference optimization SDK that transforms your trained models into <strong>lightning-fast, GPU-optimized engines</strong> ready for real-world deployment.</p><p>In this article, we’ll walk through how TensorRT can drastically improve inference speed for <strong>object detection (YOLOv8)</strong> and <strong>visual representation learning (DINOv2)</strong> — two very different yet representative classes of computer vision models.</p><h3>What is TensorRT?</h3><p><strong>NVIDIA TensorRT</strong> is a <strong>deep learning inference optimizer and runtime</strong> built to maximize performance on NVIDIA GPUs.<br>It takes your trained models (from PyTorch, TensorFlow, ONNX, etc.) and performs a series of graph and kernel-level optimizations before producing a serialized <strong>TensorRT engine</strong> file (.engine), which runs significantly faster at inference time.</p><p>TensorRT combines several performance engineering techniques:</p><ul><li><strong>Layer fusion:</strong> Combines consecutive operations (Conv → BN → ReLU) into a single CUDA kernel.</li><li><strong>Precision calibration:</strong> Converts FP32 weights to <strong>FP16</strong> or <strong>INT8</strong> for speed and memory gains.</li><li><strong>Kernel auto-tuning:</strong> Selects the most efficient GPU kernels for your hardware (e.g., A100, RTX, Jetson).</li><li><strong>Dynamic tensor memory:</strong> Reduces allocation overhead with memory pooling.</li><li><strong>Parallel streams:</strong> Increases throughput via asynchronous execution.</li></ul><h3>Why TensorRT Matters for Vision Models</h3><p>Deep neural networks in computer vision are heavy — millions of parameters, complex operations, and large image inputs.<br>TensorRT helps bridge the gap between <strong>research models</strong> and <strong>production-grade systems</strong>, enabling:</p><ul><li>Real-time object detection at <strong>&gt;300 FPS</strong></li><li>Low-latency visual feature extraction for <strong>retrieval or segmentation pipelines</strong></li><li>Efficient deployment on <strong>cloud GPUs</strong> and <strong>embedded Jetson devices</strong></li></ul><h3>TensorRT Optimization Pipeline</h3><p>Here’s an overview of the complete model optimization and inference workflow using TensorRT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Za8oACZsGnKKh4WSx4AGA.png" /><figcaption>Optimization Pipeline</figcaption></figure><p>This flow is identical regardless of the model type — CNN-based (YOLOv8) or Transformer-based (DINOv2).</p><h3>System Infrastructure for Deployment</h3><p>TensorRT is flexible — you can deploy optimized engines in the <strong>cloud</strong> or on <strong>edge devices</strong>.<br>Below is a conceptual diagram showing how YOLOv8 and DINOv2 are used within an AI inference service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ITM-okWRAdMnHRCKkcfrCQ.png" /><figcaption>Infrastructure</figcaption></figure><h3>YOLOv8 Optimization Workflow</h3><p><strong>YOLOv8</strong> (from Ultralytics) is among the most popular object detectors.<br>It’s accurate, lightweight, and easy to export — making it a great candidate for TensorRT optimization.</p><h4>Step 1 — Export YOLOv8 to ONNX</h4><pre>from ultralytics import YOLO<br>model = YOLO(&quot;yolov8n.pt&quot;)  # or yolov8s, yolov8m, yolov8l<br>model.export(format=&quot;onnx&quot;, opset=13, dynamic=True)</pre><h4>Step 2 — Convert ONNX to TensorRT Engine</h4><pre>trtexec --onnx=yolov8n.onnx --saveEngine=yolov8n_fp16.engine --fp16 \<br>--minShapes=input:1x3x640x640 --optShapes=input:8x3x640x640 --maxShapes=input:16x3x640x640</pre><p>This command performs automatic FP16 precision optimization and builds a .engine file ready for inference.</p><h4>Step 3 — Run Inference</h4><pre>import tensorrt as trt, pycuda.driver as cuda, pycuda.autoinit<br>engine = trt.Runtime(trt.Logger()).deserialize_cuda_engine(open(&quot;yolov8n_fp16.engine&quot;,&quot;rb&quot;).read())<br>context = engine.create_execution_context()<br>context.execute_v2([...])  # perform detection</pre><p><strong>Result:</strong> Up to <strong>3–4× speedup</strong>, e.g., 120 FPS → 360 FPS on an RTX 4090, with negligible accuracy drop.</p><h3>DINOv2 Optimization Workflow</h3><p><strong>DINOv2</strong> by Meta AI is a self-supervised <strong>Vision Transformer (ViT)</strong> model designed for high-quality image embeddings and semantic understanding.<br>Transformer models benefit heavily from TensorRT’s kernel fusion and attention optimization.</p><h4>Step 1 — Export DINOv2 to ONNX</h4><pre>import torch, timm<br>model = timm.create_model(&#39;vit_base_patch14_dinov2&#39;, pretrained=True).eval()<br>dummy = torch.randn(1, 3, 224, 224)<br>torch.onnx.export(model, dummy, &quot;dinov2.onnx&quot;, opset_version=13)</pre><h4>Step 2 — Build TensorRT Engine</h4><pre>trtexec --onnx=dinov2.onnx --saveEngine=dinov2_fp16.engine --fp16 \<br>--minShapes=input:1x3x224x224 --optShapes=input:8x3x224x224 --maxShapes=input:16x3x224x224</pre><h4>Step 3 — Inference</h4><pre>import tensorrt as trt, pycuda.driver as cuda, pycuda.autoinit<br>engine = trt.Runtime(trt.Logger()).deserialize_cuda_engine(open(&quot;dinov2_fp16.engine&quot;,&quot;rb&quot;).read())<br>context = engine.create_execution_context()<br>context.execute_v2([...])  # extract image embeddings</pre><p><strong>Result:</strong> 2–3× faster embedding extraction compared to PyTorch FP32 inference.</p><h3>Performance Comparison</h3><p>When moving from standard PyTorch inference to TensorRT-optimized inference, you can expect <strong>2x to 5x speedup</strong> on modern NVIDIA GPUs — depending on the model architecture, GPU type, and precision (FP16 or INT8).</p><p>For instance, a small YOLOv8 model (yolov8n) that takes around 15–20 milliseconds per frame in PyTorch may drop to roughly <strong>5–8 milliseconds</strong> with TensorRT FP16 optimization.</p><p>Similarly, a DINOv2 ViT-base model that typically requires 25–30 milliseconds for a 224×224 image in PyTorch can achieve <strong>10–12 milliseconds</strong> in TensorRT with FP16.</p><p>This acceleration allows you to handle higher frame rates, scale up batch processing, and deploy models even on smaller GPUs like NVIDIA Jetson devices. The overall GPU utilization also becomes more efficient, making TensorRT a must-have in production inference pipelines.</p><h3>Key Insights</h3><ul><li><strong>TensorRT</strong> optimizes both <strong>CNNs</strong> (YOLOv8) and <strong>Transformers</strong> (DINOv2) effectively.</li><li><strong>FP16</strong> provides the best trade-off between speed and precision for most applications.</li><li><strong>INT8 calibration</strong> can yield an additional 20–40% speedup if minor accuracy loss is acceptable.</li><li>TensorRT integrates seamlessly with <strong>ONNX Runtime</strong>, <strong>PyTorch-TensorRT</strong>, and <strong>DeepStream SDK</strong> for scalable deployment.</li><li>The resulting .engine file is portable — you can deploy it across GPU-powered servers or embedded devices like <strong>Jetson AGX Orin</strong>.</li></ul><h3>Visualizing End-to-End Optimization</h3><p>Below is a side-by-side visualization of YOLOv8 and DINOv2 pipelines — from training to deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52ad_9cMYEk4S4-zFlulTg.png" /><figcaption>End-to-End Pipeline</figcaption></figure><h3>Conclusion</h3><p>In the journey from <strong>research to production</strong>, TensorRT serves as the <strong>final accelerator</strong> that bridges model accuracy and runtime performance.</p><p>By converting YOLOv8 and DINOv2 into TensorRT engines, we:</p><ul><li>Cut inference latency by <strong>2–6x</strong></li><li>Reduced GPU memory footprint</li><li>Achieved consistent real-time performance for both detection and embedding tasks</li></ul><p>Whether you’re building <strong>autonomous vision systems</strong>, <strong>content retrieval engines</strong>, or <strong>real-time analytics pipelines</strong>, TensorRT enables you to deploy complex models <strong>at scale and at speed</strong>.</p><h3>References</h3><ul><li><a href="https://developer.nvidia.com/tensorrt">NVIDIA TensorRT Developer Guide</a></li><li><a href="https://github.com/ultralytics/ultralytics">Ultralytics YOLOv8 GitHub</a></li><li><a href="https://github.com/facebookresearch/dinov2">Meta AI DINOv2</a></li><li><a href="https://github.com/huggingface/pytorch-image-models">PyTorch Image Models (timm)</a></li><li><a href="https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html">ONNX Runtime TensorRT Execution Provider</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=287acd4c73e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self-Hosted Architecture for Image Captioning Application]]></title>
            <link>https://medium.com/@testth02/self-hosted-architecture-for-image-captioning-application-a8fe42f400e8?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8fe42f400e8</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[image-captioning]]></category>
            <category><![CDATA[self-hosted]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Wed, 05 Nov 2025 01:00:54 GMT</pubDate>
            <atom:updated>2025-11-05T01:00:54.319Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>A self-hosted image captioning system provides full control of <strong>GPU infrastructure</strong>, <strong>data residency</strong>, and <strong>model lifecycle</strong>.<br>This architecture suits research labs, regulated industries, or enterprises that require on-prem data control and custom performance tuning.</p><h3>System Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGYwI8cZ1y0zwtePSx_81Q.png" /><figcaption>System Architecture</figcaption></figure><h3>Processing Flow</h3><ol><li><strong>User Upload &amp; Auth</strong><br>The frontend app connects through <strong>Nginx</strong>, which routes authenticated requests to the <strong>FastAPI/NestJS</strong> backend.</li><li><strong>Image Storage &amp; Event Trigger</strong><br>Uploaded images are stored in <strong>MinIO</strong>, and a message is published to <strong>Kafka</strong> (or RabbitMQ) indicating a new job.</li><li><strong>Model Inference</strong><br>A <strong>GPU worker</strong> consumes messages, processes the image using a <strong>captioning model</strong>, and pushes the results to <strong>Redis</strong> (for low latency) and <strong>PostgreSQL</strong> (for persistence).</li><li><strong>Real-time Updates</strong><br>Once inference completes, the backend notifies clients via <strong>WebSocket</strong> or <strong>Server-Sent Events</strong>.</li><li><strong>Observability</strong><br><strong>Prometheus</strong> collects system metrics, while logs are aggregated in <strong>ELK</strong> or <strong>Grafana Loki</strong> for debugging.</li></ol><h3>Infrastructure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oN36XHBWxdrC3bVSp7-zaw.png" /><figcaption>Infrastructure</figcaption></figure><h3>Design Tips</h3><ul><li><strong>Containerize everything</strong> — deploy via <strong>Kubernetes</strong> with GPU scheduling.</li><li><strong>Scale horizontally</strong> using multiple inference pods behind a <strong>load balancer</strong>.</li><li>Use <strong>Triton Inference Server</strong> or <strong>Ray Serve</strong> for multi-model GPU batching.</li><li><strong>Persist metadata</strong> in PostgreSQL, but cache hot results in Redis.</li><li>Collect GPU utilization metrics via <strong>NVIDIA DCGM Exporter</strong> into Prometheus.</li><li>Apply <strong>CI/CD automation</strong> (ArgoCD / Flux) for model updates and version rollout.</li><li>Use <strong>MinIO replication</strong> for high availability and disaster recovery.</li></ul><h3>Conclusion</h3><p>Self-hosting provides full control of compute and data — crucial for organizations with privacy or latency constraints.<br>It requires DevOps expertise, but enables deep customization:</p><ul><li>GPU tuning</li><li>Optimized inference batching</li><li>Custom orchestration</li></ul><p>Over time, this setup can evolve into a <strong>hybrid model</strong> in which cloud services manage the API and monitoring layers, while on-prem GPUs handle inference workloads.</p><p>Both architectures — <strong>Serverless Cloud</strong> and <strong>Self-Hosted GPU</strong> — can serve the same application purpose.<br>The choice depends on your <strong>deployment constraints</strong>, <strong>team capability</strong>, and <strong>scaling goals</strong>:</p><ul><li>Start <strong>serverless</strong> for agility</li><li>Transition to <strong>self-hosted</strong> when data, control, or GPU optimization becomes key</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8fe42f400e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Smarter SQL Agent — Training and Fine-Tuning with Your Own Data Schema]]></title>
            <link>https://medium.com/@testth02/building-a-smarter-sql-agent-training-and-fine-tuning-with-your-own-data-schema-121a6de39e18?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/121a6de39e18</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[sql-agent]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 01:04:16 GMT</pubDate>
            <atom:updated>2025-10-28T01:04:16.524Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Smarter SQL Agent — Training and Fine-Tuning with Your Own Data Schema</h3><h3>Introduction</h3><p>In my previous article, <a href="https://medium.com/@testth02/sql-agent-architecture-from-query-to-insight-with-llms-9417ba208cb4"><strong>SQL Agent Architecture: From Query to Insight with LLMs</strong></a>, we explored how a modern SQL Agent acts as the <em>intelligent bridge</em> between natural language and structured data — transforming plain questions into SQL queries, executing them safely, and explaining results through reasoning layers.</p><p>That article focused on <strong>the architecture and runtime design</strong> — specifically, how the SQL Agent integrates with RAG, schema retrieval, and visualization to generate real-time insights.</p><p>In this follow-up, we delve a step deeper into the <strong>learning and fine-tuning process</strong> — how to make your SQL Agent <em>truly understand your database schema and business logic</em>.</p><h3>Why Fine-Tune a SQL Agent?</h3><p>Most off-the-shelf LLMs (like GPT-4, Claude, Gemini) can write SQL — but they:</p><ul><li>Don’t know your <strong>custom schema</strong> or <strong>naming conventions</strong></li><li>Can’t reason about <strong>business metrics</strong> (e.g., “conversion rate” or “active users”)</li><li>Often make <strong>syntax mistakes</strong> or wrong joins for complex DBs</li></ul><p>Fine-tuning or domain adaptation helps the SQL Agent:</p><ul><li>Understand <strong>your database structure and relationships</strong></li><li>Map <strong>natural language queries → precise SQL syntax</strong></li><li>Produce <strong>interpretable explanations</strong> and <strong>data insights</strong></li></ul><h3>System Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*BVL5u08r7QwyzVYWaFeLWg.png" /><figcaption>System main components</figcaption></figure><p><strong>Component Summary:</strong></p><ul><li><strong>Schema &amp; Query Collector:</strong> Extracts metadata and example queries.</li><li><strong>Vector DB:</strong> Stores embeddings for schema + query context.</li><li><strong>RAG Layer:</strong> Retrieves relevant schema details during query generation.</li><li><strong>Fine-Tuning / Adapter Layer:</strong> Teaches the LLM your specific schema and logic.</li><li><strong>SQL Agent Runtime:</strong> Runs in production to interpret, execute, and explain queries.</li></ul><h3>Infrastructure Design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qi_GR2LnnGlP4zJ7Gr5IQw.png" /><figcaption>Infrastructure</figcaption></figure><p><strong>Infrastructure Components:</strong></p><ul><li><strong>Data &amp; Schema Store:</strong> PostgreSQL or MySQL holds structured logs and metadata.</li><li><strong>Vector Database:</strong> Stores schema and query embeddings for semantic retrieval (FAISS, pgVector, Weaviate).</li><li><strong>LLM Runtime:</strong> Runs fine-tuned or adapter-based models using OpenAI, vLLM, or Hugging Face backends.</li><li><strong>Orchestration Layer (SQL Agent Runtime):</strong> Manages RAG, context retrieval, and SQL reasoning with LangChain or LlamaIndex.</li><li><strong>Visualization Layer:</strong> Connects insights to dashboards via Streamlit, Grafana, or Superset.</li><li><strong>Monitoring:</strong> Prometheus + Grafana to track performance, cost, and accuracy.</li></ul><h3>Fine-Tuning Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxCKGCJf-Ux4y-rYIBzbSA.png" /><figcaption>Fine-tuning workflow</figcaption></figure><p><strong>Continuous Learning Loop:</strong></p><ul><li>Gather user queries and SQL pairs from logs.</li><li>Use them to improve the fine-tuned dataset.</li><li>Regularly re-embed the updated schema to keep the RAG context fresh.</li></ul><h3>Fine-Tune the Model</h3><p>When schema complexity grows, consider <strong>model fine-tuning</strong> or <strong>adapter training</strong>:</p><ul><li><strong>Fine-Tuning:</strong> Use OpenAI’s GPT-4-turbo fine-tuning API for domain adaptation.</li><li><strong>Adapter-Based (LoRA):</strong> Lightweight and cost-effective — great for self-hosted open models like Mistral or Llama 3.</li><li><strong>Dataset Design:</strong> Include variations of your queries, schemas, and natural language phrasings.</li><li><strong>Evaluation:</strong> Test on unseen user queries to measure precision, correctness, and reasoning clarity.</li></ul><h3>Conclusion</h3><ul><li><strong>Start with RAG</strong>, then fine-tune for your schema.</li><li><strong>Keep schema embeddings fresh.</strong> Automate updates with CI/CD for embeddings.</li><li><strong>Use adapters for flexibility.</strong> They’re faster, cheaper, and easier to iterate.</li><li><strong>Close the loop.</strong> Feed misinterpreted or failed SQL queries back into training.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=121a6de39e18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Cloud-Serverless Image Captioning Application]]></title>
            <link>https://medium.com/@testth02/building-a-cloud-serverless-image-captioning-application-abf69671ae45?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/abf69671ae45</guid>
            <category><![CDATA[image-captioning]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Mon, 20 Oct 2025 04:54:36 GMT</pubDate>
            <atom:updated>2025-10-20T04:54:36.669Z</atom:updated>
            <content:encoded><![CDATA[<p>Designing a Scalable, Event-Driven AI System with Modern Cloud Infrastructure</p><h3>Introduction</h3><p>As generative AI moves from research to production, developers face a recurring challenge: <strong>how to design scalable, cost-efficient AI systems without managing heavy infrastructure</strong>.</p><p>One practical example is <strong>image captioning</strong> — automatically generating a caption for uploaded images. While the AI model itself (e.g., CLIP, BLIP, or Vision-Language Transformers) may be complex, the real challenge lies in <strong>deploying it as a reliable cloud application</strong> that can handle thousands of image uploads, generate captions asynchronously, and notify users in real time.</p><p>Traditional monolithic designs struggle with cost and scalability. Instead, the <strong>serverless architecture</strong> offers a modern approach — combining <strong>event-driven workflows</strong>, <strong>managed ML endpoints</strong>, and <strong>pay-per-use compute</strong>.</p><p>This article explores how to architect such a system using today’s best cloud practices — with a full design diagram and infrastructure flow.</p><h3>System Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcWO7b1Lg-ECAUsYynXg3g.png" /><figcaption>High-level architecture</figcaption></figure><h3>Data and Processing Flow</h3><ol><li><strong>Image Upload</strong><br>The user uploads an image via a web or mobile client.<br>The frontend requests a <strong>pre-signed URL</strong> from API Gateway, allowing direct upload to <strong>S3</strong> without exposing backend credentials.</li><li><strong>Event Triggering</strong><br>Each upload to the S3 bucket emits an <strong>event notification</strong> to <strong>SQS</strong>, decoupling storage from processing and enabling reliable async workflows.</li><li><strong>Model Inference</strong><br>A <strong>Lambda function</strong> or <strong>SageMaker Endpoint</strong> subscribes to SQS events.<br>It loads the image, performs inference with a pre-trained vision-language model, and stores the generated caption in <strong>DynamoDB</strong>.</li><li><strong>Notification Delivery</strong><br>Once the caption is ready, an <strong>SNS Topic</strong> sends a notification to the frontend through WebSocket or push messaging.<br>The user instantly sees the generated caption.</li><li><strong>Monitoring and Logging</strong><br>All Lambda and SageMaker activities are logged to <strong>CloudWatch</strong> and traced with <strong>AWS X-Ray</strong> for end-to-end visibility.</li></ol><h3>Infrastructure Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSlguHUgfErsFNp16HKiKQ.png" /><figcaption>Infrastructure</figcaption></figure><h3>Model Selection for Serverless Image Captioning</h3><p>Selecting the right model is crucial to balance <strong>accuracy, latency, and cost</strong> in a serverless setup.</p><h3>1. Define Constraints</h3><ul><li><strong>Memory limits:</strong> AWS Lambda max ~10 GB RAM, Cloud Functions ~8 GB</li><li><strong>Execution time:</strong> Typically &lt;15 minutes</li><li><strong>Cold start:</strong> Large models (&gt;1 GB) may incur delays</li><li><strong>GPU availability:</strong> Only via managed endpoints (SageMaker, Vertex AI, etc.)</li></ul><h3>2. Deployment-Based Model Choice</h3><p><strong>Lightweight / CPU inference</strong></p><ul><li>Model size: &lt; 500 MB</li><li>Example: BLIP-base, MiniGPT-2</li><li>Use case: Lambda / Cloud Functions for small-to-medium workloads</li></ul><p><strong>Moderate / Managed CPU-GPU</strong></p><ul><li>Model size: 0.5–2 GB</li><li>Example: BLIP-large, Flamingo-mini, GIT-base</li><li>Use case: Managed endpoints like SageMaker or Vertex AI</li></ul><p><strong>Large / GPU-intensive</strong></p><ul><li>Model size: &gt; 2 GB</li><li>Example: LLaVA-1.5, Kosmos-2, InternVL</li><li>Use case: GPU workers with serverless orchestration</li></ul><h3>3. Optimization Techniques</h3><ul><li><strong>Quantization:</strong> FP16 / INT8 to reduce memory &amp; speed up inference</li><li><strong>ONNX Conversion:</strong> Convert PyTorch models for faster cold starts</li><li><strong>Batch Inference:</strong> Process multiple requests in one model call</li><li><strong>Layer Caching:</strong> Cache vision encoder outputs (e.g., CLIP embeddings)</li></ul><h3>Key Design Principles</h3><h3>1. Event-Driven Architecture</h3><p>Use <strong>asynchronous triggers</strong> (S3 → SQS → Lambda) to avoid blocking upload requests and allow horizontal scaling.</p><h3>2. Stateless Compute</h3><p>Each Lambda function runs independently with <strong>stateless logic</strong>. This design makes it easier to scale and update model versions.</p><h3>3. Managed ML Serving</h3><p>Leverage <strong>SageMaker Endpoints</strong> or <strong>Vertex AI Endpoints</strong> to host models securely without managing GPU instances manually.</p><h3>4. Cost Efficiency</h3><p>The system scales to zero when idle — no servers to pay for. You only incur cost when users upload and process images.</p><h3>5. Observability and Resilience</h3><p>Integrate <strong>CloudWatch Dashboards</strong>, <strong>structured logging</strong>, and <strong>tracing</strong> to detect slow inference or failed uploads quickly.</p><h3>Benefits</h3><ul><li><strong>Speed:</strong> Build and deploy AI pipelines in days, not months.</li><li><strong>Elasticity:</strong> Scales automatically with upload frequency.</li><li><strong>Maintainability:</strong> No DevOps for servers or GPUs.</li><li><strong>Integration:</strong> Works seamlessly with managed ML platforms.</li><li><strong>Cost Control:</strong> Ideal for unpredictable workloads or demos.</li></ul><h3>Conclusion</h3><p>Serverless design represents a modern way of thinking about AI infrastructure — instead of provisioning servers for peak load, you design <strong>events, triggers, and pipelines</strong> that respond intelligently to user actions.</p><p>For image captioning, this means: <em>Upload → Trigger → Infer → Notify → Scale → Repeat.</em></p><p>This pattern generalizes to many other AI services — from video summarization to image processing tasks — enabling fast, global, and resilient deployments without managing a single server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abf69671ae45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Agent Architecture: From Query to Insight with LLMs]]></title>
            <link>https://medium.com/@testth02/sql-agent-architecture-from-query-to-insight-with-llms-9417ba208cb4?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9417ba208cb4</guid>
            <category><![CDATA[sql-agent]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Sat, 11 Oct 2025 10:06:00 GMT</pubDate>
            <atom:updated>2025-10-11T10:06:00.869Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern data-driven platforms, the <strong>SQL Agent</strong> layer bridges traditional databases and intelligent reasoning.<br>Instead of just running queries, this layer understands <em>why</em> results look the way they do — and explains patterns, anomalies, and root causes in plain language.</p><h3>What is an SQL Agent?</h3><p>An <strong>SQL Agent</strong> is an AI-powered component that:</p><ul><li>Translates <strong>natural language</strong> questions into SQL queries.</li><li>Executes queries securely on structured databases (e.g., PostgreSQL, MySQL).</li><li>Analyzes and summarizes results using <strong>LLMs</strong> (like OpenAI’s GPT-4/5).</li><li>Uses <strong>retrieval-augmented generation (RAG)</strong> and <strong>function-calling APIs</strong> to enhance accuracy and context.</li></ul><p>This layer is the brain that connects <strong>data</strong>, <strong>context</strong>, and <strong>interpretation</strong>.</p><h3>SQL Agent Architecture</h3><p>Here’s the architecture showing how data, LLM reasoning, and APIs interact:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9XcLrkErUFtwsJPQF0XNQ.png" /><figcaption>High-level architecture</figcaption></figure><h3>Key Components of the SQL-Agent Layer</h3><ul><li><strong>NL → SQL Translator</strong><br> Converts natural language into SQL with schema awareness.<br> <em>Tools / Frameworks:</em> OpenAI Function Calling, LangChain SQLChain, Text-to-SQL models</li><li><strong>SQL Executor</strong><br> Safely executes generated SQL queries.<br> <em>Tools / Frameworks:</em> psycopg2, SQLAlchemy, LangChain SQLDatabaseToolkit</li><li><strong>Analysis Module</strong><br> Runs statistics, anomaly detection, or ML checks on query results.<br> <em>Tools / Frameworks:</em> Pandas, Scikit-learn, Prophet</li><li><strong>RAG Retriever</strong><br> Provides contextual knowledge or schema details for more accurate query generation.<br> <em>Tools / Frameworks:</em> FAISS, ChromaDB, PostgreSQL pgVector</li><li><strong>LLM Reasoning Layer</strong><br> Summarizes and interprets query results to generate human-readable explanations or insights.<br> <em>Tools / Frameworks:</em> OpenAI API (GPT-4 / GPT-5), Mistral</li><li><strong>Visualization API</strong><br> Connects analysis outputs to dashboards or live data streams.<br> <em>Tools / Frameworks:</em> Grafana, Streamlit, Retool</li></ul><h3>Infrastructure Design</h3><p>Here’s the infrastructure design:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQqUNhRqSHrC_iEArH92gw.png" /><figcaption>Infrastructure</figcaption></figure><h3>RAG &amp; Function Calling Purpose</h3><p>Traditional text-to-SQL agents struggle when schema or domain knowledge is complex.<br>By combining <strong>RAG (Retrieval-Augmented Generation)</strong> and <strong>function calling</strong>, you ensure:</p><ol><li><strong>Contextual awareness</strong> — the agent retrieves the schema, data dictionary, or prior query context.</li><li><strong>Structured reasoning</strong> — the LLM can call functions for execution rather than hallucinate SQL.</li><li><strong>Explainability</strong> — after running SQL, the model interprets results with reference to retrieved documents.</li></ol><p>This hybrid method improves <strong>precision</strong>, <strong>security</strong>, and <strong>trust</strong> in automated insights.</p><h3>Example Flow</h3><ol><li>Analyst asks:<br> <em>“Why did API response time spike last week?”</em></li><li>SQL Agent retrieves relevant schema and context (via RAG).</li><li>LLM generates SQL → Executes safely → Fetches results.</li><li>The statistical module detects an anomaly (e.g., a 30% increase in latency).</li><li>LLM generates a human-readable explanation:<br> <em>“Response time increased due to elevated error retries from service A.”</em></li><li>The system outputs a summary + chart to a dashboard.</li></ol><h3>Modern Enhancements (2025+)</h3><ul><li><strong>Hybrid SQL + Graph Retrieval</strong>: Combine relational DB and knowledge graph context.</li><li><strong>Semantic Query Caching</strong>: Store embeddings of prior questions to speed up responses.</li><li><strong>Auto-RAG Optimization</strong>: Dynamically refine retrieved context based on query feedback.</li><li><strong>Multi-Agent Orchestration</strong>: One agent handles SQL, another does reasoning, and another handles visualization.</li></ul><h3>Conclusion</h3><p>The <strong>SQL Agent Layer</strong> transforms databases into <em>intelligent collaborators</em>. Instead of static dashboards, teams get real-time reasoning, anomaly detection, and explainable AI-driven insights.</p><p>Building this layer bridges the gap between <em>data accessibility</em> and <em>decision intelligence</em> — and it’s rapidly becoming the core of the modern AI analytics stack.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9417ba208cb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Learning for Image Quality Assessment: Pushing Embedded Vision Beyond Traditional Methods]]></title>
            <link>https://medium.com/@testth02/deep-learning-for-image-quality-assessment-pushing-embedded-vision-beyond-traditional-methods-87f7e18a2595?source=rss-d3f81a6749d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/87f7e18a2595</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[edge-ai]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[vision-transformer]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Thuan Bui Huy]]></dc:creator>
            <pubDate>Wed, 01 Oct 2025 00:53:43 GMT</pubDate>
            <atom:updated>2025-10-01T00:53:43.151Z</atom:updated>
            <content:encoded><![CDATA[<p>From CNNs to Vision Transformers — how deep learning redefines image quality and auto-frame selection in computer vision systems</p><h3>Why Deep Learning for IQA?</h3><p>In my previous article — <a href="https://medium.com/@testth02/the-role-of-image-quality-and-auto-frame-selection-in-embedded-devices-6a814d92c6f5">https://medium.com/@testth02/the-role-of-image-quality-and-auto-frame-selection-in-embedded-devices-6a814d92c6f5</a> — I explored how <strong>traditional image quality assessment (IQA) methods</strong> — sharpness, exposure, entropy, noise estimation — are widely used in <strong>embedded devices</strong> due to their efficiency.</p><p>However, these methods, although fast, rely on handcrafted heuristics. They often fail in complex, real-world scenarios:</p><ul><li>A slightly blurry but <strong>semantically meaningful</strong> frame (e.g., a face still recognizable) may get rejected.</li><li>A technically sharp but <strong>irrelevant</strong> frame (e.g., empty background) may get selected.</li></ul><p>This is where <strong>deep learning</strong> comes in. By learning directly from data, deep models can capture both <strong>perceptual quality</strong> and <strong>task relevance</strong> in a way that handcrafted metrics cannot.</p><h3>Popular Deep Learning Approaches to IQA</h3><h3>1. CNN-Based Models</h3><p>Early deep IQA models used Convolutional Neural Networks (CNNs):</p><ul><li><strong>NIMA (Neural Image Assessment, Google)</strong> → predicts aesthetic and technical quality scores.</li><li><strong>DeepBIQ</strong> → fine-tuned CNN for blind image quality assessment (no reference needed).</li><li><strong>RankIQA</strong> → learns to rank image pairs by quality.</li></ul><p>These models process frames and output a <strong>distribution of quality scores</strong>.</p><h3>2. Attention and Vision Transformers (ViTs)</h3><p>More recent works adopt <strong>transformers</strong>, which model global relationships:</p><ul><li><strong>MUSIQ (Google, 2021)</strong> → multi-scale transformer for image quality.</li><li><strong>HyperIQA</strong> → attention-based model that adapts to image content.</li></ul><p>Transformers excel because image quality often depends on <strong>long-range context</strong> (e.g., face region quality vs. background).</p><h3>3. Task-Aware IQA</h3><p>Sometimes, IQA is integrated with the <strong>downstream task</strong>:</p><ul><li><strong>Face IQA</strong> → models trained to predict face recognition confidence.</li><li><strong>OCR Frame Selection</strong> → models trained on text readability.</li><li><strong>License Plate IQA</strong> → optimized for alphanumeric clarity.</li></ul><p>Here, deep IQA doesn’t just measure “prettiness” but <strong>fitness for purpose</strong>.</p><h3>How Deep IQA Fits into Embedded and Cloud Systems</h3><p>Deep learning for IQA is <strong>heavier</strong> than traditional methods — so deployment depends on the platform:</p><h3>1. On Embedded Devices (Edge AI)</h3><ul><li>Use <strong>lightweight CNNs</strong> (MobileNet, EfficientNet-Lite).</li><li>Quantization &amp; pruning reduce memory and latency.</li><li>Frameworks: <strong>TensorFlow Lite, ONNX Runtime, CoreML, Edge TPU SDK</strong>.</li></ul><p>Typical use case:</p><ul><li>Run a small CNN to filter frames locally.</li><li>Only send “good” frames to the cloud/server.</li></ul><h3>2. On Cloud or Server</h3><ul><li>Use <strong>larger models (ResNet, ViT, MUSIQ)</strong> for more accurate scoring.</li><li>Can re-rank or filter frames from multiple devices.</li><li>Training and dataset curation happen here.</li></ul><h3>Deep Learning IQA Pipeline</h3><p>The simplified view of how deep IQA can be deployed is shown in the diagram below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nWXjTIpv9AHvVIsUsXJEdA.png" /><figcaption>IQA Flow</figcaption></figure><h3>Challenges in Deep IQA</h3><ol><li><strong>Datasets</strong> → Image quality is subjective; collecting annotated datasets is costly — Popular datasets: LIVE, TID2013, KADID-10k, KonIQ-10k.</li><li><strong>Efficiency</strong> → Running ViTs on edge devices is still expensive.</li><li><strong>Generalization</strong> → A model trained for aesthetics may fail for OCR or license plate tasks.</li><li><strong>Interpretability</strong> → Why did the model reject a frame? Black-box decisions can be hard to debug.</li></ol><h3>Future Works</h3><ul><li><strong>Hybrid IQA</strong> → Combining fast traditional metrics with deep learning scoring.</li><li><strong>Self-Supervised IQA</strong> → Models that learn without explicit quality labels.</li><li><strong>Task-driven IQA</strong> → Custom IQA models trained for face recognition, OCR, medical imaging, etc.</li><li><strong>Efficient Transformers</strong> → Lightweight ViTs optimized for edge devices.</li></ul><h3>Conclusion</h3><p>Deep learning has pushed IQA far beyond handcrafted metrics, allowing systems to judge quality in a <strong>semantic, context-aware way</strong>.</p><p>For embedded devices, lightweight CNNs and efficient deployment frameworks make IQA feasible today. For cloud and server-side systems, transformers and task-specific models are setting new benchmarks.</p><p>Together, they ensure that <strong>only the right frames reach the AI model</strong>, improving accuracy, efficiency, and overall system reliability.</p><p>👉 If you missed the first part of this series, check it here:<br> <a href="https://medium.com/@testth02/the-role-of-image-quality-and-auto-frame-selection-in-embedded-devices-6a814d92c6f5">The Role of Image Quality and Auto-Frame Selection in Embedded Devices</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87f7e18a2595" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>