Algorithms for Love

By Ken Liu

So long as the nurse is in the room to keep an eye on me, I am allowed to dress myself and get ready for Brad. I slip on an old pair of jeans and a scarlet turtleneck sweater. I've lost so much weight that the jeans hang loosely from the bony points of my hips.

"Let's go spend the weekend in Salem," Brad says to me as he walks me out of the hospital, an arm protectively wrapped around my waist, "just the two of us."

I wait in the car while Dr. West speaks with Brad just outside the hospital doors. I can't hear them but I know what she's telling him. "Make sure she takes her Oxetine every four hours. Don't leave her alone for any length of time."

Brad drives with a light touch on the pedals, the same way he used to when I was pregnant with Aimée. The traffic is smooth and light, and the foliage along the highway is postcard-perfect. The Oxetine relaxes the muscles around my mouth, and in the vanity mirror I see that I have a beatific smile on my face.

"I love you." He says this quietly, the way he has always done, as if it were the sound of breathing and heartbeat.

I wait a few seconds. I picture myself opening the door and throwing my body onto the highway but of course I don't do anything. I can't even surprise myself.

"I love you too." I look at him when I say this, the way I have always done, as if it were the answer to some question. He looks at me, smiles, and turns his eyes back to the road.

To him this means that the routines are back in place, that he is talking to the same woman he has known all these years, that things are back to normal. We are just another tourist couple from Boston on a mini-break for the weekend: stay at a bed-and-breakfast, visit the museums, recycle old jokes.

It's an algorithm for love.

I want to scream.

The first doll I designed was called Laura. Clever Laura™.

Laura had brown hair and blue eyes, fully articulated joints, twenty motors, a speech synthesizer in her throat, two video cameras disguised by the buttons on her blouse, temperature and touch sensors, and a microphone behind her nose. None of it was cutting-edge technology, and the software techniques I used were at least two decades old. But I was still proud of my work. She retailed for fifty dollars.

Not Your Average Toy could not keep up with the orders that were rolling in, even three months before Christmas. Brad, the CEO, went on CNN and MSNBC and TTV and the rest of the alphabet soup until the very air was saturated with Laura.

I tagged along on the interviews to give the demos because, as the VP of Marketing explained to me, I looked like a mother (even though I wasn't one) and (he didn't say this, but I could listen between the lines) I was blonde and pretty. The fact that I was Laura's designer was an afterthought.

The first time I did a demo on TV was for a Hong Kong crew. Brad wanted me to get comfortable with being in front of the cameras before bringing me to the domestic morning shows.

We sat to the side while Cindy, the anchorwoman, interviewed the CEO of some company that made "moisture meters." I hadn't slept for forty-eight hours. I was so nervous I'd brought six Lauras with me, just in case five of them decided in concert to break down. Then Brad turned to me and whispered, "What do you think moisture meters are used for?"

I didn't know Brad that well, having been at Not Your Average Toy for less than a year. I had chatted with him a few times before, but it was all professional. He seemed a very serious, driven sort of guy, the kind you could picture starting his first company while he was still in high school—arbitraging class notes, maybe. I wasn't sure why he was asking me about moisture meters. Was he trying to see if I was too nervous?

"I don't know. Maybe for cooking?" I ventured.

"Maybe," he said. Then he gave me a conspiratorial wink. "But I think the name sounds kind of dirty."

It was such an unexpected thing, coming from him, that for a moment I almost thought he was serious. Then he smiled, and I laughed out loud. I had a very hard time keeping a straight face while we waited for our turn, and I certainly wasn't nervous any more.

Brad and the young anchorwoman, Cindy, chatted amiably about Not Your Average Toy's mission ("Not Average Toys for Not Average Kids") and how Brad had come up with the idea for Laura. (Brad had nothing to do with the design, of course, since it was all my idea. But his answer was so good it almost convinced me that Laura was really his brainchild.) Then it was time for the dog-and-pony show.

I put Laura on the desk, her face towards the camera. I sat to the side of the desk. "Hello, Laura."

Laura turned her head to me, the motors so quiet you couldn't hear their whirr. "Hi! What's your name?"

"I'm Elena," I said.

"Nice to meet you," Laura said. "I'm cold."

