Wednesday, May 12, 2010

How To Teach Machines Creativity

Kasparov said of Deep Blue, after losing to it at chess, that he sometimes "saw deep intelligence and creativity in the machine's moves." Partially, this was an accusation that the IBM programmers weren't playing fairly, but it was fundamentally a testament to the quality of play Deep Blue could bring to chess.

Of course, it wasn't really exhibiting creativity. The biggest advantage a chess playing computer has is simply the depth it can think ahead. It chose its moves because it knew they'd prevent Kasparov from checkmating it in the foreseeable future, not from any deep insight into the strategies of the board.

I heard another anecdote from a professor, once, about an experiment in robotic movement. A (computer) mouse was tied to the back of a small, roomba like robot. The goal was to train it to avoid walls. Whenever the mouse rolled forward, the robot would get a 'reward'. Whenever it rolled backwards, it would be 'penalized'. These were just numbers being plugged into an algorithm, but they acted analogously to the dopamine in your brain. The robot was supposed to learn to navigate in such a way that it wouldn't have to back up, something like traveling in a circle through the room. The researchers left the robot running overnight to learn.

When they returned the next morning they were surprised to find the robot in a corner, rocking back and forth. Not the expected result. Some investigation revealed that the robot had found its way onto a rug. Whenever it moved backwards, the rug's bristles would jam up the mouse wheel. It had freedom to roll in the other direction, however. The rug let it avoid the negative feedback, circumventing the expected rules and giving it a constant euphoria as it rocked back and forth in place.

The solution seems creative. Really, though, it was just dumb luck. The robot didn't reason out that the rug might help, it blindly ended up on the rug, where it happened to take a couple simple steps that seemed positive. It tried a few repetitions, decided this was the best it was going to find, and went with it.

So how could we incorporate a more 'real' form of creativity into AI? I believe it's all about explicitly measuring creativity. Big Blue was 'rewarded' based on victories and losses. The robot was rewarded for moving forward. To create a creative machine, you have to reward creativity.

Let's use music as an example. What if we wanted to train a computer to compose music? First: a quick machine learning lesson:

Genetic Algorithms evolve a solution to a problem. For the music example, you'd take thousands of completely random musical scores, and listen to them (or ideally, evaluate them mathematically to start). They'd all sound bad, but hopefully a couple have some redeeming feature: a rhythm, or some short snippet that sounded good. After ordering them by quality, you take the best and create a new generation, just like life does. There's a few mutations thrown in (changing notes), but mostly you use genetic crossover: take two of the musical scores, cut them up and interleave them.

If you repeat this, generation after generation, the quality of the music will increase. Short snippets of good music greatly increase the odds an individual song will pass its genetic (musical?) material to the next generation, so those good snippets grow in number. Eventually music evolves.

But of course, this isn't creative. You end up with a population of songs at the end that all sound alike, as they all share most of their genetic material now. The process is creative like evolution is creative (are animals art?) but you don't have an artificial mind that can create arbitrary songs.

So we turn our attention to genetic programming. This still uses the same life-based mechanisms to evolve a population, but now you're evolving a population of computer programs. You write random computer programs, in this case programs that take some input and output a song. At first none of the computer programs do what you want (or anything, usually. Random code isn't terribly useful), but evolution still kicks in. With a large enough population, enough generations, and somebody listening to the god-awful racket this would produce, you'd eventually end up with a computer composer. Would it be creative?

Probably not. My prediction is that while the eventual eComposer would produce passable music, it would be very self-derivative. Once it finds a formula that works, why deviate? Deviating from your best stuff is only likely to get you a lower evaluation, and then you don't get any children. Best to play it safe, keep pumping out the same bass line, and keep your bytes replicating.

So what do you do? You evaluate each composer not just on quality, but on their creativity. You don't just ask for their best piece, you ask for 10 pieces, and make sure they're all good enough and different enough from each other. We usually only care about the best answer from our machine buddies, but I think that's wrong. To be right consistently, to be right when things change dramatically, you need to be able to come up with lots of different candidate solutions. It seems obvious in terms of music, but I expect this would help in lots of different machine learning domains.

Were I at grad-school, I'd write a paper about this. I'd throw together some simple problems, and see how penalizing for lack of depth in suggested solutions changes the long term performance of GP-produced programs. I'd draw some graphs, write up a conclusion suggesting further research, and find some journal to print it. But instead, not being a grad student, I've decided to publish the idea (sans research) via blog. When/If I do end up back in school, I can look back at my blog and start pumping out the papers. Or alternatively, Internet, you're welcome to do the work and take the credit if you find this first. Especially if you're a robot reading this as you consume all of humanity's written word (I'm looking at you, Google)...

Thursday, May 6, 2010

Am I You?

A very early memory of mine is staring, head back, up at a tree. I remember, in a fuzzy way, the dichotomy between the details in each minutely detailed leaf, and the whole, indivisible mass of green. I was being babysat by an aunt; my cousin was in his room for some transgression. I think it was summer: I remembered being impressed by the warmth and beauty around me.

