<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ananya S</title>
    <description>The latest articles on Forem by Ananya S (@zeroshotanu).</description>
    <link>https://forem.com/zeroshotanu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3559285%2F9f65e9ac-1144-435e-89ff-159025586c6c.png</url>
      <title>Forem: Ananya S</title>
      <link>https://forem.com/zeroshotanu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/zeroshotanu"/>
    <language>en</language>
    <item>
      <title>🚀 I Built an AI-Powered Fest Assistant with Agents, RAG &amp; Planning (Pragyan @ NITT)</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Tue, 14 Apr 2026 17:57:01 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/i-built-an-ai-powered-fest-assistant-with-agents-rag-planning-pragyan-nitt-44e9</link>
      <guid>https://forem.com/zeroshotanu/i-built-an-ai-powered-fest-assistant-with-agents-rag-planning-pragyan-nitt-44e9</guid>
      <description>&lt;p&gt;I deleted Instagram more than a year ago, and honestly, it saved me from a lot of distractions.&lt;/p&gt;

&lt;p&gt;But there was an unexpected downside.&lt;/p&gt;

&lt;p&gt;A lot of informal, real-time information — especially during college events — still lives there.&lt;/p&gt;

&lt;p&gt;During our college fest, for example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Event schedules&lt;/li&gt;
&lt;li&gt;Last-minute updates&lt;/li&gt;
&lt;li&gt;Food stall announcements&lt;/li&gt;
&lt;li&gt;Informal activities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;…everything gets posted on Instagram.&lt;/p&gt;

&lt;p&gt;At the same time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fest details and significance are on the official website&lt;/li&gt;
&lt;li&gt;Food stall info is on a separate app&lt;/li&gt;
&lt;li&gt;The entire 3-day schedule is compressed into a few posts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There’s no single place to get a clear, structured view of everything.&lt;/p&gt;

&lt;p&gt;And that’s when it hit me:&lt;/p&gt;

&lt;p&gt;Most college fests have websites.&lt;br&gt;
Some even have apps.&lt;/p&gt;

&lt;p&gt;But none of them actually &lt;strong&gt;help you navigate the fest intelligently.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They give information.&lt;br&gt;
They don’t give guidance.&lt;/p&gt;

&lt;p&gt;But I wanted to build something smarter —&lt;br&gt;
an &lt;strong&gt;AI assistant that actually understands queries, plans your day, and even helps you find teammates.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, I built &lt;strong&gt;Pragyan Mentor Assistant&lt;/strong&gt; — an AI-powered system for navigating a techno-managerial fest.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Problem
&lt;/h2&gt;

&lt;p&gt;During college fests like Pragyan (NIT Trichy):&lt;br&gt;
There are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are &lt;strong&gt;dozens of events, workshops, and shows&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Information is scattered across PDFs, sites, and posters&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Users don’t know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what to attend&lt;/li&gt;
&lt;li&gt;what matches their interests&lt;/li&gt;
&lt;li&gt;how to plan their time&lt;/li&gt;
&lt;li&gt;who to team up with&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;👉 Traditional apps = static information&lt;br&gt;
👉 I wanted &lt;strong&gt;intelligent interaction&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Solution
&lt;/h2&gt;

&lt;p&gt;I built a &lt;strong&gt;multi-tool AI assistant&lt;/strong&gt; that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🎉 Answer questions about events, workshops, proshows&lt;/li&gt;
&lt;li&gt;🍔 Show food stalls &amp;amp; mess menu&lt;/li&gt;
&lt;li&gt;🧠 Recommend activities based on user intent&lt;/li&gt;
&lt;li&gt;📅 Plan your schedule&lt;/li&gt;
&lt;li&gt;🤝 Match you with like-minded participants/Suggest potential teammates (prototype)&lt;/li&gt;
&lt;li&gt;📚 Answer fest-related questions using RAG&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 System Design
&lt;/h2&gt;

&lt;p&gt;Instead of a simple chatbot, I designed it as a &lt;strong&gt;tool-using agent system&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fetch_events&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fetch_workshops&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fetch_food_stall&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fetch_mess_menu&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pragyan_bot&lt;/code&gt; (RAG-based)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;smart_recommender&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;planner&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;buddy_matcher&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🔹 Agent Flow
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;User query&lt;/li&gt;
&lt;li&gt;LLM decides:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Which tool to call

&lt;ol&gt;
&lt;li&gt;Tool executes&lt;/li&gt;
&lt;li&gt;Response is generated in natural language&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📚 Retrieval Approach
&lt;/h3&gt;

&lt;p&gt;This system uses a hybrid retrieval strategy at the system level:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Structured retrieval (keyword-based)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Direct tool calls for events/workshops&lt;/li&gt;
&lt;li&gt;Fast and deterministic&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Semantic retrieval (RAG)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vector search over fest documents&lt;/li&gt;
&lt;li&gt;Handles open-ended queries&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;👉 This combination allows both precision and flexibility&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 RAG (Retrieval Augmented Generation)
&lt;/h2&gt;

&lt;p&gt;To handle fest knowledge:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text files (events, shows, lectures, FAQs)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Built:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FAISS vector store&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Retrieval:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Semantic search on query&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Response:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Context-aware answers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 Memory
&lt;/h2&gt;

&lt;p&gt;Using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;InMemorySaver()&lt;/code&gt; (LangGraph)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Enables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;remembering user preferences&lt;/li&gt;
&lt;li&gt;better recommendations&lt;/li&gt;
&lt;li&gt;conversational continuity&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🤖 Smart Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🎯 Recommendations
&lt;/h3&gt;

&lt;p&gt;Understands intent like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What should I attend if I like tech and fun?"&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  📅 Planner Agent
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;"Plan my next 3 hours"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Generates a structured schedule based on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;time&lt;/li&gt;
&lt;li&gt;interests&lt;/li&gt;
&lt;li&gt;available events&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🤝 Buddy Matching (Prototype)
&lt;/h3&gt;

&lt;p&gt;Matches based on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;interests&lt;/li&gt;
&lt;li&gt;level&lt;/li&gt;
&lt;li&gt;context (e.g. case study competitions)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Uses a small dataset to demonstrate logic&lt;/p&gt;




&lt;h2&gt;
  
  
  🖥️ UI
&lt;/h2&gt;

&lt;p&gt;Built with &lt;strong&gt;Streamlit&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chat-based interface&lt;/li&gt;
&lt;li&gt;Quick action buttons&lt;/li&gt;
&lt;li&gt;Structured responses&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Deployment
&lt;/h2&gt;

&lt;p&gt;Deployed on Render (free tier)&lt;br&gt;
Environment variables for API security&lt;/p&gt;




&lt;p&gt;&lt;a href="" class="article-body-image-wrapper"&gt;&lt;img width="100%"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎥 Demo
&lt;/h2&gt;

&lt;p&gt;👉 &lt;a href="https://www.loom.com/share/13f87025a9154a55b80fc240bfc91ba2" rel="noopener noreferrer"&gt;https://www.loom.com/share/13f87025a9154a55b80fc240bfc91ba2&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;LangChain&lt;/li&gt;
&lt;li&gt;OpenAI API&lt;/li&gt;
&lt;li&gt;FAISS&lt;/li&gt;
&lt;li&gt;Streamlit&lt;/li&gt;
&lt;li&gt;Render&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚠️ Challenges Faced
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RAG retrieval quality (chunking + parsing issues)&lt;/li&gt;
&lt;li&gt;Tool selection accuracy&lt;/li&gt;
&lt;li&gt;Structuring multi-agent workflow&lt;/li&gt;
&lt;li&gt;Deployment + API key handling&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔄 Ongoing Improvements
&lt;/h2&gt;

&lt;p&gt;Some features I’m actively working on:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adding database-backed user profiles for real buddy matching&lt;/li&gt;
&lt;li&gt;Improving RAG with better retrieval and evaluation&lt;/li&gt;
&lt;li&gt;Expanding dataset coverage for more complete fest information&lt;/li&gt;
&lt;li&gt;Exploring true hybrid retrieval + reranking&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  📈 What I Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Building &lt;strong&gt;agents &amp;gt; building chatbots&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;RAG needs &lt;strong&gt;data structuring, not just embeddings&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;UI matters a lot for perceived intelligence&lt;/li&gt;
&lt;li&gt;Deployment and debugging are part of the real challenge&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔗 Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🔒 Live demo available on request&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💭 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This project made me realize:&lt;/p&gt;

&lt;p&gt;👉 The future isn’t just about LLMs&lt;br&gt;
👉 It’s about &lt;strong&gt;systems built around them&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;If you have suggestions or ideas to improve this, I’d love to hear them!&lt;/p&gt;




</description>
      <category>ai</category>
      <category>python</category>
      <category>langchain</category>
      <category>rag</category>
    </item>
    <item>
      <title>Stop Calling FAISS a Database: The VectorStore vs. VectorDB Showdown🧠⚡</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Tue, 17 Mar 2026 16:40:58 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/stop-calling-faiss-a-database-the-vectorstore-vs-vectordb-showdown-4g94</link>
      <guid>https://forem.com/zeroshotanu/stop-calling-faiss-a-database-the-vectorstore-vs-vectordb-showdown-4g94</guid>
      <description>&lt;p&gt;If you’ve been building with LangChain, you’ve probably used Chroma or FAISS and called them "databases." But in a production environment, that distinction could be the difference between a smooth app and a total system crash.&lt;/p&gt;

&lt;p&gt;As AI Engineers, we need to know when to use a lightweight VectorStore and when to upgrade to a full Vector Database.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a VectorStore? (The Engine)
&lt;/h2&gt;

&lt;p&gt;A VectorStore is a specialized data structure or a local library. Its primary job is simple: Calculate the distance between vectors as fast as possible.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Best for&lt;/em&gt;: Prototypes, local research, and small datasets.&lt;br&gt;
&lt;em&gt;Pros&lt;/em&gt;: Zero latency (runs in-process), easy to set up, free.&lt;br&gt;
&lt;em&gt;Cons&lt;/em&gt;: If your app restarts, your data might vanish (if not saved to disk). It doesn't scale across multiple servers easily.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Popular Choice&lt;/em&gt;: FAISS (by Meta). It's incredibly fast but lacks "database" features like user authentication or real-time updates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.vectorstores&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAIEmbeddings&lt;/span&gt;

