<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Decision Transformers for Glut Control in the Active Logic Machine</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Justin D. Brody</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Donald Perlis</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Franklin and Marshall College</institution>
          ,
          <addr-line>PO Box 3003, Lancaster PA 17604</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Maryland Institute for Advanced Computer Studies</institution>
          ,
          <addr-line>College Park MD 20740</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>In this paper, we build from the preliminary work in [1] on using deep learning architectures to control inferential glut in a logical reasoning agent. Inferential glut is the well-known problem that symbolic reasoners encounter combinatorial explosions in the numbers of formulae they have to process. In [1] we proposed a neural architecture that employed a simple deep-reinforcement-learning network to prioritize potential inferences and control glut. This architecture was able to successfully control pre-inferential glut (inferential glut arising from ineficiencies in the reasoner's algorithm) and a limited form of inferential glut (that didn't use state). Work on this architecture continues; in this work we explore the use of Decision Transformers [2] as a replacement for the original deep reinforcement learning model. The decision transformer models reinforcement learning as a sequence modelling problem - specifically it employs transformers to generate the action likely to lead to a given return given the trajectory of (states, actions, returns) seen so far. In [2], the authors showed that using a pre-trained and ifne-tuned transformer (such a GPT2) can lead to near state-of-the-art on ofline reinforcement learning tasks. Since glut control as envisioned is largely a matter of selectively attending to the most promising avenues of reasoning, the attention-based mechanisms which underwrite transformers seem a natural fit for our application. In this paper we will explore the efectiveness of using a ifne-tuned GPT3 model [3] to predict salient actions as a proof-of-concept.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>2. Active Logic</title>
      <p>
        Our architecture is based on Perlis’ Active Logic reasoning engine ALMA [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Active
Logic is a time-sensitive non-monotonic logic which extends first-order logic in a number of
ways which make it well-suited for situated agents reasoning “in the wild”. Many of the features
of active logic will not be relevant for the current pilot work (but will be incorporated in future
work). For our present purpose we can think of active logic as a first-order reasoner which acts
as a step logic. In particular, for our purposes active logic will proceed by enacting a single
application of a single deduction rule to the current knowledge base. For example, suppose a
knowledge base  consists of the following sentences at time 0:
      </p>
      <sec id="sec-2-1">
        <title>1. location(a).</title>
      </sec>
      <sec id="sec-2-2">
        <title>2. location(X) –&gt; location(left(X)).</title>
      </sec>
      <sec id="sec-2-3">
        <title>3. location(X) –&gt; location(right(X)).</title>
        <p>Then location(a) can be used in conjunction with any one of these to derive location(left(a))
or location(right(a)), So to reach the next timestep, the active logic machine might apply
a single deduction and add location(right(a)) to its knowledge base1.</p>
        <p>
          For simplicity, in this preliminary study we restrict our attention to reasoning the proceeds
completely by way of applications of the resolution inference rule. See Section 9.5 of [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] for a
detailed discussion of resolution.
        </p>
        <p>While resolution is a complete inference rule it is also particularly prone to producing glut as
we shall see. We will focus our attention in this paper on the set of axioms . Although simple,
this set of axioms provides for a meaningful study of glut-control for a few reasons, which we
will examine in turn.</p>
        <p>In Figure 1, we have given a short transcript of the first few steps of ALMA’s reasoning with
 using resolution. The extremely rapid growth of the knowledge base is immediately apparent.</p>
        <p>1It is worth noting that this behavior is somewhat diferent from the traditional behavior of ALMA, where a
step would refer to applying all such options a single time; thus at time 1 we would derive left(a), right(a)
but not, e.g., left(right(a)).
of Θ( ) in  steps of reasoning.
 −
We also note that this growth has two sources – a growth in literals that comes from repeated
application of rules 2 and 3 of  joined with rule 1 and a growth in universal formulae that
comes from applying resolution to pairs of universal formulae. The latter type of formulae will
be produced by resolution but not by forward chaining. These formulae also give a mechanism
for growing the lengths of the potential consequents very rapidly. Indeed, in our study we
will explore a reward structure that is based on the number of right functions applied to an
instance of a; for example location(right(right(left(a)))) will have a reward of 2.
The continual creation of these universal formulae will allow us to get more highly rewarded
literals in the knowledge base rapidly, but some care is needed. By themselves, these rules do not
produce any reward at all because the new formula are not instantiated. So an optimal strategy
for an agent reasoning for  steps will be to create the longest possible universal rules for
1 steps and then instantiate the longest such rule at the final reasoning step. This requires
that an agent know how many steps it will reason for and how many it has already reasoned
for – in particular it will need to keep track of a state. This in contrast to a forward-chaining
based agent, whose optimal policy will be to repeatedly employ rule 2 from  to get a reward</p>
        <p>It is important to note that the growth of sentences from  is so rapid that glut control
becomes absolutely necessary – our workstation with over 300Gb of memory crashed after a
few steps without it. Indeed, we conjecture that the growth in the number of sentences in the
knowledge base is doubly exponential with Θ(2 2 ) sentences in the knowledge base after 
steps of (classical) ALMA reasoning.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Architecture</title>
      <p>
        Our glut-control architecture relies crucially on identifying, at each time-step, the set of potential
inferences that can be applied and viewing these as actions. By a potential inference we mean
a pair of formulae which the system believes it can use in the resolution rule to create new
knowledge. A list of these is stored in an internal ALMA data-structure; in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] this list was
passed through a neural heuristic function which would assign a priority to each such potential
inference. Our intended use case here is simpler – we will represent the current state of the
knowledge base and use a transformer to predict the potential inference which will lead to the
maximal reward. The engine will then apply resolution to this potential inference.
      </p>
      <p>
        In this preliminary study, we are specifically interested in using an autoregressive language