It's not a remarkable memory for the vista, I've seen that tree hundreds of times. Rather, it stayed with me because it was the first time my mind stumbled across a mystery that's been with me ever since. I was outside, observing manicured nature. My cousin was in his room, probably fuming at his mother. But why was my experience of the world the one looking at the tree? My cousin must certainly have this same first-person experience, feeling one individual's pain, beholding one individual's sight. I knew I was me, it's basically a tautology. I didn't doubt I was the individual named Paul Barba, but it felt so arbitrary that I shouldn't be my cousin, or my neighbor, or any of 6 billion other individuals.

It's a hard question to ask, because there's a simple question obscuring a deeper one. I am me, because I have to be somebody. That's just how the world works: each person is an individual. There's no explanation necessary, and any perceived asymmetry is just a lack of perspective on my part. But at the same time, the huge divide between Paul's experiences and everyone else's, from my point of view, was troubling as a child.

Ultimately, I think the question is one of consciousness. That was the asymmetry in the world I was detecting, but too young to really understand. Everything else is physical. My cousin, the tree: they were all physical objects describable with reference to atomic patterns. But what about this perception of the world I had? This self-understanding mind, conscious of the passage of time around it? We still don't know how to understand it, really, in terms of electrons and photons. Maybe it's the work of a soul. Maybe solipism is truth, and there is a fundamental divide between me and everyone else. But I'm inclined to believe it's ultimately a matter of matter and energy.

I was Paul at age 7. I'm Paul now, and if it's meant to be I'll be Paul 50 years hence. There's this continuous stream of awareness that links the experiences of that child staring at a tree with the young adult typing on a laptop. I don't doubt that I was experiencing that tree.

But so much has changed: my brain has grown and reformed its patterns since then. Neuroplasticity tells us that the patterns in our brain are constantly changing. Most of my cells have died since then, being replaced by new generations. With twins, you could have argued that twin brothers at 7 are more similar than the 7 year old version and the 40 year old version of the same person. But the 40 year old and the 7 year old share a linked experience of being one person...

Which leads me to believe that it's just the uninterrupted existence of Paul that leads me to connect my current experiences with that child's experiences. I've got memories, but those aren't the same as a real experience. 7 Year old Paul experienced consciousness, 24 year old Paul is experiencing consciousness: everybody is. Memories, opinions, the chemicals rushing past our neurons are just incidentals. My perception of me, my intelligence and opinions, is less fundamental then this experiencing of looking out of two eyes: that's what I relate to as me, more deeply then the realities of a single moment.

Which all, ultimately, leads me to believe that what I would most deeply connect to as myself, the core of being, that thing experiencing emotions and visions and the pinch of the cheeks during a smile and the wind blowing through your hair: that wasn't limited to the boy looking at a tree. Whatever natural phenomenon leads me to perceive the world instead of blindly reacting to physical laws is at work in everybody. Thus while at one level I am Paul, I also believe I'm everyone else, everyone who will exist, at least until humanity dies off or evolves past my experiences. It doesn't feel true, at a level. I still feel, and am, closed off from every other experience. But that division of the world into individual pockets of consciousness doesn't mean they aren't all, in an important way, the same. When I die, these thoughts will be gone, these experiences forgotten, but experiencing and thinking will persist. What I thought was my own first-person experience will continue peering out some billions of pairs of eyes.

Sunday, May 2, 2010

A Few Thoughts on Creating

I find it much easier to start a project than to see it through. I don't think anybody maintains enthusiasm through the whole of a large undertaking, but it seems to be my shortcoming more than many. It's got to have something to do with my preference for ideas: I like the new. I like working out the interactions in a complex system. I like mapping a story arc, or drawing a mock-up. Once that part is done, though, and it's time to turn ideas into realities, I start losing focus. The siren songs of new ideas beckon.

Hence two weeks without a new post.

It's easy to be productive when you've got the enthusiasm for it. Some blog posts stream effortlessly through my fingers and into the electronic aether. But sometimes it has to be forced out. It's a phenomena I don't really understand. It's easy to run out of creative juices in any activity. Sometimes you just stare at a blank sheet of paper, or type away at code despite your brain pleading for television or a walk. Getting away from it, playing a video game or reading a book can help. But consuming media just as often leaves me more lethargic and uninterested than ever.

I feel obligated to create things in a way I don't exactly understand. Having a talent feels like an injunction to use it. The ephemeral nature of life pushes and pulls in this: in the brief time I have on Earth, shouldn't I do something impressive with it? But at the same time another voice asks: with the brief time I have, shouldn't I be enjoying life?

Which is perhaps the core of it: creative activities should be enjoyable. The brain is a massively parallel machine that makes countless evaluations in the process of creating. What topics to move on to? Which to cut? What's the most effective placement of the object in a sentence? Are there too many adverbs? But without enthusiasm, threads of the brain get distracted or quiet. Less brain mass is focused on the creation, and the creation suffers for it. And it seems that maintaining this divided attention, the conscious realm pushing out sentences but the unconscious dallying on other topics, drains us.

My brain is grasping for a concluding idea, something to wrap this all up, some larger context these thoughts have fit into. But there isn't anything obvious coming to mind. Creating is hard. Motivation is hard. Thinking about either too deeply gets into weird existential questions that haven't ever been very helpful to me in creating the motivation. But perhaps the key is that while the creative tides ebb, they rise as well. My motivation for blogging, for writing, for programming have all been weak lately, but that's just one phase in a larger creative cycle. I'm blogging again, after all.