&lt;span class="c1"&gt;# 1. Initialize Embeddings
&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# 2. Create the VectorStore (In-memory)
&lt;/span&gt;&lt;span class="n"&gt;texts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AI is transforming civil engineering&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;LangChain is a framework for LLMs&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;vector_store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_texts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;texts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 3. Search (Fast, but only local)
&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What is LangChain?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vector_store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;similarity_search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 4. Persistence (Manual step required)
&lt;/span&gt;&lt;span class="n"&gt;vector_store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save_local&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;my_faiss_index&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="c1"&gt;# To use it later, you must load_local() manually
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is a Vector Database? (The Full System)
&lt;/h2&gt;

&lt;p&gt;A Vector Database is a production-ready management system. It uses a vector store under the hood but wraps it in the features we expect from enterprise software.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Best for:&lt;/em&gt; Production apps, multi-user systems, and massive datasets (millions of vectors).&lt;/p&gt;

&lt;p&gt;The "Extras" you get:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Persistence&lt;/em&gt;: Your data lives on a server, not just in your RAM.&lt;br&gt;
&lt;em&gt;Metadata Filtering&lt;/em&gt;: The ability to say "Find similar vectors, but only for documents created in 2024."&lt;br&gt;
&lt;em&gt;Scalability&lt;/em&gt;: It can handle billions of vectors by spreading them across different "pods" or nodes.&lt;/p&gt;

&lt;p&gt;Popular Choice: Pinecone or Weaviate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_pinecone&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PineconeVectorStore&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pinecone&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pinecone&lt;/span&gt;

&lt;span class="c1"&gt;# 1. Initialize Cloud Client
&lt;/span&gt;&lt;span class="n"&gt;pc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pinecone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_PINECONE_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;index_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;my-production-index&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# 2. Connect to the Index (Data lives on Pinecone's servers)
&lt;/span&gt;&lt;span class="n"&gt;vector_db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PineconeVectorStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_texts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;texts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;B.Tech students at NITT are building AI agents&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;embedding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;index_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;index_name&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 3. Search (API Call to the cloud)
# Anyone with the API key can now query this from any device
&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vector_db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;similarity_search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Who is building agents?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Observation&lt;/strong&gt;: There is no "save" step. The moment you run from_texts, the data is permanently stored in the cloud. You can delete your local code, and the data remains accessible.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;VectorStore (e.g., FAISS, Chroma)&lt;/th&gt;
&lt;th&gt;Vector Database (e.g., Pinecone, Milvus)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Architecture&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A library that runs &lt;strong&gt;inside&lt;/strong&gt; your application code.&lt;/td&gt;
&lt;td&gt;A standalone &lt;strong&gt;distributed system&lt;/strong&gt; running on a server.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Persistence&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mostly &lt;strong&gt;In-Memory&lt;/strong&gt;. Data is lost when the script ends.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Persistent by default&lt;/strong&gt;. Data is stored on cloud/disk.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scalability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited by your machine's &lt;strong&gt;RAM/Disk&lt;/strong&gt;. Hard to scale.&lt;/td&gt;
&lt;td&gt;Built for &lt;strong&gt;Horizontal Scaling&lt;/strong&gt;. Handles billions of vectors.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multi-tenancy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No built-in support for isolated users.&lt;/td&gt;
&lt;td&gt;High. Supports multiple users and &lt;strong&gt;isolated indexes&lt;/strong&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CRUD Operations&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hard to update specific vectors without rebuilding.&lt;/td&gt;
&lt;td&gt;Full &lt;strong&gt;Create, Read, Update, Delete&lt;/strong&gt; support via API.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Metadata&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Basic filtering capabilities.&lt;/td&gt;
&lt;td&gt;Advanced &lt;strong&gt;Metadata Filtering&lt;/strong&gt; (e.g., Filter by date).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Free&lt;/strong&gt; (Uses your local resources).&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Tiered&lt;/strong&gt;. Free tiers available, then paid.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Let's Discuss!&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Are you currently using a local store like Chroma or have you made the jump to a cloud database? What's the biggest challenge you've faced with vector scaling? Drop a comment below! 👇&lt;/p&gt;

</description>
      <category>ai</category>
      <category>langchain</category>
      <category>vectordatabase</category>
      <category>python</category>
    </item>
    <item>
      <title>Decoding Embedding Models: Why Your RAG Is Only as Good as Your Vectors 🚀</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Mon, 09 Mar 2026 17:36:43 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/decoding-embedding-models-why-your-rag-is-only-as-good-as-your-vectors-4k0n</link>
      <guid>https://forem.com/zeroshotanu/decoding-embedding-models-why-your-rag-is-only-as-good-as-your-vectors-4k0n</guid>
      <description>&lt;p&gt;As an AI Engineer, the first major decision you make in a RAG (Retrieval-Augmented Generation) pipeline isn't which LLM to use—it's which Embedding Model will represent your data. If your vectors are low-quality, your retrieval will fail, and even a top-tier LLM can't save a response based on the wrong context.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ What exactly is an Embedding?
&lt;/h2&gt;

&lt;p&gt;Embedding models take text tokens and map them into a multi-dimensional coordinate system (vectors).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Dimensions&lt;/em&gt;&lt;/strong&gt;: These represent the "features" the model understands. Different models represent words in vectors of different dimensions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Semantic Proximity&lt;/em&gt;&lt;/strong&gt;: In a good model, the vector for "King" and "Queen" will be mathematically closer than "King" and "Keyboard."&lt;/p&gt;

&lt;h2&gt;
  
  
  🌟 Popular Embedding Models: Hugging Face
&lt;/h2&gt;

&lt;p&gt;Hugging Face models are the go-to for privacy, local deployment, and cost-efficiency. Here are the top picks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. all-MiniLM-L6-v2&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 384&lt;br&gt;
Description: Fast, efficient, and good quality.&lt;br&gt;
Use Case: General purpose; ideal for real-time applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. all-mpnet-base-v2&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 768&lt;br&gt;
Description: The best quality in the MiniLM family, though slower than L6. More dimensions lead to an improvement in accuracy.&lt;br&gt;
Use Case: When quality matters more than speed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;3. all-MiniLM-L12-v2&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 384&lt;br&gt;
Description: Slightly better than L6 but a bit slower.&lt;br&gt;
Use Case: A solid balance of speed and quality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;4. multi-qa-MiniLM-L6-cos-v1&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 384&lt;br&gt;
Description: Optimized specifically for question-answering.&lt;br&gt;
Use Case: Q&amp;amp;A systems and semantic search.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;5. paraphrase-multilingual-MiniLM-L12-v2&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 384&lt;br&gt;
Description: Supports 50+ languages.&lt;br&gt;
Use Case: Global and multilingual applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  💰 The OpenAI Standard
&lt;/h2&gt;

&lt;p&gt;If you need massive scale and the highest "reasoning" in your vectors without managing infrastructure:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;text-embedding-3-small&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Dimensions: 1536&lt;br&gt;
Cost: ~$0.02 per 1M tokens.&lt;br&gt;
Description: Highly cost-effective with improved accuracy over older models. It also supports Matryoshka Representation Learning, allowing you to trim dimensions (e.g., to 512) to save storage costs without losing much performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. text-embedding-3-large&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 3072&lt;br&gt;
Cost: ~$0.13 per 1M tokens.&lt;br&gt;
Description: The most powerful model available. It captures incredibly fine-grained nuances in text.&lt;br&gt;
Feature: Like the "small" version, it supports Matryoshka Representation Learning, which means you can shorten the vector to 256 or 1024 dimensions to save database space while keeping most of the accuracy.&lt;br&gt;
Use Case: Enterprise-level research, legal document analysis, or complex medical data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;3. text-embedding-ada-002&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dimensions: 1536&lt;br&gt;
Cost: ~$0.10 per 1M tokens.&lt;br&gt;
Description: The previous industry standard. While still reliable, it is now considered legacy compared to the "v3" family.&lt;br&gt;
Use Case: Mostly seen in older "legacy" AI systems. For any new project in 2026, you should skip this and go straight to text-embedding-3-small.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚖️ How to Choose?
&lt;/h2&gt;

&lt;p&gt;Strict Privacy/On-Prem? ➔ Hugging Face (Local).&lt;/p&gt;

&lt;p&gt;Real-time/Low Latency? ➔ all-MiniLM-L6-v2.&lt;/p&gt;

&lt;p&gt;Multilingual Data? ➔ paraphrase-multilingual-MiniLM-L12-v2.&lt;/p&gt;

&lt;p&gt;Enterprise Scale &amp;amp; Accuracy? ➔ text-embedding-3-small.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Conclusion
&lt;/h2&gt;

&lt;p&gt;In 2026, picking the right embedding model is about balancing latency, cost, and accuracy. Don't just pick the one with the most dimensions—pick the one that fits your specific data and hardware.&lt;/p&gt;

&lt;p&gt;What's your go-to embedding model for production? Let's discuss in the comments!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>vectordatabase</category>
      <category>python</category>
      <category>langchain</category>
    </item>
    <item>
      <title>🧠 Your LLM Isn’t an Agent — Until It Has Tools, Memory, and Structure (LangChain Deep Dive)</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Mon, 02 Mar 2026 17:09:48 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/your-llm-isnt-an-agent-until-it-has-tools-memory-and-structure-langchain-deep-dive-18d8</link>
      <guid>https://forem.com/zeroshotanu/your-llm-isnt-an-agent-until-it-has-tools-memory-and-structure-langchain-deep-dive-18d8</guid>
      <description>&lt;p&gt;Most “AI apps” today are just:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Prompt → LLM → Text Response&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s not an agent.&lt;/p&gt;

&lt;p&gt;That’s autocomplete with branding.&lt;/p&gt;

&lt;p&gt;A real AI agent can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🛠 Use tools&lt;/li&gt;
&lt;li&gt;🧠 Remember context&lt;/li&gt;
&lt;li&gt;📦 Return structured outputs&lt;/li&gt;
&lt;li&gt;🔁 Reason across multiple steps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With modern LangChain, building this is surprisingly clean.&lt;/p&gt;

&lt;p&gt;Let’s build one properly.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 The Architecture of a Real Agent
&lt;/h2&gt;

&lt;p&gt;A production-ready AI agent has four core components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Model&lt;/strong&gt; – the brain&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools&lt;/strong&gt; – capabilities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structured outputs&lt;/strong&gt; – reliability and formatting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory&lt;/strong&gt; – continuity&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you’re missing one of these, you’re not building a system — you’re running a demo.&lt;/p&gt;




&lt;h2&gt;
  
  
  1️⃣ The Brain: Modern Agent Setup
&lt;/h2&gt;

&lt;p&gt;We start with &lt;code&gt;create_agent()&lt;/code&gt; — the current way to build agents in LangChain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.agents&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;create_agent&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ChatOpenAI&lt;/span&gt;

