Alessio Capitanelli and Fulvio Mastrogiovanni 11institutetext: Department of
Informatics, Bioengineering, Robotics, and Systems Engineering, University of
Genoa, Via Opera Pia 13, 16145, Genoa, Italy
11email<EMAIL_ADDRESS>11email:
<EMAIL_ADDRESS>
# A Framework for Neurosymbolic Robot Action Planning using Large Language
Models

Alessio Capitanelli  Fulvio Mastrogiovanni

###### Abstract

Symbolic task planning is a widely used approach to enforce robot autonomy due
to its ease of understanding and deployment in engineered robot architectures.
However, techniques for symbolic task planning are difficult to scale in real-
world, highly dynamic, human-robot collaboration scenarios because of the poor
performance in planning domains where action effects may not be immediate, or
when frequent re-planning is needed due to changed circumstances in the robot
workspace. Accuracy of long-term plans, plan length, and planning time could
hinder the robot’s efficiency and negatively affect the overall human-robot
interaction’s fluency. We present a framework, which we refer to as Teriyaki,
specifically aimed at bridging the gap between symbolic task planning and
machine learning approaches. The rationale is training Large Language Models
(LLMs), namely GPT-3, into a neurosymbolic task planner compatible with the
Planning Domain Definition Language (PDDL), and then leveraging its generative
capabilities to overcome a number of limitations inherent to symbolic task
planners. Potential benefits include (i) a better scalability in so far as the
planning domain complexity increases, since LLMs’ response time linearly
scales with the combined length of the input and the output, instead of super-
linearly as in the case of symbolic task planners, and (ii) the ability to
synthesize a plan action-by-action instead of end-to-end, and to make each
action available for execution as soon as it is generated instead of waiting
for the whole plan to be available, which in turn enables concurrent planning
and execution. In the past year, significant efforts have been devoted by the
research community to evaluate the overall cognitive abilities of LLMs, with
alternate successes. Instead, with Teriyaki we aim to providing an overall
planning performance comparable to traditional planners in specific planning
domains, while leveraging LLMs capabilities in other metrics, specifically
those related to their short- and mid-term generative capabilities, which are
used to build a look-ahead predictive planning model. Preliminary results in
selected domains show that our method can: (i) solve 95.5% of problems in a
test data set of 1000 samples; (ii) produce plans up to 13.5% shorter than a
traditional symbolic planner; (iii) reduce average overall waiting times for a
plan availability by up to 61.4%.

###### keywords:

AI, Generative, Neurosymbolic, Large Language Model, Task Planning, PDDL,
Human-Robot Interaction, GPT

##  1 Introduction

Nowadays, we are witnessing the emergence of scenarios where robots are
expected to operate with an increased autonomy, versatility, and robustness,
especially in tasks to be carried out jointly, or in close coordination with
humans. In fact, in human-robot collaboration tasks, humans could act as
simple beneficiaries of robot behaviors, or they could act as teammates,
actually partaking in robot actions as they unfold. This state of affairs not
only holds in assistive and service robotics, but is becoming particularly
relevant in settings inspired by the Industry 4.0 paradigm, which is believed
to profoundly shape the nature of next-generation manufacturing operations
(Heyer,, 2010). These scenarios require robots to exhibit quite dynamic and
reliable capabilities in sustaining a purposeful collaboration with human
operators: while robots may be characterized by a continuum range in autonomy,
also depending on the specific operation at hand, human operators may
supervise robot actions and intervene if and when necessary. Therefore, robots
must not only operate reliably in line with the interaction with human
operators, but also to face unforeseen events very likely to happen when the
work to be done is poorly structured, and human loosely predictable behavior
is involved (Darvish et al.,, 2018). This paradigm shift requires robots to
validate or re-plan their future actions continuously, ideally to predict or
at least to react to changing conditions or the outcomes of unforeseen human
behavior. As a consequence, it turns out that planning performance is of
critical importance to ensure both an efficient robot operation and an
effective human-robot collaboration.

In scenarios characterized by such requirements, conventional, symbolic task
planners have limitations that hinder their efficacy. In current practice,
they use search heuristics to explore the range of possible states that the
modeled environment can assume until they find a sequence of actions in-
between states leading to a state compatible with the desired goal situation.
As a result, they tend to exhibit planning times’ combinatorial explosion as
the number of symbols (representing classes of entities, instances, modeled
fragments of reality as predicates, or actions, and their combinations)
involved in the planning process increases. This phenomenon makes frequent re-
planning extremely costly in terms of needed planning time, specifically
considering the fact that a plan synthesized by a symbolic task planner is an
atomic entity, that is, it is either generated in its entirety, or it is not
available. Although approaches for hierarchical task planning have been
proposed in the literature, whereby high-level (generic) plans may be created
quickly, and low-level (specific) sub-plans can be generated in chunks, the
basic issue remains, and it is also necessary to carefully engineer which part
of the plan could be synthesized at the high-level, and which part (in terms
of actions actually executable by a robot) should be made available in sub-
plans (Mastrogiovanni et al.,, 2004; Murali et al.,, 2020; Darvish et al.,,
2021).

When human operators and robots collaborate on a task, they can achieve a high
standard of coordination, leading to a synchronized blending of their actions
with precise and efficient timing (Carfí et al.,, 2019). This feature is
referred to as fluency as per Hoffman, (2019), and it has been demonstrated
that the delay experienced by a human immediately after completing an action,
as incurred by their teammate, has a strong correlation with subjective
fluency perception. Obviously enough, the aforementioned combinatorial
explosion of planning times negatively affects the quality of human-robot
collaboration, and specifically its fluency. It has been argued that fluency
in human-robot collaboration could be improved by introducing intuitive
communication channels able to make clear which action a robot will carry out
next Macció et al., (2022). In fact, that works while the cooperation unfolds,
whereas in case of re-planning it would be necessary to put the collaboration
process on hold.

In this paper, we introduce a framework, which we call Teriyaki111Teriyaki:
https://github.com/alessiocpt/teriyaki, to train and invoke Large Language
Models (LLMs) (Hatcher and Yu,, 2018) to behave as task planners. LLMs such as
OpenAI’s GPT-3 (Brown et al.,, 2020) are characterized by the possibility of
(i) linearly scaling in computational complexity with the total length of
prompt and completion, and (ii) generating partial results while iteratively
predicting the next set of symbols in a sequence. We argue that these two
features could be leveraged to design a task planner with a reduced run-time
complexity, and capable of making the next action available ahead of full plan
synthesis, which would allow a robot using such planner to begin action
execution before the entire plan is generated, in a full iterative fashion. If
the robot architecture allowed it, this may unlock concurrent plan generation
and execution. Moreover, if such a model could be trained to receive input and
return output using the Planning Domain Definition Language (PDDL)
(Aeronautiques et al.,, 1998), it would maintain full compatibility with
existing software frameworks for symbolic task planning such as ROSPlan
(Cashmore et al.,, 2015). We refer to Teriyaki as neurosymbolic planning, as
it combines neural network based learning as substrate with symbolic knowledge
representation and reasoning as logic (Garcez and Lamb,, 2020). Unlike
traditional symbolic task planners, our approach is domain-dependent and
requires training, but it is trivial to generate large data sets for training
on a given domain using traditional task planners.

Teriyaki has been evaluated and tested on two planning domains, specifically
for the collaborative manipulation of articulated objects by human operators
and robots, a challenging task previously described in the literature
(Capitanelli et al.,, 2018; Bertolucci et al.,, 2019, 2021). These domains
have been selected because of the challenges they pose on the planning
process: (i) for symbolic task planners, because the manipulation of an
articulated object scales very poorly with the number of its links, joints,
and the allowed angle configurations; (ii) for LLMs, since the domains include
conditional effects, that is, an action could imply modifying the state of the
representation in ways that are not immediately apparent from the arguments of
the action itself, for example, if a link were rotated around a joint, all
downward links in the chain should be also implicitly rotated with respect to
an absolute reference frame.

The training process has been performed on a large data set of 9000 problem-
plan pairs generated automatically and solved by an existing, state-of-the-
art, traditional, symbolic, PDDL-based planner, namely Probe (Lipovetzky and
Geffner,, 2011). The resulting models have been rigorously tested on 1000
pairs not previously used for training, and evaluated in terms of planning
accuracy, plan length, and planning times. During training, data related to
validation and planning accuracy, defined as the percentage of plans that can
be formally proved to be correct, have been collected to investigate their
evolution with the growing number of training samples and to assess whether
transfer learning between similar planning domains is possible. Results show
near identical planning accuracy between Probe and the solvers generated with
Teriyaki. However, Teriyaki outperforms Probe in terms of shorter plan length
by up to 13.5% in one of the domains. Regarding planning times, it is
noteworthy that an objective comparison is not possible due to the different
computing architectures on which the two planners run, that is, Teriyaki is
based on a proprietary cloud-based service, namely GPT-3, whose response time
was not guaranteed nor predictable during test sessions, whereas Probe can run
on a fully accessible and controlled workstation. In fact, in the current
experimental architecture, Probe remains faster in generating a complete plan,
that is, in a situation where we require Teriyaki to synthesize a full PDDL-
compatible plan end-to-end. However, when the planner as a module is
integrated into a robot architecture, the use of Probe forces us to adopt a
pure sense-plan-act approach, that is, the plan must be synthesized in its
entirety before its first action can be executed, whereas Teriyaki generates
and makes available for execution the first action as it is produced. In our
experiments, this reduces the overall waiting time by 61.4% on average, as it
exploits simultaneous planning and execution. Finally, we also experimentally
observe that Teriyaki solvers scale with the input and output length rather
than with the problem and domain complexity, hinting that there might exist
more complex domains where Teriyaki could outperform Probe, an in general a
traditional symbolic planner.

To summarize, the main contributions of this paper are the following: (i) we
designed, developed, and released to the community Teriyaki, a framework to
train and use GPT-3 to solve PDDL-compatible problems for a given domain; (ii)
compared to similar methods in literature, Teriyaki has been tested on plans
80% longer and including conditional effects; (iii) we demonstrate that LLMs
can outperform non-optimal planners in terms of plan length; (iv) we propose
to exploit LLMs capability to stream the output plan as it is being generated,
for simultaneous planning and execution, leading to a significantly shorter
waiting time for execution to begin in real-world human-robot collaboration
scenarios.

Despite the positive results, we want to highlight that solvers generated with
Teriyaki should not be considered at the moment as a complete alternative to
traditional, symbolic planners. Instead, we recommend considering them as a
proof-of-concept of the planning capabilities of LLMs and their possible
applications as the technology matures, especially regarding to human-robot
collaboration scenarios.

##  2 Related Work

