<?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 Anik Chakraborty on Medium]]></title>
        <description><![CDATA[Stories by Anik Chakraborty on Medium]]></description>
        <link>https://medium.com/@anikch?source=rss-4c88c62a8e03------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C9I5_eYgj-A1yFOROCHTcA.jpeg</url>
            <title>Stories by Anik Chakraborty on Medium</title>
            <link>https://medium.com/@anikch?source=rss-4c88c62a8e03------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:00:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anikch/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Cognitive Dissonance Agent: Why the Best AI Reasoning Starts With Self-Doubt]]></title>
            <link>https://pub.towardsai.net/the-cognitive-dissonance-agent-why-the-best-ai-reasoning-starts-with-self-doubt-d1a7b5ffb42e?source=rss-4c88c62a8e03------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1a7b5ffb42e</guid>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[langgraph]]></category>
            <category><![CDATA[cognitive-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Anik Chakraborty]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 20:39:08 GMT</pubDate>
            <atom:updated>2026-04-01T02:41:48.861Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Part 1 of 2 - The psychology, the positioning, and the architecture</strong></h4><p><strong><em>What if the most powerful thing an AI agent could do was not give you an answer but sit with the contradiction?</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVyntgX2nduCT9Soiv2R4Q.png" /><figcaption>Image generated by the author using Google Gemini</figcaption></figure><p>For years, we have trained machines to converge upon the answer, reduce uncertainty, and optimise. However, what cognitive science tells us is something we do not have an easy time believing; namely, that the discomfort arising from simultaneously holding two contradictory beliefs (like the example Leon Festinger referred to as cognitive dissonance back in 1957) serves as one of the most powerful engines of human reasoning.<br>What if we began to <strong>build that tension into the architecture of an AI agent</strong>, not as multi-agents debating back and forth between one another as separate systems but instead as structured internal conflict occurring in one mind?</p><p>This article will demonstrate how to create a cognitive dissonance agent (CDA), i.e., a single LangGraph agent who has the internal reasoning ability designed to be built upon productive self-disagreement, with measured levels of tension and architecturally enforced revision of belief. Not a committee. Not a debate club. One agent, one state, one mind- with the capacity for genuine internal conflict.</p><h3><strong>The Psychology: Why Internal Conflict Makes You Smarter</strong></h3><p>Cognitive dissonance is the mental friction you feel when two of your beliefs clash. You may believe that smoking is bad for your health and at the same time have a habit of smoking. You may be a person who values honesty but has told a lie to spare someone’s feelings. That uncomfortable tension is not a bug in human cognition, it’s the mechanism that forces belief revision. Festinger’s original theory identified 3 ways people resolve dissonance:</p><ul><li><strong>Change the behaviour: </strong>stop smoking.</li><li><strong>Change the belief: </strong>“Is smoking as bad for you as they say it is?”</li><li><strong>Add a new cognition: </strong>“I exercise enough to nullify the death resulting from smoking.”</li></ul><p>The key point is that the dissonance itself is productive. Without it, beliefs are never stress-tested. We tend to live on autopilot, only seeking out information that confirms what we already think. Dissonance is the disruptor. But dissonance does not always resolve in the direction of truth. The very processes that reduce psychological tension can also produce motivated reasoning, denial of reality, or selective attention to confirming evidence. Humans generally resolve this discomfort in ways that protect their ego rather than reflect actual reality. Therefore, any attempt to create a model for AI agents that exhibits cognitive tension must account for both forms of resolution: one that is evidence-driven (i.e., corrects based upon available evidence) and the second that is self-justifying rationalization.</p><h3>One Agent, One Mind: Why Is This Not a Committee?</h3><p>It is simple to confuse the Cognitive Dissonance Agent with other existing concepts, but it’s actually a brand-new idea. We’re going to define the boundaries clearly: first around architecture and then against the research landscape. These distinctions are what will enable us to construct a pattern for this new concept.</p><p><strong>It’s Not a Multi-Agent System:<br></strong>If you have previously used CrewAI, AutoGen or LangGraph’s own Supervisor/Swarm libraries, you might be thinking: “I am already doing this. All I have is 3 agents set up ready to go, who just sit together and argue.&quot; That is a fundamentally different architecture.<br>The traditional concept is that of the multi-agent debate system (like Du et al.’s debate framework or AutoGen’s agent-to-agent messaging) to provide each agent with its own context window, its own state, and its own memory. The two agents communicate by passing messages back and forth between one another. As the individual agents are totally independent from each other, they can have an actual debate and reach agreements, representing an example of a <strong>“committee of minds” -</strong> thus, this method is a useful approach but not an example of cognitive dissonance because there is no unified self experiencing the tension.</p><p>A Cognitive Dissonance Agent is a single mind. Different perspectives: optimist, pessimist, skeptic- are all in the same graph and share the same state. They all access and modify the same working memory, and the dissonance value is an attribute of the agent’s routing mechanism.<br>The neuroscience model is the same: the amygdala and prefrontal cortex can “disagree” about a threat, but they are not two agents; they are subsystems of the same cognitive system processing the same information. CDA’s cognitive lenses work the same way.</p><p><strong>It’s Not a Critic Loop:<br></strong>In a critic loop pattern <strong>(generate → critique → revise)</strong>, a single agent generates an output, and a critic judges it with simple feedback such as “good/bad” or a confidence level. The agent retries until it succeeds. The feedback is a single dimension of evaluation, and the system always converges, as the critic never says that a question has no clear answer.<br>A Cognitive Dissonance Agent is different. Multiple internal lenses generate competing perspectives, and the tension score is incorporated into the agent’s internal state, rather than a pass/fail result. The system can also indicate an unresolved conflict instead of a false resolution.</p><h3>How It Differs from Research Frameworks</h3><p>The <strong>Reflexion</strong> approach (Shinn et al, 2023) is a reflect-then-retry process which contains the following steps: attempting an action, evaluating it, self-reflecting, storing that reflection, and retrying the same action again. Although this process is extremely powerful, it has the potential to create “degenerative reasoning” due to the same model replicating its own logical fallacies and inherent flaws in its own reasoning. The <strong>Multi-Agent Reflexion (MAR)</strong> paper by Ozer et al. (2025) deals with this issue by employing multi-persona debate critics for better reflections. But CDA is different in that it obtains the conflict from structurally different evidence sources (through RAG) and from different nodes in the graph, instead of using one model to critique itself.</p><p><strong>Self-Refine</strong> involves the model in loops where it is both writer and editor. Same problem, same priors for the editor and the writer.</p><p><strong>Multi-Agent Debate</strong> (Du et al., 2023) is the closest but optimizes for consensus. But CDA specifically chooses to quantify and maintain tension. Sometimes the best answer is that views are irretrievably in conflict, and the user should be aware of this.</p><p><strong>The Tree of Thought </strong>works to explore many options for solving a problem and then chooses the most optimal path towards having agreed upon a solution. Its main purpose is to use an exploration method to reach an agreement, and many of the non-optimal paths will be discarded once a final agreement is reached. Ours preserves all original pathways taken in the original process of seeking an alternate view.</p><p><strong>What the Cognitive Dissonance Agent adds?<br> </strong>The Cognitive Dissonance Agent considers disagreement as a significant indicator, rather than only something that must be reconciled in order to find common ground. Thus, when different internal perspectives are in direct opposition to one another, the agent can provide a report on the level of disagreement rather than forcing a final answer.</p><p><strong>An Honest Caveat:<br></strong>We use “cognitive dissonance” as a design metaphor based on Festinger’s theory, not to say that the agent feels dissonance in the phenomenological sense. The architecture illustrates the functional structure of dissonance: conflicting cognitions within a cohesive state, a calibrated tension signal, and an impetus for resolution via belief revision. What it doesn’t model is the motivational aversiveness (the felt “unpleasantness”) or ego-involvement that characterises human dissonance. The metaphor is accurate enough to be helpful and honest enough not to go too far. That being said, “cognitive dissonance” is a better term here than “dialectical tension” because dialectics means two different people talking to each other, which is not what this architecture is. This is one agent arguing with itself in its own mind.</p><h3>Why LangGraph: The Architecture of a Self-Doubting Mind</h3><p>Cognitive dissonance needs an architecture that has a shared state, parallel reasoning, tension-based routing, and loops that can be resumed. LangGraph’s StateGraph does exactly this; it maps closely to how dissonance works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_b6eBDFRL_ya0Sn-7ho2w.png" /><figcaption>The Cognitive Dissonance Agent (CDA)</figcaption></figure><p><strong>A Single StateGraph Is a Single Mind:</strong><br>We implement the agent as a single compiled StateGraph- one graph, one shared state, one mind. There is only one state that all nodes (views, analyses, reconciliations) work in. The <strong>DissonantAgentState</strong> serves as working memory, with conflicts occurring internally rather than among multiple agents.</p><pre>class DissonantAgentState(TypedDict):<br>    query: str<br>    optimist_view: str          # Internal perspective A<br>    pessimist_view: str         # Internal perspective B<br>    skeptic_view: str           # Internal perspective C<br>    dissonance_score: float     # The agent&#39;s felt tension<br>    reconciliation: str         # Self reconciliation attempt<br>    loop_count: Annotated[int, operator.add]  # Revision counter<br>    response: str               # Final output</pre><p><strong>Fan-Out as Parallel Thinking:</strong><br>LangGraph has built-in support for fan-out, which means that one point can connect to multiple destination nodes through multiple edges. The graph sees this pattern and runs the destination nodes at the same time in a single “superstep”. In a superstep, all nodes run at the same time and must finish before the graph can move on.<br>This is a direct match for the neuroscience analogy. When you see a spider, your amygdala (which detects threats) and prefrontal cortex (which makes rational decisions) work together, not one after the other. They work on shared representations at the same time and send out conflicting signals. LangGraph’s fan-out gives us the same pattern:</p><pre># All three lenses activate concurrently in one superstep<br># like parallel neural circuits evaluating the same stimulus<br>graph.add_edge(START, &quot;optimist_lens&quot;)<br>graph.add_edge(START, &quot;pessimist_lens&quot;)<br>graph.add_edge(START, &quot;skeptic_lens&quot;)<br><br># Explicit fan-in: all three must complete before tension measurement<br>graph.add_edge(<br>    [&quot;optimist_lens&quot;, &quot;pessimist_lens&quot;, &quot;skeptic_lens&quot;],<br>    &quot;feel_dissonance&quot;,<br>)</pre><p>If one of the 3 lenses fails, the whole superstep fails atomically, which means there is no partial state corruption. And when checkpointing is turned on, the successful nodes in the superstep are saved. So, on failure, only the failing branch needs to run again when it resumes.</p><p><strong>Conditional Edges as the Drive for Resolution:</strong><br>According to Festinger’s theory, dissonance creates a motivational state in which the agent wants to lower the tension. In LangGraph, add_conditional_edges lets us route the graph based on any part of the agent’s state. The routing signal is the dissonance score:</p><pre>graph.add_conditional_edges(<br>    &quot;feel_dissonance&quot;,<br>    resolution_drive,        # Routes based on dissonance_score<br>    {<br>        &quot;synthesise&quot;: &quot;synthesise&quot;,<br>        &quot;reconcile&quot;: &quot;reconcile_self&quot;,<br>        &quot;report_tension&quot;: &quot;report_tension&quot;,<br>        &quot;synthesise_with_caveats&quot;: &quot;synthesise_with_caveats&quot;,<br>    },<br>)</pre><p>This is how a static tension measurement becomes a dynamic behavior: the agent’s internal conflict determines what it will do next. Low tension → put together. High tension means trying to make things right. If there is ongoing tension, be honest in your report. The graph makes this happen, and no amount of prompt engineering can get around it.</p><p><strong>Why Some State Accumulates and Some Overwrites in Reducers?<br></strong>LangGraph’s reducer system decides how to combine state updates. This is important for the dissonance pattern because different fields need different meanings:<br><strong>The operator uses loop_count.add:</strong> Every time you go through the measurement node, it gives you back {“loop_count”: 1}, which adds to the total. The count goes up to 3 after three reconciliation loops, which causes the <strong>report_tension exit to happen</strong>. Without the reducer, every return would set the count to 1, and the agent would keep going in circles.<br><strong>The default for dissonance_score is last-write-wins</strong>. You want the most recent reading, not a running sum. Each measurement replaces the last score, which is correct because the agent’s current level of tension is what matters for routing, not its historical average.<br>This asymmetry, where some fields build up and others replace, is the kind of fine-grained state control that makes the dissonance pattern work.</p><p><strong>Checkpointing: Introspection that can be resumed:<br></strong>The reconciliation loop can have between 3 and 9 LLM calls per iteration (reconciliation, three belief revisions, and re-measurement). You don’t want to run the first reconciliation and all of its belief revisions again if the second one fails because of a timeout or an API error.<br><strong>LangGraph’s checkpointing</strong> saves the state at each superstep boundary. MemorySaver (for dev) or PostgresSaver (for prod) keeps the entire history of the agent’s internal conflict:</p><pre>checkpointer = MemorySaver()<br>agent = graph.compile(checkpointer=checkpointer)<br><br># Invoke with a thread_id to enable persistent checkpointing<br>result = await agent.ainvoke(<br>    {&quot;query&quot;: &quot;Should we pivot to an API-first model?&quot;},<br>    config={&quot;configurable&quot;: {&quot;thread_id&quot;: &quot;analysis-42&quot;}}<br>)</pre><p>You can also see the dissonance score at each iteration, how each lens changed through reconciliation, and whether the final synthesis really fixed the problem or just made it easier to deal with. <br>Nothe that, the state only keeps track of the current views. You can see how each lens changes over time by looking at the checkpoint history, not by looking at explicit history fields in the state.</p><p><strong>The Full Mapping:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Csx-9PPqFpwz5JzIhT5Zfg.png" /><figcaption>The Complete Mapping</figcaption></figure><p>If you’re using this in a different framework, you need to keep these architectural features: shared mutable state across all reasoning processes, parallel execution with atomic failure, tension-driven conditional routing, accumulating loop counters with replace-semantics for scores, and persistent checkpointing.</p><h3>What Comes Next: Building It</h3><p>We have set up the framework by talking about cognitive dissonance, why single StateGraph works, how it’s different from multi-agent setups and how it maps to LangGraph.</p><p><strong>Part 2: making this into code with two patterns:<br>Dissonant Mind: </strong>One agent with parallel RAG lenses that find conflict and either resolve it or bring it to light learning by arguing with itself.<br><strong>Commitment-Disruption: </strong>One agent questions its own plan and decides to change it, explain it, or make it worse, keeping track of bias with a rationalization score.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1a7b5ffb42e" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/the-cognitive-dissonance-agent-why-the-best-ai-reasoning-starts-with-self-doubt-d1a7b5ffb42e">The Cognitive Dissonance Agent: Why the Best AI Reasoning Starts With Self-Doubt</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Weight of Evidence (WoE) and Information Value (IV) — how to use it in EDA and Model Building?]]></title>
            <link>https://anikch.medium.com/weight-of-evidence-woe-and-information-value-iv-how-to-use-it-in-eda-and-model-building-3b3b98efe0e8?source=rss-4c88c62a8e03------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b3b98efe0e8</guid>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[variable-transformation]]></category>
            <category><![CDATA[weight-of-evidence]]></category>
            <category><![CDATA[information-value]]></category>
            <dc:creator><![CDATA[Anik Chakraborty]]></dc:creator>
            <pubDate>Sun, 05 Sep 2021 12:12:30 GMT</pubDate>
            <atom:updated>2021-09-19T01:16:16.709Z</atom:updated>
            <content:encoded><![CDATA[<p>Weight of Evidence (WoE) and Information Value (IV) can be used to understand the predictive power of an independent variable. WoE helps to understand if a particular class of an independent variable has a higher distribution of good or bad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*nolqSLc4K5WekDkbpFevdg.png" /><figcaption>Image by author</figcaption></figure><h3>How to calculate WOE and IV?</h3><p>If we consider a binary classification where our target variable is bad (0) / good (1) loans, and we have a feature called Age Group having 3 classes (18–35, 36–55, 56–70), we can calculate WoE for each class using below equation:</p><figure><img alt="calculating Weight of Evidence" src="https://cdn-images-1.medium.com/max/600/1*ydBoxGrvXpo54yEeLDzzMA.png" /></figure><p>In the example below, there is a total of 7302 Good (1) observations, out of which, 2000 are in 18–35 age group. Again, out of a total 693 (0) bad observations, 400 observations belong to class 18–35.</p><blockquote>WoE for 18–35 class=</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*62bxB_tofGH4zzs5aXq7Sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*sDSw-3IslnFfEC2yq5MZKA.png" /><figcaption>Image by author</figcaption></figure><p>Negative WoE value of 18–35 denotes that the <strong>distribution of bad </strong>&gt; <strong>distribution of goods</strong> for age group 18–35.</p><p>Now, Information Value can be calculated by using below equation:</p><p><strong><em>IV= WoE * (proportion of all good in the class — proportion of all bad in the class)</em></strong></p><p>So, for 18–35 class, IV= -0.75 * (.27 — .58) = .23</p><p>The overall Information value of Age Group is = (.23+ .08 + .09) = .40</p><h3>Where to use WoE?</h3><h4>A. Performing Binning of features using WoE Analysis:</h4><p>During EDA, we often perform binning of categorical and continuous variables. Assume, in a dataset, we have Age as a continuous variable and Good/Bad Loan as categorical target variable. We might be interested to find what could be the logical separations to create bins for different age groups. First, we create a higher number of age groups and then calculate WOE for each group. If there is a monotonic trend of WOE values (either descending or ascending), then we can confirm that our bins have a general trend. If it’s not monotonic, then we need to compress the bins to form new groups and need to check the WOE values again. Thus, using WOE, we can create logical bins for further data analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*44lTJ7ETkU012ey7j9IGaQ.png" /><figcaption>Image by author</figcaption></figure><p>In our first attempt, we created 5 bins for continuous variable ‘Age’. But no <strong>monotonic trend </strong>can be seen here. So, in the next attempt, we compressed two groups and created 3 bins, as shown below. Now we can see a monotonic trend (decrease in WOE value) for different classes of ‘Age’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*sDSw-3IslnFfEC2yq5MZKA.png" /><figcaption>Image by author</figcaption></figure><p>We can follow the same approach to group ordinal and nominal categorical variables having higher number of classes into lesser number of bins.</p><h4><strong>B. Using IV for Feature Selection for Binary Logistic Regression:</strong></h4><p>We can calculate overall information value of an independent variable and then if the value is between .30 and .50 we can consider the variable as a strong predictor. Any variable having IV lesser than .02 can be excluded in our binary logistic regression model. Below table is showing the relation between IV and Predictive power of a variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*prl00Y2OtCtdYj6LmTz2eQ.png" /><figcaption>Image by author</figcaption></figure><p>In our previous example ‘Age’ has IV = .40, that makes it a strong predictor to predict our target variable, if a loan is bad/good.</p><h4>C. Using WoE value to transform Continuous Variable into a discrete variable:</h4><p>In the above example we have converted continuous variable ‘Age’ into a categorical variable for performing EDA. We can further replace those categories with their WOE values and then discrete variable ‘Age’ can be used in our logistic regression model for binary prediction. It helps the model to become more stable, and a small change in ‘Age’ will not impact the model. But it comes for a price.</p><p>You can notice an interesting fact here. After reducing the number of bins from 5 to 3, overall Information Value (IV) of ‘Age’ variable also reduced a bit. Whenever we transform a continuous variable into a categorical variable or reduce the number of classes of a categorical variable using binning, we also <strong>lose some predictive power</strong> of that variable.</p><p>If the overall IV of a variable is &lt;= .1 then we consider it as a weak predictor and if IV is in between of .3 and .5 then it’s considered as a very good predictor.</p><h4>D. Using WoE value to transform Categorical Variables for model building:</h4><p>During Binary Classification using Logistic Regression, it’s required to transform any categorical variables into numeric variables. One Hot Encoding and Label Encoding both have some dis-advantages. I am not going into too many details, but one disadvantage you may think of, when a nominal variable has too many classes and performing One Hot Encoding may lead to the <strong>Curse of Dimensionality</strong>.</p><p>WOE score can be used to transform the categorical variable into a numeric variable. Calculated WOE values of different classes can be used to replace their actual values. Hence there is no requirement of performing any separate encoding for model building.</p><p><strong>Missing values can also be grouped</strong> (say, ‘Unknown’ class) and can be imputed with the computed WoE value.</p><p>WoE is a simple yet powerful method and can be very helpful in Exploratory / Confirmatory data analysis and binary logistic regression model building. You need to remember that WoE and Information Value are mainly for binary logistic regression model. If you are planning to use any other classification algorithm like <strong>SVM, Decision Tree or Random Forest, then it’s not going to give you the optimal result</strong>. One reason you can think of, Decision Tree or Random Forest can identify a non-linear relation between independent and target variables. Selecting features based on IV may result in excluding a relevant feature from the model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b3b98efe0e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>