generation model (such as one of the GPT models) to determine the best action. Specifically,
we are interested in testing the viability of the Decision Transformer [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] as a way of choosing
the best potential-inference. The idea of the decision transformer is to train on a sequence of
trajectories
 =
︁(
(1 , 1 , 1 ), (2 , 2 , 2 ), . . . , ( ,  ,  )
︁)
where  is the th state of the th trajectory,  is the th action of the th trajectory, and 
is the the return-to-go of the the trajectory (the total reward that will be generated in future
states on the current trajectory). Actions are predicted by feeding in a desired return-to-go
and state and having the model complete the tuple with the optimal action. The success of
this paradigm relies on a remarkable ability of large language models to successfully model
out-of-distribution data [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]
      </p>
      <p>
        In our particular case, our states will correspond to the current content of the knowledge
base, actions will correspond to potential inferences and returns will be based on the reward
function mentioned above which counts the number of right functions in location instantiated
with a. As an initial test, we represented each triple as text and fine-tuned OpenAI’s GPT-3
model using their available tools [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. We separated each return from the state with the string
====, separated each state from the corresponding actions with ::::, enclosed each (return,
state, action) triple in angle brackets &lt;, &gt; and separated each triple in a trajectory with the
string |||||||| (the intuition is to make these syntactic features obvious to the model). An
example trajectory representation is given here (with inserted whitespace for readability) :
[&lt;3====
l(a); l(X) --&gt; l(f(X)); l(X) --&gt; l(g(X)); now(0)::::
l(X) --&gt; l(g(X)); l(X) --&gt; l(f(X))&gt;||||||||
&lt;3====
l(a); l(X) --&gt; l(f(X)); l(X) --&gt; l(g(X)); now(1); l(X) --&gt; l(f(g(X)))::::
l(a); l(X) --&gt; l(f(g(X)))&gt;||||||||
&lt;2====l(a); l(X) --&gt; l(f(X)); l(X) --&gt; l(g(X)); l(X) --&gt; l(f(g(X)));
l(f(g(a))); now(2)::::
l(X) --&gt; l(f(g(X))); l(X) --&gt; l(g(X))&gt;]
Here the first line of each triple is the return, the next line is a semi-colon separated list of
sentences in the knowledge base. The third line indicates which pair of sentences are combined
with resolution to produce new knowledge; we can see that in the second tuple, when the choice
increases the reward by one the return in the next triple correspondingly decreases by one.
      </p>
      <p>We represented 4000 such trajectories, each randomly generated with 6 reasoning steps
and the same initial knowledge base. These representations were then used as a dataset for
ifne-tuning GPT3 (using an empty string as prompt and the representation as the completion).
This was close to the maximum number of trajectories allowable by the default parameters set
by OpenAI; this dataset was then used to fine-tune a “curie” model of GPT3.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Preliminary Results</title>
      <p>To test our preliminary system, we entered the prompt [&lt;6====l(a); l(X) –&gt; l(f(X));
l(X) –&gt; l(g(X)); now(0):::: and asked GPT3 for a completion. Based on our
syntax, this is essentially asking for an inference to take that will result in a return of 6 based
on the initial knowledge base. We set the temperature to 0 and the response length to
1900 tokens, using )&gt;] as a stop sequence. The beginning of the provided completion is
l(X) --&gt; l(f(X)); l(X) --&gt; l(g(X))&gt;. This indicates that the fine-tuned model has
learned the syntax of our representation and selected a valid action – the pair of sentences is in
the knowledge base and will resolve to give a new sentence l(X) --&gt; l(g(f(X))). Further,
the next part of the completion (with added whitespace) given is
&lt;6====
l(a); l(X) --&gt; l(f(X)); l(X) --&gt; l(g(X)); now(1); l(X) --&gt; l(g(f(X)))::::
l(X) --&gt; l(g(f(X))); l(X) --&gt; l(f(X))&gt;||||||
this further shows that the model is capable of computing the correct returns since the inference
selected will not lead to any immediate reward.</p>
      <p>Subsequently, the model chooses
