<?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 Shreyarjoshi on Medium]]></title>
        <description><![CDATA[Stories by Shreyarjoshi on Medium]]></description>
        <link>https://medium.com/@shreyarjoshi1995?source=rss-7eb9dbb0199d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VBTAAwzn-q0mdRJj</url>
            <title>Stories by Shreyarjoshi on Medium</title>
            <link>https://medium.com/@shreyarjoshi1995?source=rss-7eb9dbb0199d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:29:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shreyarjoshi1995/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[The Machine Learning Pipeline]]></title>
            <link>https://medium.com/@shreyarjoshi1995/the-machine-learning-pipeline-939453b5bd32?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/939453b5bd32</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 04:57:55 GMT</pubDate>
            <atom:updated>2026-08-04T04:57:55.930Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Complete Guide from Raw Data to Production</h3><p>Every successful ML model is the result of a well-structured pipeline. Here’s what that journey actually looks like — and how to navigate each step.</p><p>Published: April 14, 2026 · 12 min read<br>Tags: Machine Learning, Data Science, Engineering</p><p>— -</p><p>“In practice, 80% of a data scientist’s time is spent on data preparation. The pipeline is the product.”</p><p>— -</p><p>What Is an ML Pipeline?</p><p>A machine learning pipeline is a structured, sequential workflow that transforms raw, unprocessed data into a trained, evaluated, and deployed model. Each stage feeds into the next, and — critically — the pipeline is designed to be automated, repeatable, and monitorable.</p><p>Think of it like an assembly line in manufacturing. Each station has a defined job. Nothing moves to the next stage until the current one meets quality standards. And when something breaks, you know exactly which station to inspect.</p><p>The 7 Stages:<br><strong>Data Collection → EDA &amp; Analysis → Preprocessing → Feature Engineering → Model Training → Evaluation → Deployment &amp; Monitoring</strong></p><p><strong>— -</strong></p><h4>Stage 1 — Data Collection</h4><p>Every pipeline begins with data. The quality and quantity of your data will ultimately determine the ceiling of your model’s performance — no algorithm can compensate for poor data.</p><p>Data can come from internal databases, public datasets, web scraping, APIs, sensors, user logs, or third-party providers. The key questions at this stage are: Is the data representative? Is it sufficient in volume? Is it legally permissible to use?</p><p>Tools: SQL / NoSQL, REST APIs, Scrapy, Kaggle Datasets, AWS S3, Apache Kafka</p><p><em>Pro tip: Always document where your data came from, when it was collected, and any known biases. This becomes invaluable during debugging and auditing.</em></p><p>— -</p><h4>Stage 2 — Exploratory Data Analysis (EDA)</h4><p>Before writing a single line of modeling code, you must understand your data deeply. EDA involves computing summary statistics, visualizing distributions, identifying outliers, checking for class imbalances, and uncovering correlations between variables.</p><p>This stage is largely exploratory — you are asking questions, not yet answering them. What does the target variable look like? Are there missing values? Do any features have near-zero variance? Are numeric features normally distributed or heavily skewed?</p><p><em>Tools: Pandas, Matplotlib, Seaborn, Plotly, Sweetviz, ydata-profiling</em></p><p>— -</p><h4>Stage 3 — Data Preprocessing</h4><p>Raw data is almost never ready for a model. Preprocessing transforms messy, inconsistent input into a clean, structured dataset your algorithms can actually learn from. This includes:</p><p>Handling missing values — imputation with mean/median/mode, forward fill for time-series, or model-based imputation. Sometimes dropping rows or columns is the right call.</p><p>Encoding categorical variables — label encoding, one-hot encoding, or target encoding depending on cardinality and model type.</p><p>Scaling and normalization — standardization (zero mean, unit variance) or min-max scaling for algorithms sensitive to feature magnitudes like SVMs and neural networks.</p><p>Dealing with outliers — capping (Winsorization), log transformation, or removal based on domain knowledge.</p><p><em>Tools: Scikit-learn Pipelines, NumPy, Pandas, Great Expectations</em></p><p><em>“Data preprocessing is not a chore — it is where your domain expertise and engineering rigor meet. Getting this right is what separates decent models from great ones.”</em></p><p>— -</p><h4>Stage 4 — Feature Engineering</h4><p>Feature engineering is the art of transforming raw variables into inputs that help models learn better. It is perhaps the most creative — and high-impact — part of the pipeline.</p><p>This includes creating interaction features (multiplying two variables), polynomial features, date-time decomposition (extracting hour, day of week, month), text vectorization (TF-IDF, embeddings), and domain-specific aggregations (rolling averages, lag features for time series).</p><p>Feature selection then trims the set — removing redundant or low-signal features using correlation analysis, mutual information, or model-based importance scores. Fewer, better features usually beat more, noisier ones.</p><p><em>Tools: Featuretools, Scikit-learn, tsfresh, SHAP, SelectKBest</em></p><p>— -</p><h4>Stage 5 — Model Training</h4><p>With clean, engineered features in hand, you now select and train your model. The choice of algorithm depends on problem type (classification, regression, clustering, ranking), interpretability requirements, dataset size, and latency constraints.</p><p>Start simple — logistic regression, decision trees, or gradient boosting before jumping to neural networks. Always split your data into training, validation, and test sets before any modeling to prevent data leakage. Use cross-validation to get robust performance estimates.</p><p>Hyperparameter tuning — via grid search, random search, or Bayesian optimization — squeezes out additional performance after you have a working baseline.</p><p><em>Tools: Scikit-learn, XGBoost, LightGBM, PyTorch, TensorFlow, Optuna, MLflow</em></p><p><em>Key principle: Track every experiment. Log your hyperparameters, metrics, and dataset versions. You will thank yourself when you need to reproduce a result three weeks later.</em></p><p>— -</p><h4>Stage 6 — Model Evaluation</h4><p>Accuracy alone is almost never the right metric. Evaluation must be tied to business objectives. For classification: precision, recall, F1-score, AUC-ROC. For regression: MAE, RMSE, MAPE. For ranking: NDCG, MAP.</p><p>Beyond aggregate metrics, examine your model’s behavior on subgroups — fairness analysis. Check calibration: does a model that says “70% probability” actually be right 70% of the time? Visualize the confusion matrix, residuals, and learning curves to diagnose overfitting or underfitting.</p><p>Only use your test set once. Evaluating on the test set repeatedly is a form of data leakage that inflates your confidence in generalization.</p><p><em>Tools: Scikit-learn metrics, SHAP, LIME, Evidently AI, Fairlearn</em></p><p>— -</p><h4>Stage 7 — Deployment &amp; Monitoring</h4><p>A model that only lives in a notebook delivers zero value. Deployment packages your trained model behind a real-time REST API or embeds it in a batch processing pipeline, making predictions accessible to applications and users.</p><p>Modern deployment uses containerization (Docker) and orchestration (Kubernetes) for scalability. CI/CD pipelines automate retraining and redeployment when performance degrades. Shadow deployment and A/B testing allow safe rollouts.</p><p>Monitoring is not optional — it is the difference between a one-time project and a reliable product. Track prediction distributions, latency, error rates, and business KPIs. Implement drift detection to catch when incoming data no longer resembles training data.</p><p><em>Tools: FastAPI, Docker, Kubernetes, BentoML, Seldon Core, Prometheus, Grafana, Vertex AI</em></p><p><em>— -</em></p><p>Wrapping Up</p><p>The machine learning pipeline is the backbone of every successful AI system. Master it, and you move from writing ad-hoc scripts to engineering reliable, production-grade systems that create real value.</p><p>The seven stages — data collection, EDA, preprocessing, feature engineering, model training, evaluation, and deployment — each require care, tooling, and domain judgment. None can be skipped.</p><p>Start with a simple, end-to-end pipeline on your next project. Then optimize. The discipline of running a full pipeline — even a rough one — will teach you more than any isolated technique ever will.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=939453b5bd32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Generative AI & Prompt Engineering]]></title>
            <link>https://medium.com/@shreyarjoshi1995/introduction-to-generative-ai-prompt-engineering-29ebe08129ce?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/29ebe08129ce</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 17:15:48 GMT</pubDate>
            <atom:updated>2026-08-03T17:15:48.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_w-WHHypxr1JaCVJGlKXQ.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>A few weeks ago, &quot;Generative AI&quot; was just a buzzword I heard in tech news. Today, I can confidently say it has changed the way I think about building software, writing content, and even solving everyday problems. This article is my attempt to consolidate everything I learned — from the fundamentals of Generative AI to the nuances of prompt engineering — in one place, for my own reference and for anyone starting this journey.</p><p>---</p><h3>1.<strong> Introduction to Generative AI</strong></h3><h4>What is Generative AI?</h4><ul><li>Generative AI (GenAI) refers to a class of artificial intelligence systems that can <strong>create new content </strong>— text, images, audio, video, or code — rather than simply analyzing or classifying existing data.</li><li>Unlike traditional software that follows fixed rules, generative models learn patterns from massive datasets and use that knowledge to produce original, human-like outputs.</li></ul><p><strong>Think of it this way:</strong></p><ul><li>if traditional AI is like a very good librarian who can find and organize existing books,</li><li>Generative AI is like an author who has read millions of books and can now write a brand-new one in a similar style.</li></ul><p>Popular examples include:<br>- Text generation: ChatGPT, Claude, Gemini<br>- Image generation: Midjourney, DALL·E, Stable Diffusion<br>- Code generation: GitHub Copilot, Claude Code<br>- Audio/Music generation: Suno, ElevenLabs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rbw-Yy2XtNGeVJr4UFXlRg.png" /></figure><h3><strong>Applications of Generative AI</strong></h3><p>Generative AI is no longer confined to research labs — it&#39;s actively reshaping industries:</p><ol><li><strong>Content Creation</strong>- Blog posts, marketing copy, social media captions</li><li><strong>Software Development</strong> - Code completion, bug fixing, documentation generation</li><li><strong>Design</strong> — Logo generation, UI mockups, product images</li><li><strong>Customer Support</strong> - AI chatbots, automated ticket resolution</li><li><strong>Education</strong> — Personalized tutoring, summarizing textbooks</li><li><strong>Healthcare</strong> — Drug discovery, medical report summarization</li><li><strong>Entertainment</strong> — Game asset generation, scriptwriting, music composition</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZ9FNVZ4nOjaol0vYe4D0A.webp" /></figure><p>---</p><h3><strong>2. Large Language Models (LLMs)</strong></h3><h4>What are LLMs?</h4><ol><li>Large Language Models are a type of generative AI trained specifically on massive amounts of text data.</li><li>They learn the statistical relationships between words, phrases, and concepts, enabling them to generate coherent, contextually relevant text.</li><li>Examples include GPT-4, Claude, Gemini, and LLaMA.</li></ol><p><strong>How do LLMs work</strong></p><p>At a high level, LLMs are built on a neural network architecture called the <strong>Transformer</strong>, introduced in the 2017 paper &quot;Attention Is All You Need.&quot;</p><p>Here’s a simplified breakdown:</p><p>1. <strong>Tokenization</strong>: Input text is broken into smaller units called tokens (words or sub-words).<br>2. <strong>Embedding</strong>: Each token is converted into a numerical vector that captures its meaning.<br>3. <strong>Attention Mechanism</strong>: The model learns which tokens in the input are most relevant to each other, allowing it to understand context (this is the &quot;self-attention&quot; that makes Transformers so powerful).<br>4. <strong>Prediction</strong>: The model predicts the most likely next token, one at a time, based on everything it has seen so far.<br>5. <strong>Training at Scale</strong>: This process is repeated across billions of parameters and trillions of words, allowing the model to develop a broad understanding of language, facts, and reasoning patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLXPpkBevzHMmgvfL5w3Eg.jpeg" /></figure><p><strong>Capabilities of LLMs</strong></p><p>- Natural language understanding and generation<br>- Summarization and translation<br>- Question answering<br>- Code generation and debugging<br>- Reasoning and problem-solving (with proper prompting)<br>- Content creation (essays, emails, stories, poems)<br>- Data extraction and structuring</p><p><strong>Real-world use cases</strong></p><p>- <strong>Customer support chatbots</strong> that resolve queries without human agents<br>- <strong>Coding assistants</strong> like GitHub Copilot and Claude Code that speed up development<br>- <strong>Content marketing tools</strong> that draft blogs, ads, and social posts<br>- <strong>Legal and medical document</strong> summarization<br>- <strong>Personal productivity assistants</strong> for scheduling, email drafting, and research</p><p>---</p><h3><strong>3. LLM APIs</strong></h3><p>Most LLMs are accessed programmatically through APIs, which allow developers to integrate AI capabilities into their own applications.</p><p><strong>OpenAI API</strong></p><ul><li>OpenAI provides access to models like GPT-4 and GPT-4o through a simple REST API.</li><li>Developers send a prompt and receive a generated response, with control over parameters like temperature and max tokens.</li></ul><p><strong>Gemini API</strong></p><ul><li>Google&#39;s Gemini API provides access to its Gemini family of models, with strong multimodal capabilities (text, image, and video understanding) and tight integration with Google Cloud services.</li></ul><p><strong>Groq<em> </em>API</strong></p><ul><li>Groq is known for its extremely fast inference speeds, powered by custom hardware called <em>LPUs (Language Processing Units).</em></li><li>It hosts open-source models like LLaMA and Mistral, making it a popular choice for latency-sensitive applications.</li></ul><h3><strong>API Authentication (API Keys and Best Practices)</strong></h3><p>To use any of these APIs, you need an <strong>API key</strong> — a unique identifier that authenticates your requests. <strong>Best practices include:</strong></p><p>- <strong>Never hard-code API keys</strong> in your source code or commit them to GitHub.<br>- Store keys in <strong>environment variables </strong>(e.g., `.env` files) and add `.env` to `.gitignore`.<br>- Use <strong>key rotation</strong> — regularly regenerate keys, especially if exposed.<br>- Apply <strong>rate limiting and usage monitoring </strong>to detect unusual activity.<br>- Use <strong>separate keys</strong> for development and production environments.<br>- Restrict key permissions/scopes wherever the provider allows it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*u37OjzpjChZoEC-7mFhOvA.jpeg" /></figure><p>---</p><h3><strong>4. Prompt Engineering</strong></h3><p><strong>What is Prompt Engineering?</strong></p><ul><li>Prompt Engineering is the practice of designing and refining the input (prompt) given to an LLM to get the most accurate, relevant, and useful output.</li><li>It&#39;s less about &quot;coding&quot; and more about clear, structured communication with the model.</li></ul><p><strong>Importance of Prompt Engineering</strong></p><p>Since LLMs generate responses based on the input they receive, the quality of the prompt directly impacts the quality of the output. A vague prompt like <strong>&quot;write about dogs&quot;</strong> produces generic results, while a well-structured prompt produces precise, usable content.</p><p><strong>Good prompt engineering</strong>:</p><p>- Reduces back-and-forth iterations<br>- Improves factual accuracy and relevance<br>- Helps control tone, format, and length<br>- Unlocks advanced reasoning capabilities of the model</p><p><strong>Components of a Good Prompt</strong></p><p>1. <strong>Context</strong> – Background information the model needs<br>2. <strong>Instruction</strong> – The specific task you want performed<br>3. <strong>Input Data</strong>– The content the model should act on (if any)<br>4. <strong>Output Format</strong> – How you want the response structured (bullet points, table, JSON, etc.)<br>5. <strong>Constraints/Tone</strong> – Word limits, style, audience, or persona</p><p><strong>Example</strong>:<br>&quot;You are a career coach [context]. Write a 100-word LinkedIn post [instruction + format] encouraging final-year students to learn Generative AI [input], in an motivational and friendly tone [tone].&quot;</p><h3><strong>User Prompt vs System Prompt</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rC0On1ouzUy4tK14GVpUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*-NhyL8Qexqez0IXNo4tUSQ.png" /></figure><p>---</p><h3><strong>5. Prompting Techniques</strong></h3><h3><strong>Zero-shot Prompting</strong></h3><p>Asking the model to perform a task with no examples given, relying purely on its pre-trained knowledge.</p><p><strong>Prompt</strong>:<br>&quot;Classify the sentiment of this review as Positive, Negative, or Neutral: &#39;The product arrived late but works perfectly.’&quot;</p><p><strong>Output</strong>:</p><p>Neutral (mixed sentiment — negative delivery experience, positive product performance)</p><h3><strong>One-shot Prompting</strong></h3><p>Providing exactly one example to guide the model&#39;s response format or style.</p><p><strong>Prompt</strong>:<br>&quot;Translate the following English sentence to French.<br>Example: &#39;Good morning&#39; → &#39;Bonjour&#39;<br>Now translate: &#39;Thank you very much’&quot;</p><p><strong>Output</strong>:<br>Merci beaucoup</p><h3><strong>Few-shot Prompting</strong></h3><p>Providing multiple examples to help the model recognize a pattern before performing the actual task.</p><p><strong>Prompt</strong>:<br>&quot;Convert these to formal tone:<br>1. &#39;Hey, can u send the file?&#39; → &#39;Could you please send the file?&#39;<br>2. &#39;Yo, meeting’s at 5&#39; → &#39;The meeting is scheduled for 5 PM.&#39;<br>3. &#39;Thx for the update&#39; → ?&quot;</p><p><strong>Output</strong>:<br> &quot;Thank you for the update.&quot;</p><h3><strong>Chain of Thought (CoT)</strong></h3><p>Encouraging the model to reason step-by-step before arriving at a final answer — particularly useful for math, logic, and multi-step problems.</p><p><strong>Prompt</strong>:<br> &quot;A store had 120 apples. It sold 45 in the morning and 30 in the afternoon. It then received a new delivery of 60 apples. How many apples does the store have now? Think step by step.&quot;</p><p><strong>Output</strong>:<br>Step 1: Start with 120 apples.<br>Step 2: Subtract morning sales: 120 − 45 = 75.</p><p>Step 3: Subtract afternoon sales: 75 − 30 = 45.<br>Step 4: Add new delivery: 45 + 60 = 105.<br> <strong>Final Answer</strong>: 105 apples</p><h3><strong>Tree of Thoughts (ToT)</strong></h3><p>An advanced technique where the model explores <strong>multiple reasoning paths </strong>in parallel (like branches of a tree), evaluates them, and chooses the best path — useful for complex planning or creative problems.</p><p><strong>Prompt</strong>:<br> &quot;You need to plan a 3-day trip to a new city with a limited budget. Generate three different possible itineraries (budget-focused, experience-focused, balanced), evaluate the pros and cons of each, and recommend the best one.&quot;</p><p><strong>Output</strong>:<br><strong>Option A (Budget-focused):</strong> Hostel stays, public transport, free attractions — Pros: cheapest; Cons: less comfort.<br><strong>Option B (Experience-focused):</strong> Boutique hotel, guided tours, fine dining — Pros: memorable; Cons: expensive.<br><strong>Option C (Balanced):</strong> Mid-range hotel, mix of free and paid attractions — Pros: good value; Cons: moderate planning effort.<br><strong>Recommendation</strong>: Option C offers the best trade-off between cost and experience for a first-time visitor.</p><p>---</p><h3><strong>6. LLM Parameters</strong></h3><p>When calling an LLM API, you can fine-tune how the model generates text using a few key paameters.</p><p><strong>Temperature</strong></p><ul><li>Controls the <strong>randomness/creativity</strong> of the output. Ranges typically range from 0 to 1 (sometimes up to 2).</li><li><strong>Low temperature (0–0.3):</strong> Deterministic, focused, repetitive-safe outputs. Good for factual tasks.</li><li><strong>High temperature (0.7–1.0+):</strong> Creative, diverse, sometimes unpredictable outputs. Good for brainstorming or storytelling.</li></ul><p><strong>Top-p (Nucleus Sampling)</strong></p><ul><li>Instead of considering all possible next words, top-p selects from the smallest set of words whose cumulative probability adds up to <strong>p.</strong></li><li>Example 0.9 means it considers only the most likely words that together make up 90% of the probability mass.</li><li><strong>Low top-p (e.g., 0.5):</strong> Narrower, safer word choices.</li><li><strong>High top-p (e.g., 0.95):</strong> Wider variety, more creative outputs.</li></ul><p><strong>Top-k Sampling</strong></p><ul><li>Limits the model’s choice to the top k most probable next words, regardless of their combined probability.</li><li><strong>Low top-k (e.g., 10):</strong> Restricts to very likely words — more predictable.</li><li><strong>High top-k (e.g., 100):</strong> Allows more variety in word choice.</li></ul><p><strong>Comparison of Temperature vs Top-p vs Top-k</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKd8QzUJrdpkFFLEEKgnSQ.png" /></figure><h3><strong>When to Use Different Parameter Settings</strong></h3><ul><li>Factual Q&amp;A, code generation - Low temperature (0.1–0.3), low top-p.</li><li>Creative writing, brainstorming — High temperature (0.7–1.0), high top-p.</li><li>Chatbots (balanced conversation) — Moderate temperature (0.5–0.7).</li><li>Summarization - Low-to-moderate temperature (0.2–0.5)</li></ul><p>---</p><h3><strong>7. Hands-on Examples</strong></h3><p>Below are five prompts demonstrating different prompting techniques, along with the outputs I received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wospwnBK8GI3KbDdh0fijA.png" /></figure><p><strong>Example 1 — Zero-shot Prompting</strong><br> <strong><em>Prompt</em></strong>: &quot;Summarize the following paragraph in one sentence: [paragraph about climate change].&quot;</p><p><strong><em>Output</em></strong>: A single, concise sentence capturing the core idea of the paragraph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*CqQw6GYVnIvOkWsSypr-oQ.webp" /></figure><p><strong>Example 2 — One-shot Prompting</strong><br><strong><em>Prompt</em></strong>: &quot;Write a product tagline. Example: &#39;Nike — Just Do It.&#39; Now write one for a fitness app called &#39;FitTrack’.&quot;<br>Output: &quot;FitTrack — Every Step Counts.&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fJr7MV4FkaMAkyxcMn2avA.webp" /></figure><p><strong>Example 3 — Few-shot Prompting</strong><br><strong><em>Prompt</em></strong>: Providing 3 examples of converting casual text to professional email tone, then asking the model to convert a 4th.<br><strong><em>Output</em></strong>: A professionally-toned sentence matching the pattern of the examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*PAcZ82E37dxw-znDJqz0PA.webp" /></figure><p><strong>Example 4 — Chain of Thought</strong><br><strong><em>Prompt</em></strong>: A multi-step math word problem with &quot;think step by step&quot; instruction.<br><strong><em>Output</em></strong>: A step-by-step breakdown ending in the correct final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*clZaVUyXkCBMWuta5TWASg.webp" /></figure><p><strong>Example 5 — Tree of Thoughts</strong><br><strong><em>Prompt</em></strong>: Asking the model to generate multiple strategic options for a business decision, evaluate each, and recommend the best.<br><strong><em>Output</em></strong>: Three distinct options with pros/cons and a final reasoned recommendation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*lcTLTwWDhbuU4w9PHIVxmQ.webp" /></figure><p>---</p><h3><strong>8. Conclusion</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*gJqZcxo5i4QSs8LNQpYsZQ.jpeg" /></figure><p><strong>Key Takeaways</strong></p><p>- Generative AI creates new content, distinguishing it fundamentally from traditional predictive AI.<br>- LLMs, powered by the Transformer architecture, are the backbone of most modern generative text applications.<br>- APIs like OpenAI, Gemini, and Groq make it easy to integrate these models into real applications — but must be used with proper key security practices.<br>- Prompt Engineering is a skill, not a shortcut — the way we phrase a request drastically changes the quality of the response.<br>- Techniques like Zero-shot, Few-shot, Chain of Thought, and Tree of Thoughts each serve different problem complexities.<br>- Parameters like Temperature, Top-p, and Top-k give fine-grained control over creativity versus consistency.</p><h3>Future of Generative AI</h3><ul><li>Generative AI is moving toward greater <strong>multimodality</strong>(models that seamlessly handle text, image, audio, and video together), <strong>agentic behavior</strong> (models that can plan and execute multi-step tasks autonomously), and deeper <strong>integration into everyday software</strong>— from IDEs to spreadsheets to design tools.</li><li>As these models become faster, cheaper, and more capable, prompt engineering itself may evolve into more natural, conversational forms of instruction, but the core skill of communicating intent clearly will likely remain valuable.</li></ul><p><strong>My Personal Learning from This Module</strong></p><ul><li>Before this module, I saw AI tools as a novelty for generating fun text or images. Now, I understand the underlying mechanics — from tokenization to attention mechanisms — and more importantly, I’ve learned that how you ask matters as much as what you ask.</li><li>Prompt engineering taught me to think more structurally about problems in general: breaking tasks into context, instruction, and constraints is a skill that extends well beyond talking to an AI model.</li><li>I’m excited to keep experimenting with these techniques in real projects going forward.</li></ul><p>---</p><p><strong>Thank you for reading! If you found this helpful, feel free to clap and follow for more of my Generative AI learning journey.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29ebe08129ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1. Introduction to Natural Language Processing (NLP)]]></title>
            <link>https://medium.com/@shreyarjoshi1995/1-introduction-to-natural-language-processing-nlp-07fda2c28c8b?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/07fda2c28c8b</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 07:15:39 GMT</pubDate>
            <atom:updated>2026-07-28T07:15:39.178Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*PLLQ6BS_0U1hVHtRNxFfAw.jpeg" /></figure><ul><li>Natural Language Processing (NLP) is the branch of Artificial Intelligence that gives machines the ability to read, understand, interpret, and generate human language.</li><li>Language is messy — full of ambiguity, slang, grammar exceptions, and context-dependent meaning — and NLP is the field dedicated to teaching computers to deal with that mess.</li><li>Think about everything language-related that software already does for you: your email client detecting spam, your phone predicting the next word as you type, Google Translate converting a sentence into another language, or a chatbot answering your query.</li><li>All of it is powered by NLP.</li></ul><p><strong>Why NLP is hard?</strong></p><p>Unlike numbers, human language doesn&#39;t come in a clean, structured format. A machine understands 1s and 0s — but a sentence like &quot;I saw the man with the telescope&quot; can mean two completely different things depending on context. This ambiguity is one of the central challenges NLP tries to solve.</p><p><strong>Core applications of NLP</strong></p><ul><li>Machine Translation (e.g., Google Translate)</li><li>Sentiment Analysis (e.g., analyzing product reviews)</li><li>Chatbots &amp; Virtual Assistants (e.g., Siri, Alexa)</li><li>Text Summarization</li><li>Speech Recognition</li><li>Named Entity Recognition (NER)</li><li>Large Language Models like ChatGPT</li></ul><p><strong>The journey this article covers</strong></p><p>NLP hasn&#39;t always looked like ChatGPT. It evolved over decades:</p><ul><li>Traditional/statistical NLP — rule-based systems, Bag of Words, TF-IDF</li><li>Word embeddings — Word2Vec, GloVe, FastText (words start getting &quot;meaning&quot;)</li><li>Sequential deep learning — RNNs, LSTMs, GRUs (context across a sentence)</li><li>Attention &amp; Transformers — the architecture behind every modern LLM</li><li>Fine-tuning &amp; evaluation — how raw LLMs become usable products like ChatGPT</li></ul><p>This article walks through that entire evolution, step by step, explaining why each new technique was invented — usually to fix a limitation of the one before it.</p><p><strong>Here&#39;s a visual roadmap of where we&#39;re headed:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPoYjSm1wvsngKDkF35kgg.jpeg" /></figure><h3><strong>2. Text Preprocessing</strong></h3><p>Before any NLP model — whether it&#39;s a 2013 Bag-of-Words model or a 2024 LLM — can work with text, that text needs to be cleaned and standardized. Raw text is inconsistent: different cases, punctuation, extra spaces, and irrelevant words all add noise. Text preprocessing is the pipeline of steps that convert messy raw text into a clean, structured form a model can use.</p><p>Let&#39;s walk through each step using this example sentence:</p><p>&quot;The children were playing happily in the gardens!!! Running, jumping, and laughing.&quot;</p><p><strong>2.1 Tokenization</strong></p><p>Tokenization is the process of breaking text into smaller units called tokens — usually words, but sometimes subwords or characters. It&#39;s the very first step because a machine can&#39;t process a whole paragraph as one blob; it needs discrete units.</p><p><strong>python</strong><br>from nltk.tokenize import word_tokenize</p><p>text = &quot;The children were playing happily in the gardens!!!&quot;<br>tokens = word_tokenize(text)<br>print(tokens)<br># Output: [&#39;The&#39;, &#39;children&#39;, &#39;were&#39;, &#39;playing&#39;, &#39;happily&#39;, &#39;in&#39;, &#39;the&#39;, &#39;gardens&#39;, &#39;!&#39;, &#39;!&#39;, &#39;!&#39;]</p><p><strong>There are different levels of tokenization:</strong></p><ul><li>Word tokenization — splits into words</li><li>Sentence tokenization — splits into sentences</li><li>Subword tokenization — splits into smaller units like &quot;play&quot; + &quot;ing&quot; (used heavily in modern Transformers, e.g., Byte Pair Encoding)</li></ul><p><strong>2.2 Stopword Removal</strong></p><p>Stopwords are extremely common words (the, is, in, at, on, and) that carry little semantic meaning on their own. Removing them reduces noise and dimensionality.</p><p><strong>python</strong><br>from nltk.corpus import stopwords</p><p>stop_words = set(stopwords.words(&#39;english&#39;))<br>filtered = [w for w in tokens if w.lower() not in stop_words]<br>print(filtered)<br># Output: [&#39;children&#39;, &#39;playing&#39;, &#39;happily&#39;, &#39;gardens&#39;, &#39;!&#39;, &#39;!&#39;, &#39;!&#39;]</p><p><strong>2.3 Stemming</strong></p><p>Stemming reduces a word to its root form by chopping off suffixes, using fixed rules — without necessarily producing a real dictionary word.</p><p><strong>python</strong><br>from nltk.stem import PorterStemmer</p><p>stemmer = PorterStemmer()<br>words = [&quot;playing&quot;, &quot;played&quot;, &quot;plays&quot;, &quot;happily&quot;]<br>stems = [stemmer.stem(w) for w in words]<br>print(stems)<br># Output: [&#39;play&#39;, &#39;play&#39;, &#39;play&#39;, &#39;happili&#39;]</p><p>Notice &quot;happily&quot; becomes &quot;happili&quot; — not a real word. That&#39;s the trade-off of stemming: it&#39;s fast and rule-based, but crude.</p><p><strong>2.4 Lemmatization</strong></p><p>Lemmatization also reduces words to their root form, but it uses vocabulary and grammar rules (via a dictionary) to return a valid word — called a lemma.</p><p><strong>python</strong><br>from nltk.stem import WordNetLemmatizer</p><p>lemmatizer = WordNetLemmatizer()<br>words = [&quot;playing&quot;, &quot;played&quot;, &quot;plays&quot;, &quot;happily&quot;]<br>lemmas = [lemmatizer.lemmatize(w, pos=&#39;v&#39;) for w in words]<br>print(lemmas)<br># Output: [&#39;play&#39;, &#39;play&#39;, &#39;play&#39;, &#39;happily&#39;]</p><p>Lemmatization is more accurate than stemming but computationally more expensive since it needs a lookup dictionary and part-of-speech context.</p><p><strong>2.5 Text Cleaning</strong></p><p>This is the general cleanup step that handles everything else messy in raw text:</p><ul><li>Lowercasing (&quot;Playing&quot; → &quot;playing&quot;)</li><li>Removing punctuation, special characters, HTML tags</li><li>Removing numbers (if irrelevant to the task)</li><li>Removing extra whitespace<br>Expanding contractions (&quot;don’t&quot; → &quot;do not&quot;)</li><li>Removing emojis or URLs (comm in social media text)</li></ul><p><strong>python</strong><br>import re</p><p>def clean_text(text):<br> text = text.lower()<br> text = re.sub(r&#39;&lt;.*?&gt;&#39;, &#39;&#39;, text) # remove HTML tags<br> text = re.sub(r&#39;http\S+&#39;, &#39;&#39;, text) # remove URLs<br> text = re.sub(r&#39;[^a-z\s]&#39;, &#39;&#39;, text) # remove punctuation/numbers<br> text = re.sub(r&#39;\s+&#39;, &#39; &#39;, text).strip() # remove extra whitespace<br> return text</p><p>raw = &quot;The Children were PLAYING happily!!! Visit http://example.com &lt;b&gt;now&lt;/b&gt;&quot;<br>print(clean_text(raw))</p><p># Output: &quot;the children were playing happily visit now&quot;</p><p><strong>Here’s the full preprocessing pipeline visually:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CEWdP71oGqB7kCawHHz3qw.jpeg" /></figure><h3><strong>3. One-Hot Encoding</strong></h3><p>Once text is cleaned and tokenized, we hit a fundamental problem: machine learning models only understand numbers, not words. One-Hot Encoding is one of the earliest and simplest techniques to convert words into numerical vectors.</p><ol><li><strong>How it works</strong><br>Build a vocabulary of all unique words in your corpus.</li><li>For each word, create a vector of length equal to the vocabulary size.</li><li>Put a 1 at the index corresponding to that word, and 0 everywhere else.</li></ol><p><strong>Example</strong></p><p>Suppose our vocabulary is: [&quot;cat&quot;, &quot;dog&quot;, &quot;sat&quot;, &quot;mat&quot;]</p><p><strong>Word	Vector</strong><br>cat	[1, 0, 0, 0]<br>dog	[0, 1, 0, 0]<br>sat [0, 0, 1, 0]<br>mat	[0, 0, 0, 1]</p><p>Each word gets a unique vector with exactly one 1 — hence &quot;one-hot.&quot;</p><p><strong>python</strong></p><p>from sklearn.preprocessing import OneHotEncoder<br>import numpy as np</p><p>vocab = np.array([&quot;cat&quot;, &quot;dog&quot;, &quot;sat&quot;, &quot;mat&quot;]).reshape(-1, 1)<br>encoder = OneHotEncoder(sparse_output=False)<br>encoded = encoder.fit_transform(vocab)<br>print(encoded)<br># Output:<br># [[1. 0. 0. 0.]<br># [0. 1. 0. 0.]<br># [0. 0. 1. 0.]<br># [0. 0. 0. 1.]]</p><p><strong>Why this matters historically</strong></p><p>One-hot encoding was one of the very first ways to bridge the gap between words and numbers. It&#39;s simple, easy to implement, and forms the conceptual foundation for Bag of Words and TF-IDF, which we&#39;ll cover next.</p><p>But it comes with serious problems that become obvious the moment your vocabulary grows beyond a toy example — which is exactly what we&#39;ll explore in Topic 6 (Limitations).</p><p>Here&#39;s a visual of how one-hot encoding maps words to vectors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kge_JGWJXGQPICGHDiJ0nw.jpeg" /></figure><h3><strong>4. Bag of Words (BoW)</strong></h3><p>One-hot encoding gives each word a vector, but it doesn&#39;t tell us anything about a sentence or document as a whole. Bag of Words (BoW) solves this by representing an entire document as a vector based on word frequency — ignoring grammar and word order entirely (hence &quot;bag,&quot; not &quot;sequence&quot;).</p><p><strong>How it works</strong></p><ol><li>Build a vocabulary from all documents in the corpus.</li><li>For each document, count how many times each vocabulary word appears.</li><li>Represent the document as a vector of these counts.</li></ol><p><strong>Example</strong></p><p>Consider two documents:</p><p>Doc 1: &quot;the cat sat on the mat&quot;<br>Doc 2: &quot;the dog sat on the log&quot;</p><p>Vocabulary: [the, cat, sat, on, mat, dog, log]</p><p><strong>python</strong></p><p>from sklearn.feature_extraction.text import CountVectorizer</p><p>docs = [&quot;the cat sat on the mat&quot;, &quot;the dog sat on the log&quot;]<br>vectorizer = CountVectorizer()<br>bow_matrix = vectorizer.fit_transform(docs)</p><p>print(vectorizer.get_feature_names_out())<br># [&#39;cat&#39; &#39;dog&#39; &#39;log&#39; &#39;mat&#39; &#39;on&#39; &#39;sat&#39; &#39;the&#39;]</p><p>print(bow_matrix.toarray())<br># [[1 0 0 1 1 1 2]<br># [0 1 1 0 1 1 2]]</p><p><strong>Why BoW was an improvement</strong></p><p>Unlike one-hot encoding of individual words, BoW captures how important a word is to a document through frequency — a word appearing 5 times likely matters more than one appearing once. This made BoW genuinely useful for tasks like spam detection and document classification, and it was a dominant technique in NLP for years.</p><p><strong>The core problem it doesn&#39;t solve</strong></p><p>BoW throws away word order. &quot;dog bites man&quot; and &quot;man bites dog&quot; produce nearly identical vectors — even though they mean completely different things. It also treats every word&#39;s frequency as equally important, which isn&#39;t true — common words like &quot;the&quot; dominate the counts without adding much meaning. That specific issue is what TF-IDF (next topic) was designed to fix.</p><p><strong>Here&#39;s how BoW converts documents into vectors:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xlpj4akyrwcM01Uijm7vrw.jpeg" /></figure><h3><strong>5. TF-IDF (Term Frequency-Inverse Document Frequency)</strong></h3><p><strong>BoW has a subtle flaw:</strong> it treats every word&#39;s raw frequency as equally meaningful. But common words like &quot;the&quot; or &quot;is&quot; appear frequently in every document and don&#39;t help distinguish one document from another. TF-IDF fixes this by weighting words based on how important they are — not just how often they appear.</p><p><strong>The core idea</strong></p><p>A word should get a high score if:</p><ul><li>It appears frequently in a specific document (Term Frequency)</li><li>It appears rarely across other documents (Inverse Document Frequency)</li></ul><p>This way, words that are common everywhere (like &quot;the&quot;) get pushed down, while distinctive words that are frequent in one document but rare elsewhere get pushed up.</p><p><strong>The formulas</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qP206jFpeAyV52lhB0C6Kw.jpeg" /></figure><p><strong>Example</strong></p><p>Using our earlier documents:</p><p>Doc 1: &quot;the cat sat on the mat&quot;<br>Doc 2: &quot;the dog sat on the log&quot;</p><p>The word &quot;the&quot; appears in both documents → low IDF → low TF-IDF score (not distinctive).<br>The word &quot;cat&quot; appears only in Doc 1 → high IDF → higher TF-IDF score for Doc 1 (distinctive to that document).</p><p><strong>python</strong><br>from sklearn.feature_extraction.text import TfidfVectorizer</p><p>docs = [&quot;the cat sat on the mat&quot;, &quot;the dog sat on the log&quot;]<br>vectorizer = TfidfVectorizer()<br>tfidf_matrix = vectorizer.fit_transform(docs)</p><p>print(vectorizer.get_feature_names_out())<br># [&#39;cat&#39; &#39;dog&#39; &#39;log&#39; &#39;mat&#39; &#39;on&#39; &#39;sat&#39; &#39;the&#39;]</p><p>print(tfidf_matrix.toarray().round(2))<br># [[0.45 0. 0. 0.45 0.32 0.32 0.64]<br># [0. 0.45 0.45 0. 0.32 0.32 0.64]]</p><p>Notice &quot;cat&quot; and &quot;mat&quot; get non-zero scores only in Doc 1 (where they appear), while &quot;the&quot; gets the same, relatively lower-weighted score in both — reflecting that it&#39;s less informative.</p><p><strong>Why TF-IDF was a genuine step forward</strong></p><p>TF-IDF was, for a long time, the workhorse of search engines and information retrieval systems (it&#39;s essentially the foundation of how early search engines ranked documents against a query). It&#39;s simple, interpretable, and cheap to compute.</p><p><strong>What it still doesn&#39;t solve</strong></p><p>TF-IDF still represents text as a sparse, high-dimensional, frequency-based vector. It has no idea that &quot;cat&quot; and &quot;kitten&quot; are related words, and it still ignores word order and grammar. These shared limitations of One-Hot, BoW, and TF-IDF are exactly what we’ll dig into next.</p><p><strong>Here&#39;s a visual comparing BoW counts vs TF-IDF weighting:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3N_9vUW6vkSxGO1b28eeDg.jpeg" /></figure><h3><strong>6. Limitations of One-Hot Encoding, BoW, and TF-IDF</strong></h3><p>Before moving to embeddings, it&#39;s worth pausing to clearly lay out why the entire family of frequency-based techniques (One-Hot, BoW, TF-IDF) eventually hit a wall. Understanding these limitations is what motivates everything that comes after.</p><p><strong>6.1 Sparsity</strong></p><p>All three techniques produce vectors where most values are 0. If your vocabulary has 50,000 words, every document/word vector has 50,000 dimensions — and only a handful of them are non-zero.</p><p><strong>python</strong><br># A one-hot vector for a 50,000-word vocabulary<br>vector = [0, 0, 0, ..., 1, ..., 0, 0]</p><p># 49,999 zeros, 1 one</p><p>This wastes enormous memory and computation for very little actual information per vector.</p><p><strong>6.2 No Semantic Understanding</strong></p><p>These methods have zero notion of meaning. To a BoW or TF-IDF model, the words &quot;happy&quot; and &quot;joyful&quot; are just as unrelated as &quot;happy&quot; and &quot;table&quot; — they&#39;re simply different indices in a vector. There&#39;s no way to capture that &quot;king&quot; and &quot;queen&quot; are related concepts, or that &quot;good&quot; and &quot;great&quot; are near-synonyms.</p><p><strong>6.3 No Contextual Information</strong></p><p>The same word always gets the exact same representation, regardless of context. The word &quot;bank&quot; in &quot;river bank&quot; and &quot;bank account&quot; is treated identically — even though the meanings are completely different. This is the polysemy problem (one word, multiple meanings), and none of these techniques can resolve it.</p><p><strong>6.4 High Dimensionality</strong></p><p>Since vector size equals vocabulary size, real-world corpora (with vocabularies in the hundreds of thousands) produce vectors that are computationally expensive to store and process — and this dimensionality only grows as you add more text.</p><p>These four problems are the reason the field moved toward dense, learned representations — vectors that are much smaller, capture meaning, and can (eventually) account for context. This shift began with the Neural Probabilistic Language Model, which we cover next.</p><p>Here&#39;s a visual summary of the core problem — sparse vs dense representation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Dly4EXVniVk1YQwUucQSw.jpeg" /></figure><h3><strong>7. Neural Probabilistic Language Model (NPLM)</strong></h3><p>Introduced by Yoshua Bengio and colleagues in 2003, the Neural Probabilistic Language Model (NPLM) was one of the first serious attempts to fix the core problem we just identified: sparse, meaningless word vectors. NPLM introduced the idea of representing words as dense, learned vectors — a radical shift that laid the groundwork for everything that followed, including Word2Vec.</p><p><strong>The core idea</strong></p><p>Instead of hand-designing word vectors (like one-hot encoding), NPLM learns a compact, dense vector for each word by training a neural network to predict the next word in a sequence, given the previous words. In the process of learning to predict well, the network is forced to learn vector representations that capture useful relationships between words.</p><p><strong>7.1 Architecture</strong></p><p>NPLM works like this:</p><ol><li><strong>Input layer:</strong> Take the previous n words (context window) and look up their one-hot vectors.</li><li><strong>Embedding layer</strong>: Each one-hot vector is multiplied by a shared weight matrix C, producing a dense vector (the word’s &quot;embedding&quot;). This is the key innovation — words get mapped into a lower-dimensional continuous space.</li><li><strong>Hidden layer</strong>: The concatenated embeddings of the context words are passed through a hidden layer with a non-linear activation (like tanh).</li><li><strong>Output layer:</strong> A softmax layer produces a probability distribution over the entire vocabulary — predicting the most likely next word.</li></ol><p>Context words → One-hot → Embedding lookup → Hidden layer (tanh) → Softmax → Next word probability</p><p><strong>7.2 Advantages</strong></p><ul><li><strong>Dense representations:</strong> Words are now represented in low-dimensional space (e.g., 100 dimensions instead of 50,000), solving the sparsity and high-dimensionality problems.</li><li><strong>Generalization</strong>: Because the model learns from co-occurrence patterns, it starts capturing some notion of similarity — words used in similar contexts get similar vectors.</li><li><strong>Foundation for embeddings</strong>: This was the first architecture to demonstrate that word meaning could be learned rather than manually engineered.<br><strong>7.3 Limitations</strong></li><li><strong>Computationally expensive</strong>: The softmax over the entire vocabulary at the output layer is very costly to compute, especially for large vocabularies — this made training slow.</li><li><strong>Fixed context window</strong>: NPLM only looks at a small, fixed number of previous words, so it can’t capture long-range dependencies in a sentence.</li><li><strong>Not scalable:</strong> Training on large corpora with this architecture was impractical at the time, which limited its real-world adoption.</li></ul><p>These limitations are exactly what Word2Vec was designed to solve a decade later — by simplifying the architecture and making training dramatically more efficient.</p><p><strong>Here&#39;s how NPLM&#39;s architecture flows:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hql7kM6YS3lDKvdC2X-hag.jpeg" /></figure><h3><strong>8. Word2Vec</strong></h3><p>Introduced by Tomas Mikolov and his team at Google in 2013, Word2Vec took the core idea from NPLM — learned, dense word vectors — and made it dramatically faster, simpler, and scalable to massive corpora. It became the technique that made word embeddings mainstream in NLP.</p><p><strong>8.1 Overview</strong></p><p>Word2Vec is not a single model — it&#39;s a framework with two architectures (which we&#39;ll cover in detail in the next two topics):</p><ul><li><strong>CBOW (Continuous Bag of Words): </strong>predicts a target word from its surrounding context words</li><li><strong>Skip-Gram:</strong> predicts surrounding context words from a target word</li></ul><p>The key insight behind Word2Vec is the distributional hypothesis:</p><ul><li><strong>&quot;a word is characterized by the company it keeps.&quot;</strong> Words that appear in similar contexts tend to have similar meanings.</li><li>By training a shallow neural network on a simple prediction task across a huge corpus, Word2Vec learns dense vectors where semantically similar words end up close together in vector space.</li><li>Unlike NPLM, Word2Vec removes the expensive hidden layer and uses techniques like Negative Sampling and Hierarchical Softmax to avoid computing a full softmax over the entire vocabulary — this is what makes it fast enough to train on billions of words.</li><li>Word2Vec embeddings capture relationships so well that you can do arithmetic on them:</li></ul><p>vector(&quot;king&quot;) - vector(&quot;man&quot;) + vector(&quot;woman&quot;) ≈ vector(&quot;queen&quot;)</p><p><strong>python</strong><br>from gensim.models import Word2Vec</p><p>sentences = [[&quot;the&quot;, &quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;],<br> [&quot;the&quot;, &quot;dog&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;log&quot;]]</p><p>model = Word2Vec(sentences, vector_size=100, window=5, min_count=1, sg=1)<br>similar_words = model.wv.most_similar(&quot;cat&quot;, topn=3)<br>print(similar_words)<br># e.g. [(&#39;dog&#39;, 0.87), (&#39;sat&#39;, 0.65), (&#39;mat&#39;, 0.42)]</p><p><strong>8.2 Advantages</strong></p><ul><li><strong>Semantic similarity</strong>: Words with similar meaning end up with similar (nearby) vectors — something none of the frequency-based methods could do.</li><li><strong>Low dimensionality</strong>: Vectors are typically 100–300 dimensions, regardless of vocabulary size — solving the high-dimensionality and sparsity problems.</li><li><strong>Fast to train</strong>: Negative sampling makes training efficient even on huge corpora.</li><li><strong>Transferable</strong>: Pretrained Word2Vec vectors could be reused across different downstream NLP tasks.</li><li><strong>8.3 Limitations</strong></li><li><strong>Static embeddings</strong>: Each word gets exactly one vector, regardless of context. &quot;Bank&quot; has the same vector in &quot;river bank&quot; and &quot;bank account&quot; — the contextual/polysemy problem from Topic 6 is only partially addressed, not solved.</li><li><strong>Out-of-vocabulary (OOV) problem: </strong>If a word wasn’t seen during training, Word2Vec has no vector for it at all.</li><li><strong>No subword information</strong>: It treats each word as an atomic unit, so it can’t infer anything about a new word from its parts (e.g., &quot;unhappiness&quot; from &quot;un-&quot;, &quot;happy&quot;, &quot;-ness&quot;).</li></ul><p>These remaining gaps are what motivated further architectures — FastText (to handle subwords/OOV) and eventually contextual embeddings from Transformers (to handle polysemy). But first, let&#39;s look at the two specific training strategies inside Word2Vec: CBOW and Skip-Gram.</p><p><strong>Here&#39;s a visual of the distributional hypothesis and vector arithmetic:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4idK2MzjX6FI6q5kzAjh4Q.jpeg" /></figure><h3><strong>9. Continuous Bag of Words (CBOW)</strong></h3><p>CBOW is one of the two training architectures inside Word2Vec. Its objective is simple: given the surrounding context words, predict the target (middle) word.</p><p><strong>How it works</strong></p><p>Suppose we have the sentence: &quot;the cat sat on the mat&quot; and we pick a window size of 2.</p><p>For the target word &quot;sat&quot;, the context words are [&quot;cat&quot;, &quot;on&quot;] (2 words on each side, within the window).</p><p>CBOW takes these context words as input and tries to predict &quot;sat&quot; as output.</p><p>Context: [the, cat, ___, on, the] → Predict: &quot;sat&quot;<br><strong>Architecture</strong></p><ol><li><strong>Input</strong>: One-hot vectors of context words (e.g., &quot;the&quot;, &quot;cat&quot;, &quot;on&quot;, &quot;the&quot;)</li><li><strong>Projection/Embedding layer</strong>: Each context word is mapped to its embedding vector, and these are averaged (or summed) into a single vector.</li><li><strong>Output layer</strong>: This averaged vector is passed through a softmax (with negative sampling for efficiency) to predict the probability distribution over the vocabulary, aiming to maximize the probability of the actual target word &quot;sat&quot;.<br><strong>python</strong><br>from gensim.models import Word2Vec</li></ol><p>sentences = [[&quot;the&quot;, &quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;]]</p><p># sg=0 means CBOW (sg=1 would be Skip-Gram)<br>cbow_model = Word2Vec(sentences, vector_size=50, window=2, min_count=1, sg=0)<br>print(cbow_model.wv[&quot;sat&quot;][:5])</p><p># first 5 dimensions of the learned vector</p><p><strong>Why CBOW works well</strong></p><p>Because it averages multiple context words into one signal, CBOW effectively smooths over noise — it&#39;s like the model gets several &quot;clues&quot; about the target word at once. This makes CBOW:</p><ul><li><strong>Faster to train</strong> than Skip-Gram, since it processes one averaged context per training step rather than multiple word pairs.</li><li><strong>Better for frequent words</strong> — since common words appear in many contexts, CBOW gets plenty of clean training signal for them.</li></ul><p><strong>Trade-off</strong></p><ul><li>CBOW tends to perform worse on rare words, since averaging context vectors can dilute the specific signal a rare word needs to be well represented.</li><li>This is precisely the trade-off that Skip-Gram (next topic) approaches from the opposite direction — instead of predicting one word from many contexts, it predicts many context words from one target word, giving rare words more individual attention during training.</li></ul><p>Here&#39;s a visual of the CBOW prediction flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khsar_VY6iP27AHo6lAyLA.jpeg" /></figure><h3><strong>10. Skip-Gram</strong></h3><p>Skip-Gram is the mirror image of CBOW. Instead of predicting a target word from its context, Skip-Gram does the opposite: given a target word, predict the surrounding context words.</p><p><strong>How it works</strong></p><p>Using the same sentence &quot;the cat sat on the mat&quot; with window size 2, and target word &quot;sat&quot;:</p><p>Input: &quot;sat&quot; → Predict: [cat, on] (and potentially [the, the] depending on window)</p><p>For each target word, Skip-Gram creates multiple training pairs — one for each context word:</p><p>(sat, cat)<br>(sat, on)<br><strong>Architecture:</strong></p><ol><li><strong>Input</strong>: One-hot vector of the target word (&quot;sat&quot;)</li><li><strong>Embedding layer:</strong> Maps the target word to its dense vector</li><li><strong>Output layer:</strong> Softmax (with negative sampling) predicts the probability of each context word appearing near the target — trained separately for each (target, context) pair<br><strong>python</strong><br>from gensim.models import Word2Vec</li></ol><p>sentences = [[&quot;the&quot;, &quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;]]</p><p># sg=1 means Skip-Gram<br>skipgram_model = Word2Vec(sentences, vector_size=50, window=2, min_count=1, sg=1)<br>print(skipgram_model.wv.most_similar(&quot;sat&quot;, topn=3))</p><p><strong>Why Skip-Gram works well</strong></p><p>Because Skip-Gram creates a separate training example for every context word around a target (rather than averaging them into one signal like CBOW), it gives each word-context pair individual attention during training. This means:</p><ul><li><strong>Better performance on rare words</strong> — since even a word that appears infrequently still generates multiple training pairs whenever it does appear, giving the model more chances to learn a good vector for it.</li><li><strong>Captures more nuanced relationships,</strong> since it isn’t averaging away context-specific detail.</li></ul><p><strong>Trade-off</strong></p><p>Skip-Gram is slower to train than CBOW because it generates and processes many more training pairs (one per context word, rather than one averaged input per target). In practice, Mikolov&#39;s original Word2Vec paper found Skip-Gram tends to give better quality embeddings, especially with larger datasets, while CBOW is faster and works fine on smaller ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7fyaJXH8hDPf8nVMcWiLA.jpeg" /></figure><h3><strong>11. FastText</strong></h3><p>Developed by Facebook AI Research in 2016, FastText was designed to fix one of Word2Vec&#39;s clearest gaps: it treats every word as an indivisible unit, so it has no way to handle words it never saw during training, and it can&#39;t use the internal structure of a word (prefixes, suffixes, roots) to infer meaning.</p><p><strong>The core idea: subword information</strong></p><ul><li>Instead of learning one vector per whole word, FastText breaks each word down into character n-grams (chunks of consecutive characters) and learns embeddings for those n-grams.</li><li>A word’s final vector is the sum of its n-gram vectors.</li><li>For example, take the word &quot;where&quot; with n-grams of size 3 (trigrams), including boundary markers &lt; and &gt;:</li></ul><p>&quot;where&quot; → &lt;wh, whe, her, ere, re&gt;</p><p>The word &quot;where&quot; is represented as the sum of the vectors for each of these n-gram chunks, plus a special vector for the whole word itself.</p><p><strong>python</strong><br>from gensim.models import FastText</p><p>sentences = [[&quot;the&quot;, &quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;]]</p><p>ft_model = FastText(sentences, vector_size=50, window=3, min_count=1, sg=1)</p><p># FastText can even generate a vector for an unseen/misspelled word!<br>print(ft_model.wv[&quot;catx&quot;][:5])</p><p># works because it shares n-grams with &quot;cat&quot;</p><p><strong>Why this matters</strong></p><p>Because FastText builds vectors from subword pieces, it can:</p><ul><li><strong>Handle out-of-vocabulary (OOV) words:</strong> even if &quot;unhappiness&quot; was never seen during training, FastText can construct a reasonable vector for it from n-grams like &quot;un&quot;, &quot;happi&quot;, &quot;ness&quot; — pieces it likely saw in other words.</li><li><strong>Understand morphology</strong>: related word forms like &quot;run&quot;, &quot;running&quot;, &quot;runner&quot; share overlapping n-grams, so their vectors end up close together — useful for morphologically rich languages (like Turkish, Finnish, or Hindi) where a single root can have dozens of inflected forms.</li><li><strong>Handle typos and rare words</strong> gracefully, since a slight misspelling still shares most of its n-grams with the correct word.</li></ul><p><strong>Limitations</strong></p><ul><li>FastText solves the OOV and morphology problems, but it still produces one static vector per word — the fundamental contextual/polysemy problem from Topic 6 remains completely unsolved.</li><li>&quot;Bank&quot; (river) and &quot;bank&quot; (money) still get identical vectors. FastText is also more computationally expensive than Word2Vec, since it needs to generate and train on many n-grams per word instead of a single unit.</li></ul><p>Here&#39;s a visual of how FastText builds a word vector from subword n-grams:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N10wuRjJ6bCWomFhCUxWqg.jpeg" /></figure><h3><strong>12. GloVe (Global Vectors for Word Representation)</strong></h3><p>Developed at Stanford in 2014, GloVe takes a different approach to learning word embeddings compared to Word2Vec. Instead of learning purely from local context windows (predicting nearby words one window at a time), GloVe learns embeddings from global co-occurrence statistics across the entire corpus.</p><p><strong>The core idea</strong></p><ul><li>Word2Vec is a predictive model — it learns by repeatedly trying to predict a word from context (or vice versa), one small window at a time, never directly looking at overall corpus statistics.</li><li>GloVe instead is a count-based model — it first builds a giant co-occurrence matrix (how often word i appears near word j across the whole corpus), and then learns vectors such that their dot product approximates the log of that co-occurrence count.</li></ul><p><strong>How it works</strong></p><ol><li><strong>Build a co-occurrence matrix</strong> X, where X[i][j] = number of times word j appears in the context of word i, across the entire corpus.</li><li><strong>Learn word vectors</strong> w_i and w_j such that:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*LdVXyCyE3ZXJ88Ny9EaRzg.jpeg" /></figure><p><strong>Why GloVe was appealing</strong></p><ul><li><strong>Captures global statistics:</strong> since it’s built directly from corpus-wide co-occurrence counts, GloVe can capture relationships that a small sliding window (like Word2Vec’s) might miss.</li><li><strong>Efficient training:</strong> because the co-occurrence matrix is built once, training doesn’t require repeatedly scanning through the whole corpus the way Word2Vec’s window-based approach does.</li><li><strong>Strong performance</strong> on word analogy tasks, similar to Word2Vec (e.g., king − man + woman ≈ queen).</li></ul><p><strong>Limitations</strong></p><p>Just like Word2Vec and FastText, GloVe still produces static, one-vector-per-word embeddings. It has no way to give &quot;bank&quot; different vectors depending on whether it&#39;s used near &quot;river&quot; or &quot;money&quot; in a specific sentence. This — the persistent contextual/polysemy limitation — is what we formalize next, before moving into the sequence-based architectures (RNN, LSTM, GRU) and eventually Transformers that finally solve it.</p><p>Here&#39;s a visual of how GloVe uses a global co-occurrence matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmeXnQE743kfXW2FkBo7tQ.jpeg" /></figure><h3><strong>13. Limitations of Static Word Embeddings</strong></h3><p>We&#39;ve now covered the entire family of static embeddings: Word2Vec (CBOW, Skip-Gram), FastText, and GloVe. Each solved a different piece of the puzzle — density, subwords, global statistics — but they all share one fundamental architectural flaw. It&#39;s time to name it clearly, because solving it is what drives the rest of this article.</p><p><strong>13.1 The Polysemy Problem</strong></p><ul><li><strong>Polysemy</strong> means a single word having multiple distinct meanings.</li><li><strong>Static embeddings</strong> assign exactly one fixed vector per word, no matter how many meanings that word can have. Consider:</li></ul><p>&quot;I deposited money in the bank.&quot; (financial institution)<br>&quot;We sat by the river bank.&quot; (edge of a river)<br>&quot;The plane started to bank to the left.&quot; (to tilt/turn)</p><p>All three uses of &quot;bank&quot; get the exact same vector in Word2Vec, GloVe, or FastText — because these models were trained to produce one averaged representation across all the contexts a word ever appeared in during training. The vector ends up being a kind of blurred average of all these meanings, which isn&#39;t ideal for any single one of them.</p><p><strong>13.2 Lack of Contextual Understanding</strong></p><p>This is the direct consequence of polysemy not being handled: static embeddings have no mechanism to look at the specific sentence a word appears in and adjust its representation accordingly. The embedding is computed once (during training) and then frozen — it doesn&#39;t change based on neighboring words at inference time.</p><p><strong>python</strong><br># Static embeddings: same vector regardless of sentence<br>vector_bank_1 = model.wv[&quot;bank&quot;] # &quot;river bank&quot;<br>vector_bank_2 = model.wv[&quot;bank&quot;] # &quot;bank account&quot;<br># vector_bank_1 == vector_bank_2 → always true for static embeddings</p><p>This matters enormously for tasks like machine translation, question answering, and sentiment analysis, where the correct interpretation of a word often depends entirely on its surrounding context.</p><p><strong>13.3 Need for a Better Architecture</strong></p><p>Fixing this requires a fundamentally different kind of model — one that:</p><ul><li>Processes a word in relation to the rest of the sentence, not in isolation</li><li>Produces a different vector for the same word depending on its context</li><li>Can capture long-range dependencies — relationships between words that are far apart in a sentence</li></ul><p>This need led NLP research in two parallel directions that we&#39;ll now trace:</p><ol><li><strong>Sequential models</strong> (RNN → LSTM → GRU → Seq2Seq) — architectures designed to process text one word at a time while maintaining a memory of everything seen so far.</li><li>Eventually, <strong>attention and Transformers</strong> — which solve contextual understanding far more effectively, and now underpin virtually every modern LLM.</li></ol><p>Interestingly, machine translation was one of the biggest real-world drivers of this shift, so before diving into RNNs, we&#39;ll take a short detour through how machine translation itself evolved — from rule-based systems, to statistical methods, to neural approaches — since this history runs in parallel with (and motivates) the embedding-to-Transformer story.</p><p>Here&#39;s a visual summarizing the static embedding problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNsadyWyHyirQ9R4PLqAWQ.jpeg" /></figure><h3><strong>14. Rule-Based Machine Translation (RBMT)</strong></h3><p>Before we return to sequential neural architectures, it&#39;s worth tracing a parallel storyline: the evolution of machine translation, one of NLP&#39;s oldest and most important applications. This history mirrors the broader arc of NLP itself, and it&#39;s what ultimately motivated the invention of RNNs, LSTMs, and Seq2Seq models.</p><p><strong>What is RBMT?</strong></p><ul><li>Rule-Based Machine Translation was the earliest approach to automated translation, dominant from the 1950s through the 1980s.</li><li>As the name suggests, it relies entirely on hand-crafted linguistic rules written by human experts — grammarians and linguists encoding the rules of both the source and target languages directly into the system.</li></ul><p><strong>How it works</strong></p><p>RBMT systems typically follow three stages:</p><ol><li><strong>Analysis</strong>: Parse the source sentence into its grammatical structure (parts of speech, sentence structure, morphology).</li><li><strong>Transfer</strong>: Apply a set of manually written rules to convert the source language&#39;s grammatical structure into the target language&#39;s structure.</li><li><strong>Generation</strong>: Produce the final sentence in the target language, following its grammar rules.</li></ol><p>RBMT systems also depend heavily on bilingual dictionaries and large sets of grammar rules for both languages — sometimes tens of thousands of rules for a single language pair.</p><p><strong>Advantages</strong></p><ul><li><strong>Predictable and interpretable:</strong> since it&#39;s rule-based, you can trace exactly why a translation came out a certain way.</li><li><strong>No need for large parallel datasets</strong> — RBMT doesn&#39;t require example translations to &quot;learn&quot; from, only linguistic expertise.</li><li><strong>Works reasonably well</strong> for structured, technical text with limited vocabulary (like weather reports or technical manuals).</li></ul><p><strong>Limitations</strong></p><ul><li><strong>Extremely labor-intensive</strong>: writing rules for every grammatical construct, exception, and idiom in a language pair takes years of expert linguistic work.</li><li><strong>Doesn&#39;t scale to new language pairs:</strong> rules built for English–French don&#39;t transfer to English–Japanese; you need to start over almost from scratch for every new pair.</li><li><strong>Rigid</strong>: natural language is full of irregularities that don’t fit into clean rules (e.g., idioms like &quot;kick the bucket&quot; translate terribly if handled literally).Rigid: can’t adapt or improve from data — the only way to &quot;fix&quot; a bad translation is to manually add or adjust rules.</li></ul><p>These scalability and labor problems are exactly what motivated the shift to Statistical Machine Translation (SMT) in the 1990s — a system that could learn translation patterns automatically from data, rather than requiring every rule to be hand-written.</p><p><strong>Here&#39;s a visual of the RBMT pipeline:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8v4TtZ3WOMF9UyrUWggmLA.jpeg" /></figure><h3><strong>15. Statistical Machine Translation (SMT)</strong></h3><ul><li>By the late 1980s and through the 2000s, researchers (notably at IBM) shifted away from hand-written rules toward a data-driven approach: Statistical Machine Translation (SMT).</li><li>Instead of encoding grammar manually, SMT learns translation patterns automatically from large collections of parallel text — pairs of sentences that are translations of each other.</li></ul><p><strong>The core idea</strong></p><p>SMT treats translation as a probability problem: given a sentence in the source language, find the target-language sentence that is most probable as its translation.</p><p><strong>How it works</strong></p><ol><li><strong>Parallel corpus</strong>: Collect millions of sentence pairs (source ↔ target) — e.g., from translated government documents, books, or the web</li><li><strong>Word/phrase alignment</strong>: Statistically determine which words or phrases in the source sentence correspond to which words/phrases in the target sentence, based on how often they co-occur across the corpus.</li><li><strong>Translation model</strong>: Learn probabilities for translating specific words/phrases.</li><li><strong>Language model</strong>: Learn which sequences of words are fluent/natural in the target language (usually via n-gram statistics).</li><li><strong>Decoding</strong>: Search across possible translations to find the one that maximizes the combined probability.</li></ol><p><strong>Advantages over RBMT</strong></p><ul><li><strong>Scales to new language pairs</strong> much more easily — you just need a parallel corpus, not years of manual rule-writing by linguists.</li><li><strong>Learns from real usage</strong>, so it naturally captures common phrasings, idioms (to some extent), and statistical regularities that rule-writers might miss.</li><li><strong>Improves with more data</strong> — more parallel text generally means better translations, unlike RBMT which is capped by however many rules were written.</li></ul><p><strong>Limitations</strong></p><ul><li><strong>Requires massive parallel corpora</strong>, which don’t exist for many low-resource language pairs.</li><li><strong>Loses long-range context</strong>: SMT typically works with local word/phrase alignments and n-gram language models, so it struggles with long sentences where meaning depends on distant words.</li><li><strong>Produces disfluent or awkward translations </strong>at times, since it’s essentially stitching together statistically likely phrases rather than truly &quot;understanding&quot; the sentence.</li><li><strong>Complex pipeline</strong>: SMT systems have many separate components (alignment models, translation models, language models, decoders) that all need to be tuned together — making the whole system fragile and hard to optimize end-to-end.</li></ul><p>This complexity and the loss of long-range context are exactly what motivated the next big leap: Neural Machine Translation (NMT) — a single, end-to-end neural network that learns the entire translation process jointly, without needing separate hand-engineered components.</p><p><strong>Here&#39;s a visual of the SMT pipeline:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMpOjmBDIco6pI2QG7DHkw.jpeg" /></figure><h3><strong>16. Neural Machine Translation (NMT)</strong></h3><p>By the mid-2010s, Neural Machine Translation (NMT) replaced SMT as the dominant paradigm. Instead of a fragile pipeline of separately-trained components (alignment models, translation models, language models, decoders), NMT uses a single neural network trained end-to-end to directly map a source sentence to a target sentence.</p><p><strong>The core idea</strong></p><ul><li>NMT frames translation as a sequence-to-sequence problem: take a sequence of words in one language, and output a sequence of words in another language.</li><li>The entire system — from understanding the source sentence to generating the target sentence — is learned jointly by one neural network, rather than being split into hand-designed sub-modules.</li><li>The typical architecture (which we&#39;ll unpack in detail in Topic 20) has two components:</li></ul><ol><li><strong>An encoder</strong> that reads the source sentence and compresses it into a numerical representation</li><li><strong>A decoder</strong> that takes that representation and generates the target sentence, one word at a time</li></ol><p><strong>16.1 Why Neural Machine Translation was introduced</strong></p><p>NMT was introduced to directly address SMT&#39;s core weaknesses:</p><ul><li><strong>End-to-end learning:</strong> instead of training and tuning multiple separate components (alignment, translation, language models) that could each introduce errors, NMT trains one unified model that optimizes the whole translation task jointly — reducing compounding errors.</li><li><strong>Better handling of context:</strong> because NMT processes the entire sentence through a neural network rather than working with local phrase alignments, it captures long-range dependencies and word order far better than SMT.</li><li><strong>More fluent, natural output</strong>: NMT tends to produce grammatically smoother, more natural-sounding translations, since it generates language using a learned neural language model rather than stitching together statistically likely phrase chunks.</li><li><strong>Simpler architecture overall</strong>: a single trained network replaces SMT’s complex multi-stage pipeline, making the system easier to build, maintain, and improve — you can improve translation quality largely just by feeding it more (and better) data, rather than redesigning multiple sub-components.</li></ul><p><strong>The remaining challenge</strong></p><ul><li>Early NMT systems used Recurrent Neural Networks (RNNs) as their encoder and decoder — since RNNs are naturally suited to processing sequences.</li><li>But basic RNNs come with their own significant limitations (which we cover next): they struggle with long sentences, suffer from vanishing gradients, and process everything sequentially, making them slow to train.</li><li>This sets up the next major arc of the article: understanding RNNs, and then the improvements — LSTM, GRU, Seq2Seq, Attention, and ultimately Transformers — that were built to fix RNN&#39;s shortcomings, one by one.</li></ul><p><strong>Here&#39;s a visual comparing SMT&#39;s fragmented pipeline against NMT&#39;s unified approach:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1hqQEsVcDWY9VwN8rvkumw.jpeg" /></figure><h3><strong>17. Recurrent Neural Networks (RNN)</strong></h3><p>We now return to the sequential modeling storyline. Both the polysemy problem (Topic 13) and NMT (Topic 16) point to the same need: a model that processes words in sequence, maintaining memory of everything it has seen so far. Recurrent Neural Networks (RNNs) were the first widely adopted architecture designed exactly for this.</p><p><strong>17.1 Architecture</strong></p><p>Unlike a standard feedforward neural network (where inputs flow straight through in one direction), an RNN has a loop: the output from the previous time step is fed back into the network along with the next input. This loop acts as a form of memory, called the hidden state.</p><p>At each time step t, the RNN takes two things: the current input x_t and the previous hidden state h_{t-1}, and produces a new hidden state h_t:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUHY-Dcgc4XSWKr3egcLxQ.jpeg" /></figure><p>By the time the RNN reaches &quot;sat,&quot; its hidden state h3 theoretically contains a compressed summary of everything before it — &quot;the&quot; and &quot;cat&quot; — allowing the network to make context-aware predictions.</p><p><strong>python</strong> <br>import tensorflow as tf</p><p>rnn = tf.keras.layers.SimpleRNN(units=20, return_sequences=True)<br>x = tf.random.normal((1, 3, 50)) # batch=1, sequence length=3, embedding dim=50<br>output = rnn(x)<br>print(output.shape)</p><p># (1, 3, 20)</p><p><strong>17.3 Advantages</strong></p><ul><li><strong>Handles variable-length sequences</strong> — unlike fixed-window models (like NPLM), an RNN can process sentences of any length using the same architecture.</li><li><strong>Maintains context across a sequence,</strong> since each hidden state carries forward information from everything seen previously — a genuine step toward solving the contextual understanding problem.</li><li><strong>Naturally suited to sequential tasks </strong>like language modeling, translation, and speech recognition.</li></ul><p><strong>17.4 Limitations</strong></p><ul><li><strong>Vanishing gradient problem:</strong> during training (via backpropagation through time), gradients get multiplied repeatedly as they flow backward through many time steps. For long sequences, these gradients shrink toward zero, meaning the network effectively &quot;forgets&quot; information from many steps earlier — undermining the very long-range memory RNNs were designed to provide.</li><li><strong>Struggles with long sentences:</strong> in practice, plain RNNs are only good at capturing dependencies across a handful of nearby words, not across long paragraphs or sentences.</li><li><strong>Sequential computation is slow:</strong> since each hidden state depends on the previous one, RNNs must be processed one step at a time — they can’t be parallelized across the sequence length, making training slow on modern hardware (GPUs excel at parallel computation, which RNNs can’t fully exploit).</li></ul><p>These specific problems — vanishing gradients and poor long-range memory — are exactly what LSTM was designed to solve, using a more sophisticated internal structure with gates that control what information to keep or discard.</p><p><strong>Here&#39;s a visual of the RNN&#39;s recurrent loop unrolled across time steps:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gN8LquWoJguMv93xEdA5ag.jpeg" /></figure><h3><strong>18. Long Short-Term Memory (LSTM)</strong></h3><ul><li>Introduced by Hochreiter &amp; Schmidhuber in 1997 (and popularized widely in the 2010s), LSTM was designed specifically to fix RNN&#39;s biggest weakness: the vanishing gradient problem and its inability to retain information over long sequences.</li><li>LSTM does this by introducing a more sophisticated internal structure with gates that explicitly control what information gets remembered, forgotten, or output.</li></ul><p><strong>18.1 Architecture</strong></p><p>An LSTM cell maintains two things at each time step, instead of just one hidden state:</p><ul><li><strong>Cell state (C_t):</strong> a &quot;conveyor belt&quot; of memory that runs through the entire sequence with only minor, controlled modifications — this is what allows information to survive over long distances.</li><li><strong>Hidden state (h_t):</strong> the output at this time step, used both for predictions and passed to the next cell.</li></ul><p><strong>18.2 Gates</strong></p><p>LSTM uses three gates, each a small neural network layer with a sigmoid activation (output between 0 and 1, acting like a &quot;how much to let through&quot; dial):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*9bt_IavvvzF4n6q_yMnqOw.jpeg" /></figure><p><strong>python</strong></p><p>import tensorflow as tf</p><p>lstm = tf.keras.layers.LSTM(units=20, return_sequences=True, return_state=True)<br>x = tf.random.normal((1, 3, 50)) # batch=1, sequence length=3, embedding dim=50<br>output, hidden_state, cell_state = lstm(x)<br>print(output.shape) # (1, 3, 20)<br>print(cell_state.shape) # (1, 20) - the long-term memory</p><p><strong>18.3 Advantages over RNN</strong></p><ul><li><strong>Solves the vanishing gradient problem:</strong> the cell state acts like a highway that gradients can flow through with minimal transformation, so information (and gradients during training) can persist across many time steps.</li><li><strong>Selective memory</strong>: the gates let the network learn what to remember and what to forget, rather than blindly carrying forward everything (as vanilla RNNs try, and fail, to do).</li><li><strong>Much better at long-range dependencies:</strong> LSTMs can capture relationships between words that are far apart in a sentence — something plain RNNs struggle badly with.</li></ul><p><strong>Limitations</strong></p><ul><li>LSTMs solve the memory problem but are more computationally expensive than plain RNNs (three gates, each with their own weights, means significantly more parameters), and they&#39;re still inherently sequential — each time step still depends on the previous one, so training still can&#39;t be parallelized across the sequence length.</li><li>This computational cost is what motivated a simpler alternative: GRU, which we cover next.</li></ul><p><strong>Here&#39;s a visual of the LSTM cell&#39;s gate structure:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hlyQa4qRFGIU9gAtUCbiQ.jpeg" /></figure><h3><strong>19. Gated Recurrent Unit (GRU)</strong></h3><p>Introduced by Cho et al. in 2014, GRU is a simplified alternative to LSTM. It achieves similar benefits — solving the vanishing gradient problem and retaining long-range context — but with a simpler internal structure and fewer parameters, making it faster to train.</p><p><strong>19.1 Architecture</strong></p><p>GRU combines LSTM&#39;s three gates into just two gates, and merges the cell state and hidden state into a single state vector h_t (no separate cell state).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zx0inD13UbNk7W5JNHOdCQ.jpeg" /></figure><p><strong>python</strong></p><p>import tensorflow as tf</p><p>gru = tf.keras.layers.GRU(units=20, return_sequences=True, return_state=True)<br>x = tf.random.normal((1, 3, 50))</p><p># batch=1, sequence length=3, embedding dim=50<br>output, hidden_state = gru(x)<br>print(output.shape) # (1, 3, 20)<br>print(hidden_state.shape) # (1, 20)</p><p><strong>19.2 Advantages over LSTM</strong></p><ul><li><strong>Fewer parameters</strong>: with only 2 gates instead of 3, and no separate cell state, GRU has significantly fewer weights to learn — roughly 25% fewer parameters than an equivalent LSTM.</li><li><strong>Faster to train:</strong> fewer computations per time step means quicker training and inference, which matters a lot at scale.</li><li><strong>Comparable performance</strong>: in many tasks, especially with smaller datasets, GRU performs on par with LSTM despite being simpler — making it an efficient default choice in many practical applications.</li><li><strong>Simpler to implement and tune:</strong> fewer gates and hyperparameters means less complexity when building and debugging models.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOpCquqLg7Lp4oUF_ImBKw.jpeg" /></figure><p><strong>The bigger picture</strong></p><ul><li>Both LSTM and GRU meaningfully improved on plain RNNs — but they&#39;re still fundamentally sequential: each time step depends on completing the previous one, so training cannot be parallelized across the sequence.</li><li>This remains a serious bottleneck. Even with better memory retention, using RNN-family models (including LSTM/GRU) as the encoder-decoder backbone for tasks like translation still comes with structural limitations — which is exactly the context we return to next with Seq2Seq, before uncovering why Attention and ultimately Transformers were needed.</li></ul><p><strong>Here&#39;s a visual comparing LSTM&#39;s three gates to GRU&#39;s two</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*lD18eNFFFlaR-kV0y_H5hw.jpeg" /></figure><h3><strong>20. Sequence-to-Sequence (Seq2Seq) using LSTM</strong></h3><ul><li>Seq2Seq, introduced by Sutskever et al. in 2014, is the architecture that formalized NMT’s encoder-decoder idea using LSTM as the building block.</li><li>It became the standard approach for tasks where both the input and output are sequences of variable length — translation, summarization, chatbots, and more.</li></ul><p><strong>20.1 Encoder</strong></p><ul><li>The encoder is an LSTM (or stack of LSTMs) that reads the entire input sequence, one token at a time, updating its hidden state and cell state at each step.</li><li>Crucially, the encoder doesn&#39;t produce an output at every step that matters — what we care about is its final hidden state and cell state, after it has read the whole input sequence.</li></ul><p><strong>python</strong><br>import tensorflow as tf</p><p>encoder_inputs = tf.keras.Input(shape=(None, 50)) # variable-length sequence, embedding dim=50<br>encoder_lstm = tf.keras.layers.LSTM(64, return_state=True)<br>encoder_outputs, state_h, state_c = encoder_lstm(encoder_inputs)<br>encoder_states = [state_h, state_c] # this is passed to the decoder<br><strong>20.2 Decoder</strong></p><ul><li>The decoder is a separate LSTM that generates the output sequence, one token at a time.</li><li>It’s initialized using the encoder’s final hidden and cell states (rather than starting from zero), and at each step it takes its own previous output as the next input (a process called autoregressive generation), continuing until it produces an end-of-sequence token.</li></ul><p><strong>python</strong><br>decoder_inputs = tf.keras.Input(shape=(None, 50))<br>decoder_lstm = tf.keras.layers.LSTM(64, return_sequences=True, return_state=True)<br>decoder_outputs, _, _ = decoder_lstm(decoder_inputs, initial_state=encoder_states)<br>decoder_dense = tf.keras.layers.Dense(vocab_size, activation=&quot;softmax&quot;)<br>decoder_outputs = decoder_dense(decoder_outputs)</p><p>model = tf.keras.Model([encoder_inputs, decoder_inputs], decoder_outputs)</p><p><strong>20.3 Context Vector</strong></p><ul><li>The context vector is the encoder&#39;s final hidden state (and cell state) — a single, fixed-size vector that is supposed to summarize the entire meaning of the input sequence, no matter how long it is.</li><li>This vector is the only bridge between the encoder and decoder: the decoder never sees the original input sequence directly, only this compressed summary.</li></ul><p><strong>20.4 Limitations</strong></p><ul><li><strong>The information bottleneck:</strong> forcing an entire sentence — regardless of length — into one fixed-size vector is a huge constraint. A 5-word sentence and a 50-word sentence both get compressed into the same size context vector, and the longer the input, the more information inevitably gets lost or diluted.</li><li><strong>Poor performance on long sequences:</strong> because of this bottleneck, Seq2Seq’s translation quality degrades noticeably as input sentences get longer — the model &quot;forgets&quot; earlier parts of long sentences by the time it reaches the end.</li><li><strong>No direct access to input words during decoding: </strong>the decoder can’t &quot;look back&quot; at specific words in the source sentence when generating each output word — it only has the single compressed context vector, with no way to focus on the most relevant parts of the input for each output word being generated.</li><li>Still sequential, inheriting LSTM’s inability to parallelize training across time steps.</li></ul><p>This information bottleneck — the idea that everything must be squeezed into one fixed vector — is precisely the problem that the Attention Mechanism was invented to solve, by letting the decoder look back at all of the encoder&#39;s hidden states rather than just the final compressed one.</p><p><strong>Here&#39;s a visual of the Seq2Seq encoder-decoder bottleneck:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iaxWsFuOh7a57lWz8alRWw.jpeg" /></figure><h3><strong>21. Seq2Seq with Attention Mechanism</strong></h3><ul><li>Introduced by Bahdanau et al. in 2014 (and refined by Luong et al. in 2015), Attention directly solves the information bottleneck problem from basic Seq2Seq.</li><li>Instead of forcing the encoder to compress an entire sentence into one fixed-size context vector, Attention allows the decoder to look back at all of the encoder&#39;s hidden states at every decoding step, and dynamically decide which parts of the input are most relevant for generating each output word.</li></ul><p><strong>21.1 Working</strong></p><p><strong>The core idea</strong>: at each step of decoding, instead of relying on a single static context vector, the decoder computes a new, custom context vector by looking at all the encoder&#39;s hidden states and weighting them based on relevance to the current decoding step.</p><p><strong>For example</strong>, when translating &quot;Le chat est noir&quot; → &quot;The cat is black&quot;, while generating the word &quot;cat,&quot; attention should assign a high weight to the encoder&#39;s hidden state for &quot;chat&quot; and lower weights to the others.</p><p><strong>21.2 Context Vector Generation</strong></p><p>At each decoder time step t, attention is computed in three steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6hiwwpCSlbc5ou-B27srA.jpeg" /></figure><p>This context_t (different at every decoding step!) is then combined with the decoder&#39;s own hidden state to predict the next word.</p><p><strong>python</strong></p><p>import tensorflow as tf</p><p>class BahdanauAttention(tf.keras.layers.Layer):<br> def __init__(self, units):<br> super().__init__()<br> self.W1 = tf.keras.layers.Dense(units)<br> self.W2 = tf.keras.layers.Dense(units)<br> self.V = tf.keras.layers.Dense(1)</p><p>def call(self, decoder_hidden, encoder_outputs):<br> decoder_hidden_expanded = tf.expand_dims(decoder_hidden, 1)<br> score = self.V(tf.nn.tanh(self.W1(encoder_outputs) + self.W2(decoder_hidden_expanded)))<br> attention_weights = tf.nn.softmax(score, axis=1)<br> context_vector = attention_weights * encoder_outputs<br> context_vector = tf.reduce_sum(context_vector, axis=1)<br> return context_vector, attention_weights</p><p><strong>21.3 Advantages over Basic Seq2Seq</strong></p><ol><li><strong>Eliminates the fixed-size bottleneck:</strong> the decoder now has access to all encoder hidden states, not just a single compressed summary — regardless of input length.</li><li><strong>Handles long sequences far better:</strong> since the decoder can selectively focus on relevant parts of the input at each step, translation quality no longer degrades sharply as sentences get longer.</li><li><strong>Interpretability</strong>: attention weights can be visualized to see exactly which input words the model focused on when generating each output word — giving humans insight into the model’s &quot;reasoning.&quot;</li><li><strong>Improved accuracy across many NLP tasks</strong>: attention became a general-purpose mechanism, later used well beyond translation — for summarization, question answering, and image captioning.</li></ol><p><strong>The bigger realization</strong></p><ul><li>Attention was such a powerful mechanism on its own that researchers eventually asked: do we even need the RNN/LSTM at all?</li><li>What if a model built entirely out of attention mechanisms — with no recurrence at all — could process sequences even better, and in parallel?</li><li>That question led directly to the Transformer architecture, introduced in the landmark 2017 paper &quot;Attention Is All You Need,&quot; which we cover next — the architecture underlying every modern LLM.</li></ul><p><strong>Here&#39;s a visual of how attention dynamically weights encoder states while decoding:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*9Xjt2Pb7fZ4Mp0LFCHG02Q.jpeg" /></figure><h3><strong>22. Transformer Architecture</strong></h3><ul><li>Transformer, introduced in the 2017 paper &quot;Attention Is All You Need&quot; by Vaswani et al.</li><li>It discarded recurrence entirely and built a model entirely out of attention mechanisms — and this single design decision is why every major LLM today (GPT, Claude, Gemini, LLaMA) is built on some variant of this architecture.</li></ul><p><strong>22.1 Need for Transformers</strong></p><p>Recall the two remaining problems from the RNN/LSTM/GRU/Attention lineage:</p><ol><li><strong>Sequential computation</strong>: even with attention layered on top, LSTMs still process one token at a time — this can’t be parallelized, making training on huge datasets painfully slow.</li><li><strong>Long-range dependencies were still imperfect: </strong>attention helped, but the underlying recurrent structure still struggled to fully capture relationships across very long sequences.</li></ol><p><strong>Transformers solve both:</strong> by using self-attention as the core building block (instead of recurrence), the entire sequence can be processed in parallel, and every word can directly attend to every other word, regardless of distance — no more information decaying as it passes through many sequential steps.</p><p><strong>22.2 Encoder–Decoder Architecture</strong></p><ul><li>Like Seq2Seq, the Transformer has an encoder stack and a decoder stack — but each is built from stacked layers of self-attention and feed-forward networks rather than recurrent cells.</li><li>The encoder processes the entire input sequence at once (all positions in parallel) and produces a rich contextual representation for every token.</li><li>The decoder generates the output sequence, attending to both its own previous outputs (masked self-attention) and the encoder’s output (cross-attention).</li></ul><p><strong>22.3 Self-Attention</strong></p><p>Self-attention lets each word in a sequence look at every other word (including itself) and decide how much to &quot;attend to&quot; each one when building its own representation. For every token, three vectors are computed via learned weight matrices:</p><ul><li><strong>Query (Q):</strong> what this word is &quot;looking for&quot;</li><li><strong>Key (K):</strong> what this word &quot;offers&quot; as relevant information</li><li><strong>Value (V):</strong> the actual content this word contributes if attended to</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*qqEhzRNiOxBDnlgJUEVWXQ.jpeg" /></figure><p><strong>22.4 Multi-Head Attention</strong></p><ul><li>Instead of computing self-attention just once, Transformers run it multiple times in parallel (&quot;heads&quot;), each with its own learned Q, K, V projections.</li><li>Each head can learn to focus on different types of relationships (e.g., one head might track grammatical agreement, another might track long-range topical relevance).</li><li>The outputs from all heads are concatenated and projected back to the original dimension.</li></ul><p><strong>22.5 Positional Encoding</strong></p><ul><li>Since Transformers process all tokens in parallel (no recurrence), they have no inherent sense of word order.</li><li>To fix this, a positional encoding vector is added to each word’s embedding, injecting information about its position in the sequence, typically using sine and cosine functions of different frequencies.</li></ul><p><strong>22.6 Feed Forward Network</strong></p><ul><li>After the attention sub-layer, each token’s representation passes through an identical position-wise feed-forward network (applied independently to each position) — typically two linear layers with a ReLU (or GELU) activation in between.</li></ul><p><strong>22.7 Residual Connections</strong></p><ul><li>Each sub-layer (attention, feed-forward) has a residual (skip) connection around it.</li><li>The input to the sub-layer is added to its output, x + Sublayer(x).</li><li>This helps gradients flow more easily through deep stacks of layers during training, preventing the vanishing gradient issues that plagued deep RNNs.</li></ul><p><strong>22.8 Layer Normalization</strong></p><ul><li>Layer Normalization is applied after each residual connection, normalizing the values across the feature dimension for each token.</li><li>This stabilizes training and speeds up convergence, especially important given how deep Transformer stacks can get (dozens of layers in modern LLMs).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*xpXyMF7xc76x1Hy_zdbhWw.jpeg" /></figure><p>This combination — parallel training, direct long-range connections, and stackable depth — is exactly why Transformers scaled up into today&#39;s massive Large Language Models.</p><p><strong>Here&#39;s a visual of the full Transformer block:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*fN8hcMHEhjGZ6M4Gu3OF4w.jpeg" /></figure><h3><strong>23. Supervised Fine-Tuning (SFT) Pipeline</strong></h3><ul><li>Transformers gave us the architecture, but a raw Transformer trained only to predict the next word (a base LLM) doesn’t automatically behave like a helpful assistant.</li><li>Supervised Fine-Tuning (SFT) is the process that turns a raw, general-purpose language model into something like ChatGPT or Claude — a model that follows instructions and produces useful, well-formatted responses.</li></ul><p><strong>23.1 Base LLM</strong></p><ul><li>A base LLM is a Transformer that has been pretrained on a massive corpus of text (books, websites, code, etc.) using a simple next-token prediction objective — given some text, predict the next word.</li><li>This process, called pretraining, teaches the model grammar, facts, reasoning patterns, and a broad understanding of language — but the model isn&#39;t yet tuned to follow instructions.</li><li>If you ask a base LLM a question, it might just continue the text in an unhelpful way (e.g., generating more questions, rather than answering) — it&#39;s completing text, not conversing.</li></ul><p><strong>23.2 Instruction Dataset</strong></p><ul><li>To teach the model how to be a helpful assistant, we need a dataset of (instruction, ideal response) pairs — examples showing exactly what a good response to a given prompt looks like.</li></ul><p>{<br> &quot;instruction&quot;: &quot;Explain photosynthesis in simple terms.&quot;,<br> &quot;response&quot;: &quot;Photosynthesis is how plants make their own food using sunlight, water, and carbon dioxide, producing oxygen as a byproduct...&quot;<br>}</p><ul><li>These datasets are typically created by human annotators writing high-quality responses, or by using an existing strong model to generate candidate responses that are then reviewed and curated.</li></ul><p><strong>23.3 Tokenization</strong></p><p>Before training, both the instruction and the response are converted into tokens using the model&#39;s tokenizer (typically a subword tokenizer like Byte Pair Encoding — conceptually related to the n-gram idea from FastText, but used to split text into vocabulary units for the model itself).</p><p><strong>python</strong></p><p>from transformers import AutoTokenizer</p><p>tokenizer = AutoTokenizer.from_pretrained(&quot;gpt2&quot;)<br>tokens = tokenizer(&quot;Explain photosynthesis in simple terms.&quot;)<br>print(tokens[&quot;input_ids&quot;])</p><p><strong>23.4 Fine-Tuning</strong></p><ul><li>During fine-tuning, the base LLM&#39;s weights are further updated (starting from the pretrained weights, not from scratch) using the instruction dataset.</li><li>The model is trained to predict the ideal response, given the instruction — using the same next-token prediction objective as pretraining, but now on curated (instruction, response) pairs rather than raw internet text.</li></ul><p><strong>python</strong></p><p>import tensorflow as tf<br>from transformers import TFAutoModelForCausalLM</p><p>model = TFAutoModelForCausalLM.from_pretrained(&quot;gpt2&quot;)<br>optimizer = tf.keras.optimizers.Adam(learning_rate=5e-5)</p><p>model.compile(optimizer=optimizer, loss=model.hf_compute_loss)<br>model.fit(train_dataset, epochs=3) # train_dataset built from tokenized instruction pairs</p><ul><li>Since fine-tuning a full LLM is very compute-intensive, in practice, techniques like LoRA (Low-Rank Adaptation) are often used to update only a small number of additional parameters rather than the entire model — making fine-tuning far cheaper while still achieving strong results.</li></ul><p>23.5 Evaluation</p><p>After fine-tuning, the model&#39;s outputs are evaluated — both with automated metrics (which we cover in detail in the next and final topic) and, often, human evaluation, where people rate response quality, helpfulness, and safety. Many modern pipelines also add a further stage called RLHF (Reinforcement Learning from Human Feedback) after SFT, to better align model outputs with human preferences — but SFT is the essential first step that establishes basic instruction-following behavior.</p><p>23.6 Deployment</p><p>Once fine-tuned and evaluated, the model is optimized for inference (e.g., via quantization, which reduces the precision of model weights to make it faster and cheaper to run) and deployed behind an API or application — this is the model you interact with when using a chatbot like ChatGPT or Claude.</p><p>Base LLM (next-token prediction on raw text)</p><p>↓</p><p>+ Instruction dataset<br>Supervised Fine-Tuning<br> ↓<br>Evaluation (automated metrics + human feedback)<br> ↓<br>Deployment (optimized, served via API/app)</p><p>This pipeline is what bridges the gap between &quot;a model that predicts text&quot; and &quot;a model that behaves like a helpful assistant.&quot; To properly evaluate how well a model is performing at each stage — whether it&#39;s translation quality, summarization quality, or general text generation — we need standardized evaluation metrics, which brings us to our final topic.</p><p><strong>Here&#39;s a visual of the SFT pipeline:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*IT1MIrzz9PcvBLdylY9l3A.jpeg" /></figure><h3><strong>24. Evaluation Metrics</strong></h3><ul><li>We&#39;ve traced the full journey from Bag of Words to fine-tuned Transformers — now we close with the metrics used to actually measure how well these models perform.</li><li>Different NLP tasks call for different metrics, since &quot;quality&quot; means different things for translation, summarization, and classification.</li></ul><p><strong>24.1 BLEU (Bilingual Evaluation Understudy)</strong></p><p>Used primarily for machine translation, BLEU measures how much a generated translation overlaps with one or more human reference translations, based on matching n-grams (sequences of consecutive words).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*opB-7YweRnXat5fMXuU-ng.jpeg" /></figure><p><strong>python</strong></p><p>from nltk.translate.bleu_score import sentence_bleu</p><p>reference = [[&quot;the&quot;, &quot;cat&quot;, &quot;is&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;]]<br>candidate = [&quot;the&quot;, &quot;cat&quot;, &quot;sat&quot;, &quot;on&quot;, &quot;the&quot;, &quot;mat&quot;]<br>score = sentence_bleu(reference, candidate)<br>print(score) # e.g. 0.68</p><ul><li>BLEU is widely used but has known weaknesses — it only checks surface-level word overlap, so a grammatically correct paraphrase with different wording can score poorly, even if the meaning is perfectly preserved.</li></ul><p><strong>24.2 ROUGE (Recall-Oriented Understudy for Gisting Evaluation)</strong></p><ul><li>Used primarily for summarization, ROUGE measures overlap between a generated summary and reference summary — but focuses on recall (how much of the reference content is captured), unlike BLEU&#39;s precision focus.</li></ul><ol><li><strong>ROUGE-N</strong>: n-gram overlap (similar to BLEU, but recall-oriented)</li><li><strong>ROUGE-L</strong>: based on the Longest Common Subsequence between generated and reference text.</li></ol><p><strong>python</strong></p><p>from rouge_score import rouge_scorer</p><p>scorer = rouge_scorer.RougeScorer([&#39;rouge1&#39;, &#39;rougeL&#39;], use_stemmer=True)<br>scores = scorer.score(&quot;the cat sat on the mat&quot;, &quot;the cat is on the mat&quot;)<br>print(scores)</p><p><strong>24.3 Perplexity</strong></p><p>Used to evaluate language models directly (how well a model predicts text), perplexity measures how &quot;surprised&quot; a model is by the actual next word — lower perplexity means the model assigns higher probability to the correct continuation, indicating better language modeling.</p><p><strong>python</strong></p><p>import tensorflow as tf</p><p># Given cross-entropy loss from a language model:<br>loss = 2.3 # example cross-entropy loss value<br>perplexity = tf.exp(loss)<br>print(perplexity.numpy())</p><p># e.g. ~9.97</p><p><strong>24.4 Precision, Recall, F1-Score</strong></p><p>These are the classic classification metrics, used for tasks like sentiment analysis, spam detection, and Named Entity Recognition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*wV-eHb1MEDF0EUNi_rmPmQ.jpeg" /></figure><p><strong>python</strong></p><p>from sklearn.metrics import precision_score, recall_score, f1_score</p><p>y_true = [1, 0, 1, 1, 0]<br>y_pred = [1, 0, 0, 1, 1]</p><p>print(precision_score(y_true, y_pred))<br>print(recall_score(y_true, y_pred))<br>print(f1_score(y_true, y_pred))</p><p><strong>24.5 Accuracy</strong></p><p>Accuracy is simply the proportion of correct predictions out of all predictions — straightforward, but only meaningful when classes are reasonably balanced (a 95%-accurate spam filter isn&#39;t impressive if 95% of emails aren&#39;t spam to begin with).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*ywVzDiyEb8ARzttSR3Yhhw.jpeg" /></figure><p><strong>Here’s a visual summary of which metric fits which task:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wdxHveNKjhHQ43BKuKFDQ.jpeg" /></figure><h3><strong>Conclusion</strong></h3><ul><li>NLP&#39;s evolution has been a steady march toward representations that are denser, more contextual, and more scalable — from sparse one-hot vectors, to static embeddings that capture meaning, to</li><li>Transformer-based models that understand words in the full context of a sentence and can be fine-tuned into helpful assistants.</li><li>Each technique in this article existed to fix a specific limitation of the one before it — and understanding that chain of &quot;why&quot; is what turns a list of algorithms into a real grasp of how modern NLP came to be.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZC2XwpmBIfIn_iC46kz2HA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07fda2c28c8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizers in Deep Learning Made Simple: A Beginner’s Guide to Gradient Descent, Momentum, AdaGrad…]]></title>
            <link>https://medium.com/@shreyarjoshi1995/optimizers-in-deep-learning-made-simple-a-beginners-guide-to-gradient-descent-momentum-adagrad-4d4220cfd849?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d4220cfd849</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Mon, 22 Jun 2026 11:48:21 GMT</pubDate>
            <atom:updated>2026-06-22T11:48:21.820Z</atom:updated>
            <content:encoded><![CDATA[<h3>Optimizers in Deep Learning Made Simple: A Beginner’s Guide to Gradient Descent, Momentum, AdaGrad, RMSProp, and Adam</h3><p>Artificial Intelligence powers everything from Netflix recommendations to ChatGPT. But have you ever wondered how a neural network actually learns?</p><p>The answer lies in a component called an <strong>optimizer</strong>.</p><p>Think of training a neural network as trying to find the lowest point in a valley while blindfolded. The optimizer acts as a guide, helping the model take the right steps toward the lowest point, also known as the minimum loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NefOM05gxLuqKn2J8vmiaQ.png" /></figure><p>In this article, we’ll break down the most popular optimizers in the simplest possible way.</p><h3>Why Do We Need Optimizers?</h3><p>Imagine you’re standing on a mountain and trying to reach the bottom.</p><p>You cannot see the entire landscape. The only thing you know is the slope around you.</p><p>So what would you do?</p><p>You would take small steps downhill until you reach the lowest point.</p><p>This is exactly how neural networks learn.</p><h3>What Does an Optimizer Actually Do?</h3><p>During training, the model makes predictions.</p><p>The predictions are compared with actual values using a loss function.</p><p>The optimizer then asks:</p><blockquote><em>“How should I change the weights so that the error becomes smaller?”</em></blockquote><p>The answer comes from gradients.</p><p>A gradient tells us:</p><ul><li>Which direction to move</li><li>How much to move</li></ul><p>The optimizer uses this information to update weights.</p><h3>1. Gradient Descent: The Foundation of Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*_BwTwQHjBip31P78tAPAkQ.png" /></figure><p>Gradient Descent is the simplest optimization algorithm.</p><p>It calculates the error and moves the weights in the opposite direction of that error.</p><p>Think of it as walking downhill step by step.</p><h3>Formula</h3><p>Weight Update:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*7PTqugG47Shpo4Rx-vXIhQ.png" /></figure><h3>Advantages</h3><p>✔ Simple</p><p>✔ Easy to implement</p><p>✔ Easy to understand</p><h3>Limitations</h3><p>✘ Slow</p><p>✘ Uses the entire dataset every time</p><p>✘ Can get stuck</p><h3>When to Use</h3><ul><li>Learning concepts</li><li>Small datasets</li></ul><h3>2. Mini-Batch Gradient Descent: Learning in Small Chunks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*jKeZlsk3gCjGKFFj6DANYg.png" /></figure><p>Imagine studying a 1000-page book.</p><p>Instead of reading the entire book at once, you study 20 pages at a time.</p><p>That’s exactly what Mini-Batch Gradient Descent does.</p><h3>Why Is It Better?</h3><p>Because:</p><ul><li>Faster training</li><li>Uses less memory</li><li>Works well on GPUs</li></ul><p>This is why most modern deep learning systems use mini-batches.</p><h3>Limitations</h3><p>✘ Batch size must be chosen carefully</p><p>✘ Updates can be noisy</p><h3>3. Momentum: Adding Speed to Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hUNck8iLBExNJowD" /></figure><p>Imagine pushing a heavy ball down a hill.</p><p>The ball gradually gains speed and keeps moving forward.</p><p>Momentum works the same way.</p><p>Instead of relying only on the current gradient, it remembers previous gradients.</p><p>This memory helps the model move faster toward the minimum.</p><h3>Why Momentum Helps</h3><p>Without momentum:</p><ul><li>The optimizer zigzags</li></ul><p>With momentum:</p><ul><li>Movement becomes smoother</li><li>Convergence becomes faster</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*DLXSwNtXeNeJbkLZghu5Ng.png" /></figure><h3>Advantages</h3><p>✔ Faster learning</p><p>✔ Less oscillation</p><p>✔ Better convergence</p><h3>Limitations</h3><p>✘ One extra parameter to tune</p><h3>4. AdaGrad: Different Learning Rates for Different Weights</h3><p>Imagine two students.</p><p>Student A learns quickly.</p><p>Student B learns slowly.</p><p>Would you teach both students at the same speed?</p><p>Probably not.</p><p>AdaGrad thinks the same way.</p><p>Instead of giving every parameter the same learning rate, it adapts learning rates individually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*oCsJBFtTlHV2A_gS" /></figure><h3>Main Idea</h3><p>Frequently updated parameters:</p><p>⬇ Smaller learning rate</p><p>Rarely updated parameters:</p><p>⬆ Larger learning rate</p><h3>Advantages</h3><p>✔ Great for sparse data</p><p>✔ Automatic learning rate adjustment</p><h3>Limitations</h3><p>✘ Learning rate keeps shrinking</p><p>✘ Training may stop too early</p><h3>5. RMSProp: Fixing AdaGrad’s Biggest Problem</h3><p>AdaGrad reduces learning rates continuously.</p><p>Eventually, learning becomes extremely slow.</p><p>RMSProp solves this problem.</p><p>Instead of storing all past gradients, it remembers only recent gradients.</p><h3>Why RMSProp Works Better</h3><p>It prevents learning rates from becoming too small.</p><p>As a result:</p><ul><li>Training remains stable</li><li>Learning continues longer</li></ul><h3>Advantages</h3><p>✔ Stable learning</p><p>✔ Faster convergence</p><p>✔ Popular for RNNs</p><h3>Limitations</h3><p>✘ Requires tuning</p><h3>6. Adam Optimizer: The Best of Both Worlds</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*cLgSrjzq-YoUy-_9" /></figure><p>Adam stands for:</p><p><strong>Adaptive Moment Estimation</strong></p><p>It combines:</p><ul><li>Momentum</li><li>RMSProp</li></ul><p>Think of Adam as a sports car.</p><p>It has:</p><ul><li>Speed (Momentum)</li><li>Control (RMSProp)</li></ul><h3>Why Adam Is So Popular</h3><p>Adam:</p><ul><li>Learns quickly</li><li>Handles noisy data</li><li>Requires little tuning</li></ul><p>That’s why Adam is often the default optimizer in TensorFlow and PyTorch.</p><h3>Advantages</h3><p>✔ Fast</p><p>✔ Reliable</p><p>✔ Adaptive learning rates</p><p>✔ Works for most tasks</p><h3>Limitations</h3><p>✘ Uses more memory</p><p>✘ Sometimes SGD generalizes better</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1mmy7rHKnREFeCR4vRd2xQ.png" /></figure><h3>Which Optimizer Should You Choose?</h3><h3>Use Gradient Descent if:</h3><ul><li>Learning concepts</li><li>Small datasets</li></ul><h3>Use Mini-Batch GD if:</h3><ul><li>Training standard neural networks</li></ul><h3>Use Momentum if:</h3><ul><li>Training is unstable</li><li>Loss oscillates heavily</li></ul><h3>Use AdaGrad if:</h3><ul><li>Data is sparse</li></ul><h3>Use RMSProp if:</h3><ul><li>Working with RNNs or time-series</li></ul><h3>Use Adam if:</h3><ul><li>Unsure where to start</li><li>Building modern deep learning models</li></ul><h3>Conclusion</h3><p>Optimizers are the driving force behind neural network learning. While Gradient Descent laid the foundation, modern optimizers such as RMSProp and Adam significantly improve convergence speed and stability.</p><p>For most real-world applications, <strong>Adam remains the first choice</strong> because it combines adaptive learning rates with momentum, providing fast and reliable training. However, understanding all optimizers is important because different datasets and architectures may benefit from different optimization strategies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d4220cfd849" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activation Functions in Deep Learning: A Complete Guide]]></title>
            <link>https://medium.com/@shreyarjoshi1995/activation-functions-in-deep-learning-a-complete-guide-2cc25cf9ef0a?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cc25cf9ef0a</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Mon, 22 Jun 2026 10:58:30 GMT</pubDate>
            <atom:updated>2026-06-22T10:58:30.584Z</atom:updated>
            <content:encoded><![CDATA[<p>Why neural networks can’t learn without them — and how to choose between Sigmoid, Tanh, ReLU, and Softmax.</p><h3>Why do we need activation functions?</h3><p>A neural network without activation functions is just a chain of matrix multiplications. No matter how many layers you stack, the entire network collapses into a single linear transformation — identical in expressive power to a one-layer model with no hidden units at all.</p><p>Activation functions introduce <em>non-linearity</em> after each layer’s weighted sum. This single addition unlocks the ability to learn curves, complex boundaries, and relationships that no straight line can capture.</p><p><strong>The universal approximation theorem</strong> states that a neural network with at least one hidden layer containing a non-linear activation can approximate any continuous function — given enough neurons. Without non-linearity, this theorem breaks down entirely.</p><h3>Linear vs non-linear activations</h3><p>A <strong>linear</strong> activation f(x) = x passes the weighted sum straight through. Stacking N linear layers is mathematically equivalent to one linear layer: W₃(W₂(W₁x)) = Wx. No depth benefit whatsoever.</p><p>A <strong>non-linear</strong> activation breaks this collapse. Each layer can now learn a qualitatively different representation — edges in layer 1, shapes in layer 2, objects in layer 3. This hierarchical feature learning is the superpower of deep networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*5IQcvK584dJc2st0TbtZaw.png" /></figure><p><strong>Impact on learning:</strong> Non-linearity allows backpropagation to flow meaningful gradients through many layers, enabling the network to tune millions of weights toward a solution. The choice of activation function directly affects gradient magnitude, training stability, convergence speed, and the final model’s capacity to generalize.</p><h3>Sigmoid, Tanh, ReLU, and Softmax — explored interactively</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*R2Dzjjs844LvwedXXuWFJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*wU1R3-gyV2xFGTi02CQeTA.png" /></figure><p>Sigmoid squashes any real number into (0, 1), giving a clean probabilistic interpretation. Once the go-to hidden-layer activation, it fell out of favour due to the vanishing gradient problem — when |x| is large the gradient approaches zero and backpropagation stalls. Still the standard choice for binary classification output layers.</p><p><strong>✓ Advantages</strong></p><p>Smooth and differentiable everywhere</p><p>Clear probabilistic output (0 to 1)</p><p>Ideal for binary classification outputs</p><p>Works well in LSTM gate mechanisms</p><p><strong>✗ Disadvantages</strong></p><p>Vanishing gradient — saturates at both tails</p><p>Not zero-centered — slows learning in hidden layers</p><p>Computationally expensive (exponential)</p><p>Causes slow convergence in deep networks</p><p><strong>Common use cases</strong></p><p>Binary classification output</p><p>Logistic regression</p><p>LSTM gates</p><p>Attention score squashing</p><h3>Side-by-side comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*NDr3ledQ9YWqw-yFLZKkLA.png" /></figure><h3>Which activation function should you use?</h3><p>The right choice depends on where in the network you are, what problem you’re solving, and what failure modes you’re willing to tolerate.</p><p><strong>Hidden layers (most architectures)</strong>CNNs, transformers, MLPs — need fast training and deep networks?</p><p>→ ReLU</p><p><strong>Hidden layers (RNNs / LSTMs)</strong>Recurrent networks where zero-centering helps convergence?</p><p>→ Tanh</p><p><strong>Output — binary classification</strong>Need a single probability between 0 and 1?</p><p>→ Sigmoid</p><p><strong>Output — multi-class classification</strong>Need mutually exclusive class probabilities that sum to 1?</p><p>→ Softmax</p><p><strong>Dying ReLU problem</strong>Neurons permanently outputting zero during training?</p><p>→ Leaky ReLU / ELU</p><p><strong>Regression / unbounded output</strong>Output layer where values can be any real number?</p><p>→ Linear (no activation)</p><p><strong>Rule of thumb:</strong></p><p>Start with ReLU in all hidden layers. Use Sigmoid for binary outputs, Softmax for multi-class outputs. Switch to Tanh for gates and recurrent units. If you observe dead neurons with ReLU, try Leaky ReLU or ELU instead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cc25cf9ef0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Networks Made Simple: A Beginner’s Guide to Weights, Biases, Activation Functions, and MLPs]]></title>
            <link>https://medium.com/@shreyarjoshi1995/neural-networks-made-simple-a-beginners-guide-to-weights-biases-activation-functions-and-mlps-5ce7f06a6da3?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ce7f06a6da3</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 12:13:56 GMT</pubDate>
            <atom:updated>2026-06-19T12:13:56.879Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence is everywhere today — from Netflix recommendations to ChatGPT and self-driving cars. But behind all these applications lies a powerful concept called an Artificial Neural Network (ANN).</p><p>If terms like weights, bias, perceptron, and activation functions sound confusing, don’t worry. In this article, we’ll break them down in the simplest possible way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A_q1bnU78fdUxjEL" /></figure><h3>1. Weights and Bias</h3><h3>How a Neural Network Makes Decisions</h3><p>Imagine you’re buying a laptop.</p><p>You may consider:</p><ul><li>Price</li><li>Battery life</li><li>Brand reputation</li></ul><p>Not all factors are equally important.</p><p>For example:</p><ul><li>Price → Very Important</li><li>Battery → Important</li><li>Brand → Less Important</li></ul><p>The importance given to each factor is called a <strong>Weight</strong>.</p><h3>What is Bias?</h3><p>Now imagine you already love a particular brand.</p><p>Even before comparing specifications, you’re slightly inclined toward that brand.</p><p>This built-in preference is called <strong>Bias</strong>.</p><h3>Simple Diagram</h3><pre>Price --------\<br>Battery -------&gt; [Neuron] ---&gt; Decision<br>Brand --------/</pre><pre>Weights decide importance<br>Bias adds a starting preference</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zEpnNYan7MZP-or8" /></figure><h3>Key Takeaway</h3><ul><li>Weight = Importance of an input</li><li>Bias = Extra adjustment that helps make better decisions</li></ul><h3>2. Why Do Neural Networks Need Activation Functions?</h3><p>Let’s say a student studies more and gets better marks.</p><p>That’s a simple straight-line relationship.</p><p>But real life is rarely that simple.</p><p>Examples:</p><ul><li>Image recognition</li><li>Speech recognition</li><li>Disease prediction</li></ul><p>These problems contain complex patterns.</p><p>A neural network needs a way to learn those patterns.</p><p>That is where activation functions help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i83uLnguMePxuMki" /></figure><h3>Think of It Like a Light Switch</h3><p>A neuron first calculates a value.</p><p>Then the activation function decides:</p><ul><li>Should this neuron be active?</li><li>How strongly should it respond?</li></ul><h3>ReLU Activation Function</h3><pre>Input  -5  ---&gt; Output 0<br>Input   3  ---&gt; Output 3</pre><h3>Simple Diagram</h3><pre>Input<br>  ↓<br>Weighted Sum<br>  ↓<br>Activation Function<br>  ↓<br>Output</pre><h3>Why Activation Functions Matter</h3><p>Without activation functions:</p><ul><li>Deep networks become useless</li><li>Multiple layers behave like a single layer</li><li>Complex patterns cannot be learned</li></ul><h3>3. Single Layer Perceptron: The First Neural Network</h3><p>The perceptron is the simplest neural network ever created.</p><p>It contains:</p><ul><li>Input Layer</li><li>Output Layer</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kM7_JtOADy2DEvpl" /></figure><h3>Architecture</h3><pre>Input 1 ----\<br>             \<br>Input 2 ------&gt; Output<br>             /<br>Input 3 ----/</pre><h3>How It Learns</h3><p>Step 1: Make a prediction</p><p>Step 2: Compare with actual answer</p><p>Step 3: Adjust weights</p><p>Step 4: Repeat</p><p>This process helps the perceptron improve over time.</p><h3>Advantages</h3><p>✔ Easy to understand</p><p>✔ Fast training</p><p>✔ Works well for simple problems</p><h3>Limitations</h3><p>✘ Cannot solve complex problems</p><p>✘ Cannot solve XOR problem</p><p>✘ Only learns straight-line patterns</p><h3>4. Multi-Layer Perceptron (MLP): Adding Hidden Layers</h3><p>Scientists realized that a single perceptron wasn’t powerful enough.</p><p>So they added hidden layers.</p><p>This created the Multi-Layer Perceptron (MLP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*-K-sPBofFMbSWEq4" /></figure><h3>Architecture</h3><pre>Input Layer<br>      ↓<br>Hidden Layer<br>      ↓<br>Output Layer</pre><h3>Why Hidden Layers Matter</h3><p>Hidden layers help the network learn:</p><ul><li>Shapes</li><li>Patterns</li><li>Relationships</li></ul><p>For example:</p><p>In face recognition:</p><ul><li>First layer learns edges</li><li>Next layer learns eyes and nose</li><li>Final layer recognizes a face</li></ul><h3>Simple MLP Diagram</h3><pre>● ● ●  →  ● ● ● ●  →  ●<br>Input      Hidden      Output</pre><h3>5. Feedforward Neural Networks</h3><p>A Feedforward Neural Network sends information in only one direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/0*pm9x0OaanXKDsKze" /></figure><pre>Input → Hidden Layer → Output</pre><p>Information never moves backward during prediction.</p><p>Think of it like water flowing through a pipe.</p><p>It only moves forward.</p><h3>Real-Life Applications</h3><h3>Healthcare</h3><p>Disease prediction</p><h3>Finance</h3><p>Fraud detection</p><h3>E-commerce</h3><p>Product recommendations</p><h3>Computer Vision</h3><p>Face recognition</p><h3>6. Common Neural Network Terms You Should Know</h3><h3>Neuron</h3><p>A small processing unit that receives input and produces output.</p><pre>Input → Neuron → Output</pre><h3>Layer</h3><p>A group of neurons.</p><h3>Types</h3><ul><li>Input Layer</li><li>Hidden Layer</li><li>Output Layer</li></ul><h3>Epoch</h3><p>One complete pass through the training dataset.</p><p>Example:</p><p>1000 records trained once = 1 Epoch</p><h3>Parameters</h3><p>Values learned by the network.</p><p>Examples:</p><ul><li>Weights</li><li>Biases</li></ul><h3>Hyperparameters</h3><p>Values chosen before training.</p><p>Examples:</p><ul><li>Learning Rate</li><li>Number of Epochs</li><li>Batch Size</li><li>Number of Hidden Layers</li></ul><h3>Final Thoughts</h3><p>Artificial Neural Networks may sound complicated, but they are built using a few simple ideas:</p><ul><li>Weights decide importance.</li><li>Bias provides flexibility.</li><li>Activation functions help learn complex patterns.</li><li>Hidden layers make deep learning possible.</li><li>Feedforward networks move information from input to output.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ce7f06a6da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Deep Learning and Neural Networks]]></title>
            <link>https://medium.com/@shreyarjoshi1995/introduction-to-deep-learning-and-neural-networks-a52832a02c7d?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a52832a02c7d</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Fri, 19 Jun 2026 11:39:34 GMT</pubDate>
            <atom:updated>2026-06-19T11:39:34.486Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Brain to Machine: How Neurons Inspired Artificial Intelligence</h3><h3>Understanding the Biological Neuron</h3><p>Your brain contains roughly <strong>86 billion neurons</strong>. Every thought you have, every memory you hold, every emotion you feel — all of it is the result of these tiny cells talking to each other.</p><p>So what exactly is a neuron, and how does it work?</p><h3>Structure of a Neuron</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*QJ5sOrfOGvbE2nfQzsLD1g.png" /></figure><p>Fig 1. Structure of a biological neuron</p><p>A neuron has three main parts:</p><p><strong>Dendrites</strong> are the antenna-like branches that receive signals from other neurons. Think of them as the ears of the cell — always listening for incoming messages.</p><p><strong>The Cell Body (Soma)</strong> contains the nucleus. It receives all the incoming signals from dendrites, adds them up, and decides: <em>Should I fire a signal or not?</em></p><p><strong>The Axon</strong> is the long wire that carries the electrical signal away.</p><h3>How Learning Happens in the Brain</h3><p>When you practice a skill repeatedly, the neurons involved fire together again and again. The connection between them physically strengthens — becoming faster and more reliable. This is called <strong>synaptic plasticity</strong>.</p><p>This is the biological basis of memory and learning. And it directly inspired how artificial neural networks learn — by adjusting the strength of connections (weights).</p><h3>From Brain to Machine: The Analogy</h3><p>In the 1940s, scientists Warren McCulloch and Walter Pitts looked at the biological neuron and asked: <em>Can we model this mathematically?</em></p><p>They realized the neuron was doing a very simple computation: receive inputs → add them up → if the sum is big enough, fire an output. This became the <strong>artificial neuron</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*GjbVAT2F384JUYB6xzktog.png" /></figure><p>Fig 2. Biological neuron vs Artificial neuron — the analogy</p><h3>The McCulloch-Pitts (MCP) Neuron — The World’s First Artificial Neuron</h3><p>In <strong>1943</strong>, Warren McCulloch (neuroscientist) and Walter Pitts (mathematician) published a groundbreaking paper. They mathematically modeled the neuron for the first time — giving birth to what we now call Artificial Intelligence.</p><h3>Key Rules of the MCP Neuron</h3><p>The MCP neuron has simple, strict rules:</p><ul><li>Inputs are <strong>binary only</strong> — either 0 (off) or 1 (on)</li><li>Output is also binary — 0 or 1</li><li>All weights are fixed at 1 (no learning yet)</li><li>You set a <strong>threshold (θ)</strong> manually</li><li>Some inputs can be <strong>inhibitory</strong> (they suppress firing)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*y4I3-SkrqhjPatQjmAqjog.png" /></figure><p>Fig 3. The McCulloch-Pitts (MCP) Neuron model</p><p>The key insight was revolutionary: <strong>logical thought can be modeled mathematically.</strong> By choosing different threshold values (θ), this simple model can compute logical operations like AND, OR, and NAND.</p><h3>Implementing Logic Gates Using MCP Neurons</h3><p>Logic gates are the building blocks of every computer. They take binary inputs (0s and 1s) and produce a binary output. Let’s see how an MCP neuron can implement them — and where it fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*BXL6H4qEWI64mjy6rmiG4Q.png" /></figure><p>Fig 4. Logic gates implemented with MCP neurons — and why XOR fails</p><h3>AND Gate (θ = 2)</h3><p>Set the threshold to 2. The neuron only fires when <strong>both</strong> inputs are 1 (giving a sum of 2). If either input is 0, the sum stays below 2 and the neuron stays quiet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*8UMuDjAJs3m6c9fSutLbuw.png" /></figure><h3>OR Gate (θ = 1)</h3><p>Set the threshold to 1. Now any single input being 1 is enough to fire. The neuron stays quiet only when <strong>both</strong> inputs are 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*1wmdtMF2l_4zIjHidqFWQw.png" /></figure><h3>NAND Gate (Inhibitory inputs, θ = −1)</h3><p>NAND is the opposite of AND. We use <strong>inhibitory inputs</strong> (they subtract instead of add). The neuron fires in all cases <em>except</em> when both inputs are 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*LOFOd6plnmQHpprs22yn3w.png" /></figure><h3>Why XOR Cannot Be Done by a Single MCP Neuron</h3><p>XOR outputs 1 only when <strong>exactly one</strong> input is 1 — not when both are 1 or both are 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*tcyY61qFm7g7LjdchjFC3Q.png" /></figure><p>If you plot these four points on a graph, the 1s and 0s are arranged <strong>diagonally</strong>. You cannot draw a single straight line that separates them. This is called the <strong>linear separability problem</strong>.</p><p>An MCP neuron creates exactly <strong>one straight decision boundary</strong>. AND, OR, and NAND are linearly separable — you can separate their outputs with one line. XOR is not — the green and purple dots in the diagram above are diagonal from each other, with no single line that separates them.</p><p>This limitation was formally proven by Minsky &amp; Papert in their 1969 book <em>Perceptrons</em>, temporarily halting AI research for years — the so-called “AI Winter.”</p><p>The solution was <strong>multi-layer networks</strong>. By stacking neurons into hidden layers, neural networks can create complex, non-linear boundaries and solve any problem — including XOR. This became the foundation of modern <strong>Deep Learning</strong>.</p><h3>Key Takeaways</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*Svwf43FfSsWs93te_e8jOg.png" /></figure><h3>What’s Next?</h3><p>The MCP neuron couldn’t learn — you had to set the threshold manually. The next breakthrough was the <strong>Perceptron</strong> (Frank Rosenblatt, 1958), which added adjustable weights and a learning rule. After that came backpropagation, convolutional networks, and eventually transformers — the technology behind modern AI like ChatGPT.</p><p>It all traces back to McCulloch, Pitts, and one humble biological neuron.</p><p>If you found this helpful, consider following for more beginner-friendly AI explainers. 👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a52832a02c7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding the Best Fit Line: A Visual Guide to Linear Regression]]></title>
            <link>https://medium.com/@shreyarjoshi1995/finding-the-best-fit-line-a-visual-guide-to-linear-regression-575466119344?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/575466119344</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Tue, 12 May 2026 12:54:56 GMT</pubDate>
            <atom:updated>2026-05-12T12:54:56.156Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Published on Medium · Machine Learning · Data Science · 5 min read</em></p><h3>Introduction</h3><p>Imagine you have a scatter plot — dozens of dots floating in space, each representing a house (its size on x, its price on y). Your goal: draw <em>one straight line</em> that best summarises the relationship between the two. That line is what linear regression finds, and it’s one of the most powerful ideas in all of data science.</p><p>In this post, we’ll explore:</p><ul><li>What the “best fit line” actually means</li><li>The mathematics behind finding it (Ordinary Least Squares)</li><li>How residuals (errors) tell you how good the fit is</li><li>What R² means and why it matters</li></ul><p>Let’s go.</p><h3>What Is Linear Regression?</h3><p>Linear regression is a <strong>supervised learning algorithm</strong> that models the relationship between one or more input features (x) and a continuous output (y) using a straight line.</p><p>The model equation is:</p><pre>ŷ = β₀ + β₁ · x</pre><p>Where:</p><ul><li><strong>ŷ</strong> is the predicted value of y</li><li><strong>β₀</strong> is the intercept (where the line crosses the y-axis)</li><li><strong>β₁</strong> is the slope (how much y changes per unit of x)</li></ul><p>The key insight: we’re not drawing a line that passes <em>through</em> every point. We’re drawing a line that gets <em>as close as possible</em> to all of them simultaneously.</p><h3>Residuals: The Language of Error</h3><p>For each data point (xᵢ, yᵢ), the model predicts ŷᵢ = β₀ + β₁·xᵢ.</p><p>The difference between the actual value and the prediction is called the <strong>residual</strong>:</p><pre>eᵢ = yᵢ − ŷᵢ</pre><p>A positive residual means the point sits above the line. A negative residual means it’s below. The <em>total error</em> of the model is captured by the <strong>Sum of Squared Errors (SSE)</strong>:</p><pre>SSE = Σᵢ (yᵢ − ŷᵢ)²</pre><p>We square the errors for two reasons:</p><ol><li>To make all errors positive (so positive and negative don’t cancel)</li><li>To penalise large errors more heavily than small ones</li></ol><p><strong>The best fit line is the line that minimises SSE.</strong> This approach is called Ordinary Least Squares (OLS).</p><h3>Finding the Optimal Parameters</h3><p>Because SSE is a convex quadratic function of β₀ and β₁, it has a single global minimum. We can find it analytically by taking partial derivatives and setting them to zero.</p><p>The closed-form solutions are:</p><pre>β₁ = Σ[(xᵢ − x̄)(yᵢ − ȳ)] / Σ[(xᵢ − x̄)²]</pre><pre>β₀ = ȳ − β₁ · x̄</pre><p>Where x̄ and ȳ are the means of x and y respectively.</p><p>This is remarkable: no iteration required, no learning rate to tune. Given any dataset, you can compute the exact optimal line in one pass.</p><h3>Understanding R²: How Good Is the Fit?</h3><p>Once we have our line, we need to measure how well it fits. The most common metric is the <strong>coefficient of determination</strong>, R²:</p><pre>R² = 1 − (SSE / SST)</pre><p>Where SST (Total Sum of Squares) = Σ(yᵢ − ȳ)² measures total variance in y.</p><p>Interpretation:</p><ul><li><strong>R² = 1.0</strong> → perfect fit (the line explains all variance)</li><li><strong>R² = 0.8</strong> → the model explains 80% of the variance in y</li><li><strong>R² = 0.0</strong> → the model does no better than predicting the mean</li></ul><p>A high R² is encouraging, but it doesn’t mean the model will generalise well — always check for overfitting and validate on unseen data.</p><h3>Key Assumptions of Linear Regression</h3><p>Linear regression works best when these assumptions hold:</p><ol><li><strong>Linearity</strong> — the relationship between x and y is truly linear</li><li><strong>Independence</strong> — observations are independent of each other</li><li><strong>Homoscedasticity</strong> — residuals have constant variance across all x</li><li><strong>Normality of residuals</strong> — errors follow a normal distribution</li><li><strong>No multicollinearity</strong> — (for multiple regression) input features aren’t highly correlated</li></ol><p>Always check these via residual plots and statistical tests before trusting your model’s predictions.</p><h3>When to Use Linear Regression</h3><p>Linear regression is a great starting point when:</p><ul><li>Your target variable is continuous (price, temperature, score)</li><li>You expect a roughly linear relationship</li><li>You need interpretable results (the slope tells a clear story)</li><li>You want a baseline model to beat with more complex algorithms</li></ul><p>It struggles when the relationship is non-linear, when outliers are extreme, or when the assumptions above are heavily violated.</p><h3>Conclusion</h3><p>The best fit line isn’t magic — it’s the result of minimising a well-defined objective function. By understanding the geometry of residuals and the algebra of OLS, you gain intuition that carries forward to neural networks, SVMs, and every model you’ll ever build.</p><p>The line is just the beginning. Master it, visualise it, question it — and you’ll have a foundation that makes every more complex algorithm click faster.</p><p><em>Found this helpful? Clap, share, and follow for more visual guides to machine learning fundamentals.</em></p><p><em>Tags: #MachineLearning #DataScience #LinearRegression #Python #Statistics #AI</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*BVpaoaN3lQlUOxYiviElOQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=575466119344" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Machine Learning Pipeline: A Complete Guide from Raw Data to Production]]></title>
            <link>https://medium.com/@shreyarjoshi1995/the-machine-learning-pipeline-a-complete-guide-from-raw-data-to-production-db10dc0da40e?source=rss-7eb9dbb0199d------2</link>
            <guid isPermaLink="false">https://medium.com/p/db10dc0da40e</guid>
            <dc:creator><![CDATA[Shreyarjoshi]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 10:00:20 GMT</pubDate>
            <atom:updated>2026-04-15T10:00:20.211Z</atom:updated>
            <content:encoded><![CDATA[<p>Every successful ML model is the result of a well-structured pipeline. Here’s what that journey actually looks like — and how to navigate each step.</p><p>Published: April 14, 2026 · 12 min read<br>Tags: Machine Learning, Data Science, Engineering</p><p>— What Is an ML Pipeline?</p><p>A machine learning pipeline is a structured, sequential workflow that transforms raw, unprocessed data into a trained, evaluated, and deployed model. Each stage feeds into the next, and — critically — the pipeline is designed to be automated, repeatable, and monitorable.</p><p>Think of it like an assembly line in manufacturing. Each station has a defined job. Nothing moves to the next stage until the current one meets quality standards. And when something breaks, you know exactly which station to inspect.</p><p>The 7 Stages:<br>Data Collection → EDA &amp; Analysis → Preprocessing → Feature Engineering → Model Training → Evaluation → Deployment &amp; Monitoring</p><p>— -</p><p><strong>Stage 1 — Data Collection</strong></p><p>Every pipeline begins with data. The quality and quantity of your data will ultimately determine the ceiling of your model’s performance — no algorithm can compensate for poor data.</p><p>Data can come from internal databases, public datasets, web scraping, APIs, sensors, user logs, or third-party providers. The key questions at this stage are: Is the data representative? Is it sufficient in volume? Is it legally permissible to use?</p><p><em>Tools: SQL / NoSQL, REST APIs, Scrapy, Kaggle Datasets, AWS S3, Apache Kafka</em></p><p><em>Pro tip: Always document where your data came from, when it was collected, and any known biases. This becomes invaluable during debugging and auditing.</em></p><p><em>— -</em></p><p><strong>Stage 2 — Exploratory Data Analysis (EDA)</strong></p><p>Before writing a single line of modeling code, you must understand your data deeply. EDA involves computing summary statistics, visualizing distributions, identifying outliers, checking for class imbalances, and uncovering correlations between variables.</p><p>This stage is largely exploratory — you are asking questions, not yet answering them. What does the target variable look like? Are there missing values? Do any features have near-zero variance? Are numeric features normally distributed or heavily skewed?</p><p><em>Tools: Pandas, Matplotlib, Seaborn, Plotly, Sweetviz, ydata-profiling</em></p><p>— -</p><p><strong>Stage 3 — Data Preprocessing</strong></p><p>Raw data is almost never ready for a model. Preprocessing transforms messy, inconsistent input into a clean, structured dataset your algorithms can actually learn from. This includes:</p><p>Handling missing values — imputation with mean/median/mode, forward fill for time-series, or model-based imputation. Sometimes dropping rows or columns is the right call.</p><p>Encoding categorical variables — label encoding, one-hot encoding, or target encoding depending on cardinality and model type.</p><p>Scaling and normalization — standardization (zero mean, unit variance) or min-max scaling for algorithms sensitive to feature magnitudes like SVMs and neural networks.</p><p>Dealing with outliers — capping (Winsorization), log transformation, or removal based on domain knowledge.</p><p><em>Tools: Scikit-learn Pipelines, NumPy, Pandas, Great Expectations</em></p><p><em>“Data preprocessing is not a chore — it is where your domain expertise and engineering rigor meet. Getting this right is what separates decent models from great ones.”</em></p><p>— -</p><p><strong>Stage 4 — Feature Engineering</strong></p><p>Feature engineering is the art of transforming raw variables into inputs that help models learn better. It is perhaps the most creative — and high-impact — part of the pipeline.</p><p>This includes creating interaction features (multiplying two variables), polynomial features, date-time decomposition (extracting hour, day of week, month), text vectorization (TF-IDF, embeddings), and domain-specific aggregations (rolling averages, lag features for time series).</p><p>Feature selection then trims the set — removing redundant or low-signal features using correlation analysis, mutual information, or model-based importance scores. Fewer, better features usually beat more, noisier ones.</p><p><em>Tools: Featuretools, Scikit-learn, tsfresh, SHAP, SelectKBest</em></p><p>— -</p><p><strong>Stage 5 — Model Training</strong></p><p>With clean, engineered features in hand, you now select and train your model. The choice of algorithm depends on problem type (classification, regression, clustering, ranking), interpretability requirements, dataset size, and latency constraints.</p><p>Start simple — logistic regression, decision trees, or gradient boosting before jumping to neural networks. Always split your data into training, validation, and test sets before any modeling to prevent data leakage. Use cross-validation to get robust performance estimates.</p><p>Hyperparameter tuning — via grid search, random search, or Bayesian optimization — squeezes out additional performance after you have a working baseline.</p><p><em>Tools: Scikit-learn, XGBoost, LightGBM, PyTorch, TensorFlow, Optuna, MLflow</em></p><p><em>Key principle: Track every experiment. Log your hyperparameters, metrics, and dataset versions. You will thank yourself when you need to reproduce a result three weeks later.</em></p><p>— -</p><p><strong>Stage 6 — Model Evaluation</strong></p><p>Accuracy alone is almost never the right metric. Evaluation must be tied to business objectives. For classification: precision, recall, F1-score, AUC-ROC. For regression: MAE, RMSE, MAPE. For ranking: NDCG, MAP.</p><p>Beyond aggregate metrics, examine your model’s behavior on subgroups — fairness analysis. Check calibration: does a model that says “70% probability” actually be right 70% of the time? Visualize the confusion matrix, residuals, and learning curves to diagnose overfitting or underfitting.</p><p>Only use your test set once. Evaluating on the test set repeatedly is a form of data leakage that inflates your confidence in generalization.</p><p><strong>Tools: Scikit-learn metrics, SHAP, LIME, Evidently AI, Fairlearn</strong></p><p>— -</p><p><strong>Stage 7 — Deployment &amp; Monitoring</strong></p><p>A model that only lives in a notebook delivers zero value. Deployment packages your trained model behind a real-time REST API or embeds it in a batch processing pipeline, making predictions accessible to applications and users.</p><p>Modern deployment uses containerization (Docker) and orchestration (Kubernetes) for scalability. CI/CD pipelines automate retraining and redeployment when performance degrades. Shadow deployment and A/B testing allow safe rollouts.</p><p>Monitoring is not optional — it is the difference between a one-time project and a reliable product. Track prediction distributions, latency, error rates, and business KPIs. Implement drift detection to catch when incoming data no longer resembles training data.</p><p><em>Tools: FastAPI, Docker, Kubernetes, BentoML, Seldon Core, Prometheus, Grafana, Vertex AI</em></p><p>— -</p><p><strong>Wrapping Up</strong></p><p>The machine learning pipeline is the backbone of every successful AI system. Master it, and you move from writing ad-hoc scripts to engineering reliable, production-grade systems that create real value.</p><p>The seven stages — data collection, EDA, preprocessing, feature engineering, model training, evaluation, and deployment — each require care, tooling, and domain judgment. None can be skipped.</p><p>Start with a simple, end-to-end pipeline on your next project. Then optimize. The discipline of running a full pipeline — even a rough one — will teach you more than any isolated technique ever will.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PXXZQCsSWwY5ZQ3t.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db10dc0da40e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>