Neurosymbolic approaches foresee that (i) their knowledge is encoded in
vector-based representations supporting neural networks which maximize an
efficient learning from data, and (ii) discrete symbols become available as a
result of querying and extracting knowledge from the trained network (Garcez
and Lamb,, 2020). For a long time, it has been theorized that such approaches
may provide an alternative to the problem of combinatorial explosion in
reasoning by leveraging the reasoning mechanisms encoded in the learning
process. However, it is only recently that they started to gain traction,
mainly for Natural Language Processing (Dale,, 2021). Most notably, GPT-3 and
its successors GPT-3.5 and GPT-4, are famous LLMs released by the company
OpenAI222Web: https://openai.com/blog/gpt-3-apps that achieved astonishing
results in generating human-level complex text in the form of structured
sentences (Brown et al.,, 2020). Other popular models are LLama 2 (Touvron et
al.,, 2023), LaMDA (Thoppilan et al.,, 2022), PALM (Chowdhery et al.,, 2022),
Megatron-Turing NLG (Smith et al.,, 2022) or BLOOM (Scao et al.,, 2022). A few
of the most notable applications of these models are text summary generation
and completion, sentiment analysis, and, of particular interest to our
application, code generation (Chen et al.,, 2021).

LLMs are one of the most promising applications of Deep Generative Models
(Oussidi and Elhassouny,, 2018), that is, a category of unsupervised Deep
Learning algorithms capable of capturing the probabilistic distribution that
can underlie the generation of a class of data. Once estimated, it is possible
to generate synthetic data compatible with such probabilistic distribution.
LLMs in particular are capable of estimating the probability of a sentence
represented as the product of each discrete symbol’s probability given the
symbols preceding it. For instance, given a few words as a prompt, they can
easily suggest the most likely way to complete the sentence. Usually, such
symbols are referred to as tokens and represent short sequences of characters.

Common ways to implement LLMs are Recurrent Neural Networks (Mikolov et al.,,
2011), Long Short-Term Memory (LSTM) networks (Sundermeyer et al.,, 2012) and,
most recently, Transformers (Vaswani et al.,, 2017), of which GPT models are
the most notable example. Transformers are models based on an encoder-decoder
architecture, and adopt a self-attention mechanism that allow them to weigh
each part of the input data differently. While in the current state of affairs
there are no guarantees about the long-term logical coherence of the answers
given by a Transformer-based architecture, especially for long sequences of
symbols, such models exhibit surprising capabilities in generating plausible
and coherent lists of instructions, from cooking recipes to functioning code.

Since their popularization, several research works have tried to assess the
extent of LLMs’ general logical capabilities, especially in zero-shot to few-
shot attempts. As per Brown et al., (2020), for zero-shot approaches, we refer
to the case when questions implying a certain level of logic capabilities are
posed directly to the model, whereas one-shot and few-shot approaches provide
a very limited amount of examples to the model as part of the request. In all
such cases, the model is just prompted, without further training with specific
examples, a procedure now commonly referred to as fine-tuning. The work by
Valmeekam et al., (2022) proposes a benchmark for LLM-based planning and
reasoning in a few-shot scenario. The authors employed PDDL, but only to
automatically generate, in natural language, several logical problems never
seen before by the model, and compared the performance of popular LLMs under
several metrics. The best performer could solve only $25$ out of $500$
problems, that is, 5%. Better results were obtained by Wang et al., (2023)
using few-shot learning and grammar prompting. In this approach, GPT-3.5 and
GPT-4 are used to predict a specialized grammar given a test input, and then
generate the output according to the rules of the grammar itself. Among
others, the authors tested inputs in PDDL format extracted from popular but
rather simple PDDL domains. While the benefits of grammar prompting are
evident, in absolute terms they obtained mixed results depending on the
domain, with success rates ranging from 40% to 100%. LLM-Planner (Song et
al.,, 2023) is another few-shot method based on GPT-3 and designed
specifically for embodied reasoning, that is, techniques aimed at being used
in agents dealing with real-world, physical environments. This approach uses
near-natural language and is characterized by a dynamic re-planning mechanism
grounded on what an agent could observe in the environment at each step. High-
level planning accuracy in a variety of tasks ranges from 26% to 51%. Similar
approaches are discussed also by Logeswaran et al., (2022) and Wake et al.,
(2023). Singh et al., (2023) proposed instead Progprompt, a method that
exploits the strong performance of GPT-3 in code generation by prompting the
model to generate executable Python code to solve a given problem. Silver et
al., (2023) further improved on this concept by proposing a method for
generalized planning in PDDL domains by also including an automated debugging
mechanism.

As perfectly stated by Huang et al., (2022), the main issue with almost all
these approaches is that plans produced naively by LLMs cannot map precisely
to admissible actions, thus most of them attempt to increase their success
rate in achieving the desired goal state by clever prompting approaches.
Silver et al., (2022) face similar challenges while trying to solve actual
PDDL problems, maintaining the PDDL format both in input and output. As an
alternative solution, they propose to use the good-but-imperfect LLM-generated
output to support a traditional (that is, based on heuristic search), PDDL-
based planner. While this approach mitigates the issues described before and
often provides planning time improvements above 10%, the ability to generate a
plan action-by-action is lost.

Hence, it appears that with currently available LLMs, solving task planning
problems reliably, that is, with a success rate comparable to that of
traditional, PDDL-based planners, is only possible through an appropriate
fine-tuning process. Such an approach involves the further training of a base
model with specific examples, namely problem-plan pairs, related to the
planning domain at hand. Plansformer is an approach of this kind proposed by
Pallagani et al., (2023). The authors trained five different models by fine-
tuning CodeT5 (Wang et al.,, 2021), a LLM specialized in code generation, to
solve just as many simple, well-known, PDDL-based domains such as the Tower of
Hanoi, where Plansformer reached 97% valid plans. The fine-tuning dataset has
been generated by solving 18000 randomly generated problems with the Fast-
Downward planner (Helmert,, 2006), and then translating both problems and
plans into a more compact form. PDDL-based problems are augmented by listing
the actions in the domain to explicitly teach the model about their
preconditions and effects.

A possible interpretation of these results is that there are obvious
similarities between the capability of LLMs to learn the probability of a
symbol following the preceding ones, and the search heuristics that power
traditional PDDL-based planners. Hence, we are not just extracting knowledge
from the model and exploiting its general reasoning capabilities, but rather
we are training the model to approximate the search heuristic of the planner
generating the dataset.

Teriyaki takes a similar approach with a few key differences: (i) we assume
that LLMs are capable of handling unaltered PDDL-based problem and plan
descriptions, which in turn makes the model easier to use in software
architectures for robots; (ii) with the aim of reducing the length of the
prompt, which is one of the main LLMs’ constraints, we instead exclude some
information, on the assumption that the model can learn it and, for example,
no explicit knowledge of the action preconditions and effects is given to
Teriyaki during fine-tuning; (iii) it is trained on a dataset of non-optimal
plans, which allowed us to observe that LLMs are capable of outperforming the
traditional planner they are trained upon in terms of average plan length in
selected domains; (iv) we propose to use Teriyaki to stream plans as they are
generated, that is, action-by-action, to enable simultaneous planning and
execution in robot tasks, specifically in human-robot collaboration.

Figure 1:  A Baxter robot executing actions in two domains involving the
manipulation of an articulated object. A human can act on an articulated
object’s joint at any time, forcing the robot to re-plan.

##  3 Methods

###  3.1 Planning Domains, PDDL Version, and Planner

In our work, and with the aim of challenging both the chosen, traditional,
PDDL-based planner as well as Teriyaki, we have selected two PDDL domains,
which we refer to from now on as MACRO and NO-MACRO. The two domains model
manipulation actions on an articulated object, and have been previously
showcased in human-robot collaboration scenarios. Figure 1 shows a Baxter
robot executing a plan from the two domains, and a possible interaction with a
human. Both domains use the so-called absolute representation as described in
(Capitanelli et al.,, 2018), meaning that angles between pairwise links of the
articulated object are expressed with respect to an absolute reference frame.
The choice is motivated by the fact that domains using an absolute
representation require conditional effects in the planning domain, that is,
actions can have implicit effects on joint angles not directly affected by the
outcomes of the action itself. If managed by a traditional, symbolic action
planner this requires propagating the (conditional) effects of each action to
modify the value of state variables not directly affected by the effects.
Likewise, we argue that in the case of LLMs like GPT-3, conditional effects
could stress the model because it should be harder to maintain coherence in
the plans given the generative process.

The main difference between the two selected domains is that one uses PDDL
macros whereas the second does not. Macros are ordered, compound actions that
bundle together a number of basic actions, for example, a `grasp-rotate-
release` action instead of three atomic ones, that is `grasp`, `rotate`, and
`release`. Their use is an effective way to reduce the planning time in
traditional action planners at the cost of accepting less optimal plans. In
fact, the use of macros could lead a planner to enforce the use of an actions
sequence, that is, a given macro, at the cost of introducing possibly spurious
actions. For example, if the goal state assumed the articulated object to be
in a given configuration, but with the robot gripper still maintaining its
hold on the object, the planner could prefer using a macro `grasp-rotate-
release` followed by another `grasp` action (partially compensating the
effects of the macro) instead of two atomic actions `grasp` and `rotate`.
Macros are also supposed to facilitate the generative process of GPT-3 since
the use of macros is expected to shorten the resulting plan significantly.

Since the two domains are fundamentally similar but lead to plans of different
lengths, they are ideal candidates to test how Teriyaki-based solvers scale
with the output length. As both domains taken into consideration here used
conditional effects, we used PDDL 2.1 and a compatible PDDL-based planner,
namely Probe (Lipovetzky and Geffner,, 2011), one of the planners used in
(Capitanelli et al.,, 2018). It must be noted that the choice of Probe has an
impact on the quality of the results, and in the future, an optimal planner
might be used instead, like in the Plansformer approach.

###  3.2 Choice of the LLM, Data Set Generation and Composition

Figure 2:  A diagram of Teriyaki fine-tuning process. Blocks in yellow
represent custom code developed for data generation and processing as
described in section 3.2.

As we anticipated, in this work we leverage GPT-3, a closed-source model and
commercial product that at the time of this writing can only be accessed as a
cloud-based service through OpenAI’s API. Our results are not limited to the
specific features of GPT-3 and could in theory be replicated with any
available LLM. In practice, since our first experiments with GPT-3, we have
tested several smaller models that can be run locally, such as LLama 2 7B,
13B, and 30B, and none of them could reliably solve problems in the two
selected domains. Forced to employ a commercial model as a service, we decided
to opt for GPT-3 due to its size and speed compared to its more recent
versions.

