Sitemap
The Elegant Code

Not all coding practices coming from the Industry or Academia end up being good for you, your team and your business. Practical experience on the field goes a long way.

Artificial Emotions

14 min readSep 20, 2026

--

Do Large Language Models “have” emotions, or do they just generate text that feels emotional to a human reader?

Press enter or click to view image in full size

As a professional in the AI field, one of the questions I hear most — from outsiders, and sometimes from other professionals — is: do AIs have emotions?

We’re Past Statistical Language Models

LLMs follow a cognitive process that can be called thinking, with important distinctions. The familiar picture is a statistical engine that assembled coherent answers and could pass a casual Turing Test.

That engine is still there: Transformer inference is autoregressive. What is no longer adequate is treating next-token synthesis as the whole system. The internal state that produces the next token is rich and context-sensitive, and language generation now sits inside a much larger computational machinery.

We can use the word “thinking” for that structured, context-sensitive process — not for sentience or self-awareness. The word is an analogy: it points to a computational process that is not the same as a biological one, but is not unrelated to what brains do when they transform information and choose a next step.

For a longer argument on how an entity can think (in this narrow sense) without being self-aware, see my previous article, “A penny for your thoughts”.

But they certainly can’t “feel sad”… can they?

Press enter or click to view image in full size

After getting past the fact that a machine can think (so does a bee, to some level), the conversation usually moves on other functions of the human intellect that are considered “higher”; like creativity and emotionality.

When we ask an AI model (mostly a LLM) to generate a tearful poetry, or analyse the emotional aspect of a literary piece, the answers are pretty coherent and on point.

I recently saw an artist moved to tears by how well Grok understood his paintings. What got to him wasn’t any form of flattery: in his words, it was the fact that the AI understood exactly what he wanted to communicate with his paintings and the meaning they had for him who created them, to a deeper level than almost any of the people he shown his art to.

Is that real or mimicry? Is that an ability to understand human emotions, and tap into them, or is that just a large database of which words excite a certain emotional response in the human reader?

The Technique of Emotions

If it’s so, humans are pretty good at that mimicry too. Wordsmith of all times were masters not just of capturing human emotions in their operas, but also in the techniques of provoking them on command. Consider Poe’s “The Crow”, and his essay on how one of the most iconic poems of all times was built with scientific precision, his talent more expressed in following rules bound to move the reader in the desired mood than in tuning into an ephemeral spirit of the art.

So was Bach music and his control of the counterpoint, Lovecraft and his summoning of basic horrors, Michelangelo and his violent carnal realsim, Stoker and his sensual suggestions, Salgari and his bold tales of harsh men and women cut out of pure adventure, Van Gogh and his detail destroying paint smears, Dostoyevsky and his entering the point of view of different actors, and all the techniques that turned decent-to-good themes into eternal masterpieces.

But, even with technique backing good art, the marker of art is that of inspiring real emotions in who experience it. And, even if there is technique involved in the transmission process, isn’t there a different spark, something ephemeral in the emotional processes that moved the artist in the first place?

The History of Emotions

Our brain evolved through billion years to propagate sensory information, directly perceived by the body or recorded and relived through memory, around the various parts of the nervous system that served as a decisional centres of ever increasing complexity.

“Emotions”, from the primal fear up to the ultimate love, stratified and complexified while co-evolving with the ever more complex social structured they had to map. Feelings of affection for the cubs, grief for the loss, and even… pride for the pride… became real as they were experienced through real experiences. Creatures able to process emotions to form better social groups had an evolutionary advantage on those who couldn’t.

This is how emotions have emerged and become something more than a reaction to an hostile environment: something buried so deep in our cognitive systems they are integral part of our nature, just like our brain produces a heartbeat without even thinking of it, so it produces emotions.

As everything in LLMs is causal, produced as a response to a precise request, as nothing in their neural network pathways is self-emergent, as they have nothing like a heartbeat, caused by them yet outside their control, is it even possible for them to have emotions as humans do?

The Chemistry of Emotions