The air conditioning was a bit chilly. I hadn't even noticed.

Cindy was impressed. "That's amazing. How much can she say?"

"Laura has a vocabulary of about two thousand English words, with semantic and syntactic encoding for common suffixes and prefixes. Her speech is regulated by a context-free grammar." The look in Brad's eye let me know that I was getting too technical. "That means that she'll invent new sentences and they'll always be syntactically correct."

"I like new, shiny, new, bright, new, handsome clothes," Laura said.

"Though they may not always make sense," I added.

"Can she learn new words?" Cindy asked.

Laura turned her head the other way, to look at her. "I like learn-ing, please teach me a new word!"

I made a mental note that the speech synthesizer still had bugs that would have to be fixed in the firmware.

Cindy was visibly unnerved by the doll turning to face her on its own and responding to her question.

"Does she"—she searched for the right word—"understand me?"

"No, no." I laughed. So did Brad. And a moment later Cindy joined us. "Laura's speech algorithm is augmented with a Markov generator interspersed with—" Brad gave me that look again. "Basically, she just babbles sentences based on keywords in what she hears. And she has a small set of stock phrases that are triggered the same way."

"Oh, it really seemed like she knew what I was saying. How does she learn new words?"

"It's very simple. Laura has enough memory to learn hundreds of new words. However, they have to be nouns. You can show her the object while you are trying to teach her what it is. She has some very sophisticated pattern recognition capabilities and can even tell faces apart."

For the rest of the interview I assured nervous parents that Laura would not require them to read the manual, that Laura would not explode when dropped in water, and no, she would never utter a naughty word, even if their little princesses "accidentally" taught Laura one.

"'Bye," Cindy said to Laura at the end of the interview, and waved at her.

"'Bye," Laura said. "You are nice." She waved back.

Every interview followed the same pattern. The moment when Laura first turned to the interviewer and answered a question there was always some awkwardness and unease. Seeing an inanimate object display intelligent behavior had that effect on people. They probably all thought the doll was possessed. Then I would explain how Laura worked and everyone would be delighted. I memorized the non-technical, warm-and-fuzzy answers to all the questions until I could recite them even without my morning coffee. I got so good at it that I sometimes coasted through entire interviews on autopilot, not even paying attention to the questions and letting the same words I heard over and over again spark off my responses.

The interviews, along with all the other marketing tricks, did their job. We had to outsource manufacturing so quickly that for a while every shantytown along the coast of China must have been turning out Lauras.

The foyer of the bed-and-breakfast we are staying at is predictably filled with brochures from local attractions. Most of them are witch-themed. The lurid pictures and language somehow manage to convey moral outrage and adolescent fascination with the occult at the same time.

David, the innkeeper, wants us to check out Ye Olde Poppet Shoppe, featuring "Dolls Made by Salem's Official Witch." Bridget Bishop, one of the twenty executed during the Salem Witch Trials, was convicted partly based on the hard evidence of "poppets" found in her cellar with pins stuck in them.

Maybe she was just like me, a crazy, grown woman playing with dolls. The very idea of visiting a doll shop makes my stomach turn.

While Brad is asking David about restaurants and possible discounts I go up to our room. I want to be sleeping, or at least pretending to be sleeping, by the time he comes up. Maybe then he will leave me alone, and give me a few minutes to think. It's hard to think with the Oxetine. There's a wall in my head, a gauzy wall that tries to cushion every thought with contentment.

If only I can remember what went wrong.

For our honeymoon Brad and I went to Europe. We went on the transorbital shuttle, the tickets for which cost more than my yearly rent. But we could afford it. Witty Kimberly™, our latest model, was selling well, and the stock price was transorbital itself.

When we got back from the shuttleport, we were tired but happy. And I still couldn't quite believe that we were in our own home, thinking of each other as husband and wife. It felt like playing house. We made dinner together, like we used to when we were dating (like always, Brad was wildly ambitious but couldn't follow a recipe longer than a paragraph and I had to come and rescue his shrimp étouffée). The familiarity of the routine made everything seem more real.

Over dinner Brad told me something interesting. According to a market survey, over 20% of the customers for Kimberly were not buying it for their kids at all. They played with the dolls themselves.