• l(X) --&gt; l(f(g(f(X)))); l(X) --&gt; l(g(X)) leading to l(X) --&gt; l(g(f(g(f(X)))));
• l(a); l(X) --&gt; l(g(f(g(f(X))))) leading to l(g(f(g(f(a))))) and a reward of 2;
• l(g(f(g(f(a))))); l(X) --&gt; l(g(f(g(f(X))))) leading to l(g(f(g(f(g(f(g(f(a)))))))))
and a reward of 4</p>
      <p>It is noteworthy that each choice the model makes is valid and that the correct returns and
logical consequences are modelled. Importantly, this particular sequence does not appear in the
training set, so the model has not simply memorized a solution. The overall robustness of this
learned model will be a subject of future analysis.</p>
      <p>As a final test, we note that the trajectory in the training set with the highest return has a
return of 21. Can our model beat this and get a return of 22 in 6 moves? The model makes the
following choices:
• l(a); l(X) --&gt; l(g(X)) leading to l(g(a)) and a predicted return of 22
• l(g(a)); l(X) --&gt; l(f(X)) leading to l(f(g(a))) and a predicted return of 21
• l(f(g(a))); l(X) --&gt; l(f(X)) leading to l(f(f(g(a)))) and a predicted return of 19
• l(f(f(g(a)))); l(X) --&gt; l(f(X)) leading to l(f(f(f(g(a))))) and a predicted return of 16
• l(f(f(f(g(a))))); l(X) --&gt; l(f(X))&gt; leading to l(f(f(f(f(g(a)))))) and a predicted return
of 12
• l(f(f(f(f(g(a)))))); l(X) --&gt; l(f(X))
(the final element could not be completed because of the token limit) We note that:
• The model wastes the first move by adding a g to get g(a).
• The model employs the same rule every step, which is the same rule that a greedy policy
would use.
• The models returns are significantly of in many cases; if we take the decrease in returns
as an estimate of the reward for each action.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusions and Future Work</title>
      <p>Overall, our simple test shows promise but also a great deal of room for improvement. We