&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChatOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Low temperature = more deterministic reasoning.&lt;/p&gt;

&lt;p&gt;Now let’s give it capabilities.&lt;/p&gt;




&lt;h2&gt;
  
  
  2️⃣ Tools: Giving the Agent Superpowers
&lt;/h2&gt;

&lt;p&gt;Tools are just Python functions with clear docstrings.&lt;br&gt;
The docstring matters — it’s how the model decides when to use the tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.tools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tool&lt;/span&gt;

&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_revenue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Calculate total revenue given price per unit and quantity sold.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;


&lt;span class="nd"&gt;@tool&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_exchange_rate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Get the USD exchange rate for a given currency code.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;rates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;EUR&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GBP&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.25&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rates&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we assemble the agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;calculate_revenue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;get_exchange_rate&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;system_prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You are a financial analysis assistant.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;The agent now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decides when math is needed&lt;/li&gt;
&lt;li&gt;Calls tools autonomously&lt;/li&gt;
&lt;li&gt;Observes results&lt;/li&gt;
&lt;li&gt;Produces a final answer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No manual routing logic.&lt;/p&gt;




&lt;h2&gt;
  
  
  3️⃣ Structured Outputs: Stop Parsing Strings
&lt;/h2&gt;

&lt;p&gt;If you're still doing regex on LLM responses, stop.&lt;/p&gt;

&lt;p&gt;Modern agents can return structured data using schemas.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FinancialReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;revenue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;
    &lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;usd_value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we enforce structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;structured_agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;calculate_revenue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;get_exchange_rate&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;response_format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;FinancialReport&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when you invoke:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;structured_agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I sold 120 units at 50 EUR each. Convert to USD.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don’t get text.&lt;/p&gt;

&lt;p&gt;You get validated data.&lt;br&gt;
Using Pydantic structured output parsers ensures the datatype of the fields is based on how we defined it.&lt;/p&gt;


&lt;h2&gt;
  
  
  4️⃣ Memory: Making the Agent Stateful
&lt;/h2&gt;

&lt;p&gt;Without memory, every request is a new message.&lt;/p&gt;

&lt;p&gt;With memory, your agent becomes a collaborator.&lt;/p&gt;

&lt;p&gt;In LangChain, memory can be plugged in via message history.&lt;/p&gt;

&lt;p&gt;Example pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;chat_history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;chat_history&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;My product costs 20 USD.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="n"&gt;chat_history&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;chat_history&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Now calculate revenue for 300 units.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the agent remembers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product price&lt;/li&gt;
&lt;li&gt;Prior discussion&lt;/li&gt;
&lt;li&gt;Contextual decisions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Memory transforms isolated responses into evolving workflows.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What’s Actually Happening Internally?
&lt;/h2&gt;

&lt;p&gt;When you call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reads conversation + system prompt&lt;/li&gt;
&lt;li&gt;Plans next action&lt;/li&gt;
&lt;li&gt;Chooses a tool (if needed)&lt;/li&gt;
&lt;li&gt;Executes tool&lt;/li&gt;
&lt;li&gt;Feeds result back into reasoning&lt;/li&gt;
&lt;li&gt;Produces structured final output&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This loop is grounded in tool-calling rather than fragile prompt tricks.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ Common Mistakes
&lt;/h2&gt;

&lt;p&gt;Things beginner devs get wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Adding too many tools&lt;/li&gt;
&lt;li&gt;❌ Writing vague tool descriptions&lt;/li&gt;
&lt;li&gt;❌ Not enforcing structured outputs&lt;/li&gt;
&lt;li&gt;❌ Forgetting observability/logging&lt;/li&gt;
&lt;li&gt;❌ Letting the agent free-run without constraints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Agents are probabilistic planners — not deterministic scripts.&lt;/p&gt;

&lt;p&gt;Design them intentionally.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗 The Big Shift in How We Build Software
&lt;/h2&gt;

&lt;p&gt;Before agents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;APIs returned static responses&lt;/li&gt;
&lt;li&gt;Business logic was deterministic&lt;/li&gt;
&lt;li&gt;LLMs were “smart text generators”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After agents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LLMs orchestrate execution&lt;/li&gt;
&lt;li&gt;Tools become capabilities&lt;/li&gt;
&lt;li&gt;Structure guarantees reliability&lt;/li&gt;
&lt;li&gt;Memory enables continuity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You're no longer building chat interfaces.&lt;/p&gt;

&lt;p&gt;You're building &lt;strong&gt;goal-driven systems&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Final Take
&lt;/h2&gt;

&lt;p&gt;If your AI system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Doesn’t use tools&lt;/li&gt;
&lt;li&gt;Doesn’t enforce structure&lt;/li&gt;
&lt;li&gt;Doesn’t maintain memory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s not an agent.&lt;/p&gt;

&lt;p&gt;It’s autocomplete with better marketing.&lt;/p&gt;

&lt;p&gt;With modern LangChain, the barrier to real agents is gone.&lt;/p&gt;

&lt;p&gt;The question isn’t &lt;em&gt;“Can we build agents?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It’s:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What workflows are we ready to automate?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Do comment how you build agents and regarding any interesting types of agents you've built!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>langchain</category>
      <category>agents</category>
    </item>
    <item>
      <title>Understanding LangChain and Vector Embeddings: The Power Duo of Modern AI Applications</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Mon, 23 Feb 2026 17:23:19 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/understanding-langchain-and-vector-embeddings-the-power-duo-of-modern-ai-applications-3g3l</link>
      <guid>https://forem.com/zeroshotanu/understanding-langchain-and-vector-embeddings-the-power-duo-of-modern-ai-applications-3g3l</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the rapidly evolving landscape of artificial intelligence and natural language processing, two technologies have emerged as fundamental building blocks for creating intelligent applications: &lt;strong&gt;LangChain&lt;/strong&gt; and &lt;strong&gt;vector embeddings&lt;/strong&gt;. Together, they form a powerful combination that enables developers to build sophisticated AI systems capable of understanding, reasoning, and generating human-like responses. This post explores both concepts and demonstrates how they work together to create the next generation of AI applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is LangChain?
&lt;/h2&gt;

&lt;p&gt;LangChain is an open-source framework designed to simplify the development of applications powered by large language models (LLMs). It provides a comprehensive set of tools, components, and abstractions that help developers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chain together&lt;/strong&gt; multiple LLM calls and other components&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrate with external data sources&lt;/strong&gt; and APIs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implement memory&lt;/strong&gt; to maintain context across interactions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create agents&lt;/strong&gt; that can make decisions and take actions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handle complex workflows&lt;/strong&gt; with ease&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At its core, LangChain acts as a bridge between raw LLM capabilities and real-world applications, providing structure and patterns for building production-ready AI systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Vector Embeddings
&lt;/h2&gt;

&lt;p&gt;Vector embeddings are numerical representations of data (typically text, but also images, audio, etc.) in a high-dimensional space. These representations capture semantic meaning and relationships between items:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Semantic similarity&lt;/strong&gt;: Items with similar meanings have similar vector representations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dimensionality&lt;/strong&gt;: Typically 1536, 768, or other dimensions depending on the model&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distance metrics&lt;/strong&gt;: Cosine similarity or Euclidean distance can measure relatedness&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, the words "king" and "queen" would have vector embeddings that are close to each other in vector space, while "king" and "banana" would be farther apart.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Embedding Models:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;OpenAI's text-embedding-ada-002&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sentence-BERT (SBERT)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hugging Face's all-MiniLM-L6-v2&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How LangChain and Vector Embeddings Work Together
&lt;/h2&gt;

&lt;p&gt;The true power emerges when LangChain integrates vector embeddings into its architecture. Here's how they complement each other:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Retrieval-Augmented Generation (RAG)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This is perhaps the most impactful combination. LangChain uses vector embeddings to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Convert documents into vector representations&lt;/li&gt;
&lt;li&gt;Store these vectors in vector databases (like Pinecone, Chroma, or FAISS)&lt;/li&gt;
&lt;li&gt;Retrieve relevant context when a user asks a question&lt;/li&gt;
&lt;li&gt;Pass the retrieved context to an LLM for generating accurate, grounded responses
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.vectorstores&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Chroma&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ChatOpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.chains&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RetrievalQA&lt;/span&gt;

&lt;span class="c1"&gt;# Create embeddings
&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Store documents in vector database
&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Chroma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create RAG chain
&lt;/span&gt;&lt;span class="n"&gt;qa_chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RetrievalQA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_chain_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;ChatOpenAI&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;retriever&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_retriever&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;return_source_documents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get answer with context
&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;qa_chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What is vector similarity search?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. &lt;strong&gt;Semantic Search and Filtering&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Vector embeddings enable LangChain to perform semantic searches rather than just keyword matching:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find documents that are conceptually similar to a query&lt;/li&gt;
&lt;li&gt;Filter results based on semantic relevance scores&lt;/li&gt;
&lt;li&gt;Group similar content automatically&lt;/li&gt;
&lt;li&gt;Identify duplicate or near-duplicate content&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Memory and Context Management&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;LangChain uses embeddings to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store conversation history as vectors&lt;/li&gt;
&lt;li&gt;Retrieve relevant past interactions based on current context&lt;/li&gt;
&lt;li&gt;Maintain long-term memory across sessions&lt;/li&gt;
&lt;li&gt;Recognize when similar situations have occurred before&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practical Use Cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Enterprise Knowledge Base&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A company can use LangChain with vector embeddings to create an intelligent knowledge base:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ingest internal documents, manuals, and policies&lt;/li&gt;
&lt;li&gt;Convert all content to vector embeddings&lt;/li&gt;
&lt;li&gt;Allow employees to ask natural language questions&lt;/li&gt;
&lt;li&gt;Retrieve relevant information and generate comprehensive answers&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Customer Support Chatbot&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Build a chatbot that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understands customer queries semantically&lt;/li&gt;
&lt;li&gt;Retrieves relevant support articles and FAQs&lt;/li&gt;
&lt;li&gt;Provides accurate, context-aware responses&lt;/li&gt;
&lt;li&gt;Learns from past interactions to improve over time&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Research Assistant&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Create a tool that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analyzes academic papers and research documents&lt;/li&gt;
&lt;li&gt;Finds connections between different research areas&lt;/li&gt;
&lt;li&gt;Summarizes complex topics based on relevant sources&lt;/li&gt;
&lt;li&gt;Recommends related papers based on semantic similarity&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementation Considerations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Choosing the Right Embedding Model&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Consider these factors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Accuracy vs. Cost&lt;/strong&gt;: OpenAI embeddings are highly accurate but costly; open-source models like all-MiniLM-L6-v2 are free but less accurate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dimensionality&lt;/strong&gt;: Higher dimensions capture more nuance but require more storage and computation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Language support&lt;/strong&gt;: Some models work better for specific languages or domains&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Vector Database Selection&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Popular options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chroma&lt;/strong&gt;: Lightweight, easy to set up, great for development&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pinecone&lt;/strong&gt;: Fully managed, scalable, production-ready&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FAISS&lt;/strong&gt;: High performance, optimized for similarity search&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance Optimization&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chunking strategy&lt;/strong&gt;: How you split documents affects retrieval quality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Indexing techniques&lt;/strong&gt;: HNSW, IVF, or other indexing methods impact speed and accuracy&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid search&lt;/strong&gt;: Combine vector search with keyword filtering for better results&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching&lt;/strong&gt;: Store frequent queries and results to reduce latency&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Code Example: Building a Simple RAG System
&lt;/h2&gt;