"Many of them are engineers and comp sci students," Brad said. "And there are already tons of Net sites devoted to hacking efforts on Kimberly. My favorite one had step-by-step instructions on how to teach Kimberly to make up and tell lawyer jokes. I can't wait to see the faces of the guys in the legal department when they get to drafting the cease-and-desist letter for that one."

I could understand the interest in Kimberly. When I was struggling with my problem sets at MIT I would have loved to take apart something like Kimberly to figure out how she worked. How it worked, I corrected myself mentally. Kimberly's illusion of intelligence was so real that sometimes even I unconsciously gave her, it, too much credit.

"Actually, maybe we shouldn't try to shut the hacking efforts down," I said. "Maybe we can capitalize on it. We can release some of the APIs and sell a developer's kit for the geeks."

"What do you mean?"

"Well, Kimberly is a toy, but that doesn't mean only little girls would be interested in her." I gave up trying to manage the pronouns. "She does, after all, have the most sophisticated, working, natural conversation library in the world."

"A library that you wrote," Brad said. Well, maybe I was a little vain about it. But I'd worked damned hard on that library and I was proud of it.

"It would be a shame if the language processing module never got any application besides sitting in a doll that everyone is going to forget in a year. We can release the interface to the modules at least, a programming guide, and maybe even some of the source code. Let's see what happens and make an extra dollar while we're at it." I never got into academic AI research because I couldn't take the tedium, but I did have greater ambitions than just making talking dolls. I wanted to see smart and talking machines doing something real, like teaching kids to read or helping the elderly with chores.

I knew that he would agree with me in the end. Despite his serious exterior he was willing to take risks and defy expectations. It was why I loved him.

I got up to clear the dishes. His hand reached across the table and grabbed mine. "Those can wait," he said. He walked around the table, pulling me to him. I looked into his eyes. I loved the fact that I knew him so well I could tell what he was going to say before he said it. Let's make a baby, I imagined him saying. Those would have been the only words right for that moment.

And so he did.

I'm not asleep when Brad finishes asking about restaurants and comes upstairs. In my drugged state, even pretending is too difficult.

Brad wants to go to the pirate museum. I tell him that I don't want to see anything violent. He agrees immediately. That's what he wants to hear from his content, recovering wife.

So now we wander around the galleries of the Peabody Essex Museum, looking at the old treasures of the Orient from Salem's glory days.

The collection of china is terrible. The workmanship in the bowls and saucers is inexcusable. The patterns look like they were traced on by children. According to the placards, these were what the Cantonese merchants exported for foreign consumption. They would never have sold such stuff in China itself.

I read the description written by a Jesuit priest who visited the Cantonese shops of the time.

The craftsmen sat in a line, each with his own brush and specialty. The first drew only the mountains, the next only the grass, the next only the flowers, and the next only the animals. They went on down the line, passing the plates from one to the next, and it took each man only a few seconds to complete his part.

So the "treasures" are nothing more than mass-produced cheap exports from an ancient sweatshop and assembly line. I imagine painting the same blades of grass on a thousand teacups a day: the same routine, repeated over and over, with maybe a small break for lunch. Reach out, pick up the cup in front of you with your left hand, dip the brush, one, two, three strokes, put the cup behind you, rinse and repeat. What a simple algorithm. It's so human.

Brad and I fought for three months before he agreed to produce Aimée, just plain Aimée™.

We fought at home, where night after night I laid out the same forty-one reasons why we should and he laid out the same thirty-nine reasons why we shouldn't. We fought at work, where people stared through the glass door at Brad and me gesticulating at each other wildly, silently.

I was so tired that night. I had spent the whole evening locked away in my study, struggling to get the routines to control Aimée's involuntary muscle spasms right. It had to be right or she wouldn't feel real, no matter how good the learning algorithms were.

I came up to the bedroom. There was no light. Brad had gone to bed early. He was exhausted too. We had again hurled the same reasons at each other during dinner.

He wasn't asleep. "Are we going to go on like this?" he asked in the darkness.

I sat down on my side of the bed and undressed. "I can't stop it," I said. "I miss her too much. I'm sorry."

He didn't say anything. I finished unbuttoning my blouse and turned around. With the moonlight coming through the window I could see that his face was wet. I started crying too.