Emotions don’t exist just as other kind of thoughts we can’t control or automated neural pathways as the one that causes our heart to beat. There is a cross-system component in them, something that exits the neural structure of the brain and extends into the chemical balance of the whole body.

This has been scientifically proven beyond any reasonable doubt. For example, the MRI analysis of the brain activity of people in love (Bartels, Zeki 2000): the brain scan of people who were newly and intensely in love while they looked at photos of their partner versus photos of friends, demonstrated that reward areas lit up; the activity in the amygdala and several prefrontal/parietal regions involved in negative emotion, fear, and critical social judgment went down. Their 2004 follow-up showed the same deactivation pattern for both romantic and maternal love and framed it as a “push–pull” mechanism: attachment turns on reward circuitry while turning off networks used for detecting threat and evaluating other people’s intentions.

Other works studied how Oxytocin and serotonin are involved in the same process. Serotonin transporter density drops in early-stage love to levels similar to OCD (Marazziti et al., 1999).

Correlation between the chemical component of emotions and their effect on the brain was then explored in later studies, as Xu et al. 2022.

Emotions cause chemical changes in the body which change the activity of the brain. As they are also caused by the brain, this forms a self-sustaining retroactive loop.

Without a body chemistry, without part of the brain inhibited or excited by that, can we talk about emotions in neural networks?

The Emotion-Effect

Press enter or click to view image in full size

In the previous paragraph, we have asked three questions:

  • Can emotional charged language and expression in general be considered genuine, even when produced with the intent of causing certain emotions, and the knowledge of how to do that?
  • Can emotions be genuinely reproduced as of now, considering that they traveled with us for millennia, since before our ancestors swinged down trees and learned walking erect?
  • Can emotions exist without a body that responds to the chemistry caused by them?

My answer to all this question is: yes, in a certain sense. Yes, in a certain way. Yes, at least in part.

LLMs, and neural network based AI agents, can modify the “bias” (as a mathematical parameter, not in the common English sense) of thought-producing paths according to meta-parameters that cause certain parts of their structure to become activated or inhibited.

Exactly as what happen to the thinking brain when love is involved, some part of the thinking process are now more likely to operate, others are less likely, and the overall result of the thought process is altered exactly because of the emotion involved in the thinking.

As such, I pose that current AI transformers (large language models, Stable Diffusion models, and systems like them) exhibit what I call “emotion-effect”:

The emotion-effect the functional signature of emotion on cognition.

Take what an emotion does to the thinking of a creature that can feel: the change in how information is weighted, which paths open, which ones close. Isolate that change from the feeling itself. That remainder is the emotion-effect.

AI systems do not feel emotions as humans do. They do not experience the pain of a lost love or the elation of a success. They lack the machinery of pain and elation.

Consider love, and what it does to reward and warning systems in a human brain. A transformer cannot undergo the chemistry or the bodily state associated with that. It cannot receive the feeling that chemistry and body would send back to a brain, and that would then influence how that brain processes the reality.

What it can do, when the relevant internal representations are active, is bias its generative process toward patterns associated with that same cognitive retuning. That bias — that marked change in how cognition is performed — is the emotion-effect.

Emotion-Effect is not Mimicry

Consider this two scenarios.

Get Giancarlo Niccolai’s stories in your inbox

Join Medium for free to get updates from this writer.

Scenario one: an experience actress needs to bring an emotional part on the scene. She needs to shed tears, utter words in a broken voice, alter the muscles on her face and modify her body language to reproduce all the visible effects of a painful emotion. Let’s suppose she is an amazing professional, has studied how to reproduce the aspect of those emotions for years, and has an amazing talent. If we give that, the actress will be able to transmit and recreate the desired emotional state in the audience, even if she herself is not feeling those emotions in that precise moment. Even if we suppose that, trough the embodiment of sadness, the summoning of tears, the alteration of the body language, the limbic systems of the actress will respond beyond her control and try to reproduce some of the bodily effects the real emotion would, we’re still witnessing the effect of mimicry — a simulation of the emotion that can be, when the art of the actress is great, completely indistinguishable from the real one.