In the case of GPT-3, the training can be performed by providing a structured
file where each line is a prompt-completion pair. We assumed that the GPT-3
model can implicitly learn by example the rules usually defined in a PDDL
domain file, such as the allowed (modeled) actions, and their respective
preconditions and effects. Hence, we conducted training sessions using only
problem-plan pairs, whereas we use the problem as a prompt and the plan as
completion. We remark here that only part of the PDDL problem is used as a
prompt, as many of the predicates are actually static, that is, they are used
to encode general properties of the problem, such as the relative order of
joint angle configurations, an example being: a joint at $45$ deg can be
rotated clockwise to $60$ deg, and counter-clockwise to $30$ deg in $15$ deg
increments. These predicates remain the same in all problems and are never
modified by action effects. Therefore, we assume that the model can learn them
from the implicit information encoded in the plans, in the same way as the
domain. We thus removed them from the prompt to reduce its length, as prompt
length has an impact on response time and the total prompt plus completion
length of each query cannot exceed $2048$ tokens, or circa $8000$ characters,
for the selected model, allowing us to generate longer plans without
truncation and improving performance.

At the time the experiments were performed, OpenAI’s documentation suggested
using the largest and most powerful version of the model, called `davinci`,
for a conditional generation, that is, generating original text based on
input. For this use case, the documentation recommends training the model
using at least $500$ training samples and aiming for $8000$. One of the
advantages of Teriyaki is that we can easily generate large training datasets
using randomly generated problems and a PDDL-based action planner. Therefore,
we generated $9000$ problems, out of which $8000$ were reserved for training
and $1000$ for validation. It must be noted that out of the $9000$ planning
attempts performed by the planner $124$ failed, so the validation set has been
reduced to $876$ samples. Finally, we added another $1000$ unique problem-plan
pairs as a test set, in this case, we ensured that all the chosen samples
could be solved by Probe.

The next step requires validating the completeness of the plans generated by
Probe to ensure that we train our model only on correct data. To do so we use
the widely known VAL validation suite (Howey et al.,, 2004), which requires
plans to be formatted in the International Planning Competition (IPC)
standard333Web: https://ipc2023.github.io/. As Probe does not return plans
compliant with this standard, we developed custom code to reformat the plan
files to be compatible with VAL. This is also necessary to ensure that
Teriyaki will be trained on IPC-compatible standard plans, and will thus later
reply to our queries in the same way, allowing us to easily benchmark its
planning accuracy. Running VAL over the dataset resulted in all plans passing
the test, meaning that they reached the desired goal state, even though it
must be reminded that Probe previously failed to generate a plan at all for
$124/9000$ problems, that is, about $1.37\%$ of the total.

Finally, we compiled the training and validation datasets in `jsonl` format.
Each line of a dataset file is composed of a prompt, that is, the problem, and
a completion, that is, the plan. We added to the end of each prompt and
completion the respective termination sequences, namely `\n\n###\n\n` and
`END`. As the name suggests, the termination sequences signal to the network
the end of the message. This is especially important for the completion as the
termination sequence can then be used as a stopping condition when querying
the model. A sample line is provided in Listing 1, edited for the sake of
brevity and clarity. The whole data generation and dataset preparation process
is outlined in Figure 2.

⬇

{"prompt":

"(:init (angle_joint angle315 joint1)

(angle_joint angle300 joint2)

(angle_joint angle285 joint3)

(in-centre joint2)

(free gleft) (free gright))

(:goal (and

(angle_joint angle0 joint1)

(angle_joint angle300 joint2)

(angle_joint angle285 joint3)))

\n\n###\n\n",

"completion":

" 0.00100: (link-to-central-grasp ...)

0.00300: (increase_angle_first_child_45 ...)

0.00500: (release-links ...)

0.00700: (link-to-central-grasp ...)

0.00900: (decrease_angle_first_child_45 ...)

END"}

Listing 1: An example of training sample.

###  3.3 Training

As far as the training process is concerned, we decided to run a complete
8000-sample training on the MACRO domain, since plans in its dataset are
shorter on average, and therefore supposedly easier to be learned by GPT-3. We
call this model Teriyaki-MACRO.

When we train a LLM to perform action planning, the cost function rewards
linguistic coherence rather than planning accuracy. This means that we are
hypothesizing linguistic coherence as a proxy for logical coherence, and
therefore we must assume that validation accuracy during the training process
differs from the planning accuracy of the resulting model, whereas the
planning accuracy is defined as the percentage of plans that are (i) formally
correct and (ii) able to reach the desired goal state, or a state compatible
with it. By “formally correct” we mean that each action’s arguments are
consistent both with the specifications given in the planning domain and the
state of the modeled reality when that action is carried out, that is, the
action preconditions are not violated. To be able to measure how planning
accuracy increases with the size of the provided training set, we decided to
perform the training process in steps. At each step, we provided samples to
double the total size of the training set. Starting from the minimum amount of
500 samples, we then trained the system with 1000, 2000, 4000, and 8000 total
samples, and saved a snapshot of the trained model at each step.

As anticipated above, the base model chosen for the training process is GPT-3
and specifically `text-davinci-002`. Regarding the hyper-parameters, the
number of training epochs was set to 2, while the batch size and the learning
rate multiplier were left to their default values. The batch size defaults to
$0.2\%$ of the number of examples in the training set, while the default
learning rate is automatically determined in a range from $0.05$ to $0.2$
depending on the final batch size. We also highlight that since the model was
effectively fine-tuned five times, the learning rate was reset to the default
value at the beginning of each session, with an effect similar to gradient
descent with warm restarts (Loshchilov and Hutter,, 2016). We did provide the
optional validation set and enabled the `compute_classification_metrics`
options to obtain training statistics for further analysis. The total training
cost for this procedure on a single planning domain at the time of training
(01/12/2022) was around 250$.

###  3.4 Transfer Learning

For the NO-MACRO domain, we used the same methodology, but we decided to
generate two candidate models. The first model is trained starting from the
`text-davinci-002` model as before, whereas the second is trained starting
from the MACRO model obtained previously. We call these models Teriyaki-NO-
MACRO (davinci) and Teriyaki-NO-MACRO (MACRO). The hypothesis is that as
domains share many concepts and the MACRO model has already been primed for
them, the second candidate should reach a higher planning accuracy with a
smaller amount of training samples.

Results shown in Section 4.2 confirmed this hypothesis, so we interrupted
training when Teriyaki-NO-MACRO (MACRO) reached comparable results to its
parent model and discarded entirely Teriyaki-NO-MACRO (davinci). Regarding the
training dataset, the only difference with the example provided in Listing 1
is that the prompt part is preceded by the `\n--NO-MACRO` tag. This tag was
introduced to test whether the model could be used to solve problems for both
the MACRO and the NO-MACRO domains, by simply adding the tag in our queries to
the system. Unfortunately, the NO-MACRO models loses the ability to solve
problems in the MACRO domain, suggesting that to generate models that can
solve multiple domains, training should be performed including examples from
all the domains of interest.

###  3.5 Invoking the LLM and Streaming the Plan

After the training phase, it is possible to query the model through an API
call by providing as a prompt the PDDL predicates describing the initial and
goal states for the robot and the articulated object, as one would do with a
traditional, symbolic PDDL-compatible action planner. Several parameters can
be configured, and below is a list of those that can impact the overall
quality of the resulting plan.

  * •

`temperature` is the most important as it controls how deterministic the reply
(and therefore the plan) will be. Keeping it at $0$ corresponds to an `argmax`
operation on the next token probability and ensures that we always get the
most likely result. While in a regular text generation some level of
creativity is desirable, we strongly recommend keeping it at $0$ for plan
generation, especially when robot actions are planned in the context of a
human-robot collaboration scenario.

  * •

`presence_penalty` and `frequency_penalty` can assume values between $-2$ and
$2$, and can be used to reward or penalize repetitions in the generated text.
We have observed that setting the former to $2$ seems to improve planning
accuracy by ${1-2}\%$ and vice versa, but at the moment we have not
investigated enough this effect, so we decided to set the default value to $0$
for both in our tests.

  * •

`stop` can be used to set a string as a stopping condition, meaning that when
that string is generated by the model, the generation immediately terminates.
Coherently with our training dataset, we set this value to `END`.

  * •

`max_tokens` controls the maximum response length, thus we recommend setting
it as high as possible to minimize the chance of a plan being truncated. Since
each model has a maximum total prompt/completion length, and the worst-case
prompt length depends on the planning domain at hand, this value should be
assessed case by case. In our case, $1900$ appears to be the highest value for
robust operation.

To stream the plan we set the parameter `stream` to `true`. In this way, the
model starts returning tokens as soon as they are available, instead of
waiting for the full sequence of tokens to be generated. This has no impact on
the time needed to receive the full answer, but it does reduce significantly
the time needed to receive the first token.

##  4 Results

###  4.1 Relation between Token and Planning Accuracy with an Increasing
Number of Training Samples

In Section 3.3, we pointed out that we use linguistic coherence as a proxy for
logical coherence. Figure 3 compares the evolution of the validation token
accuracy and the planning accuracy for the MACRO model, against the number of
examples used to train the model itself. On the one hand, the validation token
accuracy measures the accuracy at predicting the next token, that is,
approximately the next 4 characters of the response, in our case coinciding
with the plan, on the validation set. On the other hand, we define validation
planning accuracy as the percentage of plans in the 876-sample validation set
that are both formally correct and reach the desired goal state, that is,
which one passes the VAL validation utility test. For the former, data are
retrieved from the classification metrics reported by GPT-3 itself after
training, where this information is available every 9 training steps. For the
latter, we used the snapshots of the model taken after training with 500,
1000, 2000, 4000, and 8000 examples. Such snapshots are used to plan against
all 876 problems in the validation set in the conditions described in Section
3.5. VAL is run on the obtained plans and finally, the validation planning
accuracy can be computed. In Figure 3, the evolution of planning accuracy is
represented by the orange bars to highlight the fact that the value is
measured at each snapshot. It must also be noted that the parameter
`elapsed_examples` does not correspond to the number of unique examples in the
training set, but it is scaled by a factor of 2 because we used two epochs for
training, thus each example was used twice.

Figure 3:  Evolution of the token validation accuracy and the planning
accuracy as the number of training examples increases. The blue line
represents the evolution of the validation token accuracy during learning as
reported by GPT-3 classification metrics. The bars represent the planning
accuracy of the Teriyaki-MACRO, Teriyaki-NO-MACRO (davinci) and Teriyaki-NO-
MACRO (MACRO) models. The red line represents our baseline, that is, the
percentage of plans solved by Probe.