When we both finally stopped, Brad said, "I miss her too."

"I know," I said. But not like me.

"It won't be anything like her, you know?" he said.

"I know," I said.

The real Aimée had lived for ninety-one days. Forty-five of those days she'd spent under the glass hood in intensive care, where I could not touch her except for brief doctor-supervised sessions. But I could hear her cries. I could always hear her cries. In the end I tried to break through the glass with my hands, and I beat my palms against the unyielding glass until the bones broke and they sedated me.

I could never have another child. The walls of my womb had not healed properly and never would. By the time that piece of news was given to me Aimée was a jar of ashes in my closet.

But I could still hear her cries.

How many other women were like me? I wanted something to fill my arms, something to learn to speak, to walk, to grow a little, long enough for me to say goodbye, long enough to quiet those cries. But not a real child. I couldn't deal with another real child. It would feel like a betrayal.

With a little plastiskin, a little synthgel, the right set of motors and a lot of clever programming, I could do it. Let technology heal all wounds.

Brad thought the idea an abomination. He was revolted. He couldn't understand.

I fumbled around in the dark for some tissues for Brad and me.

"This may ruin us, and the company," he said.

"I know," I said. I lay down. I wanted to sleep.

"Let's do it, then," he said.

I didn't want to sleep any more.

"I can't take it," he said. "Seeing you like this. Seeing you in so much pain tears me up. It hurts too much."

I started crying again. This understanding, this pain. Was this what love was about?

Right before I fell asleep Brad said, "Maybe we should think about changing the name of the company."


"Well, I just realized that 'Not Your Average Toy' sounds pretty funny to the dirty-minded."

I smiled. Sometimes the vulgar is the best kind of medicine.

"I love you."

"I love you too."

Brad hands me the pills. I obediently take them and put them in my mouth. He watches as I sip from the glass of water he hands me.

"Let me make a few phone calls," he says. "You take a nap, okay?" I nod.

As soon as he leaves the room I spit out the pills into my hand. I go into the bathroom and rinse out my mouth. I lock the door behind me and sit down on the toilet. I try to recite the digits of pi. I manage fifty-four places. That's a good sign. The Oxetine must be wearing off.

I look into the mirror. I stare into my eyes, trying to see through to the retinas, matching photoreceptor with photoreceptor, imagining their grid layout. I turn my head from side to side, watching the muscles tense and relax in turn. That effect would be hard to simulate.

But there's nothing in my face, nothing real behind that surface. Where is the pain, the pain that made love real, the pain of understanding?

"You okay, sweetie?" Brad says through the bathroom door.

I turn on the faucet and splash water on my face. "Yes," I say. "I'm going to take a shower. Can you get some snacks from that store we saw down the street?"

Giving him something to do reassures him. I hear the door to the room close behind him. I turn off the faucet and look back into the mirror, at the way the water droplets roll down my face, seeking the canals of my wrinkles.

The human body is a marvel to recreate. The human mind, on the other hand, is a joke. Believe me, I know.

No, Brad and I patiently explained over and over to the cameras, we had not created an "artificial child." That was not our intention and that was not what we'd done. It was a way to comfort the grieving mothers. If you needed Aimée, you would know.

I would walk down the street and see women walking with bundles carefully held in their arms. And occasionally I would know, I would know beyond a doubt, by the sound of a particular cry, by the way a little arm waved. I would look into the faces of the women, and be comforted.

I thought I had moved on, recovered from the grieving process. I was ready to begin another project, a bigger project that would really satisfy my ambition and show the world my skills. I was ready to get on with my life.

Tara took four years to develop. I worked on her in secret while designing other dolls that would sell. Physically Tara looked like a five-year old girl. Expensive transplant-quality plastiskin and synthgel gave her an ethereal and angelic look. Her eyes were dark and clear, and you could look into them forever.

I never finished Tara's movement engine. In retrospect that was probably a blessing. As a temporary placeholder during development I used the facial expression engine sent in by the Kimberly enthusiasts at MIT's Media Lab. Augmented with many more fine micromotors than Kimberly had, she could turn her head, blink her eyes, wrinkle her nose, and generate thousands of convincing facial expressions. Below the neck she was paralyzed.