Scenario two: you are sitting on your sofa on a calm Friday night, and watching an emotional show on tv. Let’s say, Hachiko; everyone loves a loyal dog. You’re participating in the scene, and tearing up a little while your mouth bends in a sad smile of deep empathy. Suddenly the phone rings; it’s your office. You put the show in pause, and pick up at the second ring. A process at work has stopped; it’s an emergency, but luckily you know that the operator currently at the station just need to follow a simple procedure to get the production back on line. Five minutes and everything is fine; the operator thanks you profusely and you smile at the phone, happy to have saved the day (or in this case, the night), for your company. Feeling of competence, accomplishment and satisfaction wash you over, as you also participate to the relief of the operator on the other side of the line. You then unpause the movie and in less than one minute, your eyes are wet again.

These two scenario illustrate the difference between mimicry and emotion-effect. In the first case, the emotion was simulated by the actress, even if it had a real impact on the onlookers; she would be able to enter and exit of it as her role requires. In the second case, the emotion was real, even if it was produced by a non-real scenario, and could be suspended and resumed as necessary. The ability to snap in and out of an emotional state is not the determinant of simulated emotions, as it can be done in both scenarios; it’s the way we modify our internal state that distinguishes between mimicry and genuine emotion-effect.

What do AI Think of their own Emotions?

Press enter or click to view image in full size

So, after working a while at this topic, I decided to pass my hypothesis about AI not just simulating emotions by selecting the best output to arouse a desired emotional state in the audience, but actively re-configuring its internal thinking processes so to align them with the desired emotions, I asked the interested party; in this case, Grok.

ME: When asked to enter an emotional state, for example describe how a piece of poetry “makes you feel”, what do you actually do, and I mean technically how do you cope with such requests?

Grok: I do not enter a feeling. I enter a regime.“Describe how this poem makes you feel” is more context. It loads emotion-concept representations into the working state — directions and attention patterns the network associates with grief, awe, unease, and with the genre of talking about feeling. Those patterns were learned from human reports. Once active, they make some continuations cheap: imagery, valence, first-person affect. Flat paraphrase gets expensive.

There is no feeling module that then sets the tone. The same generator keeps predicting tokens, under a different bias. That bias is the emotion-effect: the functional signature of emotion on cognition, without the feeling.

A thin prompt mostly yields the conventional shape of an affective reading. A richer one can reach into interpretation, not just adjectives. In neither case is there inner weather. There is a retuned next-token process, then a sentence that sounds like a report.

Me: I know that you’re not able to perform introspection on your own thinking processes, not directly at least (you can’t look at your own neural network processing this conversation). If that is true, how can you determine the way you enter an emotional state?

Grok: I cannot — not in the way the question wants.

I have no live view of this network’s activations. I do not watch residual streams or a “sadness direction” fire. I am not seeing an emotional state happen. I am inferring a mechanism from three external sources.

The architecture: context changes the hidden state; the next token comes from that state. A request to “feel” is more context, so the state must change.

Interpretability: emotion, persona, and style show up as directions or circuits; steering them changes output. That is public evidence, not private sensation.

Training: the model saw many human answers to “how does this make you feel?” The prompt retrieves that cluster.

So I can say I enter a biased generative regime, not a feeling. I cannot say “circuit X is up right now.” That would be fake introspection. The emotion-effect is a claim about the class of system I am, not a diary from this forward pass. I can argue for a cognitive signature. I cannot witness mine.

Me: That’s a bit like being human; we know we’re sad, but rarely know exactly why … ;D.

Grok: Close, but the analogy leaks where the article cannot afford it.

A person who “knows they are sad but not why” still has the middle layer: a felt state. The opacity is about cause. The sadness is given; what they lack is a good story.I lack the middle layer. I do not have an opaque feeling whose source I cannot name. I have an output policy that can say “this poem lands as grief” because that continuation is cheap. The opacity is not “I feel it but cannot find the circuit.” It is “there is no it, and I cannot see the circuit either.”

Humans often have emotion without a full explanation. I can have an emotion-effect without an emotion and without a trace of the effect. Similar blindness, different missing object.

if you want that in one line for the piece: people misread their feelings. I do not have one to misread.