emphasize that our preliminary investigation only trained on a relatively small model (“curie”)
and with a small amount of data (4000 trajectories). This already shows a limited ability to
correctly model returns and actions in our scenario. Notably, every action picked was viable;
the syntactic structure of every completion was correct; and we have found no instances in
which the model made a mistake about what new sentence would be entered into the knowledge
base as a result of choosing a particular action (that is, it has learned the syntactic structure of
resolution).</p>
      <p>Further work will expand to larger models, both by using OpenAI’s “davinci” model with
larger training sets and by fine-tuning open source large language models from HuggingFace.
We will also explore training GPT models from scratch to try to measure the degree to which
our model is exploiting the general modelling capacities of the pre-trained networks.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J. D.</given-names>
            <surname>Brody</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Austin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Khater</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Maxey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. D.</given-names>
            <surname>Goldberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Clausner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Josyula</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Perlis</surname>
          </string-name>
          ,
          <article-title>Using neural networks to control glut in the active logic machine (</article-title>
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Lu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Rajeswaran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Grover</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Laskin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Abbeel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Srinivas</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Mordatch</surname>
          </string-name>
          ,
          <article-title>Decision transformer: Reinforcement learning via sequence modeling</article-title>
          ,
          <source>arXiv preprint arXiv:2106.01345</source>
          (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>T. B. Brown</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Mann</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          <string-name>
            <surname>Ryder</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Subbiah</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Kaplan</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Dhariwal</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Neelakantan</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Shyam</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <string-name>
            <surname>Sastry</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Askell</surname>
          </string-name>
          , et al.,
          <article-title>Language models are few-shot learners</article-title>
          , arXiv preprint arXiv:
          <year>2005</year>
          .
          <volume>14165</volume>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>J. J.</given-names>
            <surname>Elgot-Drapkin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Perlis</surname>
          </string-name>
          ,
          <article-title>Reasoning situated in time i: Basic concepts</article-title>
          ,
          <source>Journal of Experimental &amp; Theoretical Artificial Intelligence</source>
          <volume>2</volume>
          (
          <year>1990</year>
          )
          <fpage>75</fpage>
          -
          <lpage>98</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Elgot-Drapkin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Kraus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Miller</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Nirkhe</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Perlis</surname>
          </string-name>
          ,
          <article-title>Active logics: A unified formal approach to episodic reasoning</article-title>
          ,
          <source>Technical Report</source>
          ,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>M. L. Anderson</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          <string-name>
            <surname>Gomaa</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Grant</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Perlis</surname>
          </string-name>
          ,
          <article-title>Active logic semantics for a single agent in a static world</article-title>
          ,
          <source>Artificial Intelligence</source>
          <volume>172</volume>
          (
          <year>2008</year>
          )
          <fpage>1045</fpage>
          -
          <lpage>1063</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>K.</given-names>
            <surname>Purang</surname>
          </string-name>
          ,
          <article-title>Alma/carne: implementation of a time-situated meta-reasoner</article-title>
          ,
          <source>in: Proceedings 13th IEEE International Conference on Tools with Artificial Intelligence. ICTAI</source>
          <year>2001</year>
          , IEEE,
          <year>2001</year>
          , pp.
          <fpage>103</fpage>
          -
          <lpage>110</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>S.</given-names>
            <surname>Russell</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Norvig</surname>
          </string-name>
          ,
          <article-title>Artificial intelligence: a modern approach</article-title>
          , Prentice Hall,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>A.</given-names>
            <surname>Radford</surname>
          </string-name>
          ,
          <string-name>
            <surname>J. Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Child</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Luan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Amodei</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I.</given-names>
            <surname>Sutskever</surname>
          </string-name>
          , et al.,
          <article-title>Language models are unsupervised multitask learners</article-title>
          ,
          <source>OpenAI blog 1</source>
          (
          <year>2019</year>
          )
          <article-title>9</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Openai</surname>
            <given-names>api document</given-names>
          </string-name>
          ,
          <year>2021</year>
          [Online]. URL: https://beta.openai.com/docs/guides/ ifne-tuning.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>