&lt;p&gt;Here's a complete example showing how to build a basic RAG system with LangChain and vector embeddings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.document_loaders&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TextLoader&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_text_splitters&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RecursiveCharacterTextSplitter&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.vectorstores&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Chroma&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ChatOpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.chains&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RetrievalQA&lt;/span&gt;

&lt;span class="c1"&gt;# Set up environment
&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your-api-key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;# Load and process documents
&lt;/span&gt;&lt;span class="n"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TextLoader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;knowledge_base.txt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;documents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;text_splitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RecursiveCharacterTextSplitter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chunk_overlap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;texts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text_splitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create embeddings and vector store
&lt;/span&gt;&lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAIEmbeddings&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;vectorstore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Chroma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;texts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create QA system
&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChatOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;qa_chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RetrievalQA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_chain_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;retriever&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;vectorstore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_retriever&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;return_source_documents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Query the system
&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Explain vector embeddings in simple terms&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;qa_chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Answer: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;result&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sources: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;source_documents&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Data Preparation&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Clean and preprocess text before embedding&lt;/li&gt;
&lt;li&gt;Remove noise, standardize formatting&lt;/li&gt;
&lt;li&gt;Consider domain-specific preprocessing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Evaluation Metrics&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Recall@k&lt;/strong&gt;: Percentage of relevant documents in top k results&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mean Reciprocal Rank (MRR)&lt;/strong&gt;: Quality of ranking&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Precision&lt;/strong&gt;: Relevance of retrieved results&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;End-to-end accuracy&lt;/strong&gt;: How well the final answer addresses the query&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Security and Privacy&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Be mindful of sensitive data in vector databases&lt;/li&gt;
&lt;li&gt;Implement proper access controls&lt;/li&gt;
&lt;li&gt;Consider data retention policies&lt;/li&gt;
&lt;li&gt;Be aware of embedding model biases&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Future Directions
&lt;/h2&gt;

&lt;p&gt;The intersection of LangChain and vector embeddings is rapidly evolving:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Multimodal embeddings&lt;/strong&gt;: Combining text, images, and audio embeddings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time indexing&lt;/strong&gt;: Near-instantaneous updates to knowledge bases&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-lingual capabilities&lt;/strong&gt;: Seamless understanding across languages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personalized embeddings&lt;/strong&gt;: Tailored to individual users or organizations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge deployment&lt;/strong&gt;: Running embedding models on devices&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;LangChain and vector embeddings represent a paradigm shift in how we build AI applications. By combining the power of large language models with semantic understanding through vector representations, developers can create systems that truly understand context, retrieve relevant information, and generate meaningful responses.&lt;/p&gt;

&lt;p&gt;The beauty of this combination lies in its accessibility – with the right tools and understanding, developers can build sophisticated AI applications without needing deep expertise in machine learning. As these technologies continue to evolve, we can expect even more powerful and intuitive applications that bridge the gap between human intention and machine capability.&lt;/p&gt;

&lt;p&gt;Whether you're building an enterprise knowledge base, a customer support system, or a research assistant, the LangChain + vector embeddings combination provides a robust foundation for creating intelligent, context-aware applications that deliver real value to users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LangChain Documentation&lt;/strong&gt;: &lt;a href="https://python.langchain.com" rel="noopener noreferrer"&gt;https://python.langchain.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hugging Face Embeddings&lt;/strong&gt;: &lt;a href="https://huggingface.co/models?library=sentence-transformers" rel="noopener noreferrer"&gt;https://huggingface.co/models?library=sentence-transformers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pinecone&lt;/strong&gt;: &lt;a href="https://www.pinecone.io" rel="noopener noreferrer"&gt;https://www.pinecone.io&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What use cases are you exploring with LangChain and vector embeddings? Share your experiences in the comments below!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>langchain</category>
      <category>vectordatabase</category>
      <category>rag</category>
    </item>
    <item>
      <title>🚀 Stop Hallucinating! Build a RAG Chatbot in 5 Minutes with LangChain</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Mon, 09 Feb 2026 18:03:48 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/stop-hallucinating-build-a-rag-chatbot-in-5-minutes-with-langchain-5da9</link>
      <guid>https://forem.com/zeroshotanu/stop-hallucinating-build-a-rag-chatbot-in-5-minutes-with-langchain-5da9</guid>
      <description>&lt;p&gt;Ever asked an AI about something that happened yesterday, only for it to confidently lie to your face? That’s because LLMs are frozen in time—limited by their training data.&lt;/p&gt;

&lt;p&gt;Enter RAG (Retrieval-Augmented Generation). It’s like giving your AI an open-book exam. Instead of guessing, it looks up the answer in your documents first.&lt;/p&gt;

&lt;p&gt;In this post, we’re building a simple RAG pipeline using LangChain. Let’s dive in! 🏊‍♂️&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 &lt;strong&gt;The "Big Idea"&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;RAG works in three simple steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Index&lt;/strong&gt;: Chop your documents into small "chunks" and turn them into math (vectors).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retrieve&lt;/strong&gt;: When a user asks a question, find the chunks that match best.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Augment&lt;/strong&gt;: Stuff those chunks into the prompt and let the AI summarize them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️The Setup&lt;/strong&gt;&lt;br&gt;
You'll need a few libraries. Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install langchain langchain-openai langchain-community chromadb pypdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💻 &lt;strong&gt;The Code&lt;/strong&gt;&lt;br&gt;
Here is a complete, minimal script to chat with a PDF. Replace "your_api_key" with your actual OpenAI key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_openai import OpenAIEmbeddings, ChatOpenAI
from langchain_community.vectorstores import Chroma
from langchain.chains import RetrievalQA

# 1. Set your API Key
os.environ["OPENAI_API_KEY"] = "sk-..."

# 2. Load your data (Change this to your PDF path!)
loader = PyPDFLoader("my_awesome_doc.pdf")
data = loader.load()

# 3. Chop it up! (Chunking)
# We split text so the AI doesn't get overwhelmed.
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
chunks = text_splitter.split_documents(data)

# 4. Create the "Brain" (Vector Store)
# This turns text into vectors and stores them locally.
vectorstore = Chroma.from_documents(
    documents=chunks, 
    embedding=OpenAIEmbeddings()
)

# 5. Build the RAG Chain
llm = ChatOpenAI(model_name="gpt-4o", temperature=0)
rag_chain = RetrievalQA.from_chain_type(
    llm=llm,
    chain_type="stuff", # "Stuff" all chunks into the prompt
    retriever=vectorstore.as_retriever()
)

# 6. Ask away!
question = "What is the main conclusion of this document?"
response = rag_chain.invoke(question)