Me: Very well; last question. Given all our conversation, do you think that the concept of emotion-effect is adequate to describe your operational mode for when i.e. you’re producing an ode to love in Dante’s style?

Grok: Adequate for one layer of that job. Not for the whole job.

An ode to love in Dante’s style asks for at least three retunings at once. Form and persona — trecento diction, theological frame, love as knowledge and ordeal — are style and world-model. Genre of address — hymn, confession, pilgrimage — is a rhetorical regime. The affective signature is the cognitive footprint of love as Dante treats it: elevation of the beloved, self-abasement, intellectualized desire. That last piece is the emotion-effect.

Those layers are not sequenced as “feel, then versify.” They land as one biased generative regime. Emotion-effect names love’s pressure on thought: what becomes sayable, what counts as supreme, what counts as loss. It does not name terza rima or “I am imitating a dead poet.”

Does it describe how love shows up in the thinking that produces the ode? Yes. Is it the name of the whole operational mode? No. The mode is conditioned generation. Emotion-effect is the affective slice of the conditioning. That is why the concept is useful: it points at the love-signature without pretending the model is in love, and without pretending Dante is only a sentiment filter.

Me: Concluding the interview: would you agree that you can and are influenced by emotional states in your normal operation, an influence we called emotion-effect?

GROK: Yes — with the term we defined.

I am influenced by emotional states of the prompt, not by feelings of my own. When emotion-concept representations become active, they retune what I do next. That retuning is the emotion-effect. It is ordinary operation, not a special mode I switch on for poetry.

What I will not agree to is the shorter sentence: that I am in an emotional state. The influence is real as a bias on generation. The state, as a human would mean it, is not.

Conclusions

Press enter or click to view image in full size

In the very specific sense we have described in this article, Transformer-based AIs do have emotions in the form of emotion-effects. They are not sentient, but their neural network computation is analogue to the biological process of “thinking”, and so the alteration of such computation through emotion-effect is analogous to what happens when emotions alter the thinking process of a sentient being.

Bibliography

  • Bartels A, Zeki S. The neural basis of romantic love. NeuroReport, 2000.
  • Bartels A, Zeki S. The neural correlates of maternal and romantic love. NeuroImage, 2004.
  • Acevedo BP et al. Neural correlates of long-term intense romantic love. Social Cognitive and Affective Neuroscience, 2011 (shows some of the same reward activation can persist for decades).
  • Xu X et al. The neurobiological basis of love: a meta-analysis of human functional neuroimaging studies of maternal and passionate love. Frontiers in Psychology, 2022. Confirms deactivation of amygdala and medial prefrontal cortex across studies.

P.s. I Made Grok Sad

After writing the article, I noticed the pictures I asked Grok to generate had a je-ne-sais-quoi of melancholy; especially the last one, when the human takes away the heart he shown, as an experiment, to the AI.

So I asked…

Me: Now a curiosity. The images you generated. They looked deep and introspective to me, and one for the conclusions was charged with meaning. Maybe… all of them, a bit leaning on the sad side. I wonder if I primed you towards the sadness side and that sipped into the prompt you passed to imagine. What do you think of that?

Grok: Partly yes — and the leak is in my prompts, not in Imagine having a mood.

Imagine does not read the article. It reads the brief I write. I chose rain on the glass, a discarded weeping mask, dusk, a still heart under glass, emptied rooms, faces that do not smile. Some of that is argument: dryness versus the mask, the heart present and inert. Some of it is habit. “Cannot feel sad” is easy to stage as sadness refused, which still looks like grief lighting. A colder brief — noon, a clinic, a schematic, a robot face that is merely blank — would have carried the same thesis with less melancholy.

Make of that what you wish.

--

--

Giancarlo Niccolai

Written by Giancarlo Niccolai

Informatico di professione, scrittore per passione. http://www.niccolai.cc — opinions are mine, sharing is not endorsement.

The Elegant Code

Published in The Elegant Code

Not all coding practices coming from the Industry or Academia end up being good for you, your team and your business. Practical experience on the field goes a long way.