<?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 Shubham Gupta on Medium]]></title>
        <description><![CDATA[Stories by Shubham Gupta on Medium]]></description>
        <link>https://medium.com/@shubham3480?source=rss-e0208b5e1604------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TPg40rknQqXqwCGQ2Vr4Uw.jpeg</url>
            <title>Stories by Shubham Gupta on Medium</title>
            <link>https://medium.com/@shubham3480?source=rss-e0208b5e1604------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 01:34:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubham3480/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[I Built an AI Frontend Engineering Team Inside VS Code — With One Master Agent]]></title>
            <link>https://medium.com/@shubham3480/i-built-an-ai-frontend-engineering-team-inside-vs-code-with-one-master-agent-5e765bc02daf?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e765bc02daf</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Wed, 18 Nov 2026 12:33:49 GMT</pubDate>
            <atom:updated>2026-11-18T12:59:14.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*3g_AFgE8fyxIAVxABGNiJQ.jpeg" /></figure><p>I’ve been experimenting with AI-powered frontend development, and I noticed something</p><p>We have AI coding assistants, MCP servers, specialized agents, accessibility tools, performance audits, testing tools and code reviewers.</p><p>But setting up a complete frontend engineering environment is still a lot of manual work. So I built <strong>FE AI Toolkit</strong>.</p><p>It’s an open-source VS Code GitHub Copilot setup with one master agent that configures a collection of specialized frontend engineering agents.</p><p>A shareable VS Code Copilot setup for frontend engineers. Run one master agent, and it configures the MCP servers, VS Code extensions, and specialized agents you need for daily frontend work: testing, PR/MR creation, read-only code review, accessibility (WCAG), SEO, performance and Core Web Vitals, and more.</p><p>Includes</p><ul><li>Accessibility auditing (WCAG 2.2 AA)</li><li>Performance and Core Web Vitals auditing</li><li>SEO auditing</li><li>Unit and E2E testing</li><li>Security scanning</li><li>PR creation and read-only code reviews</li><li>Responsive QA and visual comparisons</li><li>Dependency upgrades and bug investigation</li></ul><p>The interesting part is how the setup works</p><ol><li>Detects your existing frontend stack.</li><li>Checks your existing tools and configuration.</li><li>Proposes what needs to be installed.</li><li>Shows you the complete plan.</li><li>Waits for your approval before making changes.</li></ol><p>I also designed the agents around least privilege read-only reviewers don’t receive write or comment permissions.</p><p>The goal is simple make a professional AI-powered frontend engineering workflow easier to set up and share.</p><p>It’s open source, and I’d love feedback from frontend developers who are experimenting with AI agents.</p><p>GitHub: <a href="https://github.com/shubham348/fe-ai-toolkit">https://github.com/shubham348/fe-ai-toolkit</a></p><h3>Prerequisites</h3><ol><li><strong>VS Code (latest stable)</strong>: agent mode, custom agents, and MCP support enabled</li><li><strong>GitHub Copilot + Copilot Chat</strong>: agent mode must be allowed by your org policy</li><li><strong>Node.js 18+</strong>: needed for npxbased MCP servers</li><li><strong>Git</strong>: needed for the PR/MR agents</li><li><strong>Chrome / Chromium</strong>: used by Chrome DevTools MCP and Playwright</li><li><strong>Accounts (optional)</strong>: GitHub or GitLab, Figma, Snyk, Jira/Linear, Sentry. You only need the ones for servers you enable.</li></ol><h3>How to use</h3><ol><li>Copy fe-toolkit-setup.agent.md into your user prompts folder (or the repo’s .github/agents/).</li><li>Open Copilot Chat, switch to <strong>Agent</strong> mode, and pick <strong>fe-toolkit-setup</strong> from the agent dropdown.</li><li>Type: set up my frontend toolkit</li><li>Answer the pack and scope questions, review the plan, and confirm.</li><li>Pick an agent from the agent dropdown, then type your request. For example, pick <strong>pr-reviewer</strong> and type review MR !1234.</li></ol><h4>One-click install (optional)</h4><p>VS Code supports install links for agent files. A link of this form opens VS Code and offers to install the agent:</p><p>vscode:chat-agent/install?url=https://raw.githubusercontent.com/shubham348/fe-ai-toolkit/main/fe-toolkit-setup.agent.md</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*n7RpsAmfnIYRGua-o7Hqiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*9gzuQ4UXIh88wmBEj4WrbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*I7YAIJ3BSZyogScmlVX3Tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*IuE8TmQor0K_p4CkboXRtw.png" /></figure><h3>Workings of Master Agent</h3><p>Agent name: fe-toolkit-setup</p><ol><li><strong>Detect</strong>: reads package.json and the repo to detect the framework, test runner, linter, styling, Git host, and package manager. <em>Writes nothing.</em></li><li><strong>Ask</strong>: asks which packs (Core, Extras, Integrations) and which scope (Workspace or User) you want. <em>Writes nothing.</em></li><li><strong>Plan</strong>: shows the exact list of MCP servers, extensions, and agents it will add, and skips anything already present. <em>Writes nothing.</em></li><li><strong>Confirm</strong>: waits for your explicit “yes”. <em>Writes nothing.</em></li><li><strong>Apply</strong>: installs extensions, merges the MCP config, and copies the agent files. <strong>Writes files.</strong></li><li><strong>Report</strong>: prints a summary of what was added or skipped, what each agent does, and how to use it. <em>Writes nothing.</em></li></ol><h4>Scope options</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*BUN_AJg3PST8gX_ucCvqRg.png" /></figure><blockquote><strong><em>WSL / remote windows:</em></strong><em> user agents are read from the </em><strong><em>local</em></strong><em> VS Code profile (on WSL, the Windows </em><em>%APPDATA%\Code\User\prompts), while MCP servers and the </em><em>npx downloads run on the remote machine.</em></blockquote><blockquote><strong><em>Copilot CLI / SDK chats:</em></strong><em> these read user agents from </em><em>~/.copilot/agents/ on the machine where they run (on WSL, inside Linux), not from the VS Code prompts folder. The setup agent copies agents to both locations.</em></blockquote><blockquote><strong><em>Snyk:</em></strong><em> if the Snyk extension is set to auto-configure its MCP server, it adds a server named </em><em>Snyk itself. The setup agent skips adding another one and points </em><em>fe-security and </em><em>dep-upgrader at </em><em>Snyk/*.</em></blockquote><h3>Safety rules Agents Follow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*tfos8HTo3oON9AFH7XZ5fQ.png" /></figure><h3>MCP servers added</h3><h4>Core pack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*tk5BZlHuS51knwkXYu8KcQ.png" /></figure><p>Extras pack (optional)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*fkoNybk4lYTf_Fb0KUjeeg.png" /></figure><p>Integrations pack (optional, team-specific)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*4NZ5llV6xdPXU2NfO3qc3A.png" /></figure><p>Also, I add all the VS Extensions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*YMFlaBx_Mn9tN7sToF8h3Q.png" /></figure><h3>Agents added after the master agent runs</h3><h4>Agent modes</h4><blockquote><strong><em>How to run an agent:</em></strong><em> pick it from the agent dropdown in Chat, then type the example prompt. Custom agents are not invoked with </em><em>@.</em></blockquote><blockquote><strong><em>Tool scope:</em></strong><em> each agent can only use the servers in its own tool list. For example, a11y-auditor can’t read Jira. This is intentional. Use the default Agent for anything else.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*e4uw4HWlm899pPSGYORoxQ.png" /></figure><h4>Core Agents</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bzJmwcgLK6EEURgX4yrB7g.png" /></figure><h4>Extras pack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3NOoPFvopSpIZjGeBoGWA.png" /></figure><h4>Troubleshooting</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*diWBYVGehFCrRG4qQnFvOQ.png" /></figure><h3>Principles</h3><ol><li><strong>Least privilege:</strong> each agent gets only the tools it needs.</li><li><strong>Human in the loop:</strong> plan first, confirm, then apply.</li><li><strong>Enforce in config, guide in prompts:</strong> tool lists enforce limits; instructions only guide behavior.</li><li><strong>Detect, don’t assume:</strong> adapt to the user’s stack.</li><li><strong>Official sources and no secrets in files.</strong></li><li><strong>Safe to re-run:</strong> running setup twice changes nothing.</li></ol><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e765bc02daf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Prompt Engineering)]]></title>
            <link>https://medium.com/@shubham3480/ai-prompt-engineering-360380eea28b?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/360380eea28b</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 04:22:16 GMT</pubDate>
            <atom:updated>2026-11-15T04:25:18.183Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 9— Reliability, Cost &amp; Model Selection)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h4>API Errors and Failure Modes</h4><p>An LLM application depends on several systems working together, the frontend, your backend, the network, the AI provider, and sometimes external tools or databases.</p><p>Even if your code is correct, any one of these systems can fail. A failure can occur at any stage. A useful application must identify which kind of failure occurred rather than treating every problem as “AI failed.”</p><p>Different failures need different responses. Retrying every error is not a reliable strategy. These are common HTTP status-code meanings, specific providers may use additional codes or different error details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*WRR5dLbzv8RSumtl4JE3Aw.png" /></figure><h4>Transient failures vs permanent failures</h4><p><strong><em>Transient failure</em></strong>: A temporary problem that may disappear if the operation is attempted again. Example a temporary provider outage, a connection interruption, or a rate limit that may clear after a specified delay.</p><p><strong><em>Permanent failure</em></strong>: A problem that normally requires a change rather than another identical attempt. Example an invalid request, an incorrect API key, or insufficient permissions.</p><h4>Expected Application Behaviour</h4><p>Consider a user asking an AI assistant to summarize a document.</p><ol><li>The frontend sends the user’s request to your backend.</li><li>The backend validates the input and calls the AI provider.</li><li>If the provider succeeds, the backend checks that the response is usable.</li><li>If a failure occurs, the backend classifies it and determines the appropriate recovery.</li><li>The frontend receives a clear result or a useful error message.</li></ol><p>The user should not see raw stack traces, secret API keys, internal server details, or confusing provider-specific error dumps. Log enough diagnostic information on the server to investigate failures, while avoiding sensitive data and unnecessary prompt or response logging.</p><h4>Retry</h4><p>A retry means attempting an operation again after it fails. We’ll study retry strategies in detail in Section 4.2, but first remember this rule:</p><ul><li>Don’t automatically retry a request that is clearly invalid.</li><li>Don’t retry indefinitely.</li><li>Don’t assume a timeout means the provider never processed the request.</li><li>Respect provider guidance about retry delays and usage limits.</li><li>Give the user a clear outcome when recovery is unsuccessful.</li></ul><p>The timeout case deserves special attention. A request may have reached the provider and started generating even though your application never received the response. Repeating it can create duplicate work and additional cost.</p><h3>Retry Strategies &amp; Backoff</h3><p>A retry can recover from a temporary problem. But poorly designed retries can increase costs, overload an already struggling service, and make an outage worse.</p><p>Imagine your application sends a request to an AI provider, which is temporarily overloaded. If thousands of applications retry immediately, they can overwhelm the provider further. This is sometimes called a retry storm.</p><p>A better approach is to wait before retrying, increase the wait when failures continue, and stop after a defined limit.</p><h4><strong><em>Exponential backoff</em></strong></h4><p>Exponential backoff means waiting progressively longer between retries when failures continue.</p><p>The maximum delay prevents the waiting time from growing without bound. In a real application, you would also limit the total number of attempts and the overall time spent trying.</p><h4><strong><em>Jitter</em></strong></h4><p>Now suppose 10,000 applications fail at the same time. If all of them wait exactly one second, they may all retry together, causing another spike.</p><p><strong><em>Jitter </em></strong>adds randomness to retry delays so requests become spread out over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FgCTqF0CagC340ADVz71qw.png" /></figure><p>A common strategy is full jitter: calculate the exponential backoff limit, then choose a random delay between zero and that limit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*HvM7pkQbFznjv8nq2tR-4g.png" /></figure><p>This is one useful strategy, not the only possible retry policy.</p><p>Some APIs return a Retry-After header with a response such as HTTP 429 or 503. It tells the client when it should try again, either as a delay or as a date.</p><p>For example, if the provider asks the application to wait 10 seconds, immediately retrying after one second ignores that guidance.</p><p>A sensible policy is:</p><ol><li>Read and interpret the provider’s retry guidance.</li><li>Avoid retrying earlier than the requested time.</li><li>Apply the application’s own maximum wait and total deadline.</li><li>If the requested wait exceeds what the application can tolerate, return a controlled failure instead of retrying too early.</li></ol><p>Provider-specific documentation determines how the header should be interpreted and whether additional limits apply.</p><h4>Retry errors</h4><p>Not every failure deserves another attempt. Here are some examples</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Mg503sL2ABAk209TcQSw5A.png" /></figure><h4>Practical retry policy</h4><p>A production-oriented retry policy should define:</p><ul><li><strong><em>Retryable failures</em></strong>: which errors may be temporary.</li><li><strong><em>Attempt limit</em></strong>: how many attempts are permitted.</li><li><strong><em>Backoff</em></strong>: how the waiting period grows.</li><li><strong><em>Jitter</em></strong>: how to spread retry timing.</li><li><strong><em>Provider guidance:</em></strong> how to respect Retry-After and usage limits.</li><li><strong><em>Overall deadline:</em></strong> when to stop trying.</li><li><strong><em>Cancellation</em></strong>: when to stop because the user no longer wants the result.</li><li><strong><em>Observability</em></strong>: how to record attempts and final outcomes without exposing secrets.</li></ul><p>The key is that retries must be bounded, selective, and observable. They are a recovery mechanism, not a substitute for diagnosing persistent failures.</p><h3>Rate Limits &amp; Concurrency</h3><p>A rate limit restricts how much traffic you can send to a service within a specified period. Most common types</p><p><strong><em>Requests per minute (RPM):</em></strong> Limits how many API requests you can make during a time window. Example: 60 requests per minute.</p><p><strong><em>Tokens per minute (TPM):</em></strong> Limits the amount of token traffic processed during a time window. The exact accounting rules depend on the provider and model. Example: a large prompt and a long response may consume substantially more token capacity than a short exchange.</p><p>Other limits may apply, including concurrent-request limits, daily quotas, or account-level spending limits. Always check the provider’s actual policy.</p><h3>Concurrency</h3><p>Concurrency control limits how many operations can be active simultaneously.</p><p>Imagine 20 users submit questions at the same moment. Your backend might start all 20 requests immediately. If the provider or your own infrastructure cannot handle that level of simultaneous work, requests may queue, fail, or consume resources for too long.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*ypFvomc54cUN5KBubWJnng.png" /></figure><h4>Rate limits vs concurrency limits</h4><p>A system might accept requests into a queue, enforce a concurrency cap, track rate-limit budgets, and retry eligible failures with backoff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*a33x9KObsIoerJK5jU-Mvw.png" /></figure><h3>Queue</h3><p>A queue lets your application control the rate at which work begins. For example</p><ol><li>Five users submit requests.</li><li>Your backend has capacity for two concurrent requests.</li><li>Two requests start immediately.</li><li>Three requests wait in the queue.</li><li>When one request finishes, another begins — provided rate limits and other constraints allow it.</li></ol><p>However, queues introduce their own engineering concerns</p><ul><li>How long may a request wait?</li><li>What happens when the queue is full?</li><li>Can a user cancel a waiting request?</li><li>How are priorities handled?</li><li>What happens if the backend restarts?</li></ul><p>For an interactive application, you may reject excess work with a clear message rather than allowing an unbounded queue to grow.</p><h3>429 Error</h3><p>A 429 Too Many Requests response means a rate or usage limit has been reached, though the exact cause varies by provider. A sensible response is to</p><ol><li>Inspect the provider’s error details and retry guidance.</li><li>Wait for the appropriate interval instead of immediately retrying.</li><li>Reduce or smooth request traffic if the application is sending too much.</li><li>Limit concurrent requests and account for token usage where relevant.</li><li>Tell the user when the request cannot be completed within a reasonable time.</li></ol><p>If a provider indicates that the account’s quota is exhausted, repeatedly retrying won’t solve the underlying problem. The quota or account configuration must be addressed.</p><h3>Cost Engineering</h3><p>The goal of cost engineering is to understand what makes an AI application expensive and how to control that cost without unnecessarily sacrificing answer quality. A feature can work perfectly and still be a poor engineering solution if every user interaction costs too much.</p><blockquote><strong>Cost engineering means designing an application to achieve its required quality and performance within an acceptable operating cost.</strong></blockquote><h4>How to calculate the cost of a request</h4><p>A simplified pricing formula is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*YkkiZoKfbUlaCmvqoo8NsA.png" /></figure><pre>Ti = input tokens<br>To = output tokens<br>Pi = price per million input tokens<br>Po = price per million output tokens</pre><h4>Conversation History Cost</h4><p>Consider an AI assistant that retains the entire conversation.</p><p>The first request might contain 500 tokens. After several exchanges, the next request might include:</p><ul><li>System instructions: 300 tokens</li><li>Conversation history: 4,000 tokens</li><li>New user message: 200 tokens</li><li>Additional retrieved context: 1,500 tokens</li></ul><p>The model now receives 6,000 input tokens, even though the latest user message contains only 200 tokens.</p><p>This is a crucial distinction: the cost of a request depends on everything sent to the model, not just what the user typed most recently.</p><p>If the application sends the entire conversation on every turn, cumulative input-token usage can grow substantially.</p><p>Common ways to control this include:</p><ul><li>Retaining only relevant conversation history.</li><li>Summarizing older messages when appropriate.</li><li>Avoiding repeated instructions and duplicated context.</li><li>Retrieving only relevant document passages instead of sending an entire large document.</li><li>Setting reasonable output limits.</li></ul><p>These techniques have trade-offs. Removing too much context can make answers less accurate or cause the model to forget important constraints.</p><h4>Cost Control Strategies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*z7DUbCydlQrUBliFi4t83Q.png" /></figure><h4>Cost Effective vs Cheap</h4><p>Suppose two models solve the same task</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*AzpaxX3JHO7pVmjtxM9z6A.png" /></figure><p>Model A is cheaper per attempt, but it succeeds less often. If users repeatedly retry or require human correction, its apparent savings may disappear.</p><p>The better metric is often cost per successful outcome, considered alongside latency and quality.</p><p>For example, if the more expensive model reduces repeated attempts, support effort, or incorrect results enough, it may be the better engineering choice.</p><h4>Streaming cost</h4><p>Streaming does not automatically reduce cost. Streaming can make the application feel faster by showing output as it arrives. But if the same model processes the same input and generates the same output, streaming alone generally does not reduce token usage.</p><p>It may affect infrastructure and user behavior, and cancellation can sometimes reduce additional generation. Actual savings depend on when cancellation occurs, provider behavior, and billing rules.</p><p>Responsiveness and cost are separate dimensions. Measure both.</p><h4>Cost estimation of a Feature</h4><p>For a simple monthly estimate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*kg1FCZwQ3xRaCdQCp9xgPg.png" /></figure><p>Where N is the number of requests per month. A more realistic estimate separates different request types</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/1*VpLdGor-ukBnq-33mDXszA.png" /></figure><p>For example, document summaries, short questions, and long research tasks may have very different token usage and model costs.</p><p>Before launch, estimate:</p><ul><li>Expected active users and requests per user.</li><li>Average input and output tokens by task.</li><li>Model pricing and any applicable caching or tool costs.</li><li>Retry rates and failed requests that may still incur charges.</li><li>Peak traffic and the possibility of automated abuse.</li><li>A budget limit and alerts for unexpected spending.</li></ul><p>Estimates are useful, but after launch, actual usage data should replace assumptions wherever possible.</p><h3>Model Selection &amp; Trade-offs</h3><p>The goal isn’t to choose the most powerful model every time. It’s to choose a model that meets the application’s quality, latency, reliability, and cost requirements.</p><h4>Single Model Usage</h4><p>We can&#39;t use one model for everything. Imagine an AI application that performs three tasks</p><ul><li>Classifies a user message into one of five categories.</li><li>Summarizes a long document.</li><li>Analyzes a complex technical problem and proposes a solution.</li></ul><p>These tasks have different requirements. Classification may need a short, predictable answer. Document summarization needs enough context and good information retention. Complex analysis may require stronger reasoning capabilities.</p><h4>The six dimensions of model selection</h4><p><strong><em>Quality</em></strong>: Does the model produce correct, relevant, useful results for this task?</p><p><strong><em>Latency:</em></strong> How long does the user wait for the first content and for the complete response?</p><p><strong><em>Cost:</em></strong> What does the model cost at the expected input and output volume?</p><p><strong><em>Context capacity:</em></strong> Can it accept the required instructions, conversation history, and source material?</p><p><strong><em>Reliability</em></strong>: Does it consistently follow instructions and produce usable results across representative inputs?</p><p><strong><em>Capabilities</em></strong>: Does it support the required output formats, tools, modalities, or other features?</p><p>Not every dimension matters equally for every application. A real-time assistant may prioritize latency, while a document-analysis tool may prioritize accuracy and context capacity.</p><h4>Match the model to the task</h4><p>Consider an application that supports these features</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*Xr4ukUVLVXD-Efxn9weKAQ.png" /></figure><h4>Benchmark before deciding</h4><p>A model’s marketing claims or general benchmark score cannot tell you exactly how it will perform in your application.</p><p>Instead, create a small evaluation set containing realistic inputs, expected outcomes, difficult edge cases, and examples where mistakes would matter.</p><p>Run candidate models against the same inputs and compare</p><ul><li><strong><em>Task quality:</em></strong> Are the answers correct and useful?</li><li><strong><em>Format validity:</em></strong> Does the output satisfy the application’s schema or contract?</li><li><strong><em>Latency:</em></strong> How quickly does the response begin and finish?</li><li><strong><em>Cost</em></strong>: What is the actual cost per request and per successful task?</li><li><strong><em>Consistency:</em></strong> Does performance remain acceptable across different inputs?</li></ul><blockquote><strong>Model routing:</strong> directing different tasks to different models according to their requirements.</blockquote><h4>Avoid locking your application to one model</h4><p>Model availability, pricing, capabilities, and provider APIs can change. Your application should isolate model-specific configuration and behavior where practical.</p><p>A useful design separates</p><ul><li>Application logic: what the feature needs to accomplish.</li><li>Provider integration: how the application sends requests and receives responses.</li><li>Model configuration: which model is used and its supported settings.</li><li>Validation and evaluation: how the application determines whether the result is usable.</li></ul><p>This separation makes it easier to test alternatives or change models without rewriting the entire application.</p><p>However, changing the model is not always a simple configuration change. Models may differ in supported parameters, structured-output capabilities, tool calling, context limits, and response behavior. Test every model change before deployment.</p><h4>A practical decision process</h4><p>When selecting a model for a feature, use this order</p><ol><li>Define the task and the minimum acceptable quality.</li><li>Identify required capabilities and context size.</li><li>Compare suitable candidates on representative inputs.</li><li>Measure quality, latency, and cost.</li><li>Choose the least expensive option that reliably meets the requirements.</li><li>Monitor real-world performance and reassess when conditions change.</li></ol><p>This brings together the ideas from Sections 4.1–4.4: failure handling, retries, traffic management, and cost engineering all influence whether a model is suitable for production.</p><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=360380eea28b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Prompt Engineering)]]></title>
            <link>https://medium.com/@shubham3480/ai-prompt-engineering-e7a5233e1dc7?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7a5233e1dc7</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 04:17:28 GMT</pubDate>
            <atom:updated>2026-11-15T04:17:28.439Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 8 — Structured Outputs &amp; Streaming)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h4><strong><em>Structured output</em></strong></h4><p><strong><em>Data generated in a predefined format so software can reliably identify and use its individual fields.</em></strong></p><p>Imagine you’re building a customer-support application. A user sends: <em>My headphones arrived broken, and I want a refund.</em></p><p>Your application wants the model to identify the user’s intent and urgency so the backend can decide what workflow to initiate. The model might return</p><pre>{<br>  &quot;intent&quot;: &quot;refund_request&quot;,<br>  &quot;urgency&quot;: &quot;high&quot;,<br>  &quot;product_issue&quot;: true<br>}</pre><p>Your application can now work with specific fields rather than trying to interpret a paragraph of natural language. The flow looks like this</p><pre>Customer message<br>       ↓<br>Build LLM request<br>       ↓<br>LLM generates structured data<br>       ↓<br>Receive response<br>       ↓<br>Validate data<br>       ↓<br>Execute application logic</pre><p>The critical boundary is between receiving model output and trusting that output. A valid-looking response is not automatically a correct business decision.</p><h4>Reliable structured output</h4><p><strong><em>Schema validation: Checking that data follows an agreed structure and satisfies its defined rules.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*gPOtGNHZvQzMTcN3VgQgkg.png" /></figure><h4>JSON in a prompt versus constrained generation</h4><p>Constrained generation:<strong><em> Using a model or API mechanism to restrict generated output to a specified structure or format.</em></strong></p><p>Let’s say you are asking a model to “return valid JSON”. This is an instruction. The model may follow it, but that instruction alone does not guarantee schema compliance.</p><p>Some LLM APIs offer structured-output features that accept a supported schema and constrain generation to the specified format. The exact capabilities and limitations depend on the provider and model.</p><p>Even constrained generation does not guarantee factual correctness.</p><p>For example, this response might be structurally valid</p><pre>{<br>  &quot;intent&quot;: &quot;refund_request&quot;,<br>  &quot;reason&quot;: &quot;damaged_product&quot;,<br>  &quot;urgency&quot;: &quot;high&quot;<br>}</pre><p>But the original message might not mention a damaged product at all. Therefore:</p><ul><li>Format correctness means the response follows the schema.</li><li>Semantic correctness means its values accurately represent the input.</li><li>Authorization means the application is permitted to act on the result.</li></ul><p>These are different checks.</p><h4>Using Structured outputs</h4><p>Use them when software needs to consume the answer — for example, classification, information extraction, routing, report generation, or selecting a tool to execute.</p><p>Natural-language output is usually sufficient when the result is intended only for a person to read.</p><p>The design decision is simple: use the least restrictive output format that meets the application’s needs.</p><h3>Streaming</h3><p>Streaming is the process of delivering an AI response in pieces as it is generated, rather than waiting for the entire response.</p><p>It improves perceived responsiveness, but the application must correctly process incomplete chunks and recognize when the stream finishes.</p><h4>Usage</h4><p>Imagine asking an AI to explain how a database works.</p><p>Without streaming, the application waits until the AI has generated the entire response before displaying anything. If the answer takes eight seconds to generate, the user may see a loading indicator for nearly eight seconds and then receive the complete answer at once.</p><p>With streaming, the application starts displaying the response as pieces arrive. The user might see the first sentence while the AI is still generating the next one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*XGXeMkvzli7tUQmzgQeodw.png" /></figure><p><strong><em>Streaming changes when the user receives the response, not necessarily how long the model takes to generate the entire response.</em></strong></p><h4>How streaming works</h4><p>The connection stays active while output is being delivered. Rather than waiting for one complete response, the application receives a sequence of chunks or events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*F6qgmKHHV3XjZbJUcTsn9A.png" /></figure><blockquote><strong><em>Token</em>: </strong>a unit the model uses to process or generate text. It may represent a word, part of a word, punctuation, or another unit.</blockquote><blockquote><strong><em>Chunk</em>: </strong>a piece of data delivered to the application over the stream. It may contain part of a word, several tokens, metadata, or other information.</blockquote><p><strong><em>The application must not assume that each chunk contains a complete word, sentence, or token.</em></strong></p><h4>Measurements that matter</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*ZPJ5DeJCwGDj4IZFrs8EFw.png" /></figure><h4>Data flow</h4><p>An application commonly uses an HTTP streaming mechanism, such as Server-Sent Events (SSE), when supported by the API. Other streaming protocols and formats also exist. At this stage:</p><ul><li>The model generates output.</li><li>The provider packages and sends output incrementally.</li><li>The application receives the chunks and decides how to display or process them.</li></ul><h4>Processing a Stream</h4><p>🟠<strong>Receiving chunks is not the same as receiving complete text</strong></p><p>Imagine the AI generates: Hello, welcome to the application! Your application might receive these pieces</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*i_9TjYRnVeB_c3a6UvuLIQ.png" /></figure><p>Each chunk is only a fragment. The application combines the relevant fragments in order to reconstruct the complete text. Chunk boundaries are transport boundaries, not necessarily word or sentence boundaries.</p><p><strong>🟠The stream-processing pipeline: </strong>A typical application follows this sequence</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*X59RqJ0vTIbr5lfONNnB7g.png" /></figure><p>Not every event contains user-visible text. For example, an event may contain metadata or indicate that generation has finished. The application must follow the provider’s documented event format rather than treating every event as text.</p><p><strong>🟠Why buffering and accumulation matter: </strong>These are two related but different concepts.</p><ul><li><strong><em>Buffering</em></strong>: It means temporarily holding incoming data until enough data is available to process it correctly. This can be necessary when reading lower-level network data because a text or protocol message may span multiple reads.</li><li><strong>Accumulation</strong>: It means collecting processed content over time to form the complete response.</li></ul><p>A stream reader must respect the transport and encoding rules. One network read is not guaranteed to equal one complete application-level event. With protocols such as Server-Sent Events, for example, the parser must identify event boundaries before interpreting event data.</p><h4>Production Streaming</h4><p>In production, the challenge is making streaming behave correctly when users cancel requests, connections fail, or generation stops unexpectedly.</p><p>The central principle is that a stream is not successful merely because some text arrived. The application must track its lifecycle and distinguish completion from interruption or failure.</p><p>A production application should represent streaming as a sequence of explicit states. something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*lilE9gnOHA0nDPZyx7JGbA.png" /></figure><h4><strong>Pros</strong></h4><p>We require it because each state requires different UI behavior. A completed answer can be treated as final. A failed answer may be incomplete and need a retry option.</p><p>🟠<strong><em>Cancellation</em></strong>: Imagine a user asks for a long explanation, then presses Stop generating. A good application should</p><ol><li>Stop consuming the response where possible.</li><li>Abort the underlying request or close the stream using the supported mechanism.</li><li>Release resources and stop unnecessary UI updates.</li><li>Mark the result as cancelled rather than completed.</li></ol><p>There is an important distinction between stopping the client and stopping model generation.</p><ul><li>Client-side cancellation stops the application from continuing to read or display the response.</li><li>Provider-side cancellation stops the remote work, if the API and request path support it.</li></ul><p>Closing the client connection does not universally guarantee that the provider stops generation or billing. The backend and provider’s documented cancellation behavior determine what actually stops.</p><p>🟠<strong>Interrupted streams and partial responses</strong></p><p>Suppose the user sees</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*68NsKla49dTMgqDa5YxSuA.png" /></figure><p>Then the network connection drops. The displayed text is useful, but the sentence is incomplete. Your application should not silently treat it as a successful final response.</p><p>A sensible policy is to:</p><ul><li>Preserve already received text when useful.</li><li>Mark the answer as interrupted or incomplete.</li><li>Offer a retry or regeneration action.</li><li>Avoid blindly appending a new generation to the partial answer, because the new response may repeat or contradict earlier content.</li></ul><p>If a user retries, decide whether the application starts a fresh answer or explicitly asks the model to continue from the partial result. These are different behaviors and should be designed intentionally.</p><p>🟠<strong> Timeouts: </strong>A timeout should lead to an explicit outcome, not an indefinitely spinning loading indicator.</p><p>Timeout values depend on the product, model, expected response length, provider, and infrastructure. There is no single correct value for every AI application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*pTGT5TSzsnwqmvJuFA-2HA.png" /></figure><p>🟠<strong>Prevent stale responses from corrupting the UI</strong></p><p>Consider this sequence:</p><ol><li>A user submits question A.</li><li>Before A finishes, they submit question B.</li><li>B finishes first.</li><li>A finishes afterward.</li></ol><p>If the application accepts every update without checking which request owns the current UI, the old response from A may overwrite or mix with B.</p><p>A common solution is to associate each request with a unique identifier or generation counter. Before applying a chunk, check whether it belongs to the currently active request. If it does not, ignore it or cancel its work as appropriate.</p><p>This is especially important when users can submit multiple requests quickly, navigate away, or switch conversations.</p><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7a5233e1dc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Prompt Engineering)]]></title>
            <link>https://medium.com/@shubham3480/ai-prompt-engineering-9c302581152a?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c302581152a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 04:13:13 GMT</pubDate>
            <atom:updated>2026-11-15T04:13:13.123Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 7)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h4><em>LLM API</em></h4><p>An LLM API is the interface that lets your application send instructions/input to a remote language model and receive its generated output.</p><p>Imagine you have your application, but your application doesn’t contain the giant LLM itself. Instead, a model is running somewhere on a server</p><pre>💻 Your App<br>     │<br>     │ request<br>     ↓<br>☁️ AI Provider<br>     │<br>     ↓<br>🧠 LLM<br>     │<br>     │ response<br>     ↓<br>💻 Your App</pre><p>Think of the LLM as a restaurant kitchen. Your application is the customer. You don’t walk into the kitchen and manipulate the chef directly. You send an order. The kitchen processes it and sends it back.</p><p><strong><em>An LLM API works similarly. Your application sends a request. The AI service sends it back.</em></strong></p><h4><strong>API (Application Programming Interface)</strong></h4><p>An API is simply a defined way for one piece of software to communicate with another.</p><pre>Your application<br>      ↓<br>   API request<br>      ↓<br>AI service<br>      ↓<br>   API response<br>      ↓<br>Your application</pre><p>ChatGPT UI Is Basically Doing This. Imagine your application has</p><pre>┌─────────────────────────────┐<br>│       AI Assistant          │<br>├─────────────────────────────┤<br>│ User: What is RAG?          │<br>│                             │<br>│ AI: RAG stands for...       │<br>│                             │<br>│ User: Give me an example.   │<br>└─────────────────────────────┘</pre><p>Behind the scenes, the application may maintain something conceptually like</p><pre>[ <br>  {<br>    role: &quot;developer&quot;,<br>    content: &quot;You are an AI tutor.&quot;<br>  },<br>  {<br>    role: &quot;user&quot;,<br>    content: &quot;What is RAG?&quot;<br>  },<br>  {<br>    role: &quot;assistant&quot;,<br>    content: &quot;RAG stands for...&quot;<br>  },<br>  {<br>    role: &quot;user&quot;,<br>    content: &quot;Give me an example.&quot;<br>  }<br>]</pre><p>The application sends the relevant conversation context to the model.</p><pre>Application state<br>       ↓<br>Conversation construction<br>       ↓<br>API request<br>       ↓<br>LLM<br>       ↓<br>API response<br>       ↓<br>Application state<br>       ↓<br>UI</pre><p>The model lives behind the API, <strong>your application is responsible for constructing the request, handling the response, security, errors, cost, and user experience.</strong></p><h3>Prompt Engineering</h3><p>A prompt is the complete set of instructions, context, input, and constraints given to an LLM for a task.</p><p>Prompt engineering is the process of designing that information so the model produces reliable, useful, and appropriately formatted results.</p><pre>Your Application<br>       │<br>       │  Prompt<br>       ▼<br>┌─────────────────┐<br>│      LLM        │<br>│                 │<br>│ Instructions    │<br>│ Context         │<br>│ Input           │<br>│ Constraints     │<br>│ Examples        │<br>└─────────────────┘<br>       │<br>       │ Generated output<br>       ▼<br>Your Application</pre><h4>Prompt Engineering Is Really About Reducing Ambiguity</h4><p>Here is an example</p><pre>Give me a good laptop. <br>// Suppose I tell you ? The instruction is ambiguous.<br><br><br>Now i say Recommend a laptop for a Software developer who works<br>primarily with React, Node.js, Docker, and VS Code.<br>Budget is ₹1.2 lakh. Prioritize CPU performance,<br>32 GB RAM, battery life, and portability.<br>//Now the task is much clearer.<br></pre><p>The same principle applies to an LLM. The model does not automatically know all the requirements you have in your head. That’s one of the fundamental ideas behind prompt engineering.</p><h4>Processing Prompt</h4><p>The text is converted into tokens and processed through the model. The model uses the relationships it learned during training to determine what output is likely to follow the provided context. That’s why <strong>context matters so much</strong>.</p><pre>Text<br>  ↓<br>Tokens<br>  ↓<br>Token IDs<br>  ↓<br>Representations / embeddings<br>  ↓<br>Transformer processing<br>  ↓<br>Probability distribution<br>  ↓<br>Next token<br>  ↓<br>Next token<br>  ↓<br>Next token</pre><h4>Prompt Structure</h4><p>The basic idea is to have the following fields to make the prompt more useful</p><pre>PROMPT<br>│<br>├── Objective<br>├── Context<br>├── Input<br>├── Requirements<br>├── Constraints<br>├── Output Format<br>├── Examples<br>└── Quality Criteria<br>└── Handling Missing Informatio<br></pre><p>🟢<strong><em>Objective:</em></strong> The <strong>objective</strong> tells the model what you want it to accomplish. For example</p><pre>Analyze the following customer review and determine<br>whether the customer is satisfied or dissatisfied.</pre><p>A strong prompt makes the intended objective explicit.</p><p>🟢<strong><em>Context</em>: </strong>What Does the Model Need to Know?<strong> </strong>Context gives the model information it needs to perform the task correctly. For example</p><pre>You are reviewing feedback for an e-commerce company.<br>The company considers a customer dissatisfied when<br>the customer reports a serious problem with the product,<br>delivery, payment, or support experience.</pre><p>Now the model understands the environment in which the task exists. Context can include things such as:</p><pre>Business information<br>User information<br>Documentation<br>Retrieved documents<br>Conversation history<br>Product information<br>Policies<br>Database results<br>Previous decisions</pre><p>Context Can Come From Many Places</p><pre>                Context<br>                   │<br>       ┌───────────┼────────────┐<br>       ↓           ↓            ↓<br>  User input   Application   External data<br>                  │<br>       ┌──────────┼──────────┐<br>       ↓          ↓          ↓<br>   Database    APIs       Documents<br>                              │<br>                              ↓<br>                             RAG</pre><p>🟢<strong><em>Input: </em></strong>The input is the actual data the model needs to process. For example</p><pre>Customer review: &quot;The laptop arrived two days late, but the product itself<br>is excellent and works perfectly.&quot;</pre><p>The prompt might therefore become:</p><pre>Objective:<br>Classify customer satisfaction.<br>Context:<br>A customer is considered dissatisfied when they report<br>a significant problem with the product, payment, delivery,<br>or support experience.<br>Input:<br>&quot;The laptop arrived two days late, but the product itself<br>is excellent and works perfectly.&quot;</pre><p>Now the model has a much clearer task.</p><p>🟢<strong><em>Requirements</em></strong>: What Must the Model Consider? They tell the model which dimensions matter. Without them, the model may spend most of its response discussing formatting while completely missing a security vulnerability.</p><p>🟢<strong>Constraints: </strong>Constraints define what the model <strong>must or must not do</strong>. For example</p><pre>- Use only the provided information.<br>- Do not invent facts.<br>- Keep the answer below 100 words.<br>- Return valid JSON.<br>- Do not provide medical advice.</pre><p>Constraints are extremely important in production systems. For example, suppose you’re building a document-question-answering application. You might instruct</p><pre>Requirements:<br>- Identify security vulnerabilities.<br>- Explain each vulnerability.<br><br>Constraints:<br>- Do not rewrite the entire application.<br>- Do not assume undocumented APIs.<br>- Do not invent vulnerabilities.</pre><p>🟢<strong><em>Output Format: </em></strong>You can also tell the model what the result should look like. For example</p><pre>Return: {<br>  &quot;sentiment&quot;: &quot;positive | negative | neutral&quot;,<br>  &quot;confidence&quot;: number,<br>  &quot;reason&quot;: string<br>}</pre><p>Now your application can potentially consume the result programmatically. This is especially important for AI applications. Your backend may need</p><pre>{<br>  &quot;sentiment&quot;: &quot;positive&quot;,<br>  &quot;confidence&quot;: 0.82,<br>  &quot;reason&quot;: &quot;The customer praised the product despite delayed delivery.&quot;<br>}</pre><p>That’s the difference between using an LLM merely as a chatbot and using an LLM as a <strong>component inside software architecture</strong>.</p><p>🟢<strong><em>Examples</em></strong> — Examples can be particularly powerful when the desired behavior is difficult to describe purely with words.</p><h4>Prompt Engineering Is Not Making the Prompt Longer</h4><p>Imagine</p><pre>Prompt A: Summarize this article.<br>          <br>Prompt B:<br>You are the world&#39;s greatest summarization expert.<br>You are an elite AI.<br>You have decades of experience.<br>You are extremely intelligent.<br>You are the best summarizer in the universe.<br>Please, with your incredible expertise,<br>carefully and thoughtfully summarize this article<br>in a very detailed but concise manner...</pre><p>Prompt B is much longer. That does <strong>not</strong> automatically make it better. In fact, much of that text adds little useful information.</p><p>A better prompt might simply be</p><pre>Summarize the article in 120 words or fewer.<br>Focus on:<br>- the central argument,<br>- important supporting evidence,<br>- the final conclusion.<br>Do not introduce information that isn&#39;t present<br>in the article.</pre><p>We’re adding <strong>useful information</strong>, not decorative language.</p><blockquote><strong>Tell the model what to do, give it the information it needs, define the rules, and explain what the result should look like.</strong></blockquote><h3>Prompt Patterns</h3><p>There are multiple patterns</p><h4>🔵Zero-Shot Prompting</h4><p>Give the model the task without giving it an example of the expected answer. For example:</p><pre>Classify the following review as positive, negative, or neutral. Review:<br>&quot;The battery life is excellent, but the keyboard feels cheap.&quot;</pre><p>We’re simply relying on the model’s learned capabilities and our instruction. That’s <strong>zero-shot</strong>.</p><p>Zero-shot is usually a good starting point when</p><ul><li>the task is common,</li><li>the desired behavior is easy to describe,</li><li>the output space is obvious,</li><li>the instruction is sufficiently clear.</li></ul><p>For example: “Translate this sentence into French.” You don’t need to provide five translation examples.</p><h4>🔵One-Shot Prompting</h4><p>One-shot means providing <strong>one example</strong>.</p><h4>🔵Few-Shot Prompting</h4><p>Few-shot means providing <strong>multiple examples</strong>.</p><pre>Classify each review.<br><br>Example 1:<br>&quot;The camera is fantastic.&quot;<br>→ positive<br><br>Example 2:<br>&quot;The phone stopped working after one day.&quot;<br>→ negative<br><br>Example 3:<br>&quot;The phone is okay. Nothing special.&quot;<br>→ neutral<br><br>Now classify:<br><br>&quot;The display is beautiful, but the battery is disappointing.&quot;</pre><p>The model now sees several examples of the task. This can be particularly useful when the desired behavior isn’t easy to describe with instructions alone.</p><p>Few-shot prompting can teach more than labels. The examples communicate the expected <strong>style, depth, and structure</strong>. For example, suppose you want a particular response style.</p><pre>Question:<br>What is caching?<br>Answer:<br>Caching stores previously retrieved or computed data<br>so it can be reused instead of performing the expensive<br>operation again.</pre><p><strong><em>Use examples to cover behavioral variation, not merely to increase example count.</em></strong></p><p><strong><em>Use few-shot prompting when the examples provide enough behavioral value to justify their token cost.</em></strong></p><h4>Zero-Shot vs Few-Shot</h4><p>The decision depends on whether the model needs demonstrations to perform this particular behavior reliably.</p><h4>Structured Outputs</h4><p>Structured output means asking the model to produce data that conforms to a defined schema so your application can consume it predictably.</p><p>You provide a schema through the API’s supported structured-output functionality. Use structured output when</p><ul><li>your backend needs to process the result;</li><li>you need predictable fields;</li><li>the response feeds another function;</li><li>you’re extracting information;</li><li>you’re classifying data;</li><li>you’re building tool/function workflows;</li><li>you need reliable application state.</li></ul><p>Never let model-generated data directly become trusted application state without appropriate validation.</p><h4>Structured Output in the Larger Architecture</h4><pre>                    LLM<br>                     │<br>                     ▼<br>              Structured Output<br>                     │<br>                     ▼<br>                Validation<br>                     │<br>          ┌──────────┴──────────┐<br>          ▼                     ▼<br>      Valid data            Invalid data<br>          │                     │<br>          ▼                     ▼<br>   Business logic          Error handling</pre><h3>Prompt Optimization</h3><p>Prompt optimization is the process of improving a prompt’s effectiveness while reducing unnecessary tokens, cost, latency, and complexity.</p><p>A prompt that costs ₹1 but produces unreliable results isn’t optimized. A prompt that produces perfect results but costs 100× more than necessary may also not be optimized.</p><h4>Remove Redundant Instructions</h4><p>If two instructions produce essentially the same behavioral constraint, consider removing the redundant one.</p><p>Suppose your prompt contains:</p><pre>You are a helpful assistant.<br>Be helpful.<br>Provide a useful answer.<br>Your goal is to help the user.<br>Always try to provide the best possible answer.<br>Make sure your answer is useful.</pre><p>Much of this communicates essentially the same thing. A cleaner version might simply be</p><pre>Answer the user&#39;s question accurately and concisely.</pre><h4>Context Cost</h4><p>There might be a long conversation going on, but if you send the entire conversation to the model on every request, the model may need only a small portion of that history. This creates unnecessary</p><ul><li>input tokens,</li><li>cost,</li><li>latency,</li><li>context consumption.</li></ul><p>So context engineering becomes important. This is often the highest cost.</p><h4>Overoptimization of Context</h4><p>Suppose your application removes context</p><pre>business rules user preferences important constraints relevant documents</pre><p>just to reduce token usage. You may save tokens but destroy answer quality. The target is <strong>relevant context</strong>, not minimum context.</p><h4>Output Tokens Also Cost Money</h4><p>Developers sometimes focus only on input prompts. But the model’s generated response also consumes tokens. For example</p><p>You can constrain output when appropriate. This can reduce both cost and latency.</p><pre>Return the answer in no more than 150 words. <br>or<br>Return only the requested JSON fields.</pre><h4>Model Optimization</h4><p>Prompt optimization and model selection are connected. For example</p><pre>Simple classification<br>        ↓<br>Smaller / cheaper model <br><br>while<br><br>Complex reasoning<br>        ↓<br>More capable model</pre><p>You can even route requests</p><pre>                    Request<br>                       │<br>                 ┌─────┴─────┐<br>                 │ cClassify │<br>                 └─────┬─────┘<br>                       │<br>              ┌────────┴────────┐<br>              ▼                 ▼<br>          Simple task       Complex task<br>              │                 │<br>              ▼                 ▼<br>        Cheaper model      Stronger model</pre><h4>The Optimization Loop</h4><pre>             ┌──────────────┐<br>             │    Prompt    │<br>             └──────┬───────┘<br>                    ↓<br>                  Test<br>                    ↓<br>                 Measure<br>                    ↓<br>              Find waste<br>                    ↓<br>                Optimize<br>                    ↓<br>                  Test<br>                    │<br>                    └───────↺</pre><p>Look for:</p><ul><li>unnecessary instructions,</li><li>irrelevant context,</li><li>excessive examples,</li><li>excessive output,</li><li>unnecessarily powerful models,</li><li>repeated information.</li></ul><p>But always protect:</p><ul><li>correctness,</li><li>required context,</li><li>safety,</li><li>reliability.</li></ul><blockquote><strong>Prompt optimization means finding the smallest and most efficient combination of instructions, context, examples, output size, and model capability that still produces the required quality.</strong></blockquote><h3>General-Purpose Prompt Template for Any LLM</h3><pre>TASK<br>What do I want you to do?<br><br>CONTEXT<br>What background information do you need to know?<br><br>GOAL<br>What am I ultimately trying to achieve?<br><br>REQUIREMENTS<br>What specifically should you include or do?<br><br>CONSTRAINTS<br>What should you avoid or not do?<br><br>PREFERENCES<br>How do I want the answer written?<br>(e.g. simple, technical, concise, detailed)<br><br>OUTPUT<br>What format should the answer have?<br>(e.g. explanation, table, steps, code)<br><br>QUALITY BAR<br>What would make the answer useful to me?<br><br>IF UNCERTAIN<br>If something is missing or ambiguous, ask me<br>or clearly state the assumption rather than guessing.</pre><pre>I want [TASK].<br>Context: [important background].<br>My goal: [what I&#39;m trying to achieve].<br>Please: [important requirements/preferences].<br>Give me the answer as: [desired format].<br>If something important is unclear, ask me rather than assuming.</pre><p>Here is an example</p><pre>I’m planning a 7-day trip to Japan in April with my partner. <br>We enjoy food, nature, and cultural experiences,<br>but we&#39;re not interested in nightlife. <br>Our budget is around $2,500 excluding flights.<br>We prefer a relaxed itinerary rather than changing hotels every day.<br>Please:  <br>- Suggest the best cities/areas to visit<br>- Create a day-by-day itinerary<br>- Include approximate daily costs<br>- Suggest a few food experiences<br>- Keep travel between destinations reasonable<br>Give me: a practical itinerary in a table,<br>         followed by a rough total budget.<br>If any important information is missing,<br> tell me what assumptions you&#39;re making.<br><br>// Here is the prompt breakdown<br><br>Task       → Plan a trip<br>Context    → 7 days, April, couple, interests<br>Goal       → Relaxed enjoyable trip<br>Constraints→ Budget, no nightlife, limited hotel changes<br>Requirements → Cities, itinerary, costs, food<br>Output     → Table + budget<br>Uncertainty → State assumptions</pre><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c302581152a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Large Language Models)]]></title>
            <link>https://medium.com/@shubham3480/ai-large-language-models-30128890780c?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/30128890780c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 04:08:49 GMT</pubDate>
            <atom:updated>2026-11-15T04:08:49.168Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 6)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h3>Large Language Models</h3><p>An <strong>LLM (Large Language Model)</strong> is a large neural network, typically Transformer-based, trained on huge amounts of text to learn patterns in language. The word <strong>large</strong> mainly refers to the scale of the model, training data, and computation — not simply that the model has a particular fixed number of parameters.</p><h4>Pretraining</h4><p><strong>Pretraining</strong> is the large initial training stage where the model learns general language patterns from a huge dataset. For example, it sees enormous amounts of text from books, web Pages, articles, code, etc.</p><p>The exact training data depends on the model. During this process, the model learns patterns such as:</p><ul><li>syntax</li><li>relationships between words</li><li>concepts</li><li>patterns of reasoning</li><li>facts present in the training data</li><li>relationships between concepts</li></ul><p>It isn’t given a database of answers in the normal sense. Instead, it learns parameters that capture statistical patterns from the training data.</p><h4>Next-Token Prediction</h4><p>At its core, a language model is trained to predict the next token. Example: “The sky is.” The model might assign probabilities like</p><pre>blue    → 0.65<br>clear   → 0.12<br>dark    → 0.05</pre><p>Training compares the model’s prediction with the actual next token. Then the parameters are adjusted. Repeated billions/trillions of times, this teaches the model increasingly sophisticated language patterns.</p><blockquote>Next-token prediction trains an LLM to estimate what token should come next given the tokens that came before it.</blockquote><h4>Parameters</h4><p>Parameters are learned numbers inside the model<strong>. </strong>For an LLM</p><pre>Transformer<br>   ↓<br>Millions/billions of operations<br>   ↓<br>Millions/billions of learned parameters</pre><p>Parameters encode the patterns the model learned during training. Training</p><pre>data<br> ↓<br>prediction<br> ↓<br>loss<br> ↓<br>gradients<br> ↓<br>parameter updates</pre><p>After training, those parameters are used during inference.</p><h4>Scaling</h4><p>One of the major developments in modern AI was discovering that increasing the scale of</p><ul><li>model parameters</li><li>training data</li><li>compute</li></ul><p>can substantially improve model capabilities, within practical limits. Conceptually</p><pre>More data<br>    +<br>More parameters<br>    +<br>More compute<br>    ↓<br>More capable models</pre><p>This is called <strong>scaling</strong>. But a poorly designed model, poor-quality data, or inefficient training can still produce poor results.</p><h3>Inference</h3><p><strong>Inference</strong> is when we use the trained model to produce an output.</p><p>Training</p><pre>Data<br> ↓<br>Prediction<br> ↓<br>Loss<br> ↓<br>Backpropagation<br> ↓<br>Update parameters</pre><p>Inference</p><pre>Input<br> ↓<br>Model<br> ↓<br>Prediction<br> ↓<br>Output</pre><p>Normally, the model’s learned parameters are <strong>not updated during ordinary inference</strong>. Example:</p><pre>User:<br>&quot;What is React?&quot;<br><br>      ↓<br> LLM inference<br>        ↓<br>Generated tokens</pre><h4>How does an LLM Generate Text</h4><p>Suppose the user asks “What is React?” The model processes the input and predicts a probability distribution for the next token.</p><p>It selects a token. Then it predicts the next token again.</p><pre>What is React?<br>       ↓<br>     React<br>       ↓<br>   React is<br>       ↓<br>  React is a<br>       ↓<br>React is a JavaScript<br>       ↓<br>React is a JavaScript library<br>       ↓</pre><p>So generation happens <strong>token by token</strong>.</p><p><strong><em>This is called autoregressive generation when each generated token becomes part of the context used to generate the next one.</em></strong></p><h4>Temperature</h4><p>Temperature controls how much randomness is used when selecting from the model’s probability distribution. Conceptually</p><p><strong>Lower temperature: </strong>More deterministic:</p><pre>Most likely token<br>        ↓<br>usually selected</pre><p><strong>Higher temperature: </strong>More variation:</p><pre>Several plausible tokens<br>        ↓<br>more randomness in selection</pre><blockquote><em>Temperature doesn’t teach the model anything new.</em></blockquote><p>It changes how the model samples from its predicted probabilities during generation.</p><h3>Sampling</h3><p>The model produces probabilities for possible next tokens. For example</p><pre>blue   70%<br>green  15%<br>dark    8%<br>red     4%<br>other   3%</pre><p><strong>Sampling</strong> means choosing a token from this probability distribution. Without sampling, generation could become highly deterministic.</p><p>Sampling strategies can control which candidates are considered. One such strategy is <strong>top-p sampling</strong>.</p><h4>Top-p</h4><p>Instead of considering every possible token, top-p selects a dynamic group of the most probable tokens whose cumulative probability reaches a chosen threshold.</p><p>Then sampling occurs within that group.</p><pre>All possible tokens<br>       ↓<br>keep likely candidates<br>       ↓<br>sample<br>       ↓<br>next token</pre><h3>Model Capabilities</h3><p>LLMs can perform many tasks because they have learned broad patterns from large datasets. For example:</p><ul><li>text generation</li><li>summarization</li><li>translation</li><li>classification</li><li>code generation</li><li>question answering</li><li>extraction</li><li>reasoning-like tasks</li></ul><p>But <em>the model doesn’t have a separate hard-coded program for each of these tasks.</em></p><p>The same learned model can perform many tasks through different inputs/instructions.</p><h4>Model Limitations</h4><p>LLMs also have important limitations. Such as</p><h4>Hallucination</h4><p>A model can produce information that sounds convincing but is incorrect.</p><h4>Knowledge limitations</h4><p>A model’s knowledge depends on its training and any information supplied during inference.</p><h4>Context limitations</h4><p>Even with large context windows, there are practical limits.</p><h4>Reasoning limitations</h4><p>LLMs can make mistakes on reasoning, calculations, planning, or multi-step tasks.</p><h4>Sensitivity to input</h4><p>Different prompts or context can produce different outputs.</p><h4>No guaranteed truth</h4><p>A fluent answer isn’t proof that the answer is correct.</p><pre>Neural Networks<br>      ↓<br>Deep Learning<br>      ↓<br>Transformers<br>      ↓<br>Tokens + Embeddings<br>      ↓<br>Attention<br>      ↓<br>Large-scale pretraining<br>      ↓<br>Next-token prediction<br>      ↓<br>Learned parameters<br>      ↓<br>LLM<br>      ↓<br>Inference<br>      ↓<br>Token-by-token generation</pre><blockquote><strong>An LLM is a large neural network, usually Transformer-based, trained on huge amounts of data primarily through next-token prediction. During inference, it uses its learned parameters to predict and generate tokens, with sampling controls such as temperature affecting how those tokens are selected.</strong></blockquote><h4><strong>How does a pretrained language model become an AI assistant that can follow instructions, have conversations, and behave safely, such as </strong>ChatGPT-Style Models?</h4><p>The answer is that <strong>pretraining is only the first major stage</strong>.</p><h4>Pretraining</h4><p>A model is trained on a huge amount of data using objectives such as <strong><em>predicting the next token. </em></strong>Conceptually</p><pre>Huge dataset<br>     ↓<br>Next-token prediction<br>     ↓<br>Loss<br>     ↓<br>Backpropagation<br>     ↓<br>Parameter updates<br>     ↓<br>Pretrained model</pre><p>The resulting model has broad language capabilities.</p><p>But there is a problem. Imagine giving a raw pretrained model <em>“Explain React hooks to me.” </em>It may continue the text rather than behave like an assistant. So we need additional training.</p><h4>Base Model</h4><p>A <strong>base model</strong> is the pretrained model before assistant-specific alignment/instruction training. Its primary learned behavior is language modeling.</p><p>Think:</p><pre>Pretraining<br>    ↓<br>Base model</pre><p>It knows many patterns, but it isn’t necessarily optimized to behave like a helpful conversational assistant.</p><h4>Supervised Fine-Tuning</h4><p>Now humans provide examples of desirable behavior. For example:</p><pre>User:<br>What is React?<br><br>Assistant:<br>React is a JavaScript library for building user interfaces...</pre><p>Many examples like this are created. The model is then trained on these examples. This is <strong>supervised fine-tuning (SFT)</strong>.</p><pre>Pretrained model<br>       ↓<br>Human-created examples<br>       ↓<br>Supervised fine-tuning<br>       ↓<br>Instruction-following model</pre><blockquote><strong>Supervised fine-tuning trains a pretrained model on curated input-output examples so it learns to follow instructions and produce desired response patterns.</strong></blockquote><h4>Instruction Tuning</h4><p><strong>Instruction tuning</strong> is closely related to supervised fine-tuning. The training examples specifically teach the model to respond appropriately to instructions. For example:</p><pre>Instruction:<br>Summarize this paragraph.<br><br>Desired behavior:<br>Produce a concise summary.<br> <br>Or<br><br>Instruction:<br>Translate this into French.<br><br>Desired behavior:<br>Return the French translation.</pre><p>The model learns a broad pattern</p><pre>Instruction<br>     ↓<br>Understand requested task<br>     ↓<br>Generate appropriate response</pre><p>So instruction tuning turns a general pretrained model into something much more useful for interactive applications.</p><h4>Human Feedback</h4><p>There is another problem. Suppose the model produces two possible responses:</p><pre>Response A<br>Response B</pre><p>Both might be grammatically correct. But humans may prefer one because it is:</p><ul><li>more helpful</li><li>clearer</li><li>safer</li><li>more relevant</li><li>less verbose</li><li>better aligned with the request</li></ul><p>So human preferences can be incorporated into the training process. Conceptually</p><pre>Model responses<br>      ↓<br>Humans evaluate/rank preferences<br>      ↓<br>Preference information<br>      ↓<br>Training/optimization<br>      ↓<br>Model behavior improves</pre><h4>Preference Optimization</h4><p>Modern AI systems can use different techniques to train models toward preferred behavior. The general idea is: <strong><em>Don’t only teach the model what an answer looks like, teach it which kinds of answers are preferred.</em></strong></p><p>Historically, one important approach was <strong>RLHF — Reinforcement Learning from Human Feedback</strong>. Modern systems can also use other preference-optimization methods.</p><pre>Supervised training<br>        ↓<br>&quot;This is a desired example.&quot;<br><br>Preference training<br>        ↓<br>&quot;Between these outputs, this type is preferred.&quot;</pre><p>This becomes important when understanding how assistant behavior is shaped.</p><h4>Alignment</h4><p><strong>Alignment</strong> broadly means making model behavior better match the goals, instructions, preferences, and constraints intended by its developers/users.</p><p>For example:</p><pre>Raw capability<br>      ↓<br>Instruction following<br>      ↓<br>Helpful behavior<br>      ↓<br>Safety constraints<br>      ↓<br>Aligned assistant</pre><p>Alignment is <strong>not a single training algorithm</strong>. It is a broader goal involving multiple techniques and design decisions.</p><h4>Safety</h4><p>A powerful model can potentially generate harmful or inappropriate outputs. Therefore, AI systems incorporate safety mechanisms. These can exist at different levels</p><pre>Training<br>   ↓<br>Model behavior<br>   ↓<br>System instructions<br>   ↓<br>Input/output filtering<br>   ↓<br>Application-level controls</pre><p>Production AI systems need multiple layers of protection.</p><h4>Base Model vs Chat/Instruct Model</h4><p><strong>Base model: </strong>Primarily trained to model/generate language patterns.</p><pre>Text<br> ↓<br>Next-token prediction</pre><p><strong>Instruct/chat model: </strong>A pretrained model that has undergone additional training and/or alignment to better follow instructions and interact with users.</p><pre>Pretraining<br>     ↓<br>Base model<br>     ↓<br>Instruction / preference / alignment training<br>     ↓<br>Chat/Instruct model</pre><p>So when you interact with a modern assistant, you’re generally not interacting with a raw pretrained model.</p><h3>How a Chat Model Is Made</h3><pre>                  HUGE DATA<br>                       ↓<br>                  PRETRAINING<br>                       ↓<br>                  BASE MODEL<br>                       ↓<br>             SUPERVISED FINE-TUNING<br>                       ↓<br>              INSTRUCTION TUNING<br>                       ↓<br>          HUMAN PREFERENCES / FEEDBACK<br>                       ↓<br>             PREFERENCE OPTIMIZATION<br>                       ↓<br>                ALIGNMENT + SAFETY<br>                       ↓<br>               CHAT / INSTRUCT MODEL<br>                       ↓<br>                   INFERENCE<br>                       ↓<br>                 AI ASSISTANT</pre><p>The exact pipeline differs between model developers and model families, but this is the conceptual progression you need.</p><blockquote><strong>Pretraining gives a model broad language capabilities; instruction tuning, supervised fine-tuning, preference optimization, alignment, and safety training shape those capabilities into a model that can follow instructions and interact more usefully and safely with people.</strong></blockquote><pre>AI<br> ↓<br>Machine Learning<br> ↓<br>Neural Networks<br> ↓<br>Deep Learning<br> ↓<br>Transformers<br> ↓<br>Tokens + Embeddings<br> ↓<br>Attention<br> ↓<br>Large-scale pretraining<br> ↓<br>Next-token prediction<br> ↓<br>LLM<br> ↓<br>Instruction / Preference / Alignment training<br> ↓<br>Chat/Instruct Model</pre><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30128890780c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Neural Network)]]></title>
            <link>https://medium.com/@shubham3480/ai-neural-network-57a047e0eb87?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/57a047e0eb87</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 04:04:36 GMT</pubDate>
            <atom:updated>2026-11-15T04:04:36.198Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 5)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h4>Multiple Layers</h4><p>Multiple layers allow a neural network to learn increasingly complex patterns by combining simpler patterns learned earlier. For example, imagine recognizing a face. Different layers can learn different levels of patterns.</p><p><strong>Pixels → edges → shapes → eyes/nose/mouth → face</strong></p><h4>Representation Learning</h4><p>A <strong>representation</strong> is simply a useful numerical way of describing something. For example:</p><pre>Image<br> ↓<br>numbers<br> ↓<br>edges<br> ↓<br>shapes<br> ↓<br>objects</pre><p>The network learns internal representations that make the original problem easier to solve. We don’t manually tell the model what features to use.<strong> </strong>The model learns useful representations from data.</p><h4>Feature Learning</h4><p>Feature learning means the neural network automatically discovers useful patterns in raw data instead of requiring humans to manually define them.</p><p>For an image:</p><pre>pixels<br> ↓<br>edges<br> ↓<br>corners<br> ↓<br>shapes<br> ↓<br>object</pre><p>For language</p><pre>tokens<br> ↓<br>word relationships<br> ↓<br>phrases<br> ↓<br>meaning<br> ↓<br>context</pre><h4>Deep Neural Networks</h4><p>A neural network with many layers is called a <strong>deep neural network (DNN)</strong>.</p><p>Making networks deeper introduced problems. Some important ones:</p><p><strong><em>Vanishing gradients</em>: </strong>During backpropagation, gradients can become extremely small as they travel backward through many layers. Then earlier layers receive almost no useful learning signal.</p><p><strong><em>Exploding gradients</em>: </strong>The opposite can happen. Gradients become extremely large, making training unstable.</p><p><strong><em>Computational cost</em>: </strong>More layers and parameters means more computation, meaning more memory and more training time.</p><p><strong>Large amounts of data: </strong>Large models generally need substantial amounts of data to learn useful representations without simply memorizing training examples.</p><p>These challenges made deep networks difficult to train effectively for a long time.</p><p>Deep Learning Became Practical several developments changed the situation. The major ones were</p><pre>Better algorithms<br>       +<br>Better hardware<br>       +<br>More data<br>       +<br>Larger models<br>       ↓<br>Practical deep learning</pre><p>The most important hardware development for modern AI was the ability to perform enormous amounts of parallel numerical computation efficiently.</p><p><strong>GPUs and Parallel Computation: </strong>GPUs are useful for AI because neural networks perform huge amounts of parallel numerical computation, especially matrix operations.</p><h3>Language to Numbers</h3><p>A neural network doesn’t directly process the meaning of the word &quot;Hello&quot;. It needs numerical representations. The basic pipeline is something like this</p><pre>Human language<br>      ↓<br>Text<br>      ↓<br>Tokens<br>      ↓<br>Token IDs<br>      ↓<br>Vectors<br>      ↓<br>Embeddings<br>      ↓<br>Neural network</pre><h3>Tokens</h3><p>A <strong>token</strong> is a small piece of text that a language model processes. A token can be</p><ul><li>a whole word</li><li>part of a word</li><li>punctuation</li><li>sometimes spaces or other pieces</li></ul><p>For example, conceptually</p><pre>&quot;unbelievable!&quot;</pre><p>could become something like</p><pre>[&quot;un&quot;, &quot;believ&quot;, &quot;able&quot;, &quot;!&quot;]</pre><blockquote><strong>The exact tokenization depends on the model’s tokenizer.</strong></blockquote><h4>Words vs Token</h4><p>A token is a piece of text that an LLM converts into a numerical representation before processing it because there are enormous numbers of possible words. example</p><pre>play<br>playing<br>played<br>player<br>playground</pre><p>Instead of needing every possible word as a completely separate vocabulary item, subword tokenization can reuse pieces. This helps models handle unfamiliar words too.</p><h4>Tokenization</h4><p><strong>It </strong>is the process of converting text into tokens. The exact result depends on the tokenizer.<em> </em><strong><em>Then each token is assigned an ID.</em></strong></p><h4>Vocabulary</h4><p>A <strong>vocabulary</strong> is the set of tokens a tokenizer knows.</p><h4>Token IDs</h4><p>Once tokenized, “I watch Anime” might become [15, 823, 4217]. These are <strong>token IDs</strong>. Now we have transformed language into numbers.</p><p>But there’s a problem. AI → 4217 is not enough for a neural network to understand what AI means.</p><p>A token ID is basically a <strong>label</strong>. We need a richer numerical representation.</p><h3>Embeddings</h3><p>An embedding is a learned vector representation that allows a model to represent relationships between pieces of information numerically.</p><p>Instead of AI → 4217, we can have</p><pre>AI → [0.21, -0.73, 0.44, 0.91, ...]</pre><p>That vector contains many dimensions. During training, the model learns representations where relationships between concepts can emerge</p><blockquote><strong>The vectors for semantically related concepts can develop useful relationships.</strong></blockquote><h4>Vectors</h4><p>A <strong>vector</strong> is simply an ordered list of numbers. Example</p><pre>[0.2, -0.7, 0.4, 0.9]<br>// That&#39;s a 4-dimensional vector. <br>// Real models use vectors with many more dimensions.</pre><p>You can think of an embedding as <strong><em>A location in a mathematical space representing learned information.</em></strong></p><p>We don’t manually decide what each dimension means. The model learns useful representations during training.</p><h4>Semantic Relationships</h4><p><strong>Semantic</strong> means related to meaning. Suppose embeddings produce a conceptual space like:</p><pre>        dog<br>       /<br>     cat<br><br>                   car</pre><p>The model can learn that cat ↔ dog are related concepts, while cat ↔ carare generally less related. The important thing is not the exact coordinates. It’s the <strong>relationships between representations</strong>.</p><h3>Context</h3><p>Here is an example: the word bank could mean <strong><em>“I deposited money in the bank.” </em></strong>or <strong><em>“We sat beside the river bank”</em></strong>.</p><p>The token itself is not enough to determine the meaning, the surrounding text provides <strong>context</strong>.</p><p>LLMs therefore don’t simply process isolated words. They process sequences of tokens and use relationships between those tokens to understand what is happening.</p><h4>Context Window</h4><p>A <strong>context window</strong> is the amount of tokenized information a model can consider as its input context for a particular request.</p><p>Conceptually</p><pre>       Context Window<br>┌──────────────────────────────┐<br>│ previous conversation        │<br>│ documents                    │<br>│ instructions                 │<br>│ current question             │<br>└──────────────────────────────┘<br>                ↓<br>              Model</pre><p>If the context window is limited, you can’t simply provide unlimited conversation history or documents. This becomes extremely important when building</p><ul><li>AI chat applications</li><li>RAG systems</li><li>agents</li><li>long conversations</li></ul><pre>Human text<br>    ↓<br>Tokenization<br>    ↓<br>Tokens<br>    ↓<br>Token IDs<br>    ↓<br>Embeddings<br>    ↓<br>Vectors<br>    ↓<br>Transformer<br>    ↓<br>Meaning/contextual relationships</pre><p>Imagine a huge world map. The map has different areas</p><pre>🗺️ WORLD OF MEANING (embedding space)<br><br>🐶 Animals     🍕 Food      🚗 Vehicles (embedding)<br>🏦 Finance     💻 Technology<br>🌳 Nature      ⚽ Sports</pre><p>Think of this whole map as the <strong>embedding space</strong>. A location on that map representing meaning<strong> is called an embedding.</strong></p><p>Now take the word <strong>“bank.”</strong> The word <strong>bank</strong> can mean different things. So the word can be associated with <strong>different places on the meaning map.</strong></p><pre>&quot;bank&quot; -&gt; can mean<br>🏦 Bank → money<br>🌊 Bank → side of a river<br>💾 Bank → storage/database</pre><p>The important idea is that o<strong><em>ne thing can have different meanings, so the model may need to consider different possible locations/representations.</em></strong></p><p>So the group of coordinates for all meanings that can be associated with that word is called a vector.</p><pre>&quot;bank&quot;= [0.8, 0.1, -0.3, ...]  ← vector for bank<br>                   │<br>                   └── one location</pre><p><strong>Contextual embeddings</strong> can produce different vectors depending on the surrounding text.</p><p>The model gives more <strong>weight</strong> to the meaning that fits the context. For example, conceptually:</p><pre>🏦 Finance     → 0.90 importance<br>🌊 River       → 0.05 importance<br>💾 Storage     → 0.05 importance</pre><p>So the model chooses the <strong>finance meaning</strong>. <strong>Context gives clues, and learned weights help the model decide which information should matter more.</strong></p><p>Weights don’t directly give the probability. Instead</p><pre>Input + context<br>       ↓<br>learned weights<br>       ↓<br>scores (logits)<br>       ↓<br>probabilities<br>       ↓<br>most likely choice</pre><h3>Transformers</h3><p>Before Transformers, language models commonly relied on architectures such as <strong>RNNs (Recurrent Neural Networks)</strong>. An RNN processes a sequence step by step</p><pre>I → love → React → because → it → is → powerful</pre><p>The problem is that long sequences are difficult to process efficiently. The model has to carry information through the sequence</p><pre>token 1<br>  ↓<br>token 2<br>  ↓<br>token 3<br>  ↓<br>token 4<br>  ↓<br>...</pre><p>This creates problems with:</p><ul><li>long-range relationships</li><li>parallelization</li><li>training speed</li></ul><p>Transformers introduced a different idea. <strong><em>Instead of processing tokens strictly one at a time, it allows tokens to directly interact with other relevant tokens through attention.</em></strong></p><h4>Sequence Processing</h4><p>A <strong>sequence</strong> is an ordered collection of things. For language,<strong><em> “The cat chased the mouse”</em></strong> is a sequence of tokens.</p><p>The model needs to understand relationships between those tokens. For example, <strong><em>“The cat chased the mouse because it was hungry.” </em></strong>What does <strong>“it”</strong> refer to?</p><p>The model needs to look at other parts of the sequence to understand the relationship. This is where <strong>attention </strong>becomes important.</p><h4>Attention</h4><p><strong>Attention</strong> allows a model to determine which parts of the input are important when processing a particular token.</p><h4>Self-Attention</h4><p>Self-attention means the tokens in a sequence attend to other tokens within the same sequenc<strong>e</strong>. For example</p><pre>The dog chased the ball.<br><br>The representation of &quot;chased&quot; can consider<br><br>The<br>dog<br>ball</pre><p>The tokens communicate with each other. Conceptually</p><pre>The  ↔   dog<br> ↓        ↓<br>chased ↔ ball</pre><p>This allows the model to capture relationships within the sequence.</p><h4>Query, Key, Value</h4><p>For each token, the attention mechanism creates three representations</p><p><strong>Query: </strong>“What information am I looking for?”</p><p><strong>Key: </strong>“What information do I contain that others might be interested in?”</p><p><strong>Value: </strong>“What information should I actually provide?”</p><pre>Query<br>  ↓<br>compare with Keys<br>  ↓<br>attention scores<br>  ↓<br>select/weight Values<br>  ↓<br>new representation</pre><h4>Multi-Head Attention</h4><p>Multi-head attention runs several attention mechanisms in parallel so the model can learn different relationships in the same sequence.</p><p>One attention mechanism can learn certain relationships. But language contains many different types of relationships. For example</p><pre>Head 1 → grammatical relationships<br>Head 2 → word relationships<br>Head 3 → positional relationships<br>Head 4 → semantic relationships</pre><p>A Transformer therefore uses multiple attention mechanisms called <strong>attention heads</strong>. Conceptually</p><pre>             Input<br>               ↓<br>     ┌─────────┼─────────┐<br>     ↓         ↓         ↓<br>   Head 1    Head 2    Head 3<br>     ↓         ↓         ↓<br>     └─────────┼─────────┘<br>               ↓<br>            Combine</pre><p>This is called <strong>multi-head attention</strong>.</p><p>The heads aren’t manually assigned these jobs. During training, different heads can learn different patterns.</p><h4>Positional Information</h4><p>Attention itself doesn’t inherently mean A B C is different from C B A</p><p>The model therefore needs information about <strong>where tokens occur in the sequence</strong>. This is called <strong>positional information</strong>. Conceptually</p><pre>Token + Position<br>      ↓<br>Transformer</pre><p>For example</p><pre>&quot;I&quot;       → position 1<br>&quot;love&quot;    → position 2<br>&quot;React&quot;   → position 3</pre><p>Modern Transformer architectures can use different positional encoding/position-representation techniques.</p><p><strong><em>The model needs information about token order.</em></strong></p><h4>Transformer Block</h4><p>A Transformer isn’t just one attention operation. A simplified Transformer block looks roughly like:</p><pre>Input<br>  ↓<br>Self-Attention<br>  ↓<br>Feed-Forward Network<br>  ↓<br>Output</pre><p>In practice, there are also important mechanisms such as:</p><ul><li>residual connections</li><li>normalization</li><li>multiple layers</li></ul><p>A simplified larger picture</p><pre>Input<br>  ↓<br>Transformer Block<br>  ↓<br>Transformer Block<br>  ↓<br>Transformer Block<br>  ↓<br>Transformer Block<br>  ↓<br>Output</pre><p>Stacking many blocks gives the model substantial representational capacity.</p><h4>Encoder vs Decoder</h4><p>Transformers can be organized differently depending on the task.</p><p><strong>Encoder: </strong>The encoder is primarily designed to <strong>understand/represent input</strong>. Conceptually</p><pre>Input<br>  ↓<br>Encoder<br>  ↓<br>Representation</pre><p>Encoder-style architectures are useful for tasks such as understanding text.</p><p><strong>Decoder</strong>: The decoder is designed to <strong>generate output</strong>, typically one token at a time.</p><pre>Previous tokens<br>      ↓<br>Decoder<br>      ↓<br>Next token</pre><p>Many modern generative LLMs use a <strong>decoder-only Transformer</strong> architecture.</p><h4>Pros of Transformers</h4><p><strong>Direct token relationships: </strong>Tokens can interact through attention rather than relying purely on sequential hidden-state transmission.</p><p><strong>Parallel processing: </strong>During training, many token computations can be performed efficiently in parallel.</p><p><strong>Better scaling: </strong>Transformer architectures work extremely well as we increase</p><pre>data + parameters + compute</pre><p><strong>General-purpose architecture:</strong> Transformers became useful across:</p><ul><li>language</li><li>vision</li><li>audio</li><li>multimodal AI</li></ul><p>And most importantly for us</p><pre>Transformer<br>     ↓<br>Large-scale training<br>     ↓<br>Large Language Model<br>     ↓<br>ChatGPT-style applications</pre><blockquote><strong>A Transformer is a neural-network architecture built around attention, allowing tokens to learn relationships with other tokens efficiently. Self-attention uses Query, Key, and Value representations, while multiple Transformer blocks build increasingly powerful representations.</strong></blockquote><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57a047e0eb87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Neural Networks)]]></title>
            <link>https://medium.com/@shubham3480/ai-neural-networks-c954e7bc5778?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/c954e7bc5778</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 03:55:02 GMT</pubDate>
            <atom:updated>2026-11-13T03:55:02.932Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 4)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h3>Forward Propagation</h3><p>Forward propagation is the process of passing input data through all the layers of a neural network to produce an output.</p><p>Another common name for forward propagation is Forward Pass.</p><pre>INPUT<br>  ↓<br>Layer 1<br>  ↓<br>Layer 2<br>  ↓<br>Layer 3<br>  ↓<br>OUTPUT</pre><p>Suppose we have 2 layers here output of layer 1 become input of layer 2</p><pre>x₁ ──┬──→ Neuron 1 ──┐<br>     │                │<br>x₂ ──┼──→ Neuron 2 ──┼──→ Layer 2<br>     │                │<br>x₃ ──┴────────────────┘</pre><p>This is what happens every time a trained neural network makes a prediction. Suppose you send an image to a model. Conceptually</p><pre>Image<br> ↓<br>Numerical representation<br> ↓<br>Layer 1<br> ↓<br>Layer 2<br> ↓<br>Layer 3<br> ↓<br>...<br> ↓<br>Output</pre><p>Or for an LLM</p><pre>Text<br> ↓<br>Tokens<br> ↓<br>Numerical representations<br> ↓<br>Transformer layers<br> ↓<br>Output scores<br> ↓<br>Prediction</pre><h4>Forward propagation happens during both training and inference</h4><p>During inference, we normally aren’t updating the model’s learned parameters. We’re simply using the already-trained parameters to produce an output.</p><h3>Loss</h3><p>For machine learning, simply saying <strong>wrong</strong> is not enough. The model needs a numerical signal telling it <strong>how wrong</strong> it was. That numerical measurement is called Loss.</p><h4>Prediction vs target</h4><p>The <strong>prediction</strong> is what the neural network produces. For example, model prediction = 0.7, Maybe the model is predicting the probability that an image contains a cat.</p><p>The <strong>target</strong> is the answer we actually want. Example Target = 1Here, 1 could mean Yes, this is a cat.</p><p>We do not say it is wrong Because machine learning needs more information.</p><pre>Model A<br><br>Target = 1<br>Prediction = 0.9<br><br>Model B<br>Target = 1<br>Prediction = 0.1</pre><p>But clearly Model A is closer to target. So Model A should receive a smaller penalty. This gives the learning system a useful direction.</p><pre>Model A → small loss<br><br>Model B → large loss</pre><h3>Loss functions</h3><p>The mathematical formula used to calculate loss is called a Loss Function.</p><pre>prediction + target<br>        │<br>        ▼<br>  loss function<br>        │<br>        ▼<br>      loss</pre><p>Different problems need different ways of measuring error.</p><p>For example, predicting a number and predicting whether something belongs to a category are different problems. Therefore, we have different loss functions.</p><p>Some important ones:</p><h4>🟩Mean Squared Error — MSE</h4><p>Often used for regression-type problems where the model predicts continuous numerical values.</p><pre>prediction<br>    ↓<br>difference from target<br>    ↓<br>square the difference<br>    ↓<br>average<br>    ↓<br>loss</pre><h4>🟩Binary Cross-Entropy</h4><p>Often used when the model is making a binary decision, such as</p><pre>cat / not cat<br>spam / not spam<br>yes / no</pre><h4>🟩Cross-Entropy Loss</h4><p>For language modeling, the model predicts probabilities for possible next tokens. Example</p><pre>The cat is ___</pre><p>Possible predictions might be</p><pre>sleeping → 0.60<br>running  → 0.20<br>blue     → 0.05</pre><p>Suppose the correct next token is sleeping. The loss evaluates how much probability the model assigned to the correct answer.</p><blockquote><strong>The model is rewarded for assigning high probability to the correct answer and penalized when it assigns low probability to it.</strong></blockquote><h4>Loss is not the same thing as accuracy</h4><p>Loss can capture information about the quality of the predicted probabilities that simple accuracy does not.</p><h3>The complete training</h3><p>A neural network starts with some parameters.<strong><em>Parameters are the learned numerical values inside the model, including weights and biases.</em></strong></p><p>We give it an input. Then</p><h4>Step 1 — Input</h4><pre>Input<br>  ↓</pre><h4>Step 2 — Forward propagation</h4><p>The information travels through the network.</p><pre>Input<br> ↓<br>Layer<br> ↓<br>Layer<br> ↓<br>Output</pre><p>The model produces a prediction.</p><h4>Step 3 — Compare prediction with target</h4><pre>Prediction ─────┐<br>                ├──→ Loss<br>Target ─────────┘</pre><p>The loss tells us <em>Your prediction was this far from what you wanted.</em></p><h4>Step 4 — Use the loss to learn</h4><p><strong><em>Gradient descent </em></strong>and <strong><em>Backpropagation, </em></strong>They allow the model to determine how its parameters should change so that future predictions can produce lower loss. So the basic learning loop becomes</p><pre>Input<br>  ↓<br>Forward Propagation<br>  ↓<br>Prediction<br>  ↓<br>Loss<br>  ↓<br>Backpropagation<br>  ↓<br>Parameter Updates<br>  ↓<br>Try Again</pre><p>And this repeats many times.</p><p><strong><em>Training tries to adjust the model’s parameters so that the loss becomes smaller on the task it is learning.</em></strong></p><h3>loss vs parameter</h3><p><strong>Parameter: </strong>A parameter is a learned number inside the model.</p><p><strong>Loss: </strong>Loss is a number describing how badly the model performed on some example or set of examples.</p><pre>                    INPUT<br>                      │<br>                      ▼<br>              ┌───────────────┐<br>              │ Neural Network│<br>              │               │<br>              │ Weights       │<br>              │ Biases        │<br>              │ Layers        │<br>              │ Activations   │<br>              └───────┬───────┘<br>                      │<br>                      ▼<br>                 PREDICTION<br>                      │<br>                      ▼<br>               ┌─────────────┐<br>               │ Loss        │<br>               │ Function    │<br>               └──────┬──────┘<br>                      │<br>                      ▼<br>                    LOSS<br>                      │<br>                      ▼<br>               &quot;How wrong?&quot;</pre><blockquote>Loss is a numerical measurement of how far a model’s prediction is from the desired target. A training process uses this signal to adjust the model’s parameters so that future predictions can have lower loss.</blockquote><h3>Gradient Descent</h3><p>A <strong>gradient</strong> tells us how something changes when we change something else.</p><p><strong><em>This relationship between parameter changes and loss changes is what gradients help us measure.</em></strong></p><h4>The gradient is like a downhill arrow</h4><p>Imagine you’re standing somewhere on our loss mountain.</p><pre>                 High loss<br>                    /\<br>                   /  \<br>                  /    \<br>                 /  ●   \  we are here<br>                /        \<br>               /          \<br>              /            \<br>          ___/______________\___<br>                Low loss</pre><p>The gradient tells you about the slope around your current position. Here, the gradient points in the direction of increasing loss. Therefore, to reduce loss, we move in the <strong>opposite direction of the gradient</strong>.</p><p>This is why we call it <strong><em>Gradient descent </em></strong>Because we use the gradient to move downhill.</p><p>We don&#39;t just randomly change weights. Imagine our network has thousands of parameters. A modern neural network can have millions, billions, or even more parameters.</p><p>Suppose the model has</p><pre>w1<br>w2<br>w3<br>w4<br>...<br>w1,000,000</pre><p>We can’t simply randomly change everything and hope the model becomes better.</p><p><strong><em>We need information about: Which parameters should change, in which direction, and by how much.</em></strong></p><p><strong><em>Gradient information provides the direction. The eventual update rule will provide the amount.</em></strong></p><h4>One parameter</h4><p>Imagine we have only one parameter <strong>w, </strong>and imagine the loss depends on that parameter. We can draw it:</p><pre>Loss<br> ^<br> |          ● ← current position<br> |        /   \<br> |      /       \<br> |    /           \<br> |___/_____________\____&gt; w</pre><p>The lowest point represents the smallest loss. Our current parameter might be here. We want to move toward the bottom.</p><h4>The update idea</h4><p>The fundamental idea can be represented as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*1XsFylTW5WCygT03Ysj9wg.png" /></figure><p>But the step isn’t arbitrary. It depends on the gradient. So the famous gradient descent update looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*VUt06rMW7ufY32EHeLWEbQ.png" /></figure><p>w:The parameter we’re changing. Example: w = weight.</p><p>L:loss.</p><p>∂L/∂w: How much does the loss change when this particular parameter changes?<strong><em> You can call this the gradient.</em></strong></p><p>This is a <strong>derivative</strong>. A derivative is simply a mathematical way of measuring change or slope.</p><p>η:Learning rate. It controls how large a step we take.</p><pre>gradient → which direction?<br>learning rate → how big a step?<br><br>step/change = learning rate × gradient </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*b7HxnZeWvX7oNexvb3UD2w.png" /></figure><h3>Example</h3><p>Suppose weight = 5, and suppose the gradient is 2 and the learning rate = 0.1.</p><pre>w = 5 - (0.1 * 2) = 4.8</pre><p>So now the new weight becomes 4.8.</p><p>The weight moved. Because the gradient told us which direction would increase the loss, and we moved in the opposite direction.</p><h4>Negative Gradient</h4><p>Let&#39;s say the gradient is -2.</p><pre>w = 5 - (0.1 * -2) = 5.2</pre><p>So the weight moves <strong>upward</strong>. Because the gradient was negative.</p><blockquote><strong>Positive gradient → move parameter downward</strong></blockquote><blockquote><strong>Negative gradient → move parameter upward</strong></blockquote><p>Gradient descent is not changing the prediction directly. The model doesn’t say <em>My prediction was 7, so I’ll change 7 to 8. Instead,</em></p><pre>Prediction<br>    ↓<br>Loss<br>    ↓<br>Gradient information<br>    ↓<br>Parameters<br>    ↓<br>New prediction</pre><p>we change the parameter so eventually the prediction is changed.</p><h4>Learning Rate</h4><p>The <strong>learning rate</strong> is a value that controls how much the model’s parameters change during each optimization step. The η is the <strong>learning rate</strong>.</p><p>Suppose</p><pre>Current weight = 5<br>Gradient = 2<br>learning rate is 0.1<br><br>change = learning rate × gradient<br><br>change = 0.1 × 2 = 0.2<br><br>Old weight = 5<br>New weight = 4.8</pre><p>Here, the model took a step of 0.2</p><p>What if the step is 0.02 so the new weight will become 4.98</p><pre>Learning rate    Parameter change<br><br>0.1              0.2<br>0.01             0.02</pre><p><strong><em>Here, the gradient is the same, but the learning rate controls how aggressively the parameters are updated.</em></strong></p><h4>Low learning rate</h4><p>The model will learn, but extremely slowly. Example</p><pre>Loss<br><br>100<br> ↓<br>99.9<br> ↓<br>99.8<br> ↓<br>99.7<br> ↓<br>99.6</pre><h4>High learning rate</h4><p>Instead of steadily moving downward, training becomes unstable. Example</p><pre>Loss<br><br>10<br> ↓<br>5<br> ↓<br>9<br> ↓<br>4<br> ↓<br>12<br> ↓<br>7<br> ↓<br>15</pre><p><strong>There will be three situations based on your learning Rate</strong></p><pre>             Learning Rate<br>                  │<br>       ┌──────────┼──────────┐<br>       │          │          │<br>       ▼          ▼          ▼<br>     Small     Suitable     Large<br>       │          │          │<br>       ▼          ▼          ▼<br>     Slow       Controlled   Unstable<br>    learning     updates     updates</pre><p>The goal is to use a learning rate appropriate for the optimization problem and training setup.</p><h4>Hyperparameter vs parameter</h4><p>A <strong>parameter</strong> is a value the model learns during training. Examples: weights and Bais. The training process changes them.</p><p>A <strong>hyperparameter</strong> is a setting chosen for the training process rather than learned by the model itself. The learning rate is a hyperparameter.</p><blockquote><strong>The gradient determines that the update should go in the negative direction. The learning rate does not decide that. It only determines the magnitude of the movement.</strong></blockquote><h3>Backpropagation</h3><p>Backpropagation is an algorithmic process that works backward from the loss through the neural network to calculate how each parameter contributed to the error, producing gradients for those parameters.</p><p><strong>Backpropagation</strong> solves how to calculate the gradient for every weight and bias in a deep neural network.</p><p>Imagine you have a machine with several knobs.</p><pre>Knob A ──┐<br>Knob B ──┼──→ Machine ──→ Prediction<br>Knob C ──┘</pre><p>The machine gives a bad answer. You calculate the loss. Now you want to know <em>which knobs contributed to this error and how</em> you should change each knob to reduce the error</p><p><strong>Backpropagation works backward through the network to calculate how each parameter contributed to the loss.</strong></p><blockquote><strong>Backpropagation = propagating error information backward through the network to calculate gradients for its parameter.</strong></blockquote><p>We can’t calculate parameters independently. Suppose a network has 1M parameters. One approach would be to change<em> parameter 1 slightly → recalculate the entire network → measure the loss change. </em>And repeat this for every parameter. That would be extremely expensive.</p><p>Backpropagation gives us a much more efficient way to calculate the required gradients by <strong>reusing intermediate information from the forward computation</strong>.</p><h4>Chain Rule</h4><p><strong><em>The chain rule is a calculus rule that lets us calculate how a change in one variable affects another through a sequence of dependent operations.</em></strong></p><p>Suppose A → B → C, And changing A affects B, while changing B affects C. Then changing A ultimately affects C.</p><p>The chain rule lets us calculate the overall effect by combining the individual effects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*oBZIvLDAIamVC1PUu-3Ayg.png" /></figure><pre>the effect of A on C = effect of A on B × effect of B on C.</pre><p>This is the mathematical foundation that makes backpropagation possible.</p><h4>Simple Network</h4><p>Suppose one neuron calculates z = wx. Then suppose the output is y = z and the loss is L = (y — target)²</p><p>We want to know</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/77/1*UXWnDH49CpDBIzxXgyUj4w.png" /></figure><p>The chain rule lets us break that into</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*MflQw7cI-_vqkTSuxbPjXw.png" /></figure><p>Instead of trying to calculate the entire relationship in one giant step, we break it into smaller relationships.</p><blockquote>Backpropagation calculates the gradient, it does not update the weight. The gradient updates the weight.</blockquote><p><strong><em>We start from output because the loss is calculated from the final prediction</em></strong><em>.</em> The dependency is</p><pre>Parameters<br>   ↓<br>Network computation<br>   ↓<br>Prediction<br>   ↓<br>Loss</pre><p>The loss is therefore the endpoint of the dependency chain. To determine how earlier parameters affected it, we work backward from the loss.</p><p>That’s <strong><em>why backpropagation starts with the loss and works backward through the network.</em></strong></p><blockquote><strong>backpropagation: </strong>The model first performs forward propagation and calculates the loss. Backpropagation then works backward through the network using the chain rule to calculate the gradient of the loss with respect to each parameter, and an optimizer uses those gradients to update the parameters.</blockquote><h4>Automatic differentiation</h4><p>Automatic differentiation is a computational technique used by deep-learning frameworks to automatically calculate derivatives of complex mathematical operations.</p><p>It means software can systematically calculate derivatives of complicated mathematical computations. <strong>Automatic differentiation</strong>, often called autodiff. For example, instead of us manually calculating</p><pre>∂L/∂w1<br>∂L/∂w2<br>∂L/∂w3</pre><p>a deep-learning framework can construct the necessary computation relationships and calculate the gradients automatically.</p><p>This is a major practical reason frameworks such as PyTorch can train huge neural networks. We don’t need to manually derive every parameter’s gradient.</p><h3>Training Loop</h3><p>A <strong>training loop</strong> is the repeated process through which a neural network</p><ol><li>receives training data,</li><li>makes a prediction,</li><li>measures its error,</li><li>calculates gradients,</li><li>updates its parameters,</li><li>repeats the process.</li></ol><pre>              TRAINING DATA<br>                    │<br>                    ▼<br>             ┌─────────────┐<br>             │    INPUT    │<br>             └──────┬──────┘<br>                    ▼<br>          FORWARD PROPAGATION<br>                    │<br>                    ▼<br>               PREDICTION<br>                    │<br>                    ▼<br>                  LOSS<br>                    │<br>                    ▼<br>            BACKPROPAGATION<br>                    │<br>                    ▼<br>                GRADIENTS<br>                    │<br>                    ▼<br>              OPTIMIZER<br>                    │<br>                    ▼<br>           UPDATE PARAMETERS<br>                    │<br>                    └──────────┐<br>                               │<br>                               ▼<br>                         NEXT EXAMPLE</pre><p>The training loop does <strong>not</strong> update the input data. It updates the model’s <strong>learnable parameters</strong>.</p><p>The model needs examples to learn from. Suppose we’re training a cat classifier. Our dataset might contain</p><pre>Image 1 → Cat<br>Image 2 → Dog<br>Image 3 → Cat<br>Image 4 → Dog<br>Image 5 → Cat</pre><h4><strong><em>Dataset</em></strong></h4><p><strong><em>A dataset is a collection of examples used for learning or evaluation.</em></strong></p><h4>Batch</h4><p>Imagine we have 10M examples. Feeding all of them through the network simultaneously would require a huge amount of memory and computation.</p><p>Instead, training commonly processes smaller groups of examples. These groups are called batches.</p><p><strong><em>Memory requirements can be smaller, but the training process may be less efficient. In this case, batches are more useful.</em></strong></p><p><strong>The entire dataset at once: </strong>We may require enormous memory and computation.</p><p><strong>A batch: </strong>We process a manageable amount of data while taking advantage of efficient numerical computation.</p><p>Modern hardware such as GPUs is particularly good at processing many numerical operations in parallel.</p><h3>Epoch</h3><p>An <strong>epoch</strong> means one complete pass through the training dataset.</p><p>Suppose Dataset = 1000 examples and Batch size = 100. Then one epoch consists of</p><pre>Batch 1<br>Batch 2<br>Batch 3<br>...<br>Batch 10</pre><p>After those 10 <strong><em>batches, one epoch is complete.</em></strong></p><h4>Epoch vs iteration</h4><p>One training or one batch update is called an iteration, while one complete pass through the dataset is an epoch</p><h4>Training vs Inference</h4><p>Training changes the model’s parameters using loss and gradients, while inference uses the learned parameters to produce predictions without updating them.</p><blockquote><strong>So the learning process is essentially </strong>Make a prediction → measure the mistake → calculate how to improve → change the model → try again.</blockquote><pre>                    INPUT<br>                      │<br>                      ▼<br>              ┌───────────────┐<br>              │   NEURAL      │<br>              │   NETWORK     │<br>              │               │<br>              │ weights       │<br>              │ biases        │<br>              │ layers        │<br>              │ activations   │<br>              └───────┬───────┘<br>                      │<br>                      ▼<br>                 PREDICTION<br>                      │<br>                      ▼<br>                    LOSS<br>                      │<br>                      ▼<br>              BACKPROPAGATION<br>                      │<br>                      ▼<br>                  GRADIENTS<br>                      │<br>                      ▼<br>                 OPTIMIZER<br>                      │<br>                      ▼<br>              PARAMETER UPDATE<br>                      │<br>                      └─────────────┐<br>                                    │<br>                                    ▼<br>                              NEXT BATCH<br>                                    │<br>                                    ▼<br>                                  REPEAT</pre><h4>Overfitting</h4><p>Overfitting happens when a model learns the training data too specifically, including its noise or irrelevant details, and therefore performs poorly on new data.</p><p>Imagine you show a student the exact same 100 questions again and again. Eventually, they memorize the answers. Give them the <strong>same questions</strong> → they score very well. Give them <strong>new questions</strong> → they struggle. That’s <strong>overfitting</strong>.</p><h4>Generalization</h4><p><strong>Generalization</strong> means the model can use what it learned from training data to perform well on <strong>new, unseen data</strong>.</p><h4>Underfitting</h4><p>Underfitting happens when the model hasn’t learned the training patterns well enough.</p><h4>Neural-network training process.</h4><p>The model takes a batch of training data and performs forward propagation to produce predictions. It calculates the loss, uses backpropagation to calculate gradients, and an optimizer uses those gradients to update the model’s parameters. This process repeats across batches and epochs so the model gradually learns useful patterns from the data.</p><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c954e7bc5778" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Layers & Deep Neural Networks)]]></title>
            <link>https://medium.com/@shubham3480/ai-layers-deep-neural-networks-6819f05f5dd4?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/6819f05f5dd4</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 03:45:30 GMT</pubDate>
            <atom:updated>2026-11-13T03:45:30.406Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 3)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h3>Layer</h3><p><strong><em>A layer is a group of neurons that process information at the same stage of a neural network.</em></strong></p><p>A single neuron does</p><pre>inputs<br>  ↓<br>multiply by weights<br>  ↓<br>add them<br>  ↓<br>add bias<br>  ↓<br>activation<br>  ↓<br>output</pre><p>For three inputs</p><pre>z = x₁w₁ + x₂w₂ + x₃w₃ + b</pre><p>One neuron → one output. But now suppose we have <strong>4 neurons</strong>. Each neuron receives the same 3 inputs:</p><pre>┌── Neuron 1 ──→ y₁<br>                │<br>x₁, x₂, x₃ ────┼── Neuron 2 ──→ y₂<br>                │<br>                ├── Neuron 3 ──→ y₃<br>                │<br>                └── Neuron 4 ──→ y₄</pre><p>We now have</p><pre>3 inputs<br>   ↓<br>4 neurons<br>   ↓<br>4 outputs</pre><p>Writing every multiplication individually would become annoying very quickly. That’s where <strong>vectors and matrices</strong> become useful.</p><h4>Each neuron has its own parameters</h4><p>Suppose a layer contains</p><pre>4 neurons</pre><p>Each neuron doesn’t share one universal set of weights. Instead, each neuron generally has its <strong>own weights and bias</strong>. For example:</p><pre>Neuron 1:<br>w₁₁ w₁₂ w₁₃ + b₁<br><br>Neuron 2:<br>w₂₁ w₂₂ w₂₃ + b₂<br><br>Neuron 3:<br>w₃₁ w₃₂ w₃₃ + b₃<br><br>Neuron 4:<br>w₄₁ w₄₂ w₄₃ + b₄</pre><p>So the layer contains many parameters. Suppose we have three inputs and four neurons</p><pre><br>┌── Neuron 1 ──→ y₁<br>                 │<br>x₁ ──────────────┼── Neuron 2 ──→ y₂<br>x₂ ──────────────┼<br>                 ├── Neuron 3 ──→ y₃<br>x₃ ──────────────┼<br>                 │<br>                 └── Neuron 4 ──→ y₄</pre><p>Usually, every neuron receives the relevant inputs. So conceptually</p><pre>x₁   x₂   x₃<br>              │    │    │<br>        ┌─────┼────┼────┼─────┐<br>        │     │    │    │     │<br>        ↓     ↓    ↓    ↓     ↓<br>      [ N1 ] [ N2 ] [ N3 ] [ N4 ]<br>        │       │      │      │<br>        ↓       ↓      ↓      ↓<br>       y₁      y₂     y₃     y₄</pre><p>Now we have a <strong>layer</strong></p><h3>vector</h3><p>A vector is simply a <strong>list of numbers arranged together</strong>. For example:</p><pre>[2, 5, 3]</pre><p>We can call this our input vector</p><pre>x = [2, 5, 3]</pre><p>Think of it as a box containing related numbers.</p><h3>matrix</h3><p>A matrix is basically a <strong>table of numbers</strong>. A matrix lets us perform <strong>many mathematical operations at once</strong>. For example:</p><pre>[ 2  4  1 ]<br>[ 3  5  7 ]<br>[ 8  1  6 ]</pre><h4>Neurons into a matrix</h4><p>Suppose our input is:</p><pre>x = [2, 5, 3]</pre><p>We have 4 neurons. Their weights might be</p><pre>Neuron 1: [1, 2, 3]<br>Neuron 2: [4, 5, 6]<br>Neuron 3: [7, 8, 9]<br>Neuron 4: [2, 1, 4]</pre><p>Instead of storing them separately, we can arrange them into a matrix:</p><pre>W = [1  2  3]<br>    [4  5  6]<br>    [7  8  9]<br>    [2  1  4]</pre><p>This matrix contains the weights for all four neurons</p><h4>Matrix multiplication</h4><p>Now something fundamental happens. We can do</p><pre>W × x</pre><p>Conceptually, this performs all the neurons’ weighted calculations together. For example, neuron 1</p><pre>1×2 + 2×5 + 3×3</pre><p>which is</p><pre>2 + 10 + 9 = 21</pre><p>Neuron 2</p><pre>4×2 + 5×5 + 6×3</pre><pre>8 + 25 + 18 = 51</pre><p>And so on. So instead of thinking</p><pre>Neuron 1 calculates<br>Neuron 2 calculates<br>Neuron 3 calculates<br>Neuron 4 calculates</pre><p>we can represent the whole operation as</p><pre>W × x</pre><p>That’s one reason matrix multiplication is so important in AI.</p><p>Modern AI models perform <strong>huge numbers of mathematical operations</strong>. If we tried to manually perform every neuron calculation separately, it would be incredibly inefficient.</p><p>Matrices allow hardware such as GPUs to perform many operations efficiently in parallel.</p><p>A large part of neural-network computation can be expressed using operations involving:</p><pre>vectors<br>matrices<br>tensor operations</pre><h4>Adding Bias</h4><p>Every neuron can have its own bias. Our four neurons might have</p><pre>b = [1, 2, -1, 3]</pre><p>So the layer does conceptually</p><pre>W × x + b</pre><p>Then we apply the activation function:</p><pre>activation(W × x + b)</pre><p>That’s the mathematical skeleton of a dense/fully connected layer.</p><h3>Fully Connected Layer</h3><p>A <strong>fully connected layer</strong>, also called a <strong>dense layer</strong>, is a layer where neurons are connected to the inputs from the previous layer. For our example</p><pre>3 inputs<br>   ↓<br>4 neurons</pre><p>Each of the 4 neurons receives all 3 inputs. So:</p><pre>Input 1 ─────┬────→ Neuron 1<br>Input 2 ─────┼────→ Neuron 1<br>Input 3 ─────┘────→ Neuron 1<br><br>Input 1 ─────┬────→ Neuron 2<br>Input 2 ─────┼────→ Neuron 2<br>Input 3 ─────┘────→ Neuron 2<br>...</pre><p><strong><em>Hence, fully connected means every neuron in the layer receives input from every neuron in the previous layer.</em></strong></p><h3>Parameter counting</h3><p>Suppose we have</p><pre>Input size = 3<br>Output neurons = 4</pre><p>How many <strong>weights</strong> do we need? Each of the 4 neurons needs 3 weights</p><pre>4 × 3 = 12 weights</pre><p>Each neuron also has one bias</p><pre>4 biases</pre><p>Total</p><pre>12 + 4 = 16 parameters</pre><p>So <strong><em>A dense layer with 3 inputs and 4 neurons has 16 trainable parameters.</em></strong></p><p>Now imagine a model with</p><pre>thousands of inputs<br>thousands of neurons<br>hundreds of layers</pre><p>The number of parameters becomes enormous. This is how you should start thinking about model size.</p><h4>Parameter count</h4><p>This matters as you will see models described as</p><pre>7B<br>13B<br>70B<br>400B</pre><p>The B means <strong>billion</strong>. For example</p><pre>70B<br>=<br>approximately 70 billion parameters</pre><p>Those parameters are learned numerical values. They aren’t simply</p><pre>70 billion facts</pre><p>They’re values used throughout the model’s mathematical transformations.</p><h3>Tensor</h3><p>Initially, you can think of it as</p><pre>number<br> ↓<br>vector<br> ↓<br>matrix<br> ↓<br>higher-dimensional array</pre><p>All can be treated as tensors. For example,</p><pre>Number: 5</pre><p>can be considered a 0-dimensional tensor. A vector</p><pre>[1, 2, 3]</pre><p>is a 1-dimensional tensor. A matrix is a 2-dimensional tensor. And you can have more dimensions.</p><blockquote><strong><em>Tensor is a general structure for organizing numerical data across one or more dimensions.</em></strong></blockquote><h4>GPUs</h4><p>GPUs are designed to perform huge numbers of mathematical operations efficiently and in parallel.</p><h4>From layer to deep network</h4><p>Now let’s put multiple layers together. Suppose</p><pre>Input size = 3<br><br>Layer 1:<br>4 neurons<br><br>Layer 2:<br>5 neurons<br><br>Output:<br>2 neurons</pre><p>We have</p><pre>       3<br>        ↓<br>   [4 neurons]<br>        ↓<br>   [5 neurons]<br>        ↓<br>   [2 neurons]</pre><p>The output of layer 1 becomes the input to layer 2. So</p><pre>x<br> ↓<br>W₁x + b₁    layer 1<br> ↓<br>activation<br> ↓<br>W₂h₁ + b₂   layer 2<br> ↓<br>activation<br> ↓<br>W₃h₂ + b₃  layer 3<br> ↓<br>output</pre><p>The key idea is that each<strong><em> layer transforms the representation produced by the previous layer.</em></strong></p><h4>Feature learning</h4><p>Suppose we’re processing an image. The early layers might detect simple patterns <strong>edges, l</strong>ater layers detect <strong>shapes </strong>and later <strong>parts of objects. T</strong>his is a simplified conceptual picture, but it demonstrates the important idea:</p><pre>raw data<br>   ↓<br>representation<br>   ↓<br>transformed representation<br>   ↓<br>more abstract representation<br>   ↓<br>prediction</pre><p>The model isn’t simply storing the original input. It is repeatedly transforming it.</p><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6819f05f5dd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI (Neural Networks)]]></title>
            <link>https://medium.com/@shubham3480/ai-neural-networks-c317e3dafa2c?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/c317e3dafa2c</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 03:41:24 GMT</pubDate>
            <atom:updated>2026-11-13T03:41:24.418Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 2)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CaCWlrUR3V8K_0Er" /></figure><h3>Neuron</h3><p>A neural network is made of small mathematical units called neurons. A neuron receives some numbers as input, processes them, and produces a number as output.</p><pre>  INPUTS<br>    ↓<br>┌─────────┐<br>│ NEURON  │<br>└────┬────┘<br>     ↓<br>  OUTPUT</pre><blockquote><strong><em>A neuron is a small mathematical unit that takes inputs, processes them, and produces an output. </em>A neural network is simply many of these units connected together.</strong></blockquote><h4>Our first artificial neuron</h4><p>Suppose our neuron receives three inputs</p><pre>x₁ = hours studied<br>x₂ = attendance<br>x₃ = previous score</pre><p>We can represent them as</p><pre>         x₁<br>           \<br>            \<br>          ┌─────┐<br>          │     │<br>          │neuron│ ───→ output<br>          │     │<br>          └─────┘<br>            /<br>           /<br>          x₂<br><br>         x₃</pre><p>Not every input matters equally. For example, Hours studied might be very important. While Attendance might matter somewhat less and Previous score might have another influence.</p><p>So we need a way to control how strongly each input influences the neuron. So now weights come into the picture.</p><pre>x₁ ── weight₁ ──┐<br>                │<br>x₂ ── weight₂ ──┼──→ NEURON → output<br>                │<br>x₃ ── weight₃ ──┘</pre><blockquote><strong><em>A neuron needs weights so it can decide how important each input is.</em></strong></blockquote><p>The neuron uses the inputs <strong>and their weights</strong>. Suppose:</p><pre>Hours studied = 8<br>Attendance = 0.9<br>Previous score = 75</pre><p>And suppose the weights are</p><pre>Weight 1 = 0.5<br>Weight 2 = 0.2<br>Weight 3 = 0.1</pre><p>For now, we’re just demonstrating the mechanism. The neuron combines them</p><pre>8 × 0.5<br>+<br>0.9 × 0.2<br>+<br>75 × 0.1</pre><p>The result is</p><pre>4<br>+ 0.18<br>+ 7.5<br>= 11.68</pre><p>The neuron now has 11.68. Now a neuron usually applies another mathematical operation to that result. That’s called an</p><h4>Activation function</h4><pre>Inputs<br>  ↓<br>Weighted combination<br>  ↓<br>Activation function<br>  ↓<br>Output</pre><p>So our neuron is roughly:</p><pre>┌─────────────────┐<br>x₁ ── weight₁ ───→  │                 │<br>x₂ ── weight₂ ───→  │     NEURON      │ ───→ output<br>x₃ ── weight₃ ───→  │                 │<br>                    └─────────────────┘</pre><h4>Weights</h4><p>Weights are what allow a neuron to learn from its mistakes.</p><p>When a neuron first starts, its weights are just initial values. They might not be good enough to produce accurate predictions. During training, the model checks how far its prediction was from the correct answer and adjusts those weights to reduce the error.</p><p>This process happens again and again. With every adjustment, the neuron changes how it responds to different inputs. Over time, its predictions become more accurate.</p><p>But a single neuron isn’t intelligent. It doesn’t understand language, recognise concepts, or think on its own. It’s simply performing mathematical calculations.</p><p>Now, when billions of these simple calculations are connected together and trained on enormous amounts of data. Together, they can learn complex patterns and behaviours that we recognise as intelligence.</p><p>Imagine you’re trying to recognize a face. You could have different neurons responding to different patterns. Here is an example</p><pre>Input image<br>    ↓<br>Neurons detect simple patterns<br>    ↓<br>Neurons combine those patterns<br>    ↓<br>Higher-level patterns<br>    ↓<br>Face prediction</pre><p>One group might respond to edges, another shapes and so on and eventually to faces.</p><p><strong><em>Networks of neurons can build increasingly complex representations from simpler computations.</em></strong></p><p><strong>AI models are enormous mathematical systems whose parameters are learned from data. </strong>A neuron is one small mathematical building block. A neural network is many such computations connected together. A deep neural network contains many layers of these computations.</p><p>Modern LLMs use much more sophisticated architectures — especially <strong>Transformers</strong> — but underneath, they are still built from mathematical operations performed by neural networks.</p><h3>Bias</h3><p>Bias is a learned number that gives a neuron an additional adjustment to its result, independent of the current inputs.</p><p>Here is a simple example</p><pre>input = 0</pre><p>If the neuron only uses</p><pre>input × weight</pre><p>then</p><pre>0 × weight = 0</pre><p>No matter what the weight is. The neuron has no way to shift its result.</p><p>But if we add a bias:</p><pre>input × weight + bias</pre><p>and:</p><pre>input = 0<br>weight = 5<br>bias = 2</pre><p>then</p><pre>0 × 5 + 2<br>= 2</pre><p>The bias gives the neuron an additional value.</p><blockquote><strong>The inputs are: <em>“How much should I push?”</em></strong></blockquote><blockquote><strong>The weights determine: <em>“How important is each push?”</em></strong></blockquote><blockquote><strong>The bias says: <em>“Before considering those pushes, start from here.”</em></strong></blockquote><pre>Inputs<br>  ↓<br>Weights determine influence<br>  ↓<br>Combine everything<br>  ↓<br>Bias adjusts the result<br>  ↓<br>Neuron output</pre><h4>The basic neuron equation</h4><p>A neuron can calculate</p><pre>z = x₁w₁ + x₂w₂ + x₃w₃ + b</pre><p>Let’s translate every symbol:</p><pre>x₁ = input 1<br>x₂ = input 2<br>x₃ = input 3<br><br>w₁ = weight for input 1<br>w₂ = weight for input 2<br>w₃ = weight for input 3<br>b = bias</pre><p>So <strong><em>literally multiply each input by its weight, add them together, then add the bias.</em></strong></p><h4>weights vs bias</h4><p>Weights control how much the <strong>inputs</strong> influence the result. Bias gives the neuron an additional degree of freedom. We can&#39;t replace one with another.</p><p>During training, the model learns values for things such as</p><pre>Weight 1<br>Weight 2<br>Weight 3<br>Bias</pre><p>Training repeatedly adjusts these learned values so the network becomes better at its task. So</p><pre>Training<br>   ↓<br>Adjust weights<br>   ↓<br>Adjust biases<br>   ↓<br>Better predictions</pre><blockquote><strong>Weighted sum: </strong><em>The result of multiplying inputs by their weights and adding them together.</em></blockquote><h3>Output</h3><p>Suppose we want it to decide whether a student is likely to pass. We give it two pieces of information</p><pre>x₁ = hours studied<br>x₂ = attendance</pre><p>But the neuron doesn’t simply add hours studied and attendance. Instead, each input has a weight because perhaps studying is more important than attendance. Example</p><pre>x₁ = 4<br>x₂ = 3<br><br>weights:  w₁ = 2<br>          w₂ = 0.5<br><br>Bias: b = 1</pre><p>The neuron performs:</p><pre>(4 × 2) + (3 × 0.5) + 1<br>8 + 1.5 + 1<br>10.5</pre><p>This is called the neuron’s <strong>weighted sum plus bias</strong>. We can call this intermediate result z = 10.5. This is where something important happens. The neuron takes 10.5 and passes it through an<strong><em> Activation Function</em></strong></p><h4>Activation Function</h4><p>Think of the activation function as a <strong>little gate</strong>.</p><pre>Weighted result<br>      ↓<br>   [ GATE ]<br>      ↓<br>   output</pre><p>The gate decides how the neuron’s mathematical result should be transformed. For example, an activation function might transform 10.5 into something like 1 or 0.999… depending on which activation function we’re using.</p><h4>Gate</h4><p>Imagine we build a network without activation functions. We have</p><pre>Input<br> ↓<br>Neuron<br> ↓<br>Neuron<br> ↓<br>Neuron<br> ↓<br>Output</pre><p>Every neuron is basically performing mathematical operations like</p><pre>multiply<br>+<br>add</pre><p>If you stack enough purely linear operations together, the whole thing can still be represented as essentially <strong>one linear transformation</strong>. That means adding lots of layers wouldn’t give us the rich behavior we want.</p><p>The activation function introduces <strong>non-linearity</strong>.</p><h4>Non-linearity</h4><p><strong>Linear</strong>: <em>A relationship that behaves in a simple, proportional way.</em></p><p><strong>Non-linear</strong>: <em>The relationship can bend, change, and represent much more complicated patterns.</em></p><blockquote><strong><em>Activation functions allow neural networks to represent complicated relationships rather than behaving like one giant simple mathematical equation.</em></strong></blockquote><h4>activation function example</h4><h4>ReLU: <strong><em>Rectified Linear Unit</em></strong></h4><p>Its behavior is incredibly simple</p><pre>If input &lt; 0 → output 0<br>If input &gt; 0 → output input</pre><p>So</p><pre>input → output<br><br>-5 → 0<br>-2 → 0<br> 0 → 0<br> 2 → 2<br> 7 → 7</pre><pre>negative numbers       positive numbers<br>     ↓                       ↓<br>     0                    same number</pre><p>So if our neuron produced z = 10.5, ReLU gives 10.5. But if the neuron produced z = -4, ReLU gives 0</p><h4>The complete neuron</h4><pre>             INPUTS<br>          /          \<br>         ↓            ↓<br>        x₁            x₂<br>         │             │<br>         ↓             ↓<br>        ×w₁           ×w₂<br>          \           /<br>           \         /<br>            ↓       ↓<br>          ADD THEM<br>              +<br>            BIAS<br>              ↓<br>              z<br>              ↓<br>      ACTIVATION FUNCTION<br>              ↓<br>            OUTPUT<br><br>z = x₁w₁ + x₂w₂ + b<br>output = activation(z)</pre><h3>learning</h3><p><strong>These values are learned during training</strong>. Imagine the neuron makes a prediction</p><pre>Prediction = 0.3</pre><p>But the correct answer is:</p><pre>Actual = 1</pre><p>The prediction is wrong. The training process measures <strong>how wrong</strong> it is. <strong>That measurement is called Loss</strong></p><blockquote><strong><em>Loss is a number that tells the model how bad its prediction was.</em></strong></blockquote><p>Then the training process uses that information to adjust the model’s learned parameters. Conceptually</p><pre>Prediction<br>    ↓<br>How wrong?<br>    ↓<br>Loss<br>    ↓<br>Adjust parameters<br>    ↓<br>Try again<br>    ↓<br>Better prediction</pre><p>And those parameters include the weights and biases.</p><p>A neural network doesn’t learn because someone manually tells it. Instead, training repeatedly adjusts its parameters based on its errors. Eventually:</p><pre>Bad weights<br>     ↓<br>Bad prediction<br>     ↓<br>Measure error<br>     ↓<br>Adjust weights<br>     ↓<br>New prediction<br>     ↓<br>Measure error<br>     ↓<br>Adjust again<br>     ↓<br>...<br>     ↓<br>Better model</pre><blockquote>A neuron is essentially: <strong><em>Take inputs → give each input an importance → combine them → shift the result → transform the result → produce an output.</em></strong></blockquote><p>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c317e3dafa2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Artificial Intelligence]]></title>
            <link>https://medium.com/@shubham3480/artificial-intelligence-850310940904?source=rss-e0208b5e1604------2</link>
            <guid isPermaLink="false">https://medium.com/p/850310940904</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Shubham Gupta]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 03:23:32 GMT</pubDate>
            <atom:updated>2026-11-13T03:23:32.169Z</atom:updated>
            <content:encoded><![CDATA[<h4>(Part 1)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*uxZUfce4SToH63vJ" /></figure><h4>Artificial Intelligence</h4><p><strong>Artificial Intelligence (AI)</strong> means<strong><em> making computers or machines perform tasks that normally require some form of human intelligence.</em></strong></p><p>Examples:</p><ul><li>perception</li><li>reasoning</li><li>language understanding</li><li>planning</li><li>decision making</li><li>learning</li><li>generation</li></ul><p><strong><em>Machine Learning</em></strong>: In simple terms, it means teaching a computer to learn patterns from examples/data instead of manually writing every rule. <strong>Data</strong> simply means <strong><em>Information that a computer can use.</em></strong></p><p><strong>Training</strong> means <strong><em>the process of giving a machine learning system data and adjusting it so that it becomes better at a task.</em></strong></p><p>For example, we need to sort out emails manually we need to sort each one of them instead we train a model to do that work on the given data so it performs the sorting on its own in the future instead of doing it manually.</p><pre>100,000 labeled emails<br>          ↓<br>       training<br>          ↓<br>       ML model<br>          ↓<br>    new email<br>          ↓<br>    spam probability</pre><p>A <strong>model</strong> is <strong><em>a learned mathematical system that has captured patterns from training data and can use those patterns to make predictions or generate outputs.</em></strong></p><h4>Deep Learning</h4><p>Deep learning is machine learning based primarily on <strong>multi-layer neural networks</strong>.</p><p>A neural network is basically a <strong><em>mathematical system made of many connected units that learns patterns by adjusting numbers inside itself.</em></strong></p><pre>Machine Learning<br>       │<br>       ▼<br>Neural Networks<br>       │<br>       ▼<br>Deep Neural Networks<br>       │<br>       ▼<br>Deep Learning</pre><p>Modern LLMs are built using deep learning.</p><h4>Generative AI</h4><p>Traditional machine-learning systems often answer <em>Which category does this belong to? </em>Generative systems can answer <em>What should I generate? </em>AI systems that can generate new content based on what they have learned.</p><p>Examples</p><pre>Text       → text<br>Text       → image<br>Text       → audio<br>Text       → code<br>Image      → text<br>Document   → summary</pre><p>Large language models are a form of generative AI focused primarily on language.</p><h4>Large Language Model</h4><p>An LLM is a neural-network model trained on enormous amounts of text/data to learn statistical patterns in language and generate or transform text. LLM is <strong>not a database</strong></p><h4>Traditional AI vs Generative AI</h4><p>Imagine two systems. You give one system a photo. It says DOG. That’s primarily a prediction/classification task. That&#39;s traditional AI</p><p>To another system, you give it create a picture of a dog astronaut. It creates an image. That’s generative AI.</p><h3>Training vs Inference</h3><p>Training is the process of teaching a model using data so that it learns useful patterns.</p><pre>DATA<br> ↓<br>TRAINING<br> ↓<br>LEARNED MODEL</pre><p>Imagine we start with a model that knows absolutely nothing useful about recognizing dogs. We show it images of dogs. The model makes a prediction:</p><pre>CAT: 70%<br>DOG: 20%<br>HORSE: 10%</pre><p>So we tell the training system <em>No. This was a dog. </em>We show it another example. We repeat the process Millions or billions of times until it produces results like</p><pre>DOG: 98%<br>CAT: 1%<br>HORSE: 1%</pre><p>Now the model has become much better. This is called Training.</p><pre>              ┌──────────────┐<br>              │ TRAINING DATA│<br>              └──────┬───────┘<br>                     ↓<br>              ┌──────────────┐<br>              │    MODEL     │<br>              └──────┬───────┘<br>                     ↓<br>                 PREDICTION<br>                     ↓<br>                 &quot;WRONG?&quot;<br>                     ↓<br>             Adjust internal<br>                numbers<br>                     ↓<br>                 Try again</pre><h4>Inference</h4><p>Now I give the model a <strong>new image</strong> it has never seen before. The model processes the input and gives me DOG: 99%. Now we are not training it, instead using it.</p><p><strong><em>Inference is using a trained model to produce an output for new input.</em></strong></p><pre>TRAINING = teaching the model<br><br>INFERENCE = using the model</pre><blockquote><strong>When you use an LLM API, you’re normally doing Inference with your prompt. The provider’s infrastructure runs the trained model. You’re asking the already-trained model to perform inference.</strong></blockquote><h4>Training</h4><p>Imagine training data contains the capital of France is Paris. The model doesn’t necessarily store the sentence like this.</p><pre>KEY:<br>capital of France<br><br>VALUE:<br>Paris</pre><p>Instead, training changes the model’s internal parameters so that it learns statistical patterns and relationships.</p><h4>error</h4><p>Suppose the correct answer to your question is dog, but you get cat. The training system needs some way to measure how wrong the model was. That measurement is called <strong>loss</strong>.</p><p><strong><em>Loss is a numerical measurement of how wrong a model’s prediction is during training.</em></strong></p><p>A lower loss generally means the model is performing better on the training objective.</p><h4>optimization</h4><p>Optimization is the process of adjusting a model’s parameters to improve its performance according to a chosen objective.</p><pre>                  TRAINING<br>                     │<br>                     ▼<br>              Training Data<br>                     │<br>                     ▼<br>                  Model<br>                     │<br>                     ▼<br>                Prediction<br>                     │<br>                     ▼<br>                   Loss<br>                     │<br>                     ▼<br>               Optimization<br>                     │<br>                     ▼<br>          Adjust Parameters<br>                     │<br>                     └───────────┐<br>                                 │<br>                                 ▼<br>                            Repeat many<br>                              times<br>                                 │<br>                                 ▼<br>                         TRAINED MODEL<br>                                 │<br>                                 │<br>                         ────────┼────────<br>                                 │<br>                                 ▼<br>                             INFERENCE<br>                                 │<br>                                 ▼<br>                              New Input<br>                                 │<br>                                 ▼<br>                               Output</pre><h3>Models, Parameters &amp; Weights</h3><p>Imagine a little brain made of knobs. Imagine a machine with millions of tiny knobs. Each knob can have a different number</p><pre>Knob 1 → 0.23<br>Knob 2 → -1.72<br>Knob 3 → 0.004<br>Knob 4 → 2.91<br>...</pre><p>During training, the machine keeps adjusting these numbers. At first BAD SETTINGS. After lots and lots of learning, BETTER SETTINGS. We call those learned numbers <strong>parameters</strong>.</p><p><strong><em>A parameter is a learned number inside a model that helps determine what the model does.</em></strong></p><p>A <strong>model</strong> is the complete mathematical system that takes input and produces an output.</p><pre>             MODEL<br>        ┌───────────────┐<br>        │               │<br>Input → │  Parameters   │ → Output<br>        │               │<br>        └───────────────┘</pre><p>The parameters are part of what makes the model behave the way it does.</p><h4>Parameters</h4><p>A parameter is simply a value that influences the behavior of a mathematical system. Imagine this tiny equation</p><pre>y = 2x</pre><p>The 2 determines how strongly x affects y. If we change it:</p><pre>y = 10x</pre><p>the behavior changes dramatically. That 2 or 10 is functioning like a parameter.</p><p>Real neural networks have <strong>huge numbers of parameters</strong>, and they interact with each other.</p><h4>Weights</h4><p>A <strong>weight</strong> is a learned numerical value that controls how strongly one piece of information influences another inside a neural network.</p><p><em>The model has 7 billion parameters. </em>Those parameters are largely represented by learned <strong>weights</strong> (and, depending on the architecture, other learned values such as biases). In simple terms</p><pre>parameters ≈ learned numbers<br>weights ≈ important learned numbers controlling connections</pre><p>Imagine</p><pre>Input<br>  │<br>  ▼<br>  ○──────○<br>   \    /<br>    \  /<br>     ○<br>     │<br>     ▼<br>   Output</pre><p>The connections between the units have numbers associated with them. For example</p><pre>Input ──(0.7)──&gt; Neuron<br>Input ──(-0.2)─&gt; Neuron</pre><p>Those numbers influence what happens. If training discovers that one connection should matter more, its learned value can change.</p><p>Maybe 0.7 → 1.4 Or -0.2 → -0.8 The model’s behavior changes.</p><p><strong><em>During training, the learning algorithm repeatedly adjusts the model’s parameters so that the model becomes better at its training objective.</em></strong></p><pre>Parameters<br> ├── Weights<br> └── Other learned parameters</pre><p>So <strong>all weights are parameters, but not every parameter is necessarily a weight.</strong></p><pre>DATA<br> ↓<br>Model makes prediction<br> ↓<br>Measure error<br> ↓<br>Adjust parameters<br> ↓<br>Try again<br> ↓<br>Adjust parameters<br> ↓<br>Try again<br> ↓<br>...</pre><p>Suppose we train a model on millions of examples of English. At the beginning, its parameters are not useful enough. After training, the parameters have been adjusted so the model has learned many patterns.</p><p>For example, it can learn relationships involving:</p><pre>words<br>grammar<br>syntax<br>meaning<br>code<br>facts<br>patterns<br>relationships</pre><p>Not because someone manually entered</p><pre>&quot;cat&quot; → &quot;animal&quot;<br>&quot;Paris&quot; → &quot;France&quot;</pre><p>into a traditional database. Rather, training modifies the model’s parameters.</p><p>Again, neural networks are <strong>not brains</strong>, but this analogy gives us an intuition:</p><pre>Training<br>   ↓<br>Parameter changes<br>   ↓<br>Future predictions change</pre><h4>Training</h4><p>Suppose our model sees</p><pre>&quot;The cat sat on the ___&quot;</pre><p>The correct next word might be mat. The model produces probabilities. For example</p><pre>mat      10%<br>floor     5%<br>chair     3%<br>dog       1%<br>...</pre><p>That output is not right, so the training process calculates how wrong the prediction was. Then it adjusts parameters. Later</p><pre>mat      65%<br>floor     8%<br>chair     4%<br>...</pre><p>It keeps doing this across enormous amounts of training data.</p><h4>The parameters are not the training data</h4><p>Let’s say we have some data</p><pre>TRAINING DATA<br><br>&quot;The cat sat on the mat.&quot;<br><br>&quot;The dog ran across the street.&quot;<br><br>...</pre><p>After training</p><pre>MODEL<br> ├── Parameters<br> ├── Architecture<br> └── Other model configuration</pre><p>The model isn’t simply A giant text file containing everything it read.</p><p>The training process has transformed information through optimization into learned numerical parameters.</p><h4>Parameters quantity</h4><p>No, parameter quantity does not make a model better, model quality depends on many things</p><pre>Architecture<br>+<br>Training data<br>+<br>Data quality<br>+<br>Training method<br>+<br>Parameter count<br>+<br>Post-training<br>+<br>Inference method<br>+<br>Context handling<br>...</pre><p>A smaller model can sometimes be better for a particular task. And smaller models can have major advantages</p><pre>Lower cost<br>Lower latency<br>Less memory<br>Easier deployment</pre><h3>Parameters vs hyperparameters</h3><h4>Hyperparameter</h4><p>A <strong>hyperparameter</strong> is a setting chosen by the people designing/training the model rather than something the model learns directly from training.</p><p>For example:</p><pre>Learning rate<br>Batch size<br>Number of layers<br>Training settings</pre><pre>Parameter<br>MODEL LEARNS IT<br><br>Hyperparameter<br>HUMAN/ENGINEER CHOOSES IT</pre><p>Suppose we’re training a neural network. We choose</p><pre>Learning rate = 0.001</pre><p>The model doesn’t normally discover that number as part of its learned parameters. We choose it as a training configuration.</p><p><strong>Learning rate: <em>A setting that controls how big a change the training process makes to the model&#39;s learned numbers at each update.</em></strong></p><p>Meanwhile,</p><pre>Weight #1 = 0.238<br>Weight #2 = -0.918<br>Weight #3 = 1.284</pre><p>are learned during training.</p><h4>Model checkpoint</h4><p>It generally means obtaining the learned numerical values produced by training.</p><p>A <strong>checkpoint</strong> is a saved state of a model, including its learned parameters, so the model can later be restored or used.</p><h4>Model size</h4><p>A rough way of describing how many learned parameters a model contains.</p><h3>Foundation Model</h3><p>In the past, there could be multiple systems that are designed specifically for certain tasks.</p><p>However, it was found that rather than building an independent model for each task, we could train a single, very large model on a huge volume of diverse data, and it would pick up generic features and then adapt to specific tasks.</p><p>This is the basic idea behind a Foundation Model</p><blockquote><strong><em>A foundation model is a large model trained on broad amounts of data that can serve as a starting point for many different AI applications and tasks.</em></strong></blockquote><p>Imagine we have a model that has been exposed during training to</p><pre>Books<br>Articles<br>Code<br>Web pages<br>Conversations<br>Documentation<br>Mathematical text</pre><p>It has learned many patterns from this broad data. We can then use it for</p><pre>Question answering<br>Summarization<br>Translation<br>Writing<br>Coding<br>Classification<br>Information extraction</pre><p>We don’t necessarily need to build a completely separate model from scratch for each one. That’s the power of the foundation-model approach.</p><h4>Foundation models aren’t only language models</h4><p>A foundation model can be designed around different kinds of data, and there can be models that work with multiple modalities.</p><pre>Foundation Models<br>       │<br> ┌─────┼────────┐<br> ↓     ↓        ↓<br>Text  Image    Audio</pre><h4>Modality</h4><p>A type or form of information that an AI system can process. <strong>Multimodal</strong> means <strong><em>the model can work with more than one type of information, such as text and images.</em></strong></p><h4>LLM</h4><p>A language-focused foundation model can learn from enormous amounts of text/code and then become useful for many language-related tasks.</p><pre>Foundation Model<br>       │<br>       ├── Language-focused<br>       │       ↓<br>       │      LLM<br>       │<br>       ├── Vision-focused<br>       │       ↓<br>       │   Vision model<br>       │<br>       └── Multimodal<br>               ↓<br>        Text + Image + ...</pre><h4>Pretraining</h4><p>The large initial training stage where a model learns general patterns from a huge and broad dataset before being adapted for particular uses.</p><pre>Huge diverse data<br>       ↓<br>   PRETRAINING<br>       ↓<br>General-purpose model<br>       ↓<br>Adaptation<br>       ↓<br>Specific applications</pre><p>Pretraining exposes the model to much broader information.</p><pre>SPECIALIZED TRAINING<br><br>100% focused on ONE job<br><br>PRETRAINING<br>Broad exposure to MANY patterns</pre><p>So it is better not to train the model for one task.</p><h4>Adaptation</h4><p>Once we have a foundation model, we can adapt it for particular uses.</p><p>Changing or guiding a general-purpose model so it becomes more useful for a particular task, behavior, or application.</p><p>There are multiple ways to do this. For example</p><pre>Foundation Model<br>      │<br>      ├── Prompting<br>      │<br>      ├── Fine-tuning<br>      │<br>      ├── RAG<br>      │<br>      └── Tool use</pre><h4>Foundation model vs Traditional ML model</h4><h4>Traditional specialized model</h4><p>You might build:</p><pre>Training data:<br>customer transactions</pre><pre>Goal:<br>fraud detection<br>Output:<br>fraud / not fraud</pre><h4>Foundation model</h4><p>Training data is much broader:</p><pre>Text<br>Code<br>Documents<br>Books<br>Other data</pre><p>The resulting model can support many applications.</p><pre>FOUNDATION MODEL<br>                  /      |       \<br>                 /       |        \<br>              Chat     Coding    Search<br>                |         |         |<br>             Summary   Analysis  Extraction</pre><p>A badly trained giant model can perform worse than a smaller, better-designed model for a specific task.</p><pre>DATA<br>                     ↓<br>                PRETRAINING<br>                     ↓<br>              FOUNDATION MODEL<br>                     ↓<br>        ┌─────────────┬─────────────┐<br>        ↓             ↓             ↓<br>    Prompting      Fine-tuning      RAG<br>        ↓             ↓             ↓<br>        └─────────────┼─────────────┘<br>                      ↓<br>               AI APPLICATION<br>                      ↓<br>                   USER</pre><h4>LLMs Vs G<strong>enerative AI</strong></h4><pre>AI<br>│<br>└── Machine Learning<br>      │<br>      └── Deep Learning<br>            │<br>            └── Neural Networks<br>                  │<br>                  └── Transformers<br>                        │<br>                        └── Large Language Models<br>                              │<br>                              └── Generative AI apps</pre><p>LLMs are <strong>one important type of generative AI system</strong>. Generative AI can generate</p><pre>Text<br>Images<br>Audio<br>Video<br>Code</pre><p>An LLM is primarily focused on language-related data.</p><pre>Generative AI<br>│<br>├── Text generation<br>│      └── LLMs<br>│<br>├── Image generation<br>│<br>├── Audio generation<br>│<br>├── Video generation<br>│<br>└── Other generative systems</pre><h4>If you’d like to be in the know, subscribe, clap, like, and share. Cheers!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=850310940904" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>