print(f"🤖 AI: {response['result']}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🤔 &lt;strong&gt;Why did we do that?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;RecursiveCharacterTextSplitter&lt;/em&gt;: Why not just feed the whole PDF? Because LLMs have a "context window" (limit). Chunking keeps the info bite-sized and relevant.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ChromaDB&lt;/em&gt;: This is our temporary database. It stores the "meaning" of our text so we can search it numerically.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;chain_type&lt;/em&gt;="stuff": This is the funniest name in LangChain. It literally means "stuff all the retrieved documents into the prompt."&lt;/p&gt;

&lt;p&gt;🌟 &lt;strong&gt;Pro-Tips for the Road&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Overlap matters&lt;/em&gt;: Notice chunk_overlap=100? This ensures that if a sentence is cut in half, the context lives in both chunks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Local Models&lt;/em&gt;: Don't want to pay for OpenAI? Swap ChatOpenAI for Ollama and run it 100% locally!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Garbage In, Garbage Out&lt;/em&gt;: If your PDF is a messy scan, your RAG will be messy too. Clean your data!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🎁 Wrapping Up&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You just built a production-grade logic loop. RAG is the backbone of almost every AI startup today. Whether it's a legal bot, a medical assistant, or a "Chat with your Resume" tool—you now have the blueprint.&lt;/p&gt;

&lt;p&gt;What are you planning to build with RAG? Let me know in the comments! 👇&lt;/p&gt;

</description>
      <category>ai</category>
      <category>langchain</category>
      <category>rag</category>
      <category>python</category>
    </item>
    <item>
      <title>From Words to Meaning: Core NLP Concepts Every Beginner Must Know</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Tue, 27 Jan 2026 17:48:10 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/from-words-to-meaning-core-nlp-concepts-every-beginner-must-know-3hl3</link>
      <guid>https://forem.com/zeroshotanu/from-words-to-meaning-core-nlp-concepts-every-beginner-must-know-3hl3</guid>
      <description>&lt;p&gt;In the previous post, we covered the basics of NLP such as tokenization, stemming, lemmatization, and stop words.&lt;/p&gt;

&lt;p&gt;In this continuation, we will understand how machines extract meaning from text and represent language numerically.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Named Entity Recognition (NER)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Named Entity Recognition (NER) is an NLP technique used to identify and classify real-world entities in text.&lt;/p&gt;

&lt;p&gt;Common entity types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Person&lt;/li&gt;
&lt;li&gt;Organization&lt;/li&gt;
&lt;li&gt;Location&lt;/li&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Time&lt;/li&gt;
&lt;li&gt;Money&lt;/li&gt;
&lt;li&gt;Percentage&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example sentence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Elon Musk is the CEO of Tesla and lives in the USA.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NER output:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Elon Musk → PERSON&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tesla → ORGANIZATION&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;USA → LOCATION&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why NER is important:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helps extract structured information from unstructured text&lt;/li&gt;
&lt;li&gt;Used in resume parsing and document processing&lt;/li&gt;
&lt;li&gt;Widely applied in medical and legal NLP systems&lt;/li&gt;
&lt;li&gt;Improves search engines and chatbots&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;2. Bag of Words (BoW)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Bag of Words is one of the simplest techniques to convert text into numbers.&lt;/p&gt;

&lt;p&gt;Core idea:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Word order is ignored&lt;/li&gt;
&lt;li&gt;Grammar is ignored&lt;/li&gt;
&lt;li&gt;Only word frequency matters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Sentence 1: I love NLP  
Sentence 2: I love AI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vocabulary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[I, love, NLP, AI]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Vector representation:&lt;/p&gt;

&lt;p&gt;Sentence 1 → [1, 1, 1, 0]&lt;/p&gt;

&lt;p&gt;Sentence 2 → [1, 1, 0, 1]&lt;/p&gt;

&lt;p&gt;Advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very easy to implement&lt;/li&gt;
&lt;li&gt;Works well for small datasets&lt;/li&gt;
&lt;li&gt;Useful as a baseline model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No understanding of context&lt;/li&gt;
&lt;li&gt;No semantic meaning&lt;/li&gt;
&lt;li&gt;Treats all words as equally important&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;3. TF-IDF (Term Frequency – Inverse Document Frequency)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;TF-IDF improves Bag of Words by assigning importance scores to words.&lt;/p&gt;

&lt;p&gt;TF-IDF= TF*IDF&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TF(t,d)= Total number of terms in document d/Number of times term t appears in document d

IDF(t)=log( Number of documents containing term t/Total number of documents)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Intuition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Words that occur frequently in a document are important.&lt;/li&gt;
&lt;li&gt;Words that occur in many documents are less important.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Components:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Term Frequency (TF)&lt;/strong&gt;: frequency of a word in a document&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inverse Document Frequency (IDF)&lt;/strong&gt;: rarity of the word across documents&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why TF-IDF is better than BoW:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduces importance of common words like the and is&lt;/li&gt;
&lt;li&gt;Highlights meaningful words&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performs well in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search engines&lt;/li&gt;
&lt;li&gt;Spam detection&lt;/li&gt;
&lt;li&gt;Document similarity tasks&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does not capture semantic meaning&lt;/li&gt;
&lt;li&gt;Synonyms are treated as different words&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4. Word2Vec&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Word2Vec represents words as dense numerical vectors that capture meaning and context.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Key idea:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Words used in similar contexts have similar meanings. The vectors used to represent King, Queen, Man and Woman when undergo arithmetic operations, give results as below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Famous examples:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;King − Man + Woman ≈ Queen&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Paris − France + Italy ≈ Rome&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Word2Vec has 2 components:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. CBOW (Continuous Bag of Words)&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Predicts a word using surrounding context.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Sentence: "Raj went to school yesterday"
Window size: 1

Input: [Raj, to] → Output: went
Input: [went, school] → Output: to
Input: [to, yesterday] → Output: school

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Working:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The context words are converted to one-hot vectors.&lt;/li&gt;
&lt;li&gt;These vectors are summed or averaged&lt;/li&gt;
&lt;li&gt;They are passed through the hidden layer.&lt;/li&gt;
&lt;li&gt;The model predicts the target word&lt;/li&gt;
&lt;li&gt;Error is calculated&lt;/li&gt;
&lt;li&gt;Weights are updated using backpropagation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Skip-Gram&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Predicts surrounding words using a target word.&lt;br&gt;
 For same sentence,&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Target word: went
Context words: Raj, to

Training pairs:
Input: went → Output: Raj
Input: went → Output: to

Target = to
Context words: went, school

Training pairs:
Input: to → Output: went
Input: to → Output: school

Target = school
Context words: to, yesterday

Training pairs:
Input: school → Output: to
Input: school → Output: yesterday

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Working&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The target word is converted to a one-hot vector&lt;/li&gt;
&lt;li&gt;Passed through the hidden layer&lt;/li&gt;
&lt;li&gt;The model predicts each context word&lt;/li&gt;
&lt;li&gt;Error is calculated&lt;/li&gt;
&lt;li&gt;Weights are updated using backpropagation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 The hidden layer weights become the word embeddings&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Captures semantic relationships&lt;/li&gt;
&lt;li&gt;Produces dense and meaningful embeddings&lt;/li&gt;
&lt;li&gt;Useful for clustering and similarity tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Same word has the same vector in all contexts&lt;/p&gt;

&lt;p&gt;Example: &lt;br&gt;
bank (river) and bank (money)&lt;/p&gt;

&lt;p&gt;This limitation is addressed by contextual models like BERT.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use Each Technique?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Bag of Words when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building simple text classifiers&lt;/li&gt;
&lt;li&gt;Creating baseline NLP models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use TF-IDF when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Working on search systems&lt;/li&gt;
&lt;li&gt;Performing document similarity&lt;/li&gt;
&lt;li&gt;Detecting spam&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Semantic similarity is important&lt;/li&gt;
&lt;li&gt;Building recommendation systems&lt;/li&gt;
&lt;li&gt;Clustering text data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;These techniques show the evolution of NLP from counting words to weighting word importance to understanding semantic meaning.&lt;br&gt;
They form the foundation for modern NLP and Generative AI systems.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>nlp</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>🌱 NLP for Beginners: Understanding the Basics of Natural Language Processing</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Thu, 22 Jan 2026 16:03:32 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/nlp-for-beginners-understanding-the-basics-of-natural-language-processing-4784</link>
      <guid>https://forem.com/zeroshotanu/nlp-for-beginners-understanding-the-basics-of-natural-language-processing-4784</guid>
      <description>&lt;p&gt;Natural Language Processing (NLP) is one of the most exciting areas of Artificial Intelligence today. From chatbots and search engines to spam detection and sentiment analysis, NLP helps machines understand human language.&lt;/p&gt;

&lt;p&gt;If you’re just starting out and feel confused by terms like &lt;em&gt;tokenization&lt;/em&gt; or &lt;em&gt;lemmatization&lt;/em&gt;, this post will give you a clear and gentle introduction.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 What is Natural Language Processing (NLP)?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Natural Language Processing (NLP)&lt;/strong&gt; is a subfield of Artificial Intelligence that enables computers to &lt;strong&gt;understand, analyze, and generate human language&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In simple terms:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NLP allows machines to work with text and speech in a meaningful way.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Real-world applications of NLP
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Chatbots and virtual assistants&lt;/li&gt;
&lt;li&gt;Google Search and autocomplete&lt;/li&gt;
&lt;li&gt;Spam email detection&lt;/li&gt;
&lt;li&gt;Sentiment analysis of reviews&lt;/li&gt;
&lt;li&gt;Language translation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🗺️ A Beginner-Friendly Roadmap to Learn NLP
&lt;/h2&gt;

&lt;p&gt;Before diving into complex models, it’s important to understand how text is processed.&lt;/p&gt;

&lt;h3&gt;
  
  
  A simple conceptual roadmap
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Text Preprocessing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tokenization&lt;/li&gt;
&lt;li&gt;Stop words removal&lt;/li&gt;
&lt;li&gt;Stemming&lt;/li&gt;
&lt;li&gt;Lemmatization&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Text Representation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bag of Words&lt;/li&gt;
&lt;li&gt;TF-IDF&lt;/li&gt;
&lt;li&gt;Word Embeddings&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Classical NLP Tasks&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text classification&lt;/li&gt;
&lt;li&gt;Sentiment analysis&lt;/li&gt;
&lt;li&gt;Named Entity Recognition&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Advanced NLP (Later Stage)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transformers&lt;/li&gt;
&lt;li&gt;BERT&lt;/li&gt;
&lt;li&gt;GPT&lt;/li&gt;
&lt;li&gt;Large Language Models&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧹 Why Text Preprocessing is Important
&lt;/h2&gt;

&lt;p&gt;Machines don’t understand language like humans do.&lt;/p&gt;

&lt;p&gt;Example sentence: "I am learning Natural Language Processing!"&lt;/p&gt;

&lt;p&gt;To a machine, this is just a sequence of characters.&lt;br&gt;&lt;br&gt;
Text preprocessing helps convert raw text into a format that machine learning models can understand.&lt;/p&gt;


&lt;h2&gt;
  
  
  ✂️ Tokenization
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tokenization&lt;/strong&gt; is the process of breaking text into smaller units called &lt;strong&gt;tokens&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Sentence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love learning NLP"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After tokenization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["I", "love", "learning", "NLP"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Types of tokenization
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Word tokenization&lt;/li&gt;
&lt;li&gt;Sentence tokenization&lt;/li&gt;
&lt;li&gt;Subword tokenization (used in transformers)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛑 Stop Words
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Stop words&lt;/strong&gt; are commonly used words that usually don’t add much meaning to the text.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;is, am, are, the, a, an, in, on, and
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why remove stop words?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;They add noise&lt;/li&gt;
&lt;li&gt;They increase dimensionality&lt;/li&gt;
&lt;li&gt;They often don’t help in tasks like classification&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🌿 Stemming
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Stemming&lt;/strong&gt; reduces words to their &lt;strong&gt;root form&lt;/strong&gt; by removing suffixes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast&lt;/li&gt;
&lt;li&gt;Not always linguistically correct&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common stemming algorithms: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PorterStemmer() : just removes suffix or prefix without context understanding.&lt;/li&gt;
&lt;li&gt;SnowballStemmer() : better than PorterStemmer and supports many languages.&lt;/li&gt;
&lt;li&gt;RegexStemmer() : removes prefix or suffix based on given expression to be removed.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;words=['eating','eaten','eat','write','writes','history','mysterious','mystery','finally','finalised','historical']
from nltk.stem import PorterStemmer
stemming=PorterStemmer()
for word in words:
    print(word+"------&amp;gt;"+ stemming.stem(word))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
eating------&amp;gt;eat&lt;br&gt;
eaten------&amp;gt;eaten&lt;br&gt;
eat------&amp;gt;eat&lt;br&gt;
write------&amp;gt;write&lt;br&gt;
writes------&amp;gt;write&lt;br&gt;
history------&amp;gt;histori&lt;br&gt;
mysterious------&amp;gt;mysteri&lt;br&gt;
mystery------&amp;gt;mysteri&lt;br&gt;
finally------&amp;gt;final&lt;br&gt;
finalised------&amp;gt;finalis&lt;br&gt;
historical------&amp;gt;histor&lt;/p&gt;

&lt;p&gt;Stemming just removes prefixes or suffixes and doesn't give meaning words.&lt;/p&gt;


&lt;h2&gt;
  
  
  🍃 Lemmatization
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Lemmatization&lt;/strong&gt; converts words into their &lt;strong&gt;dictionary base form&lt;/strong&gt;, called a &lt;em&gt;lemma&lt;/em&gt;.&lt;br&gt;
NLTK provides WordNetLemmatizer class which is a thin wrapper around the wordnet corpus&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from nltk.stem import WordNetLemmatizer
## WordNet is a dictionary dataset which has words with their base form.We need to download this dataset to use WordNetLemmatizer
import nltk
nltk.download('wordnet')
lemmatizer=WordNetLemmatizer()
lemmatizer.lemmatize('going') #output: going
lemmatizer.lemmatize('going', pos='v') #ouput : go
#This lemmatize command we can add pos_tags that identify the word as verb, noun, adjective, etc. to help decide how to go to root word.
## Parts of Speech: Noun -n, Verb-v, adverb-r, adjective-a. Default pos tag is 'n'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Considers grammar and context&lt;/li&gt;
&lt;li&gt;Produces meaningful words&lt;/li&gt;
&lt;li&gt;More accurate but slower than stemming&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚖️ Stemming vs Lemmatization
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Stemming&lt;/th&gt;
&lt;th&gt;Lemmatization&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Speed&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Slower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td&gt;Lower&lt;/td&gt;
&lt;td&gt;Higher&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;May not be a real word&lt;/td&gt;
&lt;td&gt;Always a valid word&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grammar-aware&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧠 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;NLP is not magic — its structured text processing combined with machine learning.&lt;br&gt;
Which is your favorite concept in NLP?&lt;br&gt;
Drop a comment down below!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>nlp</category>
      <category>ai</category>
      <category>python</category>
    </item>
    <item>
      <title>How AI Sees Images: A Gentle Introduction to Convolutional Neural Networks</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Wed, 31 Dec 2025 12:15:19 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/how-ai-sees-images-a-gentle-introduction-to-convolutional-neural-networks-2npi</link>
      <guid>https://forem.com/zeroshotanu/how-ai-sees-images-a-gentle-introduction-to-convolutional-neural-networks-2npi</guid>
      <description>&lt;p&gt;If you’ve ever wondered &lt;strong&gt;how Instagram recognizes faces&lt;/strong&gt;, &lt;strong&gt;how self-driving cars see roads&lt;/strong&gt;, or &lt;strong&gt;how medical scans detect diseases&lt;/strong&gt;, the answer often starts with one thing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Convolutional Neural Networks (CNNs)&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But don’t worry — no heavy math, no scary equations.&lt;br&gt;
Let’s understand CNNs &lt;strong&gt;step by step, visually and intuitively&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Why Not Just Use Normal Neural Networks?
&lt;/h2&gt;

&lt;p&gt;Imagine you have a &lt;strong&gt;100×100 image&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That’s &lt;strong&gt;10,000 pixels&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you feed this into a normal neural network:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every pixel connects to every neuron&lt;/li&gt;
&lt;li&gt;Millions of parameters 😵&lt;/li&gt;
&lt;li&gt;Overfitting happens fast&lt;/li&gt;
&lt;li&gt;Spatial information is lost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 CNNs were created &lt;strong&gt;specifically for images&lt;/strong&gt; to solve this problem.&lt;/p&gt;


&lt;h2&gt;
  
  
  👀 How Humans See vs How CNNs See
&lt;/h2&gt;

&lt;p&gt;When &lt;em&gt;you&lt;/em&gt; look at an image, you don’t see pixels.&lt;/p&gt;

&lt;p&gt;You see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edges&lt;/li&gt;
&lt;li&gt;Shapes&lt;/li&gt;
&lt;li&gt;Patterns&lt;/li&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CNNs try to learn &lt;strong&gt;exactly this hierarchy&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧩 The Core Idea of CNNs (In One Line)
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CNNs learn small patterns first (edges), then combine them to learn complex objects.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  🧱 The Building Blocks of a CNN
&lt;/h2&gt;

&lt;p&gt;Let’s break it down.&lt;/p&gt;


&lt;h3&gt;
  
  
  1️⃣ Convolution Layer — The “Feature Detector”
&lt;/h3&gt;

&lt;p&gt;This is the heart of CNNs ❤️&lt;/p&gt;

&lt;p&gt;Instead of looking at the entire image at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CNN uses a &lt;strong&gt;small filter (kernel)&lt;/strong&gt; like &lt;code&gt;3×3&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Slides it across the image&lt;/li&gt;
&lt;li&gt;Detects &lt;strong&gt;patterns&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vertical edges&lt;/li&gt;
&lt;li&gt;Horizontal edges&lt;/li&gt;
&lt;li&gt;Curves&lt;/li&gt;
&lt;li&gt;Corners&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌 Think of it like a &lt;strong&gt;magnifying glass&lt;/strong&gt; scanning the image.&lt;/p&gt;


&lt;h3&gt;
  
  
  🔍 What is a Filter (Kernel)?
&lt;/h3&gt;

&lt;p&gt;A filter is a &lt;strong&gt;small matrix&lt;/strong&gt; that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiplies with image pixels&lt;/li&gt;
&lt;li&gt;Extracts specific features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different filters learn different features automatically.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuqx50xr8c93tr1az13xy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuqx50xr8c93tr1az13xy.gif" alt="📌 This animation shows how a 3×3 convolution kernel multiplies with image pixels&amp;lt;br&amp;gt;
element-wise and sums the result to produce a feature map value.&amp;lt;br&amp;gt;
" width="1000" height="400"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2️⃣ ReLU — Adding Non-Linearity
&lt;/h3&gt;

&lt;p&gt;After convolution, we apply &lt;strong&gt;ReLU&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReLU(x) = max(0, x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keeps positive values&lt;/li&gt;
&lt;li&gt;Removes unnecessary noise&lt;/li&gt;
&lt;li&gt;Makes the network capable of learning complex patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌 Without ReLU, CNNs would just be fancy linear models.&lt;/p&gt;




&lt;h3&gt;
  
  
  3️⃣ Pooling Layer — Reducing Size, Keeping Meaning
&lt;/h3&gt;

&lt;p&gt;Pooling helps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce image size&lt;/li&gt;
&lt;li&gt;Reduce computation&lt;/li&gt;
&lt;li&gt;Prevent overfitting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most common:&lt;br&gt;
👉 &lt;strong&gt;Max Pooling (2×2)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It keeps the &lt;strong&gt;most important value&lt;/strong&gt; from a region.&lt;/p&gt;

&lt;p&gt;📌 Think of it as &lt;strong&gt;compressing an image without losing important details&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  4️⃣ Fully Connected Layer — The Decision Maker
&lt;/h3&gt;

&lt;p&gt;After convolution + pooling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We flatten everything&lt;/li&gt;
&lt;li&gt;Feed it into a normal neural network&lt;/li&gt;
&lt;li&gt;Make final predictions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example outputs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cat / Dog&lt;/li&gt;
&lt;li&gt;Healthy / Diseased&lt;/li&gt;
&lt;li&gt;Car / Pedestrian / Tree&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 How CNNs Learn (Training Intuition)
&lt;/h2&gt;

&lt;p&gt;CNNs learn by:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Making predictions&lt;/li&gt;
&lt;li&gt;Calculating error (loss)&lt;/li&gt;
&lt;li&gt;Adjusting filters using &lt;strong&gt;backpropagation&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Repeating until accuracy improves&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;📌 CNNs don’t start smart — they &lt;strong&gt;become smart through data&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 A Simple CNN Example (Keras)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tensorflow.keras.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Sequential&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tensorflow.keras.layers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Conv2D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MaxPooling2D&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Dense&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Sequential&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="nc"&gt;Conv2D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;relu&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input_shape&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="nc"&gt;MaxPooling2D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nc"&gt;Flatten&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nc"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;relu&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nc"&gt;Dense&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;activation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sigmoid&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;adam&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;binary_crossentropy&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;accuracy&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📌 Don’t worry about memorizing this — understand &lt;strong&gt;what each layer does&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗 How CNNs Learn Features (Very Important)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer Depth&lt;/th&gt;
&lt;th&gt;Learns&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Early layers&lt;/td&gt;
&lt;td&gt;Edges, lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Middle layers&lt;/td&gt;
&lt;td&gt;Shapes, textures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deep layers&lt;/td&gt;
&lt;td&gt;Objects, faces&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is why CNNs are &lt;strong&gt;so powerful&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Real-World Applications of CNNs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🏥 Medical image diagnosis&lt;/li&gt;
&lt;li&gt;🚗 Autonomous driving&lt;/li&gt;
&lt;li&gt;📸 Face recognition&lt;/li&gt;
&lt;li&gt;🛒 Product image search&lt;/li&gt;
&lt;li&gt;🔍 OCR (text from images)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If it involves &lt;strong&gt;images or vision&lt;/strong&gt;, CNNs are probably involved.&lt;/p&gt;




&lt;h2&gt;
  
  
  ❌ Common Beginner Mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Training huge CNNs on small datasets&lt;/li&gt;
&lt;li&gt;Ignoring overfitting&lt;/li&gt;
&lt;li&gt;Not visualizing results&lt;/li&gt;
&lt;li&gt;Blindly copying architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌 Start &lt;strong&gt;small&lt;/strong&gt;, then scale.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧭 Where Should You Go Next?
&lt;/h2&gt;

&lt;p&gt;If you’re learning CNNs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build a simple image classifier&lt;/li&gt;
&lt;li&gt;Experiment with:

&lt;ul&gt;
&lt;li&gt;Filter sizes&lt;/li&gt;
&lt;li&gt;Pooling&lt;/li&gt;
&lt;li&gt;Dropout&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Visualize predictions&lt;/li&gt;
&lt;li&gt;Try transfer learning (ResNet, VGG)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  💬 Let’s Discuss!
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What confused you most about CNNs?&lt;/li&gt;
&lt;li&gt;What project are you building with CNNs?&lt;/li&gt;
&lt;li&gt;Want a post on &lt;strong&gt;CNN interview questions&lt;/strong&gt; or &lt;strong&gt;visual intuition&lt;/strong&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👇 Drop a comment — let’s learn together!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>deeplearning</category>
      <category>tensorflow</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Machine Learning for Everyone: A Friendly Intro to the Future!</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Tue, 23 Dec 2025 16:19:15 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/machine-learning-for-everyone-a-friendly-intro-to-the-future-1i1d</link>
      <guid>https://forem.com/zeroshotanu/machine-learning-for-everyone-a-friendly-intro-to-the-future-1i1d</guid>
      <description>&lt;p&gt;Hey dev.io fam! Ever feel like "machine learning" is this magical, super-complex term that only rocket scientists understand? Well, guess what? It's not! Machine learning is actually all around us, making our lives easier and more interesting every single day. Think of this as your friendly, no-jargon introduction to the world of ML. Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  So, What Even Is Machine Learning?
&lt;/h2&gt;

&lt;p&gt;At its core, machine learning is about teaching computers to learn from data, just like humans learn from experience. Instead of explicitly programming every single rule, we feed the computer tons of information, and it figures out the patterns and relationships on its own.&lt;br&gt;
Imagine you want a computer to tell the difference between a picture of a cat and a dog. The old way would be to write down rules: "If it has pointy ears, it's a cat. If it has floppy ears, it's a dog." But what about cats with floppy ears or dogs with pointy ones? It gets complicated fast!&lt;br&gt;
With machine learning, you show the computer thousands of pictures labeled "cat" and "dog." The ML model then learns what characteristics distinguish a cat from a dog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where Do We See ML in Action?&lt;/strong&gt;&lt;br&gt;
You're probably interacting with ML without even realizing it!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Netflix/Spotify Recommendations&lt;/strong&gt;: Ever wonder how they know exactly what you want to watch or listen to next? Yep, that's ML working its magic, analyzing your past preferences and what similar users enjoy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spam Filters&lt;/strong&gt;: Those pesky spam emails that never make it to your inbox? Thank machine learning for identifying and filtering them out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voice Assistants (Siri, Alexa, Google Assistant)&lt;/strong&gt;: When you ask your device a question, ML is behind the scenes, understanding your speech and figuring out the best response.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Facial Recognition on Your Phone&lt;/strong&gt;: Unlocking your phone with your face? ML!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online Shopping Product Suggestions&lt;/strong&gt;: "Customers who bought this also bought..." - another classic ML example.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  The Basic Ingredients: Data, Model, and Learning!
&lt;/h2&gt;

&lt;p&gt;To make an ML system work, you generally need three things:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data&lt;/em&gt;: This is the fuel for your ML engine. The better quality, relevant data you have, the better your model will learn.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Model&lt;/em&gt;: This is the algorithm or mathematical structure that learns the patterns from your data. Think of it as the "brain" that processes the information.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Learning Algorithm&lt;/em&gt;: This is the process that adjusts the model's parameters based on the data, minimizing errors and improving its performance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Below is an example of house prediction using supervised learning method of Linear Regression.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.linear_model import LinearRegression

# Features: [Square Footage] (Needs to be a 2D array)
X = [[1000], [1500], [2000], [2500]]

# Labels: Price in Dollars
y = [200000, 300000, 400000, 500000]

# Create and train the regressor
model = LinearRegression()
model.fit(X, y)

# Predict: Price for a 1800 sq ft house
price_prediction = model.predict([[1800]])

print(f"Predicted Price: ${price_prediction[0]:,.2f}")
# Output: Predicted Price: $360,000.00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Different Flavors of ML
&lt;/h2&gt;

&lt;p&gt;There are generally three main types of machine learning:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Supervised Learning:&lt;/strong&gt; This is what we just did! We have data with both inputs (movie genre, rating) and the correct outputs (liked/didn't like). The model learns to map inputs to outputs. Think of it like learning with a teacher.&lt;br&gt;
Examples: Image classification, spam detection, predicting house prices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unsupervised Learning:&lt;/strong&gt; Here, the data doesn't have labels. The model tries to find hidden patterns or groupings within the data on its own. Think of it like exploring without a map.&lt;br&gt;
Examples: Customer segmentation (grouping similar customers), anomaly detection (finding unusual data points), data compression.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reinforcement Learning:&lt;/strong&gt; This is about an agent learning to make decisions by performing actions in an environment to maximize a reward. Think of teaching a dog tricks with treats.&lt;br&gt;
Examples: Training robots, game AI (like AlphaGo), self-driving cars.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready to Explore Further?
&lt;/h2&gt;

&lt;p&gt;This is just the tip of the iceberg! The field of machine learning is constantly evolving and incredibly exciting. Don't be intimidated; start small, build some projects, and you'll be amazed at what you can create!&lt;/p&gt;

&lt;p&gt;What are your thoughts on ML? Have you built anything cool with it? Let us know in the comments below!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding Errors in Machine Learning: Accuracy, Precision, Recall &amp; F1 Score</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Tue, 16 Dec 2025 18:59:02 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/understanding-errors-in-machine-learning-accuracy-precision-recall-f1-score-4cc0</link>
      <guid>https://forem.com/zeroshotanu/understanding-errors-in-machine-learning-accuracy-precision-recall-f1-score-4cc0</guid>
      <description>&lt;p&gt;Machine Learning models are often judged by &lt;strong&gt;numbers&lt;/strong&gt;, but many beginners (and even practitioners) misunderstand &lt;em&gt;what those numbers actually mean&lt;/em&gt;. A model showing &lt;strong&gt;95% accuracy&lt;/strong&gt; might still be &lt;em&gt;useless&lt;/em&gt; in real-world scenarios.&lt;/p&gt;

&lt;p&gt;In this post, we’ll break down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Types of errors in Machine Learning&lt;/li&gt;
&lt;li&gt;Confusion Matrix&lt;/li&gt;
&lt;li&gt;Accuracy&lt;/li&gt;
&lt;li&gt;Precision&lt;/li&gt;
&lt;li&gt;Recall&lt;/li&gt;
&lt;li&gt;F1 Score&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All explained &lt;strong&gt;intuitively&lt;/strong&gt;, with examples you can confidently explain in interviews or apply in projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  1️⃣ Types of Errors in Machine Learning
&lt;/h2&gt;

&lt;p&gt;In a &lt;strong&gt;classification problem&lt;/strong&gt;, predictions fall into four categories:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Actual \ Predicted&lt;/th&gt;
&lt;th&gt;Positive&lt;/th&gt;
&lt;th&gt;Negative&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Positive&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;True Positive (TP)&lt;/td&gt;
&lt;td&gt;False Negative (FN)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Negative&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;False Positive (FP)&lt;/td&gt;
&lt;td&gt;True Negative (TN)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🔴 False Positive (Type I Error)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Model predicts &lt;strong&gt;Positive&lt;/strong&gt;, but the actual result is &lt;strong&gt;Negative&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Example: Email marked as &lt;em&gt;Spam&lt;/em&gt; but it is actually &lt;em&gt;Not Spam&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔵 False Negative (Type II Error)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Model predicts &lt;strong&gt;Negative&lt;/strong&gt;, but the actual result is &lt;strong&gt;Positive&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Example: Medical test says &lt;em&gt;No Disease&lt;/em&gt; but the patient actually has it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These errors directly impact evaluation metrics.&lt;/p&gt;




&lt;h2&gt;
  
  
  2️⃣ Confusion Matrix (The Foundation)
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;confusion matrix&lt;/strong&gt; summarizes prediction results:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                Predicted
               P       N
Actual P      TP      FN
Actual N      FP      TN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All metrics are derived from this table.&lt;/p&gt;




&lt;h2&gt;
  
  
  3️⃣ Accuracy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📌 Definition
&lt;/h3&gt;

&lt;p&gt;Accuracy measures how often the model is correct.&lt;/p&gt;

&lt;h3&gt;
  
  
  📐 Formula
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accuracy = (TP + TN) / (TP + FP + FN + TN)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ❗ Problem with Accuracy
&lt;/h3&gt;

&lt;p&gt;Accuracy can be &lt;strong&gt;misleading&lt;/strong&gt; in &lt;strong&gt;imbalanced datasets&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;99 normal patients&lt;/li&gt;
&lt;li&gt;1 patient with disease&lt;/li&gt;
&lt;li&gt;Model predicts &lt;em&gt;No Disease&lt;/em&gt; for everyone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Accuracy = &lt;strong&gt;99%&lt;/strong&gt;, but the model is &lt;strong&gt;dangerous&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;👉 Accuracy alone is &lt;strong&gt;not enough&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  4️⃣ Precision
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📌 Definition
&lt;/h3&gt;

&lt;p&gt;Precision answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Of all predicted positives, how many are actually positive?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  📐 Formula
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Precision = TP / (TP + FP)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When to focus on Precision?
&lt;/h3&gt;

&lt;p&gt;When &lt;strong&gt;False Positives are costly&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Examples:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Spam detection&lt;/li&gt;
&lt;li&gt;Fraud detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t want to wrongly flag legitimate cases.&lt;/p&gt;




&lt;h2&gt;
  
  
  5️⃣ Recall (Sensitivity)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📌 Definition
&lt;/h3&gt;

&lt;p&gt;Recall answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Of all actual positives, how many did the model correctly identify?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  📐 Formula
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Recall = TP / (TP + FN)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When to focus on Recall?
&lt;/h3&gt;

&lt;p&gt;When &lt;strong&gt;False Negatives are dangerous&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Examples:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Cancer detection&lt;/li&gt;
&lt;li&gt;Accident detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Missing a positive case can have severe consequences.&lt;/p&gt;




&lt;h2&gt;
  
  
  6️⃣ Precision vs Recall Tradeoff
&lt;/h2&gt;

&lt;p&gt;Increasing Precision often &lt;strong&gt;decreases Recall&lt;/strong&gt;, and vice versa.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Priority&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Spam Filter&lt;/td&gt;
&lt;td&gt;Precision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Disease Detection&lt;/td&gt;
&lt;td&gt;Recall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fraud Detection&lt;/td&gt;
&lt;td&gt;Recall&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This tradeoff leads us to F1 Score.&lt;/p&gt;




&lt;h2&gt;
  
  
  7️⃣ F1 Score
&lt;/h2&gt;

&lt;h3&gt;
  
  
  📌 Definition
&lt;/h3&gt;

&lt;p&gt;F1 Score is the &lt;strong&gt;harmonic mean&lt;/strong&gt; of Precision and Recall.&lt;/p&gt;

&lt;h3&gt;
  
  
  📐 Formula
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;F1 = 2 × (Precision × Recall) / (Precision + Recall)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✅ Why F1 Score?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Balances Precision &amp;amp; Recall&lt;/li&gt;
&lt;li&gt;Best for &lt;strong&gt;imbalanced datasets&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Penalizes extreme values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If either Precision or Recall is low, F1 score drops sharply.&lt;/p&gt;




&lt;h2&gt;
  
  
  8️⃣ Summary Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Best Used When&lt;/th&gt;
&lt;th&gt;Focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td&gt;Balanced data&lt;/td&gt;
&lt;td&gt;Overall correctness&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Precision&lt;/td&gt;
&lt;td&gt;FP costly&lt;/td&gt;
&lt;td&gt;Prediction quality&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recall&lt;/td&gt;
&lt;td&gt;FN costly&lt;/td&gt;
&lt;td&gt;Detection completeness&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F1 Score&lt;/td&gt;
&lt;td&gt;Imbalanced data&lt;/td&gt;
&lt;td&gt;Balanced performance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  9️⃣ Real-World Case Studies
&lt;/h2&gt;

&lt;p&gt;Understanding metrics becomes much clearer when we map them to &lt;strong&gt;real-world problems&lt;/strong&gt;. Below are some common and interview-relevant case studies.&lt;/p&gt;




&lt;h3&gt;
  
  
  🏥 Case Study 1: Disease Detection (Cancer / COVID)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
A model predicts whether a patient has a disease.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Error:&lt;/strong&gt; False Negative (FN)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Predicting &lt;em&gt;Healthy&lt;/em&gt; when the patient actually has the disease&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Recall Matters More:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing a sick patient can delay treatment and cost lives&lt;/li&gt;
&lt;li&gt;It is acceptable to have some false alarms (FPs), but not to miss real cases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Primary Metric:&lt;/strong&gt; Recall&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In healthcare, we prioritize recall over precision.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  💳 Case Study 2: Credit Card Fraud Detection
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
The model identifies fraudulent transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Error:&lt;/strong&gt; False Negative (FN)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fraud transaction marked as legitimate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tradeoff:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Too many false positives annoy customers.&lt;/li&gt;
&lt;li&gt;Too many false negatives cause financial loss.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here if we optimize only for Recall then even the slightest unusual transaction would be considered fraud. If we use Precision, then it would only detect fraud if it were very confident.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Best Metric:&lt;/strong&gt; F1 Score&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;F1 balances customer experience and fraud prevention.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  📧 Case Study 3: Spam Email Detection
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
Classifying emails as Spam or Not Spam.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Error:&lt;/strong&gt; False Positive (FP)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Important email marked as spam&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Precision Matters:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users may miss critical emails (job offers, OTPs, invoices)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Primary Metric:&lt;/strong&gt; Precision&lt;/p&gt;




&lt;h3&gt;
  
  
  🚗 Case Study 4: Autonomous Driving (Pedestrian Detection)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
Detecting pedestrians using camera and sensor data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Error:&lt;/strong&gt; False Negative (FN)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pedestrian not detected&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Recall is Crucial:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing even one pedestrian can be fatal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Primary Metric:&lt;/strong&gt; Recall&lt;/p&gt;




&lt;h3&gt;
  
  
  🏭 Case Study 5: Manufacturing Defect Detection
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
Detecting defective products on an assembly line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Error Depends On:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High FP → Waste and increased cost&lt;/li&gt;
&lt;li&gt;High FN → Faulty product reaches customer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Balanced Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Precision + Recall together&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Best Metric:&lt;/strong&gt; F1 Score&lt;/p&gt;




&lt;h2&gt;
  
  
  🔚 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Never blindly trust &lt;strong&gt;accuracy&lt;/strong&gt;.&lt;br&gt;
Always ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What kind of error is more dangerous?&lt;/li&gt;
&lt;li&gt;Is my dataset imbalanced?&lt;/li&gt;
&lt;li&gt;What is the real-world cost of FP vs FN?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding these metrics makes you a &lt;strong&gt;better ML engineer&lt;/strong&gt;, not just a model builder.&lt;/p&gt;




&lt;p&gt;If this helped you, feel free to share or comment your favorite ML pitfall!!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>The Science of Prompt Evaluation: From BLEU &amp; ROUGE to Real Human Feedback</title>
      <dc:creator>Ananya S</dc:creator>
      <pubDate>Mon, 08 Dec 2025 17:13:29 +0000</pubDate>
      <link>https://forem.com/zeroshotanu/the-science-of-prompt-evaluation-from-bleu-rouge-to-real-human-feedback-31mh</link>
      <guid>https://forem.com/zeroshotanu/the-science-of-prompt-evaluation-from-bleu-rouge-to-real-human-feedback-31mh</guid>
      <description>&lt;p&gt;Prompt engineering feels magical—change a few words and the model behaves differently.&lt;br&gt;
But how do you measure whether one prompt is actually better than another?&lt;br&gt;
Just reading the outputs is not enough.&lt;br&gt;
For real AI applications, you need evaluation metrics.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. BLEU Score
&lt;/h2&gt;

&lt;p&gt;BLEU (Bilingual Evaluation Understudy) checks how many n-grams from the reference appear in the generated output.&lt;br&gt;
An n-gram is a sequence of n consecutive words (or tokens) in a sentence.&lt;br&gt;
Unigram: “the”, “cat”, “sat”&lt;br&gt;
Bigram: “the cat”, “cat sat”&lt;/p&gt;

&lt;p&gt;Great for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;summarization&lt;/li&gt;
&lt;li&gt;translation&lt;/li&gt;
&lt;li&gt;structured responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not great for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creative writing&lt;/li&gt;
&lt;li&gt;open-ended generation&lt;/li&gt;
&lt;li&gt;varied response styles&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's say the reference is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The cat sits on the mat.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the LLM output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A cat is sitting on the mat.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;BLEU will give a high score because many words and n-grams match.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. ROUGE Score
&lt;/h2&gt;

&lt;p&gt;ROUGE is more recall-focused than BLEU. ROUGE measures how much of the reference (ground-truth) text appears in the generated output.&lt;/p&gt;

&lt;p&gt;ROUGE Recall = (overlapping units) / (total units in reference)&lt;br&gt;
This is why ROUGE is used heavily in summarization, where the model must capture key points from the original text.&lt;/p&gt;

&lt;p&gt;ROUGE-1: unigram overlap (Measures overlap of single words.)&lt;br&gt;
ROUGE-2: bigram overlap (Measures overlap of word pairs.)&lt;br&gt;
ROUGE-L: longest common subsequence (Measures longest in-order word sequence shared by both texts.)&lt;/p&gt;

&lt;p&gt;Best for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;summarization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Q&amp;amp;A where key facts must be present&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;comparing prompt improvements&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from rouge_score import rouge_scorer

scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', 'rougeL'], use_stemmer=True)

reference = "The cat sits on the mat"
generated = "The mat has a cat sitting on it"

scores = scorer.score(reference, generated)
print(scores)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;use_stemmer increases the rouge score as it ensures rouge compares words to their base meaning. Hence sitting, sits, sat will be seen similar to sit. This shows the generated text captures the meaning accurately and hence the score can be higher.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 'rouge1': Score(precision=0.625, recall=0.7142857142857143, fmeasure=0.6666666666666666),
 'rouge2': Score(precision=0.2727272727272727, recall=0.3333333333333333, fmeasure=0.3),
 'rougeL': Score(precision=0.5, recall=0.5555555555555556, fmeasure=0.5263157894736842)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your exact numbers might differ slightly. &lt;em&gt;fmeasure = F1 score&lt;/em&gt;&lt;br&gt;
These evaluation techniques fall under Natural Language Processing (NLP) and is commonly used to assess the quality of text generation models such as chatbots, summarizers, and translation systems.&lt;br&gt;
To run the example code, make sure to install the &lt;em&gt;&lt;strong&gt;rouge_score&lt;/strong&gt;&lt;/em&gt; library first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install rouge_score

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ROUGE-L is especially useful because it checks sentence structure similarity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For prompt performance, you care about:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;correctness&lt;/li&gt;
&lt;li&gt;coherence&lt;/li&gt;
&lt;li&gt;reasoning&lt;/li&gt;
&lt;li&gt;readability&lt;/li&gt;
&lt;li&gt;hallucinations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;→ BLEU/ROUGE cannot measure these.&lt;/p&gt;

&lt;p&gt;That’s where Human Evaluation comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Human Evaluation
&lt;/h2&gt;

&lt;p&gt;Human eval means real people rate outputs based on criteria like:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;What It Measures&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Accuracy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Is the answer correct?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Relevance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Is it on topic?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Clarity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Easy to read and understand?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Completeness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Did it answer the full question?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Safety&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No harmful or biased content?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Simple Human Evaluation Procedure&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick a prompt (Prompt A)&lt;/li&gt;
&lt;li&gt;Generate output&lt;/li&gt;
&lt;li&gt;Modify prompt → (Prompt B)&lt;/li&gt;
&lt;li&gt;Generate output&lt;/li&gt;
&lt;li&gt;Ask 3–5 evaluators to rate on a 1–5 scale.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Comparing Two Prompts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Prompt A&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Summarize this article in one sentence.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Prompt B&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Provide a short, factual one-sentence summary of the article below.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say, after generating summaries for 50 samples we get:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Prompt A&lt;/th&gt;
&lt;th&gt;Prompt B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;BLEU&lt;/td&gt;
&lt;td&gt;0.42&lt;/td&gt;
&lt;td&gt;0.57&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ROUGE-L&lt;/td&gt;
&lt;td&gt;0.61&lt;/td&gt;
&lt;td&gt;0.72&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Human Score&lt;/td&gt;
&lt;td&gt;3.4&lt;/td&gt;
&lt;td&gt;4.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;→ &lt;strong&gt;Prompt B&lt;/strong&gt; is clearly superior.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Evaluating prompt quality shouldn't be based on guesswork. Use metrics like:&lt;/p&gt;

&lt;p&gt;BLEU → precision of n-gram match&lt;br&gt;
ROUGE → recall and similarity&lt;br&gt;
Human Evaluation → truth, clarity, completeness&lt;/p&gt;

&lt;p&gt;Together, they give you a reliable, real-world view of how good your prompts actually are.&lt;/p&gt;

&lt;p&gt;If you found this useful, hit the ❤️ or 🔥 so others can discover it too.&lt;br&gt;
Which evaluation metric do you prefer—BLEU, ROUGE, or human evaluation?&lt;br&gt;
To understand the meaning of precision, recall and accuracy check out this article: &lt;a href="https://dev.to/zeroshotanu/understanding-errors-in-machine-learning-accuracy-precision-recall-f1-score-4cc0"&gt;Understanding Errors in Machine Learning: Accuracy, Precision, Recall &amp;amp; F1 Score&lt;/a&gt;&lt;br&gt;
Drop your answer in the comments. I reply to every comment!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>promptengineering</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