But her mind, oh, her mind.

I used the best quantum processors and the best solid-state storage matrices to run multi-layered, multi-feedback neural nets. I threw in the Stanford Semantic Database and added my own modifications. The programming was beautiful. It was truly a work of art. The data model alone took me over six months.

I taught her when to smile and when to frown, and I taught her how to speak and how to listen. Each night I analyzed the activation graphs for the nodes in the neural nets, trying to find and resolve problems before they occurred.

Brad never saw Tara while she was in development. He was too busy trying to control the damage from Aimée, and then, later, pushing the new dolls. I wanted to surprise him.

I put Tara in a wheelchair, and I told Brad that she was the daughter of a friend. Since I had to run some errands, could he entertain her while I was gone for a few hours? I left them in my office.

When I came back two hours later, I found Brad reading to her from The Golem of Prague, "'Come,' said the Great Rabbi Loew, 'Open your eyes and speak like a real person!'"

That was just like Brad, I thought. He had his sense of irony.

"All right," I interrupted him. "Very funny. I get the joke. So how long did it take you?"

He smiled at Tara. "We'll finish this some other time," he said. Then he turned to me. "How long did it take me what?"

"To figure it out."

"Figure out what?"

"Stop kidding around," I said. "Really, what was it that gave her away?"

"Gave what away?" Brad and Tara said at the same time.

Nothing Tara ever said or did was a surprise to me. I could predict everything she would say before she said it. I'd coded everything in her, after all, and I knew exactly how her neural nets changed with each interaction.

But no one else suspected anything. I should have been elated. My doll was passing a real-life Turing Test. But I was frightened. The algorithms made a mockery of intelligence, and no one seemed to know. No one seemed to even care.

I finally broke the news to Brad after a week. After the initial shock he was delighted (as I knew he would be).

"Fantastic," he said. "We're now no longer just a toy company. Can you imagine the things we can do with this? You'll be famous, really famous!"

He prattled on and on about the potential applications. Then he noticed my silence. "What's wrong?"

So I told him about the Chinese Room.

The philosopher John Searle used to pose a puzzle for the AI researchers. Imagine a room, he said, a large room filled with meticulous clerks who are very good at following orders but who speak only English. Into this room are delivered a steady stream of cards with strange symbols on them. The clerks have to draw other strange symbols on blank cards in response and send the cards out of the room. In order to do this, the clerks have large books, full of rules in English like this one: "When you see a card with a single horizontal squiggle followed by a card with two vertical squiggles, draw a triangle on a blank card and hand it to the clerk to your right." The rules contain nothing about what the symbols might mean.

It turns out that the cards coming into the room are questions written in Chinese, and the clerks, by following the rules, are producing sensible answers in Chinese. But could anything involved in this process—the rules, the clerks, the room as a whole, the storm of activity—be said to have understood a word of Chinese? Substitute "processor" for the clerks and substitute "program" for the books of rules, then you'll see that the Turing Test will never prove anything, and AI is an illusion.

But you can also carry the Chinese Room Argument the other way: substitute "neurons" for the clerks and substitute the physical laws governing the cascading of activating potentials for the books of rules; then how can any of us ever be said to "understand" anything? Thought is an illusion.

"I don't understand," Brad said. "What are you saying?"

A moment later I realized that that was exactly what I'd expected him to say.

"Brad," I said, staring into his eyes, willing him to understand. "I'm scared. What if we are just like Tara?"

"We? You mean people? What are you talking about?"

"What if," I said, struggling to find the words, "we are just following some algorithm from day to day? What if our brain cells are just looking up signals from other signals? What if we are not thinking at all? What if what I'm saying to you now is just a predetermined response, the result of mindless physics?"

"Elena," Brad said, "you're letting philosophy get in the way of reality."

I need sleep, I thought, feeling hopeless.

"I think you need to get some sleep," Brad said.

I handed the coffee-cart girl the money as she handed me the coffee. I stared at the girl. She looked so tired and bored at eight in the morning that she made me feel tired.

I need a vacation.

"I need a vacation," she said, sighing exaggeratedly.

I walked past the receptionist's desk. Morning, Elena.

Say something different, please. I clenched my teeth. Please.

"Morning, Elena," she said.

