Tuesday, August 07, 2012

Attempting to codify thought

I've been thinking lately that AI doesn't spend enough time trying to understand and emulate what it means to have a Train of Thought, or for that matter, what a Thought is.  So here's my best guess.  The next step is to try actually coding it up.

class Thought {
  // Rises when Fire()d, decays over time
  float activity;
  List(Association): associations;

class Association {
  Thought other_thought;
  float association_strength;

And a specific type of Thought would be a SensoryMemory, a sort of leaf node that has not only associations with other Thoughts but also a certain sensation unique to that SensoryMemory: a particular smell or sound or visual feature.

Sensory input threads: a Sensor is a thread that takes in sensory input and calls Fire() on the corresponding SensoryMemorys.

Thought::Fire() {

Thought::activate() {
  this.activity += approximately(1.0);

Thought::randomly_activate_nearby_thoughts() {
  related = choose_random_related_thought();  // Weighted by association_strength
  if ( related.active >= 1.0) {
    // Maybe the Association threads make this unnecessary?

Association Threads: an Associator looks at active Thoughts and makes new thoughts that tie together chains of thoughts that are all active right now, or associates active unrelated thoughts:

Associate() {
  thought = choose_random_active_thought();
  chain = recursively_find_all_connected_active_thoughts(thought);
  // Associate the new thought with the entire active chain:
  if (chain.length > 1)  create_new_thought(chain);
  else {
    // A lonely thought!  Find it a friend.
    other = choose_random_active_thought();
    add_association(thought, other);

Decay threads reduce the activity level of thoughts over time.

Chaos threads (probabilistically) randomly activate Thoughts.

So your Train of Thoughts is the sequence of most active Thoughts over time.  What's missing?

TODO: perhaps we need some sort of global arousal level that treats pleasure and pain properly, causing us to shrink from pain and seek pleasure.  Or a notion of how much we are seeking: fatigue makes us sleepy, food increases our curiosity.


Tweek said...

Great start. The problem that I see is that each random thought or association has its own spawned thoughts and associations. It becomes an n*n*n problem.

That introduces the potential for meltdown, which in turn requires a "settling" routine to reign things in. Unfortunately in a logic model these all are unpredictable if true to human thought. They can only be constrained in the context of the "individual".

Is there a way to work that in without over complicating the model?

Tweek said...

Seeing that the "decay" model might be applicable here....

Anonymous said...

Yeah, I really have no idea whether it'll blow up with useless associations or do nothing or what. I keep thinking it's going to have a lot of parameters to tweak, which is often a bad thing, but then I think my brain probably does have a lot of baked-in parameters evolved over time.

I just need to code it up and see.

I keep thinking that this is what the whole field of AI needs: lots of people who aren't already deeply entrenched in the existing thinking, making crazy hypotheses, coding them up, and sharing what they learn. Seems like we'd get a much better intuition for what thinking is if we get our hands dirty like that.

Tweek said...

Still finding this really interesting. If you code it up please put it on Google code or Github so we can clone it.

Seems like hunger, pain etc... might need definition. May be best to summarize them real simply as stubs so the rest can continue until they are needed. But I think they are important factors so need a place in the framework at some point (along with any other applicable human reactions that can be reasonably included).

Anonymous said...

Sure, this is all about working in the open. I think I'll end up with a lot of senses beyond the traditional five, and some of those will be things like the passage of time. But mental arousal may have to be a more global effect: I'm still pondering the relationship between pain and contentment and desire to seek new interesting stimulus.

Anonymous said...

Here's my
first pass at an implementation in python, although I haven't really tried to do anything useful with it yet:

$ ./ai.py
INFO:root:New thought: a
INFO:root:New thought: b
INFO:root:associate a -> b = 1.000000
INFO:root:decay a=0.231175
INFO:root:decay b=0.252850
INFO:root:associate a -> b = 2.154276
INFO:root:chaos: a=0.590278
INFO:root:chaos: b=0.461374
INFO:root:decay a=0.410285
INFO:root:decay b=0.191536
INFO:root:associate a -> b = 2.939903
INFO:root:chaos: a=0.781264
INFO:root:chaos: b=0.359394