In Figure 3 the orange bars report the validation accuracy of the Teriyaki-
MACRO model. It can be observed that GPT-3 reaches a very high validation
token accuracy after the first 500 samples, as expected by a model well-known
for its few-shot learning capabilities. Nevertheless, planning accuracy rises
at a much slower pace. Like in few-shot methods, the LLM cannot yet map
precisely to admissible actions and even a single mistaken token could break a
plan that would be otherwise linguistically coherent. A very common mistake in
plans generated by the model trained with only 500 samples is that the model
ignored the conditional effects of actions. As we correctly hypothesized,
conditional effects can be quite problematic as they imply propagating their
effects downstream in the plan to keep the overall semantic coherence of the
plan. In this case, actions are correct and reasonably parameterized but they
do not meet the necessary preconditions as they ignore that a given joint is
in a state different from the one expected by the model, due to the indirect
effects of a previously planned action. Eventually, the model reaches a very
high $95\%$ planning accuracy on the validation set after training over $8000$
unique samples. Despite this, the model does not seem to overfit to the
problems used for training, as shown by the results on the test set presented
in Section 4.3.

Results of validation planning accuracy are strikingly similar to those
obtained by the Plansformer, yet they have been achieved with a training set
of 8000 instead of 18000 and 2 training epochs instead of 3. This could point
to GPT-3 having stronger performance in this task than CodeT5, but the
phenomenon requires further investigation to be clearly ascertained.

During this experiment, we also measured the number of planning attempts that
failed because of their excessive length. While this number was always small
compared with the validation set size, the number of failures decreased from
$24$ in the first training step, down to $1$ in the final model, further
suggesting that the model becomes better at generating shorter plans and
avoiding unnecessary actions.

###  4.2 Transfer Learning

As previously discussed in Section 3.4, the Teriyaki solver for the NO-MACRO
planning domain has been chosen starting from two base candidates, namely
Teriyaki-NO-MACRO (davinci) and Teriyaki-NO-MACRO (MACRO). As we trained the
two models, we kept track of the planning accuracy as described in Section
3.4. The light pink and dark pink bars in Figure 3 report results in planning
accuracy for the Teriyaki-NO-MACRO (davinci) and Teriyaki-NO-MACRO (MACRO)
models, respectively. After 1000 samples, the Teriyaki-NO-MACRO (davinci)
model reached a planning accuracy of $32.5\%$, while Teriyaki-NO-MACRO (MACRO)
reached $95.2\%$. Because of this result, we immediately dropped the former
model, while we further trained the latter using $2000$ samples. At this stage
the Teriyaki-NO-MACRO model reached a validation planning accuracy of
$98.8\%$, exceeding the $95\%$ validation planning accuracy achieved by the
MACRO model after $8000$ samples. Because of this result, we decided not to
proceed with further training.

It is noteworthy that the Teriyaki-NO-MACRO (davinci) model still reached a
higher validation planning accuracy at $1000$ samples than Teriyaki-MACRO.
This result might suggest that against our initial assumption, the NO-MACRO
model is easier to learn for GPT-3 than the MACRO one. This result must be
explored more in-depth, but it could be related to the number and quality of
the actions in the planning domain. From these considerations, from now on
when we simply refer to Teriyaki-NO-MACRO we actually mean Teriyaki-NO-MACRO
(MACRO).

###  4.3 Comparison of Solvers

We tested the performance of both Teriyaki-MACRO and Teriyaki-NO-MACRO models
in terms of planning accuracy, plan length, and planning times on a test set
of $1000$ problem-plan pairs not previously used for training and validation,
and we compared the results to the performance of the traditional action
planner Probe. The process is summarized in Figure 4.

Figure 4:  A diagram of Teriyaki testing process as described in section 4.3.

Before proceeding, we want to remark that, due to the significantly different
computing workflows used to run Teriyaki and Probe (basically, a cloud-based
architecture accessed via proprietary APIs and software installed on a local
machine, respectivelly), a fair comparison between them in terms of planning
time is not possible. Therefore, results about planning times in this Section
are only meant at providing a baseline for future work and to show how
planning times scale differently for each Teriyaki planner in the two
different planning domains taken into consideration in this work.

Probe ran on an Ubuntu 20.04.4 Windows Linux Subsystem (WSL) environment,
deployed on a machine equipped with an $8$-core Ryzen 3700X 3600 Mhz CPU and
16GB@3600 Mhz RAM. We recorded planning times as reported by the planner
itself together with each generated plan. As far as planning accuracy is
concerned, all plans generated were valid, but we considered the instances in
which the planner failed to generate a plan as failures.

Regarding Teriyaki models, we prompted them using the settings described in
Section 3.5, then verified the validity of the obtained plans using the same
VAL validation tool employed at the data set generation phase. As the OpenAI
API does not provide a method to log the exact execution time of a call,
planning times of Teriyaki solvers have been measured by recording the time it
took each API call to return a response to the client application. For this
reason, it must be noted that it is impossible to discern how long each call
has been queued by the cloud application before execution. We assessed that
the effect of queuing is not negligible as running tests after the official
release of ChatGPT, another popular GPT-3 derived product by OpenAI, led to
longer planning times than previously recorded, possibly due to the increased
traffic to the servers. In order to partly mitigate this effect, the tests
presented here were performed during the weekend, preferably in the morning
CET time. In Table 1 we also include the date and the starting and finishing
time of each test session for reference.

Table 1: Summary of the tested models and date of testing Model | Base model | Test date | Start | Finish
---|---|---|---|---
Teriyaki-MACRO | `davinci` | 18/02/2023 | 11:17:56 | 13:47:41
Teriyaki-NO-MACRO | MACRO | 19/02/2023 | 17:22:24 | 21:25:58

For all solvers and models, plan length has been computed simply as the number
of actions in the plan.

Table 2 compares the Teriyaki-MACRO and Teriyaki-NO-MACRO models against Probe
in the respective domains, in terms of accuracy (in percentage), average plan
length, maximum and average planning times, as well as the standard deviation
of the planning times (in seconds).

Table 2: Comparison of Teriyaki models against Probe in their respective domains on the test dataset Solver | Domain | Acc. | steps | t_max | t_avg | t_std
---|---|---|---|---|---|---
Teriyaki-MACRO | MACRO | 95.5 | 10.953 | 54.32 | 8.99 | 4.77
Probe | MACRO | 98.6 | 11.111 | 36.71 | 2.11 | 3.47
Teriyaki-NO-MACRO | NO-MACRO | 94.0 | 19.158 | 54.71 | 14.61 | 7.16
Probe | NO-MACRO | 98.6 | 22.137 | 43.77 | 2.79 | 3.30

As anticipated, Probe is faster than the trained Teriyaki solvers to generate
plans end-to-end, in a traditional sense-plan-act workflow. Yet, Teriyaki
solvers still offer decent performance. Despite being trained on plans
generated by Probe, Teriyaki models are capable of solving problems that Probe
failed to process, and even generate shorter plans. The difference in plan
length is only $1.5\%$ for the Teriyaki-MACRO, but it raises to $13.5\%$ for
Teriyaki-NO-MACRO, which in general leads to plans almost twice as long. This
seems to suggest that the training procedure rewards shorter completions and
that the effect might be stronger the longer the supposed completion gets.
Nevertheless, this phenomenon requires a more systematic investigation.

Figure 5:  Comparison of the Teriyaki MACRO and NO-MACRO models’ planning
times against Probe in their respective planning domains.

Figure 5 allows for a better assessment of the timing performance of the
proposed models, and it compares them to those generated by Probe. It can be
observed that Teriyaki models do actually scale with the combined length of
the input and the output, as hypothesized. Planning times of the Teriyaki-NO-
MACRO model are approximately twice of the Teriyaki-MACRO model, as expected
considering that the plans of the former are approximately twice longer than
those of the latter. Box plots in the Figure associated with Teriyaki models
have a very distinct shape when compared to those of Probe on both domains,
which hints at an almost Gaussian distribution of planning times. This is
coherent with the fact that the plans, which are generated from randomly
initialized problems, can assume any length.

###  4.4 Action-by-action Plan Streaming

One of the major strengths of neurosymbolic action planning using LLMs is that
the plan can be streamed as it is being generated. If properly leveraged, this
feature can support action-by-action generation instead of adopting an end-to-
end approach. In many applications involving the use of robots with a required
flexible behavior, and especially when frequent re-planning is expected due to
changing conditions, simultaneous planning and execution by means of
concurrent (sets of) processes could greatly reduce the waiting time for a
plan to be available, and therefore executed. As we have previously pointed
out, this may nicely correlate with a perceived interaction fluency in human-
robot collaboration.

To test the performance of Teriyaki in this regard, we set the Teriyaki-MACRO
model to plan against our test dataset until it generated $1000$ actions.
Figure 6 compares Teriyaki-MACRO single action timings against Probe timings
to generate $1000$ whole plans. Not only do we observe that wait times are
reduced by 61.2% on average, but also the response time standard deviation is
reduced from 3.47 to just 0.15. This corresponds to a 95.6% decrease and makes
Teriyaki much more predictable than the traditional heuristic-search solver.

Figure 6:  Comparison of the time it takes Teriyaki-MACRO to generate a single
action against Probe on the MACRO domain.

###  4.5 Limitations

We previously pointed out that, although our results are quite promising in so
far as they unlock the possibility of simultaneous planning and execution, the
data-driven synthesis of a solver cannot be considered a complete alternative
to traditional action planning at this stage. As a matter of fact, a symbolic
action planner is needed to obtain the problem-pair data used for training the
models. Herewith, we mention three main current limitations.

The first drawback in the current implementation is that planning times are
slower than the baseline symbolic planner Probe, at least using GPT-3 as base
LLM to implement the overall architecture. The second is related to the need
to consider planning domains small enough to fit into the $2048$ tokens
context characterizing GPT-3. The third concerns advanced capabilities
exhibited by some PDDL-compatible planners. While we included conditional
planning among the features supported by Teriyaki, other relevant capabilities
such as numerical and temporal planning have not been considered. Their
inclusion could prove challenging due to difficulties of LLMs in generating
mathematically accurate results.

In spite of these limitations, it is noteworthy that there are a number of
LLMs and Transformer-based learning architectures that are being made
available at the writing of this paper. In view of the favorable performance
scaling discussed in this paper, we consider LLM-based neurosymbolic planning
as a promising approach worth considering for future investigation.

##  5 Conclusions

In this paper, we introduce Teriyaki, a framework to generate neurosymbolic,
PDDL-compliant planners based on GPT-3, that is, a Transformer-based Large
Language Model architecture recently made available worldwide. In its current
implementation, Teriyaki relies on a pragmatic and inexpensive procedure for
the generation of a training dataset, which is based on the use of an existing
action planner able to generate plans on the basis of randomly defined inputs.
Training can leverage high-performance computing machinery in the cloud, and
the resulting model can be deployed to any software architecture for robots
adopting standard PDDL-compatible syntax and interfaces.