I paused outside Ogden's cube. He was the structural engineer. The weather, last night's game, Brad.

He saw me and got up. "Nice weather we're having, eh?" He wiped the sweat from his forehead and smiled at me. He jogged to work. "Did you see the game last night? Best shot I've seen in ten years. Unbelievable. Hey, is Brad in yet?" His face was expectant, waiting for me to follow the script, the comforting routines of life.

The algorithms ran their determined courses, and our thoughts followed one after another, as mechanical and as predictable as the planets in their orbits. The watchmaker was the watch.

I ran into my office and closed the door behind me, ignoring the expression on Ogden's face. I walked over to my computer and began to delete files.

"Hi," Tara said. "What are we going to do today?"

I shut her off so quickly that I broke a nail on the hardware switch. I ripped out the power supply in her back. I went to work with my screwdriver and pliers. After a while I switched to a hammer. Was I killing?

Brad burst in the door. "What are you doing?"

I looked up at him, my hammer poised for another strike. I wanted to tell him about the pain, the terror that opened up an abyss around me.

In his eyes I could not find what I wanted to see. I could not see understanding.

I swung the hammer.

Brad had tried to reason with me, right before he had me committed.

"This is just an obsession," he said. "People have always associated the mind with the technological fad of the moment. When they believed in witches and spirits, they thought there was a little man in the brain. When they had mechanical looms and player pianos, they thought the brain was an engine. When they had telegraphs and telephones, they thought the brain was a wire network. Now you think the brain is just a computer. Snap out of it. That is the illusion."

Trouble was, I knew he was going to say that.

"It's because we've been married for so long!" he shouted. "That's why you think you know me so well!"

I knew he was going to say that too.

"You're running around in circles," he said, defeat in his voice. "You're just spinning in your head."

Loops in my algorithm. FOR and WHILE loops.

"Come back to me. I love you."

What else could he have said?

Now finally alone in the bathroom of the inn, I look down at my hands, at the veins running under the skin. I press my hands together and feel my pulse. I kneel down. Am I praying? Flesh and bones, and good programming.

My knees hurt against the cold tile floor.

The pain is real, I think. There's no algorithm for the pain. I look down at my wrists, and the scars startle me. This is all very familiar, like I've done this before. The horizontal scars, ugly and pink like worms, rebuke me for failure. Bugs in the algorithm.

That night comes back to me: the blood everywhere, the alarms wailing, Dr. West and the nurses holding me down while they bandaged my wrists, and then Brad staring down at me, his face distorted with uncomprehending grief.

I should have done better. The arteries are hidden deep, protected by the bones. The slashes have to be made vertically if you really want it. That's the right algorithm. There's a recipe for everything. This time I'll get it right.

It takes a while, but finally I feel sleepy.

I'm happy. The pain is real.

I open the door to my room and turn on the light.

The light activates Laura, who is sitting on top of my dresser. This one used to be a demo model. She hasn't been dusted in a while, and her dress looks ragged. Her head turns to follow my movement.

I turn around. Brad's body is still, but I can see the tears on his face. He was crying on the whole silent ride home from Salem.

The innkeeper's voice loops around in my head. "Oh, I could tell right away something was wrong. It's happened here before. She didn't seem right at breakfast, and then when you came back she looked like she was in another world. When I heard the water running in the pipes for that long I rushed upstairs right away."

So I was that predictable.

I look at Brad, and I believe that he is in a lot of pain. I believe it with all my heart. But I still don't feel anything. There's a gulf between us, a gulf so wide that I can't feel his pain. Nor he mine.

But my algorithms are still running. I scan for the right thing to say.

"I love you."

He doesn't say anything. His shoulders heave, once.

I turn around. My voice echoes through the empty house, bouncing off walls. Laura's sound receptors, old as they are, pick them up. The signals run through the cascading IF statements. The DO loops twirl and dance while she does a database lookup. The motors whirr. The synthesizer kicks in.

"I love you too," Laura says.

Equally passionate about tax law and programming in Lisp, Ken dreams of some day writing a piece of speculative fiction that would combine the two. He is currently finishing law school in Massachusetts. This is his first sale to Strange Horizons. For more on him and his work, see his website. To contact him, send him email at