<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tauseefahmed Tam on Medium]]></title>
        <description><![CDATA[Stories by Tauseefahmed Tam on Medium]]></description>
        <link>https://medium.com/@tauseefahmed.tam?source=rss-c9cff60cdd5f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*e9vPdgEC5dgMSuZl.jpg</url>
            <title>Stories by Tauseefahmed Tam on Medium</title>
            <link>https://medium.com/@tauseefahmed.tam?source=rss-c9cff60cdd5f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 07:21:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tauseefahmed.tam/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[LangChain vs LangGraph: Choosing the Right AI Workflow Framework]]></title>
            <link>https://medium.com/red-buffer/langchain-vs-langgraph-choosing-the-right-ai-workflow-framework-1718e21199f0?source=rss-c9cff60cdd5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1718e21199f0</guid>
            <dc:creator><![CDATA[Tauseefahmed Tam]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 06:39:59 GMT</pubDate>
            <atom:updated>2026-02-10T06:39:59.412Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*6pTZp0HvU0ZBBUUSRsVSBw.png" /></figure><p>Large language model (LLM) frameworks now offer multiple ways to structure your pipelines. LangChain and LangGraph come from the same ecosystem but serve different needs.</p><p><strong>LangChain</strong> is a linear, chain-of-operations framework ideal for straight line workflows you already understand.</p><p><strong>LangGraph</strong> is a low level, graph based orchestrator for complex, stateful agent systems. The choice isn’t automatic: for clear sequential tasks, LangChain’s simplicity is often faster and more efficient.</p><h4>Architecture &amp; Primitives</h4><blockquote><em>LangChain </em>primarily optimized for linear workflows<em>; LangGraph routes state through a branching graph of nodes.</em></blockquote><p>LangChain is designed around linear pipelines, where prompts, models, retrievers, and tools are executed in a fixed sequence. This makes it well-suited for simple, well-defined workflows like retrieval followed by summarization and answering. LangGraph, on the other hand, represents workflows as stateful graphs, allowing nodes to branch, loop, and revisit earlier steps. By passing a shared state through the graph, LangGraph natively supports conditional logic, retries, checkpoints, and human-in-the-loop interactions capabilities that are difficult to model cleanly with linear chains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*hAKmUsoyVMkJSAC8m8fawg.png" /><figcaption>Figure: Simplified architectural patterns. (Left) A LangChain pipeline executes each component in order. (Right) A LangGraph workflow is cyclic/graph-based, with an LLM agent node, conditional “Need tool?” logic, and the possibility of looping.</figcaption></figure><p>Under the hood, LangChain provides building blocks like prompt templates, memory modules, vector retrievers and tool interfaces, all composed into chains or agents.</p><blockquote>The mental model is like Lego blocks: small operations fit together in a fixed sequence.</blockquote><p>LangGraph, by contrast, is very low-level and <strong>stateful. </strong>You define <em>state schemas</em> and <em>graph nodes</em> in code. The framework guarantees <em>durable execution</em>: on failure or pause, you can checkpoint and resume from the last state. It even offers streaming outputs, long-term memory(enables persistence and checkpointing, but memory storage still needs to be designed explicitly), and visual debugging tools for production agents.</p><p>In short, LangChain’s in DAG looping or revisiting steps is possible but awkward compared to LangGraph, whereas LangGraph’s directed graph explicitly allows revisiting prior steps or branching off; a powerful but heavier abstraction.</p><h4>When to Stick with LangChain</h4><ul><li><strong>Linear Pipelines:</strong> LangChain is ideal for straightforward, sequential workflows like text transformation or RAG, where each step feeds cleanly into the next and no mid-pipeline decision-making is required.</li><li><strong>Simple RAG and Q&amp;A Systems:</strong> Static knowledge-base applications such as FAQ bots or document summarizers fit naturally into LangChain’s model, requiring only retrieval, prompting, and optional short-term memory.</li><li><strong>Fast Prototyping:</strong> LangChain minimizes boilerplate and cognitive overhead, making it easier to iterate quickly compared to heavier agent or graph-based frameworks.</li><li><strong>Lower Operational Overhead:</strong> For short-lived or single-shot requests, LangChain avoids the additional orchestration complexity introduced by stateful graph execution.</li><li><strong>Latency-Sensitive Use Cases:</strong> Simpler execution paths generally result in lower end-to-end latency, making LangChain better suited for real-time or “quick hit” queries.</li><li><strong>Stateless or Lightly Stateful Systems:</strong> When requests are independent and long-term state or branching logic isn’t required, LangChain is typically the more efficient and pragmatic choice.</li></ul><h4>When LangGraph Shines</h4><ul><li><strong>Stateful, Long-Running Workflows:</strong> LangGraph is well-suited for systems that require persistent state across steps or sessions, such as virtual assistants or multi-turn reasoning workflows, with built-in checkpointing and recovery.</li><li><strong>Conditional Logic and Loops:</strong> Native support for branching, retries, and looping allows workflows to adapt dynamically based on outcomes, without embedding complex control logic throughout the codebase.</li><li><strong>Multi-Agent Coordination:</strong> Graph-based execution enables multiple specialized agents or tools to operate in parallel or sequence, making complex task orchestration natural and maintainable.</li><li><strong>Human-in-the-Loop Workflows:</strong> LangGraph supports pausing execution for review, approval, or intervention, with full state visibility and resumability built in.</li><li><strong>Production-Grade Resilience:</strong> Designed for durable, mission-critical systems, LangGraph offers crash recovery, detailed tracing, and scalability features that reduce operational risk in complex AI applications.</li></ul><h4>Performance and Complexity Trade-offs</h4><p>LangChain has a lighter execution and cognitive footprint, making it well-suited for short-lived, low-latency, and retrieval-heavy workloads where additional orchestration would add unnecessary overhead. For simple queries or linear pipelines, LangChain — or even direct LLM calls — often delivers better performance and faster iteration. LangGraph introduces extra per-step overhead through state management and scheduling, but this cost pays off when workflows require branching, retries, persistence, or re-planning. In those cases, LangGraph outperforms ad-hoc chain-based solutions both in clarity and execution. From a productivity standpoint, LangChain is easier to learn and reason about, while LangGraph’s graph and state-machine model carries higher upfront complexity, making it a poor fit for simple tasks where it would slow teams down rather than accelerate them. As one experienced engineer puts it:</p><blockquote><em>“Avoid implementing a full graph when no loops or persistent state are needed. Over-engineering reduces clarity and increases maintenance cost.”</em></blockquote><p>On the other hand, when an application truly needs a multi-turn agent or fine-grained control, trying to hack it with LangChain often leads to fragile code and hidden bugs.</p><h3>Decision Checklist</h3><p>A quick heuristic often helps teams decide:</p><ul><li><strong>Single-pass vs Multi-pass:</strong> If your workflow is a one-shot pipeline with known steps (e.g. RAG answering or document Q&amp;A), choose <strong>LangChain</strong>. If you foresee multiple decision points or a loop-until-done pattern, lean <strong>LangGraph</strong>.</li><li><strong>Statefulness:</strong> Do you need to remember information across user interactions or iterations? If yes (long chat memory, task lists, session state), LangGraph is preferable. If each call is independent or only uses short-term memory, LangChain (with a simple memory module) is sufficient.</li><li><strong>Error Handling:</strong> For pipelines that must retry or continue on errors, LangGraph has built‑in support (checkpoints, retry edges). In LangChain you’d have to manually catch exceptions and re-call chains.</li><li><strong>Complexity vs Speed:</strong> If rapid prototyping or iteration speed is critical, start with LangChain; it gets you un-stuck faster. Only graduate to LangGraph once your requirements demand it (branching logic, long sessions, human steps).</li><li><strong>Operational Concerns:</strong> Consider deployment. LangChain’s ease to be deployed in stateless enironment design fits well in simple serverless or containerized setups. LangGraph (with its persistent threads) may need additional infrastructure (like a managed agent platform). If your environment is constrained, factor that in.</li><li><strong>Trends:</strong> The community feedback is clear: <strong>there’s no one-size-fits-all standard</strong> anymore. Use LangChain when its abstraction cuts your work; use LangGraph when you’re tackling long-lived, agentic workflows that really need it.</li></ul><h4>Conclusion</h4><p>Avoid over-engineering. If a plain chain does the job, run with it. Only graphify your architecture once your requirements grow beyond the capabilities of a simple chain. By aligning the framework to the problem complexity, teams can move faster and stay focused on building value, not wrestling with unnecessary abstraction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1718e21199f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/langchain-vs-langgraph-choosing-the-right-ai-workflow-framework-1718e21199f0">LangChain vs LangGraph: Choosing the Right AI Workflow Framework</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agentic AI Systems with Integrated XAI: Building Smarter, Transparent, and Trustworthy AI]]></title>
            <link>https://medium.com/red-buffer/agentic-ai-systems-with-integrated-xai-building-smarter-transparent-and-trustworthy-ai-087502181fd0?source=rss-c9cff60cdd5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/087502181fd0</guid>
            <dc:creator><![CDATA[Tauseefahmed Tam]]></dc:creator>
            <pubDate>Fri, 06 Feb 2026 07:35:33 GMT</pubDate>
            <atom:updated>2026-02-06T07:35:33.972Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BThywYG3Nts04Q27twvnww.png" /></figure><p>Artificial Intelligence (AI) has evolved from simple predictive models into agentic systems. Agentic systems are AI entities that can reason, plan, and take autonomous actions. But as AI becomes more capable, one critical question arises:</p><blockquote>How do we trust its decisions?</blockquote><p>This is where Explainable AI (XAI) enters the stage. By integrating XAI into agentic AI systems, we can build agents that not only act but also explain why they act the way they do.</p><h4>🧠 What are Agentic AI Systems?</h4><p>An agentic AI system is more than just a machine learning model. Unlike traditional ML models that passively output predictions (e.g., “spam” vs. “not spam”), an agentic system can:</p><p>Perceive its environment (through inputs like text, images, or sensor data)</p><p><em>Reason about goals and constraints</em></p><p><em>Plan a sequence of actions</em></p><p><em>Act autonomously to achieve objectives</em></p><p><em>Learn and Adapt from new data and outcomes</em></p><p>Think of ChatGPT with internet access, or a trading bot that adjusts strategies dynamically. These are agentic because they operate like intelligent decision-makers.</p><h4>🔎 Why Do We Need XAI (Explainable AI)?</h4><p>The more autonomy we give to AI, the more important <strong>trust and accountability</strong> become.</p><p>Imagine:</p><ul><li>A healthcare agent suggests a treatment plan.</li><li>A financial agent executes trades on your behalf.</li><li>A legal agent reviews contracts.</li></ul><p>Would you follow their advice blindly? Probably not.</p><p>This is why <strong>Explainable AI (XAI)</strong> is critical: it makes decisions <strong>transparent</strong> by showing reasoning, evidence, and trade-offs.</p><p>Benefits of integrating XAI into agents:</p><ul><li><strong>Trust</strong> → Users can see <em>why</em> a decision was made</li><li><strong>Debugging</strong> → Engineers can identify biases or flaws</li><li><strong>Compliance</strong> → Regulations (like GDPR) require explanation of automated decisions</li><li><strong>Adoption</strong> → People are more likely to use AI they understand</li></ul><h4>⚙️ Architecture of Agentic AI with XAI</h4><p>An <strong>agentic AI system with XAI</strong> typically has these 5 layers:</p><ol><li><strong>Perception Layer</strong> → Collects input (text, data, sensors)</li><li><strong>Cognition Layer (Reasoning Engine)</strong> → Uses ML + symbolic reasoning</li><li><strong>Decision Layer</strong> → Plans and selects best action</li><li><strong>Action Layer</strong> → Executes the decision</li><li><strong>XAI Layer (Transparency Module)</strong> → Generates human-readable explanations</li></ol><pre>[Input Data] → [Perception] → [Reasoning/Planning] → [Decision] → [Action]<br>                                                    ↘ [XAI Explanation]</pre><h4>💻 Coding a Simple Agent with XAI</h4><p>Let’s build a <strong>toy AI agent</strong> that:</p><ul><li>Takes a <strong>goal</strong> (e.g., recommend a movie)</li><li>Makes a <strong>decision</strong> using ML</li><li>Provides a <strong>human-friendly explanation</strong> with SHAP (SHapley Additive exPlanations)</li></ul><p><strong>Step 1: Build a simple recommendation agent</strong></p><pre>import shap<br>import numpy as np<br>from sklearn.datasets import load_iris<br>from sklearn.ensemble import RandomForestClassifier<br><br># Step 1: Environment perception (load dataset)<br>data = load_iris()<br>X, y = data.data, data.target<br><br># Step 2: Cognition (train ML model)<br>model = RandomForestClassifier(n_estimators=50)<br>model.fit(X, y)<br><br># Step 3: Agent makes a decision<br>sample = X[42].reshape(1, -1)<br>prediction = model.predict(sample)[0]<br>decision = data.target_names[prediction]<br><br>print(f&quot;Agent&#39;s decision: Recommend &#39;{decision}&#39;&quot;)</pre><h4>Step 2: Add XAI explanation with SHAP</h4><pre># Explain WHY the decision was made<br>explainer = shap.TreeExplainer(model)<br>shap_values = explainer.shap_values(sample)<br>shap_values_for_class = shap_values[prediction][0]<br><br># Handle case where number of SHAP values doesn&#39;t match number of features<br>if len(shap_values_for_class) != n_features:<br>    # Pad SHAP values with zeros to match number of features<br>    padded_shap = np.zeros(n_features)<br>    padded_shap[:len(shap_values_for_class)] = shap_values_for_class<br>    shap_values_for_class = padded_shap<br><br>print(&quot;\nExplanation (Top features influencing decision):&quot;)<br>for i, feature_name in enumerate(feature_names):<br>    if i &lt; len(shap_values_for_class):<br>        shap_value = shap_values_for_class[i]<br>    else:<br>        shap_value = 0.0  # Default if SHAP value is missing<br>    print(f&quot;{feature_name}: {shap_value:.3f}&quot;)</pre><p><strong>Output Example:</strong></p><pre>Agent&#39;s decision: Recommend &#39;setosa&#39;<br><br>Explanation (Top features influencing decision):<br>sepal length (cm): 0.066<br>sepal width (cm): -0.039<br>petal length (cm): -0.028<br>petal width (cm): 0.000</pre><p>This means the agent didn’t just pick a flower but it also explained that petal length and petal width were the most important features.</p><h4>🌍 Real-World Applications</h4><p>Healthcare Agents → AI diagnosis systems explaining risk factors for diseases</p><p>Financial Agents → Trading bots that justify investment moves</p><p>Legal Agents → Contract analysis with traceable reasoning</p><p>Customer Service Agents → Transparent recommendations, not “black box” replies</p><p>Autonomous Vehicles → Explaining navigation decisions in case of accidents</p><h4>🚀 Future of Agentic AI with XAI</h4><p>The future is moving towards self-reflective agents systems that:</p><p>Explain their decisions in natural language</p><p>Audit themselves for bias</p><p>Provide confidence levels for their outputs</p><p>Learn user preferences to give personalized explanations</p><p>Imagine a world where your AI assistant doesn’t just tell you what to do but also explains why it’s the best option for you specifically.</p><blockquote>With more AI comes more explanation — ML Engineer</blockquote><h4>Conclusion</h4><p>Agentic AI is shaping the next generation of intelligent systems that are autonomous, adaptive, and action-driven. But without explainability, they risk becoming black boxes we can’t trust. The combination of Agentic AI + XAI paves the way for responsible, ethical, and human-aligned AI.</p><p>Code notebook: <a href="https://colab.research.google.com/drive/1gV-Ca5Lzt7mWPm_zMkdgPU58ZS9Xqm3_?usp=sharing">https://colab.research.google.com/drive/1gV-Ca5Lzt7mWPm_zMkdgPU58ZS9Xqm3_?usp=sharing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=087502181fd0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/agentic-ai-systems-with-integrated-xai-building-smarter-transparent-and-trustworthy-ai-087502181fd0">Agentic AI Systems with Integrated XAI: Building Smarter, Transparent, and Trustworthy AI</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Content-Based Filtering?]]></title>
            <link>https://medium.com/red-buffer/what-is-content-based-filtering-a1895aa9425d?source=rss-c9cff60cdd5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1895aa9425d</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[content-filtering]]></category>
            <dc:creator><![CDATA[Tauseefahmed Tam]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 10:32:55 GMT</pubDate>
            <atom:updated>2025-01-13T10:32:55.337Z</atom:updated>
            <content:encoded><![CDATA[<p>Content-based filtering (CBF) is a transformative technique that leverages item attributes to deliver personalized recommendations. Unlike collaborative filtering, which relies on user behavior, CBF focuses on the characteristics of the items themselves. This guide explains the fundamentals of content-based filtering and provides practical steps to build your own model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFCsetmEaYH1lr0SlSBQhA.jpeg" /><figcaption>Content-Based Filtering: A Comprehensive Guide</figcaption></figure><p>Content-based filtering uses item attributes to recommend similar items to users. For example, if a user enjoys action movies starring Tom Cruise, the system might recommend other action movies with similar features. Similarity between items is computed using mathematical methods such as cosine similarity, Euclidean distance, or Pearson correlation.</p><h3>Advantages of Content-Based Filtering</h3><ul><li><strong>Personalization:</strong> Recommendations are tailored to an individual user’s preferences.</li><li><strong>Cold Start for Users:</strong> Can recommend items to new users without requiring data on others’ preferences.</li><li><strong>Transparency:</strong> Easy to understand why a particular item is recommended based on attributes.</li></ul><h3>Step-by-Step Guide to Building a Content-Based Filtering System</h3><h4>1. Data Collection and Preprocessing</h4><p>Gather a dataset containing items and their attributes. Examples include genres, tags, cast, and creators for movies, or descriptions and categories for products.</p><p><strong>Example Dataset:</strong></p><p>MovieGenreActorDirectorRatingMovie AActionTom CruiseJames Gunn4.5Movie BComedyAdam SandlerSteven Spielberg4.0Movie CActionTom HanksJames Cameron3.5Movie DSci-FiKeanu ReevesThe Wachowskis4.2</p><p><strong>Preprocessing Steps:</strong></p><ul><li>Combine relevant attributes into a single text string (e.g., genre, actor, and director).</li><li>Clean the data by handling missing values and normalizing text.</li></ul><h4>2. Feature Extraction and Vectorization</h4><p>Convert textual attributes into numerical representations using techniques like:</p><ul><li><strong>TF-IDF (Term Frequency-Inverse Document Frequency):</strong> Measures word importance in item descriptions.</li><li><strong>Word Embeddings (e.g., Word2Vec, GloVe):</strong> Captures semantic meanings of words.</li></ul><h4>3. Similarity Computation</h4><p>Once items are represented as vectors, calculate their similarity using methods such as:</p><ul><li><strong>Cosine Similarity:</strong> Measures the cosine of the angle between two vectors (ranges from -1 to 1).</li><li><strong>Euclidean Distance:</strong> Measures the straight-line distance between vectors.</li><li><strong>Jaccard Similarity:</strong> Measures set similarity as the ratio of intersection over union.</li></ul><h4>4. Recommendation Generation</h4><p>Rank items based on their similarity scores to the user’s previously liked items and recommend the top items.</p><h3>Python Implementation Example</h3><p>Here’s how to create a basic content-based filtering system using Python and scikit-learn:</p><pre>import pandas as pd<br>from sklearn.feature_extraction.text import TfidfVectorizer<br>from sklearn.metrics.pairwise import cosine_similarity</pre><pre># Sample movie dataset<br>data = {<br>    &#39;Movie&#39;: [&#39;Movie A&#39;, &#39;Movie B&#39;, &#39;Movie C&#39;, &#39;Movie D&#39;],<br>    &#39;Genre&#39;: [&#39;Action&#39;, &#39;Comedy&#39;, &#39;Action&#39;, &#39;Sci-Fi&#39;],<br>    &#39;Actor&#39;: [&#39;Tom Cruise&#39;, &#39;Adam Sandler&#39;, &#39;Tom Hanks&#39;, &#39;Keanu Reeves&#39;],<br>    &#39;Director&#39;: [&#39;James Gunn&#39;, &#39;Steven Spielberg&#39;, &#39;James Cameron&#39;, &#39;The Wachowskis&#39;],<br>    &#39;Rating&#39;: [4.5, 4.0, 3.5, 4.2]<br>}<br>df = pd.DataFrame(data)</pre><pre># Combine features into a single string<br>df[&#39;Features&#39;] = df[&#39;Genre&#39;] + &#39; &#39; + df[&#39;Actor&#39;] + &#39; &#39; + df[&#39;Director&#39;]</pre><pre># TF-IDF Vectorization<br>tfidf_vectorizer = TfidfVectorizer()<br>tfidf_matrix = tfidf_vectorizer.fit_transform(df[&#39;Features&#39;])</pre><pre># Compute cosine similarity<br>cosine_sim = cosine_similarity(tfidf_matrix, tfidf_matrix)</pre><pre># Recommend items similar to a given movie<br>user_likes = [&#39;Movie A&#39;]<br>movie_index = df[df[&#39;Movie&#39;].isin(user_likes)].index[0]<br>similar_movies = list(enumerate(cosine_sim[movie_index]))<br>similar_movies = sorted(similar_movies, key=lambda x: x[1], reverse=True)[1:3]  # Exclude the movie itself<br>recommended_movies = [df.iloc[movie[0]][&#39;Movie&#39;] for movie in similar_movies]</pre><pre>print(&quot;Recommended movies:&quot;, recommended_movies)</pre><p><strong>Output:</strong></p><pre>Recommended movies: [&#39;Movie C&#39;, &#39;Movie D&#39;]</pre><h3>Evaluation Metrics</h3><p>Evaluate your content-based filtering system using:</p><ul><li><strong>Precision and Recall:</strong> Measure relevance of recommendations.</li><li><strong>Mean Squared Error (MSE):</strong> For numerical ratings.</li><li><strong>Coverage:</strong> Fraction of items that can be recommended.</li></ul><h3>Conclusion</h3><p>Content-based filtering is a robust technique for delivering personalized recommendations based on item attributes. By following this guide, you can create a content-based filtering system tailored to your specific use case. As you refine your system, consider integrating advanced methods such as deep learning embeddings or hybrid approaches for enhanced performance.</p><p>Unlock the potential of content-based filtering to build smarter, more effective recommendation systems today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1895aa9425d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/what-is-content-based-filtering-a1895aa9425d">What is Content-Based Filtering?</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Controlling ControlNet: A Game-Changer for Diffusion Models]]></title>
            <link>https://medium.com/red-buffer/controlling-controlnet-a-game-changer-for-diffusion-models-ee1152305d9b?source=rss-c9cff60cdd5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee1152305d9b</guid>
            <category><![CDATA[diffusion]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[hugging-face]]></category>
            <category><![CDATA[controlnet]]></category>
            <category><![CDATA[generative-ai]]></category>
            <dc:creator><![CDATA[Tauseefahmed Tam]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 08:28:55 GMT</pubDate>
            <atom:updated>2024-03-20T08:28:55.185Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*NIsI4sRR3CCzn9gg" /><figcaption>Create your images in a controlled pose¹.</figcaption></figure><p>If you’ve ever worked with diffusion models, you’ve likely encountered the frustrating randomness that accompanies their AI-generated outputs. Despite crafting precise prompts, generating a character in a specific pose often results in unusable outputs more often than not.</p><p>This inherent issue in diffusion models, rooted in their learning of distributions rather than features and their reliance on noise as a starting point, poses a challenge. However, a solution exists: ControlNet.</p><h3>The Role of ControlNet</h3><p>ControlNets, aptly named for their role in controlling the output of diffusion models, come in various types tailored to different desired outputs. Whether you seek to control the pose, expressions, placement, style, coloring, depth, orientation, or any other characteristic, there’s a ControlNet for it.</p><p>At its core, ControlNets are neural networks that employ a conditioning image to guide the output. This conditioning image can take various forms, from sketches to depth maps or pose maps, as long as it contributes to the structure or artistic aspects of the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tf6GqOYEGiblxkMH" /><figcaption>A neural block takes a feature map x as input and outputs another feature map y, as shown in (a). To add a ControlNet to such a block we lock the original block and create a trainable copy and connect them together using zero convolution layers, i.e., 1 × 1 convolution with both weight and bias initialized to zero. Here c is a conditioning vector that we wish to add to the network, as shown in (b)².</figcaption></figure><p>The process involves duplicating the neural network weights into a “locked” and a “trainable” copy. The “trainable” copy adjusts to your specific conditions, while the “locked” one maintains the original model. This method ensures that training with a small dataset of image pairs does not compromise the integrity of the production-ready diffusion models.</p><p>The concept of “zero convolution” involves initializing a 1x1 convolution with weights and biases set to zero. Prior to training, all zero convolutions output zeros, ensuring that the ControlNet does not distort the model in any way³.</p><p>Rather than training layers from scratch, this approach involves fine-tuning the model, preserving the original architecture. This makes it possible to train models on smaller devices while also facilitating the merging, replacement, or offsetting of models, weights, blocks, or layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/0*EWDrMqML9kIGgB1F" /><figcaption>Stable Diffusion’s U-net architecture connected with a ControlNet on the encoder blocks and middle block. The locked, gray blocks show the structure of Stable Diffusion V1.5 (or V2.1, as they use the same U-net architecture). The trainable blue blocks and the white zero convolution layers are added to build a ControlNet².</figcaption></figure><h3>Implementation and Impact</h3><p>ControlNet, introduced by <a href="https://www.semanticscholar.org/author/Lvmin-Zhang/17744884">Lvmin Zhang</a>³ and <a href="https://scholar.google.com/citations?user=YPzKczYAAAAJ&amp;hl=en&amp;oi=sra">Maneesh Agrawala</a>⁴ in their paper “<a href="https://openaccess.thecvf.com/content/ICCV2023/html/Zhang_Adding_Conditional_Control_to_Text-to-Image_Diffusion_Models_ICCV_2023_paper.html">Adding Conditional Control to Text to Image Diffusion Models</a>” has revolutionised the use of diffusion models. It’s akin to the “Discriminator” in GANs, introducing the concept of features to the distribution-learning nature of diffusion models.</p><p>Generative AI possesses immense potential across numerous use cases, but this potential is only realised with proper regulation. ControlNets serve as the regulatory mechanism, channeling diffusion models toward specific use cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*xK4DdiZC-0RcD0oY" /><figcaption>The first row is the type of different conditioning image, the rest is images developed using the condition image².</figcaption></figure><h3>Use Cases and Training</h3><p>ControlNets can be applied in various scenarios. For instance, suppose you admire an actor’s iconic pose or an artist’s unique style but lack the artistic skill to recreate or adopt it. In that case, you can input your image and the desired conditioning image, and the ControlNet will generate an image of you in the actor’s pose or in the artist’s style.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xwWJ7LUze42Yjmpd" /><figcaption>Showing the adhered consistency of diffuser model using ControlNet².</figcaption></figure><p>Training a ControlNet is akin to fine-tuning a stable diffusion model for image-to-image translation. However, there are some differences, such as higher resource requirements and variations in dataset creation.</p><h3>Personal Experiences and Recommendations</h3><p>Having trained several ControlNets,it is important to note that using diffuser’s official repo with provided training files and guidelines makes this process the easiest, these files can be found in their repo under examples&gt;controlnets. There are two files, one is for training controlnet for SDXL and the other one is for <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5">SD1.5</a> and <a href="https://huggingface.co/stabilityai/stable-diffusion-2-1">SD2.1</a>, one just needs to change the name of the model while using the second file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/0*bv5B6m7i4Sah8Fv0" /><figcaption>Location of the training files⁵.</figcaption></figure><p>I’ve encountered some experiences worth sharing:</p><p>1. Resource Requirements: Training ControlNets demands significant resources. Even with a powerful GPU like the NVIDIA A6000 with 48GB of VRAM, achieving a train batch size of 3 was the maximum. Using the official repository’s provided training files and guidelines is the most straightforward approach.</p><p>2. VAE: The default VAE may not work optimally, as evidenced by black validation images during training. Experimenting with different VAEs is advisable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*pZ2u-nBgphP_aKWr" /><figcaption>The official repo itself mentions avoiding the default VAE⁶.</figcaption></figure><p>3. Conditioning Images: It’s preferable to have conditioning images with consistent backgrounds. While many guides use black backgrounds, I found that using the same background as my dataset improved training outcomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h23x-RiyZyTlKjT1" /><figcaption>Note that canny image (conditioning image) has black background⁶.</figcaption></figure><p>4. Prompts: Writing descriptive prompts can significantly enhance training results, especially for strict adherence to conditioning images. Incorporating trigger words can further refine the output.</p><p>In conclusion, ControlNet offers a refined approach to the use of diffusion models, providing a level of control previously unattainable. While it comes with its own challenges and nuances, the benefits it offers make it a valuable tool for the AI community.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XN2j_vngfsBlpPpD" /></figure><h3>References</h3><ol><li><a href="https://medium.com/@techlatest.net/stable-diffusion-and-control-net-a-beginners-guide-9efefe2790f">https://medium.com/@techlatest.net/stable-diffusion-and-control-net-a-beginners-guide-9efefe2790f</a></li><li>Zhang, Lvmin, Anyi Rao, and Maneesh Agrawala. “Adding conditional control to text-to-image diffusion models.” <em>Proceedings of the IEEE/CVF International Conference on Computer Vision</em>. 2023.</li><li><a href="https://www.semanticscholar.org/author/Lvmin-Zhang/17744884">https://www.semanticscholar.org/author/Lvmin-Zhang/17744884</a></li><li><a href="https://scholar.google.com/citations?user=YPzKczYAAAAJ&amp;hl=en&amp;oi=sra">https://scholar.google.com/citations?user=YPzKczYAAAAJ&amp;hl=en&amp;oi=sra</a></li><li><a href="https://github.com/huggingface/diffusers">https://github.com/huggingface/diffusers</a></li><li><a href="https://blog.openvino.ai/blog-posts/enable-lora-weights-with-stable-diffusion-controlnet-pipeline">https://blog.openvino.ai/blog-posts/enable-lora-weights-with-stable-diffusion-controlnet-pipeline</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee1152305d9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/controlling-controlnet-a-game-changer-for-diffusion-models-ee1152305d9b">Controlling ControlNet: A Game-Changer for Diffusion Models</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>