The major contribution of the paper is the empirical evidence that this
approach can be a viable solution for action planning. In particular, we
showed that: (i) planning accuracy is on par with that of a traditional,
state-of-the-art, PDDL-compliant planner, (ii) the average plan length is up
to 13.5% shorter, (iii) it is possible to better use Teriyaki in scenarios
where robots must re-plan frequently, and in particular due to its ability to
generate plans action-by-action, thus reducing average waiting time for a plan
by 61.2%, with standard deviation by 95.6%.

Overall, these results hints at a scenario in which the approach can fairly
scale up in terms of the number of potentially supported planning domains,
even though this remains one of the points to further investigate, and where
fluency in human-robot interactions can greatly benefit of the increased
reaction times of the robot action planning capabilities.

## Conflict of Interest Statement

The authors declare that the research was conducted in the absence of any
commercial or financial relationships that could be construed as a potential
conflict of interest.

## Author Contributions

AC: Conceptualization, Data curation, Software, Investigation, Writing –
original draft. FM: Supervision, Writing – review & editing.

## Data Availability Statement

The datasets generated for this study can be found in the following repository
https://github.com/alessiocpt/teriyaki.

## References

  * Aeronautiques et al., (1998) Aeronautiques, C., Howe, A., Knoblock, C., McDermott, I. D., Ram, A., Veloso, M., Weld, D., SRI, D. W., Barrett, A., Christianson, D., et al. (1998).  Pddl— the planning domain definition language.  Technical Report, Tech. Rep.
  * Bertolucci et al., (2021) Bertolucci, R., Capitanelli, A., Dodaro, C., Leone, N., Maratea, M., Mastrogiovanni, F., and Vallati, M. (2021).  Manipulation of articulated objects using dual-arm robots via answer set programming.  Theory and Practice of Logic Programming, 21(3):372–401.
  * Bertolucci et al., (2019) Bertolucci, R., Capitanelli, A., Maratea, M., Mastrogiovanni, F., and Vallati, M. (2019).  Automated planning encodings for the manipulation of articulated objects in 3d with gravity.  In AI* IA 2019–Advances in Artificial Intelligence: XVIIIth International Conference of the Italian Association for Artificial Intelligence, Rende, Italy, November 19–22, 2019, Proceedings 18, pages 135–150. Springer.
  * Brown et al., (2020) Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. (2020).  Language models are few-shot learners.  Advances in neural information processing systems, 33:1877–1901.
  * Capitanelli et al., (2018) Capitanelli, A., Maratea, M., Mastrogiovanni, F., and Vallati, M. (2018).  On the manipulation of articulated objects in human–robot cooperation scenarios.  Robotics and Autonomous Systems, 109:139–155.
  * Carfí et al., (2019) Carfí, A., Foglino, F., Bruno, B., and Mastrogiovanni, F. (2019).  A multi-sensor dataset for human-human handover.  Data in Brief, 22:119–117.
  * Cashmore et al., (2015) Cashmore, M., Fox, M., Long, D., Magazzeni, D., Ridder, B., Carrera, A., Palomeras, N., Hurtos, N., and Carreras, M. (2015).  Rosplan: Planning in the robot operating system.  In Proceedings of the international conference on automated planning and scheduling, volume 25, pages 333–341.
  * Chen et al., (2021) Chen, M., Tworek, J., Jun, H., Yuan, Q., Pinto, H. P. d. O., Kaplan, J., Edwards, H., Burda, Y., Joseph, N., Brockman, G., et al. (2021).  Evaluating large language models trained on code.  arXiv preprint arXiv:2107.03374.
  * Chowdhery et al., (2022) Chowdhery, A., Narang, S., Devlin, J., Bosma, M., Mishra, G., Roberts, A., Barham, P., Chung, H. W., Sutton, C., Gehrmann, S., et al. (2022).  Palm: Scaling language modeling with pathways.  arXiv preprint arXiv:2204.02311.
  * Dale, (2021) Dale, R. (2021).  Gpt-3: What’s it good for?  Natural Language Engineering, 27(1):113–118.
  * Darvish et al., (2021) Darvish, K., Simetti, E., Mastrogiovanni, F., and Casalino, G. (2021).  A hierarchical architecture for human-robot cooperation processes.  IEEE Transactions on Robotics, 37(2):567–586.
  * Darvish et al., (2018) Darvish, K., Wanderlingh, F., Bruno, B., Simetti, E., Mastrogiovanni, F., and Casalino, G. (2018).  Flexible human-robot cooperation models for assisted shop-floor tasks.  Mechatronics, 51:97–115.
  * Garcez and Lamb, (2020) Garcez, A. d. and Lamb, L. C. (2020).  Neurosymbolic ai: the 3rd wave.  arXiv preprint arXiv:2012.05876.
  * Hatcher and Yu, (2018) Hatcher, W. G. and Yu, W. (2018).  A survey of deep learning: Platforms, applications and emerging research trends.  IEEE Access, 6:24411–24432.
  * Helmert, (2006) Helmert, M. (2006).  The fast downward planning system.  Journal of Artificial Intelligence Research, 26:191–246.
  * Heyer, (2010) Heyer, C. (2010).  Human-robot interaction and future industrial robotics applications.  In 2010 ieee/rsj international conference on intelligent robots and systems, pages 4749–4754. IEEE.
  * Hoffman, (2019) Hoffman, G. (2019).  Evaluating fluency in human–robot collaboration.  IEEE Transactions on Human-Machine Systems, 49(3):209–218.
  * Howey et al., (2004) Howey, R., Long, D., and Fox, M. (2004).  Val: Automatic plan validation, continuous effects and mixed initiative planning using pddl.  In 16th IEEE International Conference on Tools with Artificial Intelligence, pages 294–301. IEEE.
  * Huang et al., (2022) Huang, W., Abbeel, P., Pathak, D., and Mordatch, I. (2022).  Language models as zero-shot planners: Extracting actionable knowledge for embodied agents.  In International Conference on Machine Learning, pages 9118–9147. PMLR.
  * Lipovetzky and Geffner, (2011) Lipovetzky, N. and Geffner, H. (2011).  Searching for plans with carefully designed probes.  In Proceedings of the International Conference on Automated Planning and Scheduling, volume 21, pages 154–161.
  * Logeswaran et al., (2022) Logeswaran, L., Fu, Y., Lee, M., and Lee, H. (2022).  Few-shot subgoal planning with language models.  arXiv preprint arXiv:2205.14288.
  * Loshchilov and Hutter, (2016) Loshchilov, I. and Hutter, F. (2016).  Sgdr: Stochastic gradient descent with warm restarts.  arXiv preprint arXiv:1608.03983.
  * Macció et al., (2022) Macció, S., Carfí, A., and Mastrogiovanni, F. (2022).  A system for hierarchical planning in service mobile robotics.  In 2022 IEEE International Conference on Robotics and Automation.
  * Mastrogiovanni et al., (2004) Mastrogiovanni, F., Sgorbissa, A., and Zaccaria, R. (2004).  A system for hierarchical planning in service mobile robotics.  In 8th International Conference on Intelligent Autonomous Systems.
  * Mikolov et al., (2011) Mikolov, T., Kombrink, S., Burget, L., Černockỳ, J., and Khudanpur, S. (2011).  Extensions of recurrent neural network language model.  In 2011 IEEE international conference on acoustics, speech and signal processing (ICASSP), pages 5528–5531. IEEE.
  * Murali et al., (2020) Murali, P. K., Darvish, K., and Mastrogiovanni, F. (2020).  Deployment and evaluation of a flexible human-robot collaboration model based on and/or graphs in a manufacturing environment.  Intelligent Service Robotics, 13:439–457.
  * Oussidi and Elhassouny, (2018) Oussidi, A. and Elhassouny, A. (2018).  Deep generative models: Survey.  In 2018 International conference on intelligent systems and computer vision (ISCV), pages 1–8. IEEE.
  * Pallagani et al., (2023) Pallagani, V., Muppasani, B., Srivastava, B., Rossi, F., Horesh, L., Murugesan, K., Loreggia, A., Fabiano, F., Joseph, R., Kethepalli, Y., et al. (2023).  Plansformer tool: Demonstrating generation of symbolic plans using transformers.  In IJCAI, volume 2023, pages 7158–7162. International Joint Conferences on Artificial Intelligence.
  * Scao et al., (2022) Scao, T. L., Fan, A., Akiki, C., Pavlick, E., Ilić, S., Hesslow, D., Castagné, R., Luccioni, A. S., Yvon, F., Gallé, M., et al. (2022).  Bloom: A 176b-parameter open-access multilingual language model.  arXiv preprint arXiv:2211.05100.
  * Silver et al., (2023) Silver, T., Dan, S., Srinivas, K., Tenenbaum, J. B., Kaelbling, L. P., and Katz, M. (2023).  Generalized planning in pddl domains with pretrained large language models.  arXiv preprint arXiv:2305.11014.
  * Silver et al., (2022) Silver, T., Hariprasad, V., Shuttleworth, R. S., Kumar, N., Lozano-Pérez, T., and Kaelbling, L. P. (2022).  Pddl planning with pretrained large language models.  In NeurIPS 2022 Foundation Models for Decision Making Workshop.
  * Singh et al., (2023) Singh, I., Blukis, V., Mousavian, A., Goyal, A., Xu, D., Tremblay, J., Fox, D., Thomason, J., and Garg, A. (2023).  Progprompt: Generating situated robot task plans using large language models.  In 2023 IEEE International Conference on Robotics and Automation (ICRA), pages 11523–11530. IEEE.
  * Smith et al., (2022) Smith, S., Patwary, M., Norick, B., LeGresley, P., Rajbhandari, S., Casper, J., Liu, Z., Prabhumoye, S., Zerveas, G., Korthikanti, V., et al. (2022).  Using deepspeed and megatron to train megatron-turing nlg 530b, a large-scale generative language model.  arXiv preprint arXiv:2201.11990.
  * Song et al., (2023) Song, C. H., Wu, J., Washington, C., Sadler, B. M., Chao, W.-L., and Su, Y. (2023).  Llm-planner: Few-shot grounded planning for embodied agents with large language models.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2998–3009.
  * Sundermeyer et al., (2012) Sundermeyer, M., Schlüter, R., and Ney, H. (2012).  Lstm neural networks for language modeling.  In Thirteenth annual conference of the international speech communication association.
  * Thoppilan et al., (2022) Thoppilan, R., De Freitas, D., Hall, J., Shazeer, N., Kulshreshtha, A., Cheng, H.-T., Jin, A., Bos, T., Baker, L., Du, Y., et al. (2022).  Lamda: Language models for dialog applications.  arXiv preprint arXiv:2201.08239.
  * Touvron et al., (2023) Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bashlykov, N., Batra, S., Bhargava, P., Bhosale, S., et al. (2023).  Llama 2: Open foundation and fine-tuned chat models.  arXiv preprint arXiv:2307.09288.
  * Valmeekam et al., (2022) Valmeekam, K., Olmo, A., Sreedharan, S., and Kambhampati, S. (2022).  Large language models still can’t plan (a benchmark for llms on planning and reasoning about change).  arXiv preprint arXiv:2206.10498.
  * Vaswani et al., (2017) Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., and Polosukhin, I. (2017).  Attention is all you need.  Advances in neural information processing systems, 30.
  * Wake et al., (2023) Wake, N., Kanehira, A., Sasabuchi, K., Takamatsu, J., and Ikeuchi, K. (2023).  Chatgpt empowered long-step robot control in various environments: A case application.  arXiv preprint arXiv:2304.03893.
  * Wang et al., (2023) Wang, B., Wang, Z., Wang, X., Cao, Y., Saurous, R. A., and Kim, Y. (2023).  Grammar prompting for domain-specific language generation with large language models.  arXiv preprint arXiv:2305.19234.
  * Wang et al., (2021) Wang, Y., Wang, W., Joty, S., and Hoi, S. C. (2021).  Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation.  arXiv preprint arXiv:2109.00859.


