From 232eeccbcb0d7a8a96cb2ccb3adf538771d6acc8 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Fri, 8 Feb 2013 00:01:22 -0600 Subject: [PATCH] Markov: let backwards chainer go randomly longer the code, in a kind of trial state, would very quickly stop trying to work backwards. (part of this was for performance reasons, i believe.) since that seems to have proven stable, let's mess with it --- the backwards chainer can now go backwards a random distance, rather than just what almost always turned out to be 2 --- modules/Markov.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/Markov.py b/modules/Markov.py index 5c413d3..c7376c4 100644 --- a/modules/Markov.py +++ b/modules/Markov.py @@ -383,10 +383,16 @@ class Markov(Module): self.log.debug("working_backwards: {0:s}".format(" ".join(working_backwards))) # now work backwards until we randomly bump into a start + # to steer the chainer away from spending too much time on + # the weaker-context reverse chaining, we make max_size + # a non-linear distribution, making it more likely that + # some time is spent on better forward chains + max_back = random.randint(1, max_size/2) + random.randint(1, max_size/2) + self.log.debug("max_back: {0:d}".format(max_back)) while True: key_hits = self._retrieve_k2_for_value(working_backwards[0], context_id) - if self.start2 in key_hits and len(working_backwards) > 2: - self.log.debug("working backwards forced start, finishing") + if self.start2 in key_hits and len(working_backwards) > max_back: + self.log.debug("max_back exceeded, cleanly finishing") gen_words += working_backwards self.log.debug("gen_words: {0:s}".format(" ".join(gen_words))) break