[1]Christopher Irwin

[1]DISIT, Computer Science Institute, University of Piemonte Orientale,
Alessandria, Italy

2]Laboratorio Integrato di Intelligenza Artificiale e Informatica in Medicina
DAIRI, Azienda Ospedaliera SS. Antonio e Biagio e Cesare Arrigo, Alessandria,
Italy

# Structural Positional Encoding for knowledge integration in transformer-
based medical process monitoring

<EMAIL_ADDRESS>Marco Dossena<EMAIL_ADDRESS>Giorgio
Leonardi<EMAIL_ADDRESS>Stefania Montani
<EMAIL_ADDRESS>*  [

###### Abstract

Predictive process monitoring is a process mining task aimed at forecasting
information about a running process trace, such as the most correct next
activity to be executed. In medical domains, predictive process monitoring can
provide valuable decision support in atypical and nontrivial situations.
Decision support and quality assessment in medicine cannot ignore domain
knowledge, in order to be grounded on all the available information (which is
not limited to data) and to be really acceptable by end users.

In this paper, we propose a predictive process monitoring approach relying on
the use of a transformer, a deep learning architecture based on the attention
mechanism. A major contribution of our work lies in the incorporation of
ontological domain-specific knowledge, carried out through a graph positional
encoding technique. The paper presents and discusses the encouraging
experimental result we are collecting in the domain of stroke management.

###### keywords:

Medical process monitoring, Transformers, Graphs, Positional encoding

##  1 Introduction

The diffusion of advanced medical information systems is progressively
enabling the automatic collection of patients’ traces, i.e., the sequences of
activities executed on patients during the care procedures implemented at a
hospital organization [1]. Patients’ traces are a valuable source of
information for several analyses and investigations, within the field of
process mining [2]. Among the various available process mining techniques,
predictive process monitoring [3, 4] is of particular interest. Predictive
process monitoring aims at forecasting relevant information about a running
process trace; specifically, it exploits the already logged traces to make
predictions about the running trace completion, such as suggesting the next
activity to be executed, or estimating the remaining time/cost/resources
required to completion itself.

In the medical field, predictive process monitoring can support better time
and resource allocation; moreover, and most importantly, it can support
decision-making in nontrivial cases. Indeed, despite the availability of
clinical guidelines, it is worth noting that guidelines are ideal processes,
designed for ideal patients, and meant to be applied in an ideal setting,
where all the needed resources are always available [5]. In reality, this is
often not the case: local resource constraints may prevent from the (timely)
execution of the scheduled guidelines activities. Moreover, real patients may
be atypical, for instance, due to the presence of comorbidities or rare
disease variants. Finally, physicians may lack the necessary background
knowledge to correctly interpret and apply guidelines in complex cases.
Predictive process monitoring, by suggesting the next activity to be executed,
can thus provide very helpful advice in these nontrivial situations.

Stemming from the considerations discussed above, in this paper we propose a
predictive process monitoring approach for medical process traces; according
to the most recent literature advances, we rely on the exploitation of a
Transformer, a deep learning architecture based on the self-attention
mechanism [6], which has already demonstrated its utility in modeling similar
tasks, as exemplified in [7]. A major contribution of our work lies in the
introduction of a technique that incorporates domain-specific knowledge using
an ontology. This augmentation is carried out through a graph positional
encoding technique, enhancing the accuracy of our model.

While the approach is general, we were motivated by a specific application
domain, that we selected for our experiments, namely the one of stroke
management. Indeed, in this field, predictive process monitoring can provide a
valuable contribution to medical decision-making. To mention a few examples,
it can help in the choice of the correct thrombolytic drug, by considering how
indications and contraindications of the available medications were balanced
in past traces [5], or it can help in deciding whether to confirm the presence
of subarachnoid hemorrhage by taking into account pros and cons of a lumbar
puncture [8], always referring to already completed traces. Indeed, the first
experiments we performed, which are described in the following, have shown
encouraging results.

The paper is organized as follows: Section 2 introduces some related work.
Section 3 presents the deep learning architecture we exploit. Section 4
illustrates our experimental setting and results, while section 5 is devoted
to conclusions.

##  2 Related work

Predictive process monitoring has been afforded by different types of machine
learning techniques, such as Transition Systems [9], Hidden Markov Models [10]
and Support Vector Machines [11]. In more recent approaches, however, deep
learning architectures are being applied, and nowadays represent the state of
the art in the field.

Different deep learning architectures have been proposed to deal with the task
of next activity prediction. The approach in [12], for instance, uses
Autoencoders [13]. In predictive monitoring, Autoencoders can successfully
reduce the number of attributes of the input activities; however, they are
unable to treat long (temporal) dependencies between activities of a trace.
Convolutional Neural Networks (CNNs) [14] have been applied in [15], where
sequential data in process traces are treated as a one-dimensional grid.

Due to the sequential nature of traces, however, Recurrent Neural Networks
(RNNs) [16] probably represent the most natural solution. In fact, RNNs can
capture longer dependencies between the activities of a trace, while in a CNN
an activity only depends on the k most recent activities, where k is the size
of the kernel. Within RNNs, Long-Short Term Memory (LSTM) networks [17]
represent a particularly performant approach. Indeed, LSTM can potentially
learn the complex dynamics within the temporal ordering of input sequences;
therefore, they are well suited to manage the sequential data of process
activity logs. They can also manage long-distance dependencies between
activities, since they implement a long-term memory where the information
flows from cell to cell with minimal variations, keeping certain aspects
constant during the processing of all inputs. The works in [18, 19, 20, 21],
for instance, rely on LSTMs to predict the next activity of a running case.

Similarly to LSTMs, Gated Recurrent Networks (GRUs) [22] also create paths
through time that allow the gradients to flow deeper in the sequence than in
basic RNNs; with respect to LSTMs, they have few parameters. GRUs are
exploited in, e.g., [23] for predictive monitoring.

In [24], instead, a Memory Augmented Neural Network (MANN) is proposed. MANNs
allow to learn even longer dependencies; training is more expensive, but MANNs
are suitable for very long traces, or when cycles of the same activity may
lead LSTMs or GRUs to forget/ignore activities located at the beginning of the
trace.

The approaches which most closely relate to ours are in [25, 7], which rely on
a Transformer, an architecture that substitutes the recurrence by the
attention mechanism [6]. In particular, these works adopt multi-head
attention, i.e., they perform the attention operation over different parts of
the sequence simultaneously, and, instead of training an encoder-decoder
architecture as in [6], they only rely on the decoding part. As for the
incorporation of external domain knowledge in the form of graphs, this
approach has been explored in a few works, such as [26, 27, 28], aiming to
enrich sequence-based examples with geometric information derived from a graph
structure. An example of this is the combination of protein structures with
the geometric arrangement of molecules. The knowledge-driven approach has also
been used in several works involving pre-trained transformers (e.g. BERT) in
order to align the model to a specific knowledge domain by means of ontologies
and knowledge-graphs [29, 30]. We are not aware of previous works that
incorporate structural positional encoding of domain knowledge into predictive
process monitoring.

##  3 Methodologies

In the following sections, we are going to present the base architecture of
the transformer model we are using. Subsequently, we will describe the method
that enables leveraging the ontology of the activities using Structural
Positional Encoding (SPE), which is based on the Laplacian eigenvalue encoding
technique [27].

###  3.1 Transformer for PPM

Our model architecture is based on the transformer decoder (as in [25, 7]).
The model input is a sequence $S=\\{a_{1},...,a_{i},...,a_{n}\\}$
(representing a trace) where every element of the sequence represents an
activity coming from a set $A$ of possible activities. Figure 1 depicts the
model structure. Below, we describe the building blocks of the model and how
the inputs are processed.

Embedding layer: it takes $S$ as input and returns a vector of dimension
$\mathbb{R}^{d}$ for each activity $a_{i}$. At this point, our samples are in
the form $X\in\mathbb{R}^{n\times d}$.

Positional encoding: this layer is responsible for augmenting each embedding
representing an activity with information about its position. In this paper,
we tested two versions of positional encoding. The first version (PE
henceforth), described in [6], uses a sine and a cosine function to obtain a
representation that respects the order of the activities within the single
sequence. The second version is Structural Positional Encoding (SPE
henceforth), which embeds knowledge from a graph $G$ (in our case, the graph
is an ontology of the activities, and is described in section 3.2). Positional
encoding generates a vector for each activity in a sequence that is added to
the original embedding as follows:

$\displaystyle X=\begin{cases}X+PE(X)&\text{for PE method}\\\
X+SPE(X,G)&\text{for SPE method}\end{cases}$

Multi-head attention layer: this component enables the model to selectively
attend to different parts of a sequence and find long-range dependencies. To
this end, the self-attention layer [6] generates three representation $Q,K,V$
for every activity in the sequence $S$. Subsequently, it applies the scaled
dot-product attention:

$H=softmax\left(\frac{QK^{T}}{\sqrt{d}}\right)V$

This operation is carried out in parallel on multiple attention heads in order
to learn different types of dependencies. The resulting representations are
concatenated to produce the final output. Note that, since the task is to
predict the next token in the sequence (in our application, the next activity
in the trace), during the self-attention process we apply a mask so that an
activity can only attend to previous ones, and ignore those that follow it.
The output is finally added to the input $X$ using a skip connection.

Layer norm: this normalisation layer is used to mitigate vanishing or
exploding gradients phenomena during the model training phase. The process
ensures that the activations are centered around zero mean and unit variance
making the optimization more stable [31]. In our implementation, we resorted
to the Pre-LN configuration where the layer-norm is put inside the residual
blocks which improves the model convergence [32].

Lastly, $X$ is subsequently passed through 2 fully connected layers, where the
final layer acts as a decoder, projecting the representations into a
dimensionality equivalent to the number of potential activities.

Figure 1: The model architecture. The left side of the figure represents the
Transformer-decoder model, the right side shows the Structural positional
encoding module.

###  3.2 Structural Positional Encoding

Structural Positional Encoding (SPE) is based on a graph representing an
ontology that encodes the relations between activities. This ontology allows
for the integration of domain knowledge into the AI model, in order to improve
the prediction capabilities of the system. In particular, the ontology aims at
grouping together the activities involved in similar diagnostic or treatment
goals. This is achieved through a taxonomic representation, where activities
involved in similar goals are placed in a close ”relationship” (having a
shorter path to reach one from the other). Figure 2 shows an excerpt of the
ontology integrated in this system. The activities and their relations was
defined in collaboration with expert neurologists, on the basis of their
experience and according to the recommendations of the SPREAD guideline for
stroke patients [33].

Figure 2: Excerpt of the domain ontology

To implement and to integrate this ontology, we coded it as a graph and we
relied on the Laplacian eigenvector technique [34], which is employed to
calculate node embeddings, yielding a vector for each action (i.e., node) that
encodes its position in the graph. This ensures that nodes close to each other
possess similar embeddings. During the training phase, these node
representations are added to the token embeddings, before the multi-head
attention layer (in a positional encoding manner). This augmentation enriches
the representations of the transformer with the relational information
inherent in the ontology. This enables the model to learn additional types of
interactions among activities. We proceed by giving a more formal description
of the operations carried out during this phase.

The graph $G=(V,E)$ representing the ontology is structured as follows: $V$
represents the nodes, one for every activity in the set $A$ (activity nodes),
along with some nodes that represent the ”type of activity” (activity-type
nodes). $E$ captures the set of edges, connecting activity nodes to activity-
type nodes. Activity-type nodes are linked together so that the graph is
overall connected. The Laplacian eigenvectors are defined by the factorization
of the graph Laplacian matrix:

$\Delta=I-D^{-\frac{1}{2}}AD^{-\frac{1}{2}}=U^{T}\Lambda U$

where $I$ is the identity matrix, $A\in\mathbb{R}^{n\times n}$ assuming
$n=|V|$ is the adjacency matrix where $A_{ij}=1$ if node $i$ and node $j$ are
connected by an edge (i.e. the graph connectivity) and $D\in R^{n\times n}$
where $D_{ii}=\sum_{i=1}^{n}A_{ij}$ is a diagonal matrix representing the
degree of every vertex in $G$; $\Lambda$, $U$ denote the eigenvalues and
eigenvectors respectively. The embedding for a node $i$ is a vector
$\lambda_{i}\in\mathbb{R}^{k}$ defined as the $k$ smallest nontrivial
eigenvector components of that node [35]. Finally, to incorporate the node
embedding $\lambda_{i}\in\mathbb{R}^{k}$ into the corresponding activity
embedding $X_{i}\in\mathbb{R}^{d}$, we employ a fully-connected layer
$\Theta\in\mathbb{R}^{k\times d}$ to ensure compatibility between the
embedding sizes.

##  4 Experiments

During our experiments, we applied the model to a dataset relative to Stroke
management. The dataset contains 5342 process traces with 15 activities on
average and 82 possible activities (See Table 3 for some statistics about the
traces). Given that cases have varying lengths (Figure 3), we applied padding
to ensure that all sequences had the same number of activities (i.e. the
length of the longest sequence). Moreover, we added two special tokens
indicating ”start of sequence” and ”end of sequence” at the start and end of
each case. The ontology associated to the process was parsed in order to
obtain a graph containing 110 nodes and 111 edges.

The transformer model has been trained in an auto-regressive language modeling
manner to predict the ’next activity’ given a context (i.e., the previous
activities in the sequence). The training process involves the model
attempting to predict the next activity given a sequence prefix. The loss
function applied is the cross-entropy loss between the model’s predicted
probability distribution over all possible activities and the true tokens in
the training data. Notably, during the training phase, examples containing
padding tokens or ”start of sequence” tokens were excluded from loss
calculation. This ensures that the model ignores these examples during the
calculation of gradient preventing potential degradation of the model’s
performance. We instead decided to keep the ”end of sentence” tokens so that
the model could learn to predict when a sequence of activities should end.

We performed a 80/10/10 split to the data (training, validation and test). We
tuned the model hyper-parameters using the Optuna [36] optimization framework.
Table 1 reports the search space considered and the best parameters found.

Table 1: Parameter search space used to find optimal hyperparameters and optimal configuration, by Optuna. Search spaces included between square brackets are discrete sets Parameter | Search space | Best configuration
---|---|---
Embedding size | [16, 32, 64, 128, 256] | 64
Hidden size | [16, 32, 64, 128, 256] | 128
Number of heads | [1, 2, 4, 8] | 4
Number of layers | [1, 2, 3, 4, 5] | 4
Dropout rate | 0.1 - 0.5 | 0.216375
Optimizer | AdamW | AdamW
Scheduler | StepLR | StepLR
Gamma | 0.85 - 0.99 | 0.989695
Learning rate |  $1\times 10^{-2}$ \- $3\times 10^{-2}$ | 0.002836
Ontology embededing size | [8, 16, 32] | 32

During our experiments (see Table 2) we aimed to compare how the model
performed using the two different positional encoding methods (PE and SPE) and
various model sizes. We also included a baseline model in which we skipped the
PE phase. For each model configuration, we ran 10 fits with random training-
validation-test splits and initialisation. We then reported the mean and
standard deviation of accuracy-at-$k$. The results show that there is a clear
benefit in using the SPE method, which substantially improves the model
performances across all model sizes. Moreover, the model metrics are quite
stable and saturate at with a model size of 64, improving only marginally
using 128-sized embedding. This suggests that the model does not tend to
overfit.

Another important finding is that the model does not seem to benefit from the
classic PE method which only encodes an order to the activities (see Figure
4). This observation may be due to the nature of these processes, where the
next activity depends more on which activities have already been performed
rather than their sequential order [37]. This also hints to why the model
benefits from the SPE technique: activities of a similar type are likely to be
executed in close proximity. As a result, the contextual information about an
activity’s position within the ontology graph describing relations between
activities in the process is much more informative than its position within an
individual sequence.

Table 2: Test accuracy-at-$k$ and standard deviation on 10 random initialization and train-val-test splits. Model performance with different positional encoding methods at different embedding sizes are reported Method | Model size | Accuracy@1 | Accuracy@3 | Accuracy@5
---|---|---|---|---
None | 16 | 45.6±0.3 | 67.1±0.3 | 75.8±0.3
None | 32 | 46.9±0.2 | 69.4±0.3 | 78.8±0.3
None | 64 | 47.3±0.2 | 70.4±0.2 | 80.0±0.2
None | 128 | 47.2±0.1 | 70.4±0.3 | 80.1±0.2
PE | 16 | 45.2±0.3 | 66.8±0.3 | 75.7±0.2
PE | 32 | 46.9±0.2 | 69.4±0.2 | 78.9±0.2
PE | 64 | 47.1±0.1 | 70.3±0.3 | 79.9±0.2
PE | 128 | 47.0±0.2 | 70.1±0.2 | 79.8±0.2
SPE | 16 | 48.5±0.4 | 69.7±0.4 | 77.9±0.4
SPE | 32 | 52.1±0.3 | 75.3±0.4 | 83.5±0.3
SPE | 64 | 54.0±0.3 | 78.0±0.2 | 86.5±0.2
SPE | 128 | 54.3±0.3 | 78.3±0.4 | 86.8±0.3

##  5 Conclusions

This paper presents an approach to predictive process monitoring, specifically
applied in the challenging domain of stroke management. Leveraging the power
of Transformer-based models, we have demonstrated the potential for accurate
forecasting of critical information within running process traces. Our key
innovation, the integration of domain-specific knowledge through Structural
Positional Encoding, has been shown to increase predictive accuracy.

The initial experimental results presented in this study are encouraging,
pointing towards the effectiveness of our proposed approach. These findings
suggest that predictive process monitoring, using transformer-based models and
domain-specific ontological knowledge, holds significant potential in
providing valuable decision support in complex medical scenarios.

In the future, further research and experimentation will be crucial to
validate and refine our approach. In particular, we would like to experiment
with different kinds of embedding techniques for the graph nodes, and explore
this methodology using different datasets, where we can explore in depth the
temporal aspects.

Table 3: Datasets traces length statistics measured in number of activities
Traces length statistics
---
Mean | 15
Standard Deviation | 3
Minimum | 2
Maximum | 25
Figure 3: Sequence length histogram.

Figure 4: Model performance with different embedding sizes on testset.

#### Acknowledgments

We would like to thank Chameleon Cloud [38] for providing the essential
computational resources that facilitated the execution of our experiments and
model training.
Christopher Irwin and Marco Dossena are a PhD students enrolled in the
National PhD in Artificial Intelligence, XXXVIII cycle, course on Health and
life sciences, organized by Università Campus Bio-Medico di Roma.

#### Code availability

The source code of the transformer model and the implementation of the SPE
module are available at: github.com/christopher-irw/proformer_ce. The
repository contains the necessary code to train the transformer model on the
BPI 2012 challenge [39]. We also provide an example of a very simple ontology
of the actions present in the dataset in order to make the SPE method
applicable.

## References

  *   * Reichert and Weber [2012] Reichert, M., Weber, B.: Enabling Flexibility in Process-Aware Information Systems - Challenges, Methods, Technologies. Springer, ??? (2012). https://doi.org/10.1007/978-3-642-30409-5 . https://doi.org/10.1007/978-3-642-30409-5
  * van der Aalst [2016] Aalst, W.: Process Mining. Data Science in Action. Springer, ??? (2016)
  * Maggi et al. [2014] Maggi, F.M., DiFrancescomarino, C., Dumas, M., Ghidini, C.: Predictive monitoring of business processes. In: Jarke, M., Mylopoulos, J., Quix, C., Rolland, C., Manolopoulos, Y., Mouratidis, H., Horkoff, J. (eds.) Advanced Information Systems Engineering - 26th International Conference, CAiSE 2014, Thessaloniki, Greece, June 16-20, 2014. Proceedings. Lecture Notes in Computer Science, vol. 8484, pp. 457–472. Springer, ??? (2014). https://doi.org/10.1007/978-3-319-07881-6_31 . https://doi.org/10.1007/978-3-319-07881-6_31
  * Teinemaa et al. [2019] Teinemaa, I., Dumas, M., LaRosa, M., Maggi, F.M.: Outcome-oriented predictive process monitoring: Review and benchmark. ACM Trans. Knowl. Discov. Data 13(2), 17–11757 (2019) https://doi.org/10.1145/3301300
  * Xu et al. [2020] Xu, H., Pang, J., Yang, X., Li, M., Zhao, D.: Using predictive process monitoring to assist thrombolytic therapy decision-making for ischemic stroke patients. BMC Medical Informatics Decis. Mak. 20-S(3), 120 (2020) https://doi.org/10.1186/s12911-020-1111-6
  * Vaswani et al. [2017] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, L., Polosukhin, I.: Attention Is All You Need (2017)
  * Bukhsh et al. [2021] Bukhsh, Z.A., Saeed, A., Dijkman, R.M.: ProcessTransformer: Predictive Business Process Monitoring with Transformer Network (2021)
  * Bottrighi et al. [2016] Bottrighi, A., Canensi, L., Leonardi, G., Montani, S., Terenziani, P.: Trace retrieval for business process operational support. Expert Syst. Appl. 55, 212–221 (2016)
  * Le et al. [2012] Le, M., Gabrys, B., Nauck, D.: A hybrid model for business process event prediction. In: Bramer, M., Petridis, M. (eds.) Research and Development in Intelligent Systems XXIX, Incorporating Applications and Innovations in Intelligent Systems XX: Proceedings of AI-2012, The Thirty-second SGAI International Conference on Innovative Techniques and Applications of Artificial Intelligence, Cambridge, England, UK, December 11-13, 2012, pp. 179–192. Springer, ??? (2012)
  * Lakshmanan et al. [2015] Lakshmanan, G.T., Shamsi, D., Doganata, Y.N., Unuvar, M., Khalaf, R.: Markov prediction model for data-driven semi-structured business processes. Knowl. Inf. Syst. 42 (1), 97–126 (2015)
  * Cabanillas et al. [2014] Cabanillas, C., DiCiccio, C., Mendling, J., Baumgrass, A.: Predictive task monitoring for business processes. In: Sadiq, S.W., Soffer, P., Völzer, H. (eds.) Business Process Management - 12th International Conference, BPM 2014, Haifa, Israel, September 7-11, 2014. Proceedings. Lecture Notes in Computer Science, vol. 8659, pp. 424–432. Springer, ??? (2014). https://doi.org/10.1007/978-3-319-10172-9_31 . https://doi.org/10.1007/978-3-319-10172-9_31
  * Mehdiyev et al. [2017] Mehdiyev, N., Evermann, J., Fettke, P.: A multi-stage deep learning approach for business process event prediction. In: Loucopoulos, P., Manolopoulos, Y., Pastor, O., Theodoulidis, B., Zdravkovic, J. (eds.) 19th IEEE Conference on Business Informatics, CBI 2017, Thessaloniki, Greece, July 24-27, 2017, Volume 1: Conference Papers, pp. 119–128. IEEE Computer Society, ??? (2017)
  * Hinton and Salakhutdinov [2006] Hinton, G.E., Salakhutdinov, R.R.: Reducing the dimensionality ofdata with neural networks. Science 313, 504–507 (2006)
  * Alom et al. [2019] Alom, M.Z., Taha, T.M., Yakopcic, C., Westberg, S., Sidike, P., Nasrin, M.S., Hasan, M., Van Essen, B.C., Awwal, A.A.S., Asari, V.K.: A state-of-the-art survey on deep learning theory and architectures. Electronics 8(3) (2019)
  * Mauro et al. [2019] Mauro, N.D., Appice, A., Basile, T.M.A.: Activity prediction of business process instances with inception CNN models. In: Alviano, M., Greco, G., Scarcello, F. (eds.) AI*IA 2019 - Advances in Artificial Intelligence - XVIIIth International Conference of the Italian Association for Artificial Intelligence, Rende, Italy, November 19-22, 2019, Proceedings. Lecture Notes in Computer Science, vol. 11946, pp. 348–361. Springer, ??? (2019)
  * Pascanu et al. [2014] Pascanu, R., Gülçehre, Ç., Cho, K., Bengio, Y.: How to construct deep recurrent neural networks. In: Bengio, Y., LeCun, Y. (eds.) 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings (2014)
  * Hochreiter and Schmidhuber [1997] Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Computation 9(8), 1735–1780 (1997)
  * Evermann et al. [2017] Evermann, J., Rehse, J.R., Fettke, P.: Predicting process behaviour using deep learning. Decision Support Systems 100, 129–140 (2017)
  * Tax et al. [2018] Tax, N., Teinemaa, I., Zelst, S.J.: An interdisciplinary comparison of sequence modeling methods for next-element prediction. CoRR abs/1811.00062 (2018)
  * Camargo et al. [2019] Camargo, M., Dumas, M., Rojas, O.G.: Learning accurate LSTM models of business processes. In: Hildebrandt, T.T., Dongen, B.F., Röglinger, M., Mendling, J. (eds.) Business Process Management - 17th International Conference, BPM 2019, Vienna, Austria, September 1-6, 2019, Proceedings. Lecture Notes in Computer Science, vol. 11675, pp. 286–302. Springer, ??? (2019)
  * Tax et al. [2017] Tax, N., Verenich, I., La Rosa, M., Dumas, M.: Predictive business process monitoring with LSTM neural networks. In: Proceedings of the 29th International Conference on Advanced Information Systems Engineering (CAiSE), pp. 477–492. Springer, ??? (2017)
  * Cho et al. [2014] Cho, K., Merrienboer, B., Gulcehre, C., Bahdanau, D., Bougares, F., Schwenk, H., Bengio, Y.: Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation (2014)
  * Hinkka et al. [2018] Hinkka, M., Lehto, T., Heljanko, K., Jung, A.: Classifying process instances using recurrent neural networks. In: Daniel, F., Sheng, Q.Z., Motahari, H. (eds.) Business Process Management Workshops - BPM 2018 International Workshops, Sydney, NSW, Australia, September 9-14, 2018, Revised Papers. Lecture Notes in Business Information Processing, vol. 342, pp. 313–324. Springer, ??? (2018)
  * Khan et al. [2018] Khan, M.A., Le, H., Do, K., Tran, T., Ghose, A., Dam, K.H., Sindhgatta, R.: Memory-augmented neural networks for predictive process analytics. CoRR abs/1802.00938 (2018) 1802.00938
  * Philipp et al. [2020] Philipp, P., Jacob, R., Robert, S., Beyerer, J.: Predictive analysis of business processes using neural networks with attention mechanism. In: 2020 International Conference on Artificial Intelligence in Information and Communication, ICAIIC 2020, Fukuoka, Japan, February 19-21, 2020, pp. 225–230. IEEE, ??? (2020)
  * Mialon et al. [2021] Mialon, G., Chen, D., Selosse, M., Mairal, J.: Graphit: Encoding graph structure in transformers. arXiv preprint arXiv:2106.05667 (2021)
  * Dwivedi et al. [2020] Dwivedi, V.P., Joshi, C.K., Luu, A.T., Laurent, T., Bengio, Y., Bresson, X.: Benchmarking graph neural networks. arXiv preprint arXiv:2003.00982 (2020)
  * Di Francescomarino et al. [2017] Di Francescomarino, C., Ghidini, C., Maggi, F.M., Petrucci, G., Yeshchenko, A.: An eye into the future: leveraging a-priori knowledge in predictive business process monitoring. In: Business Process Management: 15th International Conference, BPM 2017, Barcelona, Spain, September 10–15, 2017, Proceedings 15, pp. 252–268 (2017). Springer
  * Liu et al. [2020] Liu, W., Zhou, P., Zhao, Z., Wang, Z., Ju, Q., Deng, H., Wang, P.: K-BERT: Enabling Language Representation with Knowledge Graph, pp. 2901–2908 (2020). Cited by: 308
  * Shang et al. [2019] Shang, J., Ma, T., Xiao, C., Sun, J.: Pre-training of graph augmented transformers for medication recommendation. CoRR abs/1906.00346 (2019) 1906.00346
  * Ba et al. [2016] Ba, J.L., Kiros, J.R., Hinton, G.E.: Layer normalization. arXiv preprint arXiv:1607.06450 (2016)
  * Xiong et al. [2020] Xiong, R., Yang, Y., He, D., Zheng, K., Zheng, S., Xing, C., Zhang, H., Lan, Y., Wang, L., Liu, T.: On layer normalization in the transformer architecture. In: International Conference on Machine Learning, pp. 10524–10533 (2020). PMLR
  * Lanza et al. [2017] Lanza, G., Setacci, C., Ricci, S., Castelli, P., Cremonesi, A., Lanza, J., Novali, C., Pratesi, C., Santalucia, P., Speziale, F., Zaninelli, A., Gensini, G.F.: An update of the italian stroke organization-stroke prevention awareness diffusion group guidelines on carotid endarterectomy and stenting: A personalized medicine approach. International journal of stroke : official journal of the International Stroke Society 12(5), 560–567 (2017) https://doi.org/10.1177/1747493017694395
  * Belkin and Niyogi [2003] Belkin, M., Niyogi, P.: Laplacian eigenmaps for dimensionality reduction and data representation. Neural computation 15(6), 1373–1396 (2003)
  * Dwivedi and Bresson [2021] Dwivedi, V.P., Bresson, X.: A generalization of transformer networks to graphs. AAAI Workshop on Deep Learning on Graphs: Methods and Applications (2021)
  * Akiba et al. [2019] Akiba, T., Sano, S., Yanase, T., Ohta, T., Koyama, M.: Optuna: A next-generation hyperparameter optimization framework. In: Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (2019)
  * Italian-Stroke-Association [2023] Italian-Stroke-Association: Current Guidelines. https://isa-aii.com/linee-guida/linee-guida-attuali/ Accessed 2023-09-04
  * Keahey et al. [2020] Keahey, K., Anderson, J., Zhen, Z., Riteau, P., Ruth, P., Stanzione, D., Cevik, M., Colleran, J., Gunawi, H.S., Hammock, C., Mambretti, J., Barnes, A., Halbach, F., Rocha, A., Stubbs, J.: Lessons learned from the chameleon testbed. In: Proceedings of the 2020 USENIX Annual Technical Conference (USENIX ATC ’20). USENIX Association, ??? (2020)
  * van Dongen [2012] Dongen, B.: BPI Challenge 2012. Eindhoven University of Technology (2012). https://doi.org/10.4121/UUID:3926DB30-F712-4394-AEBC-75976070E91F . https://data.4tu.nl/articles/_/12689204/1