A Framework for End-to-End Learning on Semantic Tree-structured Data

# A Framework for End-to-End Learning on Semantic Tree-structured Data

## Abstract

While learning models are typically studied for inputs in the form of a fixed dimensional feature vector, real world data is rarely found in this form. In order to meet the basic requirement of traditional learning models, structural data generally have to be converted into fix-length vectors in a handcrafted manner, which is tedious and may even incur information loss. A common form of structured data is what we term “semantic tree-structures”, corresponding to data where rich semantic information is encoded in a compositional manner, such as those expressed in JavaScript Object Notation (JSON) and eXtensible Markup Language (XML). For tree-structured data, several learning models have been studied to allow for working directly on raw tree-structure data, however such learning models are limited to either a specific tree-topology or a specific tree-structured data format, e.g., synthetic parse trees. In this paper, we propose a novel framework for end-to-end learning on generic semantic tree-structured data of arbitrary topologies and heterogeneous data types, such as data expressed in JSON, XML and so on. Motivated by the works in recursive and recurrent neural networks, we develop exemplar neural implementations of our framework for the JSON format. We evaluate our approach on several UCI benchmark datasets, including ablation and data-efficiency studies, and on a toy reinforcement learning task. Experimental results suggest that our framework yields comparable performance to use of standard models with dedicated feature-vectors in general, and even exceeds baseline performance in cases where compositional nature of the data is particularly important. The source code for a JSON-based implementation of our framework along with experiments can be downloaded at https://github.com/EndingCredits/json2vec.

###### keywords:
Semantic tree-structured data, recursive neural networks, compositional information processing, global contextual information, heterogeneous data types, end-to-end learning, classification of tree-structured data

## 1 Introduction

In their natural form, real world data typically appears in a manner that effectively encodes semantic and structural information surrounding the underlying data. However, most traditional machine learning algorithms are only applicable to fixed-dimensional feature vectors, which requires handcrafted feature extraction from structured data such as trees, sets and graphs. Recently, novel deep learning models have been emerging to handle structured data towards avoiding handcrafted feature engineering, e.g., set networks Zaheer et al. (2017) and graph neural networks Zhou et al. (2018). Such learning models have been manifested in enhancing the capacity of learning models via exploitation of structural information and better performance in dealing with complex structured data.

Another ubiquitous form of data is what we refer to as “semantic tree-structured data”. Semantic tree-structured data can be seen as a variant on more conventional tree structures, but where additional semantic information is incorporated into the structure. In general, branch nodes are used to accommodate high-level objects, instantiated from various semantic classes, while leaf nodes represent a variety of primitives in different data formats. Importantly, the data contained within semantic tree-structures is typically significantly heterogeneous, both at a technical level and at a semantic level. Although some tree-structured learning models have been studied, all of those so far are limited to a specific tree-topology, e.g., all the leaf nodes located in a layer of the same depth to the root Hammer et al. (2004); Zhang et al. (2018), or a specific tree-structured data format, e.g., syntactic parse trees widely used in nature language processing Socher et al. (2013); Irsoy and Cardie (2013); Paulus et al. (2014); Irsoy and Cardie (2014); Tai et al. (2015); Kokkinos and Potamianos (2017), where all objects at the same tree depth are of the same form. To the best of our knowledge, there are no learning models that can directly deal with generic semantic tree-structured data of arbitrary topologies, where nodes in the same layer may contain entities of heterogeneous data types, although the importance of this emerging topic was highlighted (including example application for JSON data) and some theoretical analysis regarding universal approximation was studied in the recent work of Pevny and Kovarik (2019).

In this paper, we present a learning framework, semantic tree-structured recursive learning architecture (STRLA), for end-to-end learning2. STRLA allows for inputting generic semantic tree-structured data, e.g. JSON data, directly and fulfils automatic feature extraction and model learning simultaneously. Unlike the prior work of Pevny and Kovarik (2019), our framework details how to construct a learning model for any semantic tree-structured format. Additionally, our framework performs architectural construction at the prediction stage, allowing application to arbitrary data topologies without modification. Motivated by the ideas underlying the deep set network Zaheer et al. (2017) and recurrent neural networks Hochreiter and Schmidhuber (1997); Tai et al. (2015), we carry out our STRLA framework with two different neural implementations for the JSON data format, leading to different deep recursive neural networks of heterogeneous components. In our experiments, we demonstrate the empirical strength of our neural implementation of STRLA based on several UCI benchmark datasets Dua and Graff (2017a), where we emulate JSON descriptions of data examples. Our work presented in this paper provides an enabling technology which automatically creates a neural architecture for dealing with generic semantic tree-structured data, and alleviate the requirement to transmute such data to a fixed set of feature vectors: a missing technical component in all the ongoing AutoML paradigms 1.

The main contributions in this paper are summarised as follows:

• We formalise the notion of a semantic tree-structure, which encompasses various hierarchical semantically-annotated data formats such as JSON and XML.

• A novel yet generic framework, STRLA, is proposed for end-to-end supervised learning on arbitrary semantic tree-structured data, which simultaneously extracts structural and semantic features underlying tree-structured data and model learning.

• Exemplar neural implementations of our STRLA framework are developed for JSON and XML.

• A thorough comparative study is conducted to demonstrate the effectiveness of our STRLA framework on a variety of data expressed in JSON.

The rest of this paper is organised as follows. Section 2 reviews related works, and Section 3 describes a notational scheme that covers all the descriptive notations or languages of generic semantic tree-structured data. Sections 4 and 5 presents our STRLA framework and its different neural implementations, respectively. Section 6 describes experimental settings and reports the experimental results. Section 7 discusses the issues arising from our work, and the last section draws conclusions.

## 2 Related work

In this section, we make a connection to the previous works closely relevant to our work presented in this paper and highlight the main differences between those and ours.

Dated back to 1990’s, recursive neural networks Coller and Kuchler (1996); Frasconi et al. (1998) had been proposed to tackle the problems arising from structured data. Since then, those ideas have inspired the development of learning models for different structured data, e.g., Zaheer et al. (2017); Zhou et al. (2018); Socher et al. (2013); Irsoy and Cardie (2013); Paulus et al. (2014); Irsoy and Cardie (2014); Tai et al. (2015); Kokkinos and Potamianos (2017). Regarding tree-structured data, such ideas are widely utilised in learning models for semantic parsing and syntax transformation, e.g., Socher et al. (2011); Rabinovich et al. (2017); Chen et al. (2018), and exploitation of syntactic structures, e.g, Socher et al. (2013); Irsoy and Cardie (2013); Paulus et al. (2014); Irsoy and Cardie (2014); Tai et al. (2015); Kokkinos and Potamianos (2017); Li et al. (2015). In a broad sense, our work presented in this paper is also inspired by the general ideas of original recursive neural networks Coller and Kuchler (1996); Frasconi et al. (1998) to deal with the compositional information encoded in semantic tree-structured data recursively.

For semantic parsing and syntax transformation, several recursive learning modes have been proposed, e.g., Socher et al. (2011); Rabinovich et al. (2017); Chen et al. (2018). Such models make use of recursive properties to discover a tree-structured representation from input data such as 2-D images and sequential text/code, e.g., Socher et al. (2011); Rabinovich et al. (2017) or transform tree-structure data of one type into another, e.g., Chen et al. (2018). Although such models share general ideas with ours in a broad sense in dealing with tree-structural information, those models work especially for semantic parsing and syntax transformation tasks, which are distinct from those problems tackled by our framework presented in this paper; i.e., our framework is proposed for end-to-end supervised learning directly from raw semantic tree-structured data rather than generation of a tree-structured representation from input data of other forms.

So far, most of recursive learning models related to tree-structured data have been studied to exploit the tree-structured information underlying sequential text formed with syntactic rules for various natural language processing (NLP) tasks, e.g., Socher et al. (2013); Irsoy and Cardie (2013); Paulus et al. (2014); Irsoy and Cardie (2014); Tai et al. (2015); Kokkinos and Potamianos (2017); Li et al. (2015). To this end, each sentence in text is first converted into a syntactic parse tree and then a learning model is developed to exploit additional structural/syntactic information underlying text for various NLP tasks ranging from sentiment analysis to question answering and relation classification. Those recursive learning models working on parse trees in an end-to-end manner have turned out to be very effective for various NLP tasks. However, a syntactic parse tree represents the syntactic structure of strings according to some context-free grammar, which is simply a class of specific semantic tree-structure data. Hence, such models cannot deal with generic semantic tree-structured data such as JSON, XML and HTML where intermediate nodes may accommodate objects/entities instantiated from different semantic classes and leaf nodes may represent various types of primitives in different data formats. Moreover, there are other challenging problems in generic semantic tree-structured data beyond syntactic parse trees, e.g., a path from a root to a specific node in generic semantic tree-structured data provide useful global contextual information for supervised learning and hence needs to be explored in a learning model. To the best of our knowledge, the global path information has yet to be explored in all the existing recursive learning models working on synthetic parse trees although the local parent-child relation information was used in some recursive learning model such as the global belief recursive neural Networks Paulus et al. (2014). Nevertheless, those ideas behind the existing recursive learning models for syntactic parse trees generally inspire our work presented in this paper. In particular, the neural implementation of our framework is motivated by the tree-structured LSTM networks Tai et al. (2015), a recursive learning model originally proposed for syntactic parse trees. Given the fact that as several existing recursive learning models, e.g., Socher et al. (2013); Irsoy and Cardie (2013); Paulus et al. (2014); Irsoy and Cardie (2014); Tai et al. (2015); Kokkinos and Potamianos (2017); Li et al. (2015), have been developed especially for syntactic parse trees by making good use of their specific properties, our work presented in this paper does not target those problems arising from syntactic parse trees but tackles the challenging issues arising from generic semantic tree-structured data of arbitrary topologies and heterogenous data types for end-to-end supervised learning.

There are yet other methods that deal with tree-structured data for representation learning, e.g., recursive self-organizing networks Hammer et al. (2004) and Tree2vector Zhang et al. (2018). Unlike those aforementioned recursive learning models for tree-structure discovery/transformaton and supervised NLP tasks, these unsupervised learning models tend to deal with tree-structured data via decomposition of the structures into their basic constituents for feature extraction Hammer et al. (2004) or learn a vectorial representation of a fixed length for tree-structured data Zhang et al. (2018). However, such methods assume consistent semantic meaning between the nodes at any given level of a tree and the same depth of all the leaf nodes to the root. Hence, such methods can only work on specific tree-structured data of an ad hoc topology and homogeneous data types but cannot deal with generic semantic tree-structured data. Unlike our framework working in an end-to-end fashion for supervised learning, moreover, such learning models cannot be applied to supervised learning directly. For supervised learning on tree-structured data, such models yield a vectorial representation of tree-structure data only and other supervised learning models have to be employed based on the vectorial representation. In other words, two stages, feature extraction and model learning, have to be undergone, which is suboptimal for supervised learning, apart from its limited applicability to specific semantic tree-structured data stated above.

During the process of this manuscript, an unpublished work mentioned in Pevny and Kovarik (2019) emerged, which appears closely relevant to ours presented in this paper. Based on their code and our personal communication with the authors (as the technical details of their approach are not included in Pevny and Kovarik (2019)), we understand that this work reflects a preliminary effort in handling semantic tree-structured data in the JSON format towards automatic machine learning, focusing the inherent problem of multi-tier variadicy of JSON and other semantic tree structure forms. However, as implemented, their approach can only cope with the semantic tree-structured data of a fixed data schema, meanwhile our recursive architecture is established via dynamic construction for semantic tree-structured data of arbitrary topologies. Moreover, while Pevny and Kovarik (2019) provides a specific technical implementation for JSON data, we provide a more general framework, and introduce a number of additional concepts such as element paths.

## 3 Semantic Tree Structure Description

To understand how our framework can be applied to arbitrary semantic tree-structured data, we first describe a meta-notational scheme of the generic semantic tree-structure with the syntax of the Backus Naur form (BNF) Knuth (1964). Specific descriptive notations or mark-up languages of semantic tree structures, e.g., JSON and XML, can be instantiated or derived from this meta-notational scheme. We then give an illustrative example of semantic tree-structured data expressed in JSON to facilitate our presentation in the next section. Finally, we highlight the element path, an important concept associated with structural and compositional information.

### 3.1 Meta-notational Scheme

In general, we specify generic semantic tree-structured data as serialisation of data that can be represented with a variety of different hierarchical semantically-annotated data formats that conforms to several requirements as follows:

• The data can be decomposed into individual data elements, each of which can be uniquely identified as belonging to one of a finite number of pre-specified types.

• Elements are allowed to contain other elements within them recursively. Moreover, there is at least one of the identified types consisting of a list of (potentially wrapped) elements, with no additional data. Such types are named “containers” and the remaining types are referred as to “primitives”.

• There is a wrapper format used to denote a given element with a name (given as a string). Optionally, this wrapper may also denote an element with a description.

To describe the semantic tree structures formally, we present a meta-notational scheme with the BNF syntax, as depicted in Figure 1. As demonstrated in Figure 2, data in such a format can be viewed as a semantic tree where the root node indicates the whole object. The branch and leaf nodes are used to accommodate the container and primitive elements respectively, and edges between nodes are annotated with semantic tags. Unlike a traditional tree, however, only leaf nodes in a semantic tree are associated with any data items, while branch nodes serves purely for hierarchical organization reflecting compositional relationship between parent and sibling nodes, with the exception of added information in the form of certain additional “description” tags within certain formats. Furthermore, the semantic tree generally has a heterogeneous nature; i.e. both branch and leaf nodes may accommodate objects/data belonging to different classes and various data types.

Furthermore, the meta-notational scheme entails a number of core concepts such as element types, primitives, containers and wrapped-elements. This scheme enables us to approach the problem in a implementation-agnostic fashion so as to build a general framework from which we can derive architectures for a variety of different human-readable data formats of semantic tree structures. For instance, the specification of JSON format can be achieved by instantiating the corresponding components in the meta-notational scheme with its constituents; i.e., three primitive elements, <number>, <string> and <boolean>, and two container elements, <object> and <array>. Thus, the JSON format can be specified formally with this meta-notational scheme. Likewise, XML and other semantic tree structure formats can be specified in the same manner. To facilitate the reader’s understanding, we illustrate the specification of JSON and XML formats derived from the meta-notational scheme in Appendix A.

### 3.2 Illustrative Example

To understand the semantic tree-structured data, we employ a “Train Journey” scenario as an illustrative example regarding the specification of this semantic class and an object instantiated from this class.

The “Train Journey” scenario can be described with several pieces of information organised in different categories, departure-time, stops, and train-info: number-of-carriages, is-there-a-shop. It can be viewed as a semantic class organised with a semantic tree where separate data elements “tagged” with different names via wrappers. For a concrete train journey, an object can be instantiated from the class. For instance, given a concrete train journey from Manchester to Glasgow in U.K., the time the train leaves the first station is 12:43, it stops at Manchester, Preston, and Glasgow, and the information regarding this train is that it has 6 carriages and no shop on board. Hence, this specific train journey object can be expressed by a semantic tree shown in Figure 2.

Represented in the JSON format (c.f. Figure A.1), the above example illustrates how the different features enable the creation of rich data structures. The elements of types string, number and boolean contain the actual data in leaf nodes of the structure, and the two containers, array and object, organise the raw data elements in branch nodes to create a hierarchy. The range of different element types allows the structure to represent individual data snippets more precisely. Finally, the tagged data elements enable the annotation of elements within the hierarchy with semantic tags. Hence, the “train journey” object can be represented in the JSON format as follows:

{
"time": "12:43",
"stops": [ "Manchester", "Preston", "Glasgow" ],
"train": { "carriages": 6, "shop": false }
}


### 3.3 Element Path

As shown in Figure 1, wrappers are used to annotate sub-structures via a name field, effectively specifying the elements contained within. However, the immediate name of an element does not always fully describe its semantic context. For example, if a given sub-structure is labelled as an “address”, it is not clear whether the data corresponds to the address of an individual, a building, an organisation etc. Nevertheless, the ambiguity would be avoidable if it is known that this “address” structure is part of a larger “employee” structure. Hence, the context or the compositional information conveys very important structural information in semantic tree-structured data, which is referred as to element path in this paper.

Formally, we define a path, of an element , with respect to some parent element , to be the sequence of names of wrappers by moving up the hierarchy along with the associated branches from to . Thus, an element path is formed by a sequence of strings denoted as a single string generated by the concatenation of those stings for names of wrappers in reverse order separated by slashes. Assume that c, b, a are strings for names of wrappers for an element within a parent element , its element path is represented by a single string, “a/b/c”. The construction of this path follows the same rules as for existing concepts such as Xpath for XML Clark and DeRose (1999), and JSONPath Goessner (2007) for JSON, which are typically used for addressing individual elements. However, we note that these element addresses are equally usefully for describing semantic context.

More specifically, for the “train journey” object described in Section 3.2, the is-there-a-shop element, the value false, is directly wrapped with a wrapper with name shop, which is contained within a JSON object. This JSON object is wrapped with another wrapper, now with name train. Therefore, the element path of the is-there-a-shop within the root is “train/shop”. Nevertheless, the departure-time element, with value (”12:43”) is wrapped with only a single wrapper, with name time, hence its element path within the root is simply “time”. Similarly, despite being contained in a further list container, the stops elements, Manchester, Preston, and Glasgow, are only within a single wrapper, and hence all have the element path “stops”.

In practice, it can often be worthwhile to add extra information to this element path, such as container types or ordinal positions in lists. Under this scheme, the element paths for Manchester, Preston, and Glasgow would become stops/1, stops/2, and stops/3, providing a bit more context for these elements. Since the mapping of wrappers can be achieved by mapping from one definition of semantic tree structures to another before any application of our framework3, we treat this an implementation detail. In our presentation, we hence use only the strict definition of element path defined above.

Here, we emphasise that the proper use of element paths in our framework presented in the next section is a salient characteristic that significantly distinguishes ours from all the related works for tree structures reviewed in Section 2.

## 4 Framework

In this section, we present the semantic tree-structure recursive learning algorithm (STRLA), which is a generic framework for end-to-end supervised learning directly from semantic tree-structured data (as it was specified in Section 3). This framework stands in a format-agnostic manner and hence serves as a general solution for addressing the common issues underlying any semantic tree-structures at a functional level.

As a semantic tree-structured document is intrinsically expressed as tree structure, our framework takes the general idea behind the recursive neural networks Coller and Kuchler (1996); Frasconi et al. (1998), a well-known architecture for tree-structural learning, and adapts it to address the common issues in learning from semantic tree-structured data. A recursive neural network employs a common neural-network component for each node of the tree by assigning each one a latent “hidden-state” vector based on the data associated with the current node and the hidden-states of its child nodes (where they exist). This neural network component is applied recursively to each node of a tree, moving up from the leaves of the tree to the root, such that every node would be eventually assigned a hidden state. In order to develop an effective recursive learning architecture to tackle our problem, we consider those salient features and common issues underlying generic semantic tree-structure data. As a result, we identify several aspects of semantic tree-structure data that must be considered, but which differ from other types of tree-structured data (such as syntactic parse trees for natural language).

These aspects specific to semantic tree-structured data are summarised as follows:

1. The data associated with leaf nodes may be heterogeneous, conforming to a variety of different primitive types specified by the specific data format.

2. The branch nodes of a semantic tree may also be heterogeneous, corresponding to different container types.

3. The number of children of each branch node is not fixed, which allows a branch node to have any number of children.

4. Additional structural or contextual information encoded in the element path as defined in Section 3.3 is carried with each node, which we would exploit to facilitate the learning from semantic tree-structured data.

To address the aforementioned issues arising from semantic tree-structured data, we come up with a general recursive learning framework that takes into account all the requirements: 1. To address the issue on heterogeneity of data, our framework would employ a set of functions, {}, to deal with different primitive types separately. 2. Similarly, for branch nodes, we employ a set of functions, {}, to be applicable to all of the permissible container types. 3. Since the number of children of each node is not fixed, branch/container node functions are required to deal with the input of an arbitrary number of latent vectors. 4. As highlighted previously, we would also exploit the contextual information carried in the element path. To this end, we incorporate the element path information into each of all the aforementioned functions, {} and {}, where path information is supplied as an additional input.

As described above, our framework is reliant on a set of functions, {} and {}, known as the element embedding functions, which map from each element to a latent hidden-state vector. For each primitive type, a function is employed so as to yield a fixed-length latent representation that encodes all the information relevant to any node of that type, along with a path description. Formally, for each primitive type a primitive embedding function is required to generate a -dimensional latent representation for leaf nodes as follows:

 fp:Xp×P→Rm, (1)

where is the space corresponding to valid forms of element data of type , and is the space of all the valid element paths. The number of functions, {}, required is the same as that of all the permissible primitive types, where each of different primitive type is dealt with by a separate function. Similarly, for each container type , an embedding function to yield a -dimensional latent representation for branch nodes is required. Unlike those functions made for leaf nodes, a function for branch nodes has to yield a latent representation upon the input of both those latent representations (hidden-state vectors) of its immediate children, and the local description information associated with the element (if there is any), e.g., attributes of a tag in XML. Formally, each must be of the form

 fc:(Rm)N×P×D→Rm, (2)

where denotes the space of sets of -dimensional latent representations, is the space of all the valid element paths, and is the space of all the valid description on the local information of branch nodes, which is purely dependent on the specific descriptive notation or mark-up language in question.

Given a semantic tree structure , rooted at element , then an -dimensional latent representation for is obtained by iteratively applying those functions {} and {} to the nodes of the tree, as shown in Figure 4: The latent representation of each leaf node is given by applying to the node data, , and node path, , via , where is the type of (Figure 3(a)). For branch nodes whose child elements have all been assigned a latent hidden-state, , the latent representation is given by applying to the set of child hidden-states, along with node path, , and description, , via (Figure 3(b)). This latter step is applied repeatedly as more branch nodes are mapped, until finally the root node, is mapped to a latent hidden state vector (Figure 3(c) ).

This process can be described via a recursive function , which maps from a given element, , along with its path , and description , to an -dimensional latent representation: Given an element , then the type of can be determined by the formatting rules of the specific descriptive notation or mark-up language. If is a leaf node belonging to a primitive type, , then the primitive embedding function, , is directly applied to , along with to obtain its latent representation,

 he=ft(e,pe)

Otherwise, if is a branch node belonging to a container type, , then contains a number of child elements, . For a given child element , if is a wrapped element with name and description , then the path is set to . Otherwise if is unwrapped then the child path, , is set to and is set to . The recursive function is applied to each child along with the child path and description, and , to obtain a set of child latent representations: . The container embedding function, , is applied to the set , along with and , to obtain its latent representation,

 he=fc((h1,⋯,hne),pe,de)

Applying to the root element of a given semantic tree structure via yields a latent vector, , for the root of the tree, which can be taken as the latent representation of the tree.

For supervised learning the embedding functions, {} and {}, must be inferred from training data, . This is fulfilled by applying a final parametric mapping function, , to the latent state associated with the root of the tree. The full model is given by the function , where is a collective notation of all the parameters in those parametric functions of {} and {}. Thus, the end-to-end supervised learning from semantic tree-structured data is done by minimising a proper loss function, , with respect to the parameters and . Typically, the mean squared error loss is used for regression, and the 0/1 loss is used for classification.

For reinforcement learning, as same as done in supervised learning, our STRLA framework can be directly employed to learn approximating its value or Q function working on semantic tree-structured data in an end-to-end manner, which will be demonstrated in Section 6.2.

If deep neural networks are employed as parametric models, the optimisation of a loss function can be done via gradient-based optimisation, using back-propagation through structure Coller and Kuchler (1996). Moreover, it has been proven in Pevny and Kovarik (2019) that the learned function operating based on appropriately chosen {} and {} functions acts as a universal approximator for semantic tree-structured data. Thus, our proposed framework is capable of acting as a general recursive learning architecture for supervised learning from any semantic tree-structured data. On the other hand, our proposed framework is primarily at a functional level and there are several non-trivial issues in its implementation such as developing proper deep neural networks to meet the requirements of various embedding functions, {} and {}, incorporating the element path information into those deep neural networks and dealing with specifics of a concrete notational format describing semantic tree-structured data.

## 5 Neural Implementation

While our framework presented in Section 4 is generic and format-agnostic, an implementation of this framework has to take into account the specific aspects of the target notational format used for describing semantic tree-structured data. As described in Section 4, our framework for end-to-end supervised learning works via function operating based on embedding functions, {} and {}, and output function . In our work, we employ a linear transformation for the final output transformation . Thus, the main challenges lie in how to implement those embedding functions, {} and {}. In this section, we come up with exemplar implementations for the commonly-used notational format, JSON. We first address a common issue on how to incorporate the element path information into an implementation of any notational formats. Then, we present the implementations for the JSON format, respectively, where the element path information is exploited.

### 5.1 Encoding the Element Path

As described in Section 3.3, the element path provides the certain level of contextual information, which can be used in avoiding possible semantic ambiguities in semantic tree-structure data. In the following, we describe our implementations for incorporating this path information into the embedding functions, {} and {}.

In our methods, we encode all the possible element paths in via a dictionary that can be constructed based on training data. While is infinite, the number of paths within the data will be finite. For embedding functions {} and {}, we use the case-wise functions, where the functions regarding a given type (or ) and given path are as follows:

 fp(∘,pe)=fp,pe(∘),
 fc(∘,pe,∘)=fc,pe(∘,∘),

where each path is associated with a set of functions, {} and {}. Now, we consider two different strategies to construct these functions.

#### Path specific weights

We use parametric models of the same learning architectures for all paths, but having different learnable parameters decided by the element path, :

 fp(∘,pe):=^fp(∘ | Θp,pe)
 fc(∘,pe,∘):=^fc(∘,∘ | Θc,pe)

where and are instances of parameters for the models and for given path . In other words, we use separate network weights for each different path.

Encoding the element path information in this manner simplifies the implementation of the embedding functions specified in Eqs. (1) and (2) such that our neural implementation can deal with the semantic aspects directly without loss of structural information underlying semantic tree-structured data. It mimics the natural approach to constructing architectures combining multiple separate input sources of information, where separate network weights are used for different inputs, and is also effectively equivalent to the method employed in Pevny and Kovarik (2019). Hence, we focus on this method of encoding path information throughtout the majority of our experiments. However, we emphasise that this is not the only method to encode the element path information, and in Section 5.1.2 we discuss an extension of this idea. Additionally in 7 we discuss how variations on this method could be used to exploit other aspects of the data.

#### Path specific functions

One issue with path specific weights is that the same function is used for all elements of the same type. However, as well as variations between different types, even primitive data of the same type within a semantic tree structure may differ substantially. For example, in the “Train Journey” example of Section 3.2, the strings "12:43" and "Manchester" contain very different data, even though they are both of the string type.

Here, we propose an extension to path specific weights, where instead of using the same base functions and for all paths, we employ a set of functions and , which we apply on a path-specific basis. To do this, for each type we employ a mapping mapping from the space of paths, , to a set of functions . We then use the function corresponding to the mapping applied to the given element path:

 fp(∘,pe):=^fp,Dp(pe)(∘,pe | Θp,pe)
 fc(∘,pe,∘):=^fc,Dc(pe)(∘,pe,∘ | Θc,pe)

The mapping functions are given via a user-defined mapping dictionary, which maps from each path to a function template. For ease of application, in our implementation, we employ a psuedo-JsonPath Goessner (2007) format, which allows wildcards to be used to specify multiple paths.

This can be considered an extension of the path-specific weights of Section 5.1.1, where the topology of the underlying network is allowed to vary for different parts of the data schema. However, a downside to this method is that it relies on a manually-specified user-defined mapping from paths to function templates.

### 5.2 JSON Recursive Networks

As illustrated in Figure A.1, when expressed as a semantic tree-structure, the JSON format consists of five types: two container types,“array” and “object”, and three primitive types, “number”, “string” and “boolean”. As there are different requirements in implementing those primitive and container embedding functions, we employ proper neural networks to implement those embedding functions of different types. Unless otherwise stated, we use the path-specific weights of Section 5.1.1 for incorporating paths.

#### Primitive Embedding Networks

For all three primitive types, the embedding task is simply building a mapping from input of “number”, “string” and “boolean” to an -dimensional latent representation.

For the number type, we use a linear neural network to implement it. Let denote the linear neural network: , where , is the scalar input, and and are -dimensional weight and bias vectors. Given a leaf-node containing a scalar number, , and its element path, , the embedding of the number type is carried out by

 fnum(x|Θnum,pe)=lin(^x,Θnum,pe), (3)

where ( and are the mean and the standard deviation of all ) if there are more than one number-type leaf nodes in training data of path , and otherwise.

For the boolean type, its value, , can be converted into integers: if and if . Thus, we would use the same linear neural network formulated in Eq. (3) to carry it out; i.e., for a leaf-node containing a boolean value, , and its element path, ,

 fbool(x|Θbool,pe)=lin(int(x),Θbool,pe). (4)

For the type, the embedding task is more complex as a string consists of numerous characters and its length may vary. To tackle this sequence modeling problem, we employ a simple single-layer recurrent neural network of LSTM units Hochreiter and Schmidhuber (1997) to carry out the string embedding task at the character level since LSTM has turned out to be one of the most effective techniques in dealing with ordered sequences of variable lengths. For a leaf-node carrying a string, , and having the element path, , the embedding function is carried out by the LSTM network of units as follows:

 fstr(s|Θstr,pe)=1|s||s|∑i=1hLSTMi, (5)

where is the collective notation of all the learnable parameters in the LSTM network (see Appendix B.1 for details) and is the hidden state vector when character is sequentially input to the LSTM network, which is obtained by

 hLSTMi⇐LSTM({lin(s1,Θs1),⋯,lin(si,Θsi)},Θstr,pe),

where leads to an -dimensional latent representation of character for .

#### Container Embedding Networks

For the containers, an array is a list of raw JSON entries while an object is a list of wrapped JSON entries in the form of name-JSON pairs. In the JSON format, there is no additional description for branch nodes, i.e. . Therefore, we need to implement instead of . As containers are associated with branch nodes that may have a variable number of children in a semantic tree, an implementation of container embedding functions has to tackle this issue. Here, we present two different implementations based on deep set networks Zaheer et al. (2017) and different LSTM learning architectures Hochreiter and Schmidhuber (1997); Tai et al. (2015).

Deep-set based Implementation Deep sets Zaheer et al. (2017) has been proposed to tackle the learning problem when the input is in the form of permutation invariant sets, where the number of elements in a set may vary. If we treat two container types, array and object, as sets, the deep set networks thus become an enabling technique to carry out two container embedding functions in the same manner. A deep set network consists of two components: element-embedding and pooling nets. In our work, the element-embedding net is implemented by a fully-connected feed-forward neural network and the pooling net is carried out with the averaging sum of the output of all the element-embedding nets applied to different elements in a set. Let denote a linear hidden layer: , where , is its input, and and are its weight matrix and bias vector, and denote the output of a hidden layer consisting of ReLU units based on the corresponding linear hidden layer, i.e., . Thus, the output of any hidden layers in the element-embedding net can be achieved recursively; i.e., if there are hidden layers, their output are

 h(l)=ReLu(Lin(h(l−1),θ(l−1))),  l=1,⋯,L

where is the external input to the element-embedding net. Assume that a branch node, , of a container type, , has children whose latent representations are . The output of the element-embedding net with the parameters, , corresponding to a child is for . That is, all the element-embedding nets for a container type, array” or “object”, share the same parameters, , for invariant permutation. Accordingly, the pooling net is implemented by

 ϕave(h1,⋯,hne|θave,c)=ReLu(Lin(1nene∑n=1h(L)n,θave,c)).

By incorporating the element path, , two container embedding functions are carried out based on the deep set networks described above in the same manner; i.e., for array” or “object”,

 fc(h1,⋯,hne|Θc,pe)=Lin(ϕave(h1,⋯,hne|θave,c),θc,pe), (6)

where is a collective notation of all the parameters; i.e., .

LSTM based Implementation A potential drawback of the deep-set based implementation is that two container types are treated the same. However, an array is different from an object; an object contains wrapped/named elements and is hence permutation/order invariant, while an array consists of raw elements whose order may be an important information source. Therefore, we employ the vanilla LSTM Hochreiter and Schmidhuber (1997) to implement the array embedding function and the Child-Sum Tree-LSTM (SumLSTM) to carry out the object embedding function. SumLSTM is actually one of Tree-LSTM models Tai et al. (2015), a variant of the LSTM, which can recursively deal with data expressed in syntactic parse trees for different learning tasks. Given a branch node of the array type, , having the element path, , and children, the array embedding function is carried out with the LSTM as follows:

 farray({(c1,h1),⋯,(cne,hne)}|Θarray,pe)=hLSTMne, (7)

where is the collective notation of all the parameters in the vanilla LSTM for an element path, . is achieved recurrently via

 hLSTMk⇐LSTM({c1||h1,⋯,ck||hk},ΘLSTM),

where “” is the concatenation operator of two vectors and are the memory cell and hidden state vectors of the SumLSTM unit corresponding to child of the branch node, (see Appendix B.2 for details). For a branch node of the object type, , having the element path, , and children, the object embedding function is carried out with the SumLSTM as follows:

 fobj({(c1,h1),⋯,(cne,hne)}|Θobj,pe)=(cSumLSTMe,Lin(hSumLSTMe,θobj,pe)). (8)

Here, is the collective notation of all the parameters in the parametric model implementing the object embedding function, including all the parameters in the SumLSTM, , shared by all branch node of the object type and the parameters of linear transformation, , merely applied to the hidden state vector, , in order to incorporate the element path information into the object embedding function. As described in Appendix B.2, and are achieved via

 (cSumLSTMe,hSumLSTMe)⇐SumLSTM({(c1,h1),⋯,(cne,hne)},ΘSumLSTM).

It is worth stating that when any child of a branch node is a leaf node (primitive), its corresponding “memory cell vector”, , is always set to zero while the latent embedding representation of this primitive node (c.f. Section 5.2.1) is treated its corresponding“hidden state vector”, , in the above SumLSTM implementation of the object container.

Here, we emphasise that the implementations for the JSON format presented above is easily extensible to any other notational formats specified in Figure 1, as demonstrated in Appendix C for the XML format.

## 6 Experiments

In this section, we describe our experimental settings on a comparative study and report the experimental results on several benchmark datasets.

### 6.1 Experiments on UCI datasets

To demonstrate our proposed models, we compare the two JSON models described above to several baselines on a number of different classification tasks. In particular, we choose a number of well-known benchmark datasets from the UCI machine learning repository Dua and Graff (2017b). Since these datasets appear in “tabular” form, we synthesize their corresponding JSON versions by deriving JSON structures from the intrinsic semantic-relationship between different attributes for each dataset.

#### Dataset Preparation

For each of those benchmark datasets, we recover a hierarchical structure from its attributes, then represent its hierarchical structure in the JSON format. To do so, we apply a number of criteria to select different benchmark datasets for our experiments as follows: 1) Datasets where specific hierarchies are given explicitly (e.g. Car Evaluation); 2) Datasets where a hierarchy can be inferred either from variable names (e.g. Mushroom) or domain knowledge (e.g. Automobile); and 3) Datasets with a clear candidate for lists (e.g. Seismic). In summary, the information of all the chosen datasets are described in Table 1.

There are two different representations for input attributes in each of the chosen datasets; feature vector and JSON format. For feature vector, the input of each example is converted into a vector of various features of the data. Categorical features are encoded as one-hot vectors, and numerical features were normalised by their mean and standard-deviation (across the whole dataset). For JSON format, the input of each example is given as a semantic tree expressed in the JSON format. For each dataset, we manually construct a plausible JSON schema, and convert the input of each example automatically to a JSON entry by using this schema. Example entries for each dataset are shown in Appendix F.

Those datasets with particularly unbalanced classes (i.e. where ¿80% of examples were a single class) are re-balanced to a 2:1 split by randomly under-sampling on the dominant class, which enables use of classification accuracy across all datasets without involving the mix of classification accuracy issue and avoids using other evaluation metrics for unbalanced datasets.

#### Main Experiments

In our comparative study, our JSON models, deep-set and LSTM based implementations described in Section 5.2, are employed to work on the JSON format directly for supervised learning. For the main neural network baseline, we used a Multi-Layer Perceptron (MLP) – a fully-connected neural network architecture which accepts fixed-size feature vectors as inputs—applied to the standard categorical and numerical features for each dataset. Furthermore, we compare to a uniquely existing JSON model developed in Pevny and Kovarik (2019), which is referred to as the “JSON-Grinder” model, using the source code provided by the authors8. Note that this implementation only handles datasets with fixed JSON schemas, hence is only applicable to certain datasets. In addition, we also employe a number of off-the-shelf machine learning models working on the feature vector representation, including logistic regression, support vector machine (SVM) and random forest.

Both our JSON models, and the MLP were implemented using pytorch and trained using the Adam optimiser Kingma and Ba (2014), on the softmax cross-entropy loss of the raw output of each network. Due to the difficulty of batching examples using the proposed framework, we used pseudo-minibatching, where gradients are accumulated over several examples, and then applied every few steps. This is mathematically equivalent, but generally less computationally efficient due to reduced parallelism. For the JSON-Grinder model we used the original Julia code provided by the authors, while for the non-neural baselines we used the standard implementations from the sklearn python library.

Experiments are conducted by using 5-fold cross validation Kohavi (1995) and taking the the mean and standard deviation of classification accuracy across the folds. Hyper-parameter search is done independently for each fold using grid search on a held-out 10% validation set, except for three small datasets (automobile, seismic, and student) where -fold cross-validation was applied on the whole train fold. The chosen hyper-parameters for each fold are given in Tables A.2 to A.5. An error in the hyper-parameter tuning code means that the learning rate is always set to the default setting, and not adjusted. However, tests with adjusting the learning rate on the car and nursery datasets did not lead to improved performance for the MLP model, hence, this does not appear to have adversely affected the baseline over the proposed models. A subset of the results, including only the neural network models, is described in Table 2. The full results is reported in Table A.1.

It is evident from Tables 2 and A.1 that our JSON models outperforms other models on several datasets where the semantic structure information plays an important role in classification, e.g, Automobile and Car. Overall, the performance yielded by our JSON models is comparable to other models on all the datasets used in our experiments.

#### Ablation Study

To investigate the importance of different components in our framework, we also carry out an ablation study where certain key components of the TreeLSTM-based model, corresponding to the various aspects of the framework, are removed, and the resultant simplified model is re-run on those UCI datasets with the same settings described in Section 6.1.2. Thus, we have three simplified JSON models: 1) Homogenous types, where all types within the same category were treated as a single type - objects for containers, and strings for primitives. In particular was replaced by and and were set to ; 2) Pathless, where the path information was removed from the network. This amounts to tying the weights for all values of path ; and 3) Both ablations, where both of the above were applied.

Experimental results of this ablation study are listed in Table 3. The experimental results suggest that the main components in our framework play an irreplaceable role apart from the embedding function for data of different primitive types.

#### Data Efficiency

In order to test the effect of using different amounts of training data in learning models, we conduct a data-efficiency study where the training set size was reduced to various fractions. For this study the UCI poker hands dataset is used due to its large number of training examples. This dataset is preprocessed with the input of feature-vector and the JSON format in the same fashion as those UCI datasets described in Section 6.1.1. Each learning model is run with training sets of 5%, 20%, 50%, and 100% of the original number of training examples, where fractional training datasets were constructed by randomly under-sampling from the original training set. Hyper-parameter tuning was done for each model/fraction using random-search on random splits of the train data, using the remaining train examples as the validation set. Testing was done on the provided test set, and each model was trained 5 times using different splits of the full training set. We report the mean, and standard deviation, of the classification accuracy on the test set over the 5 runs. Results are given in Table 4. Chosen hyper-parameters are given in Table A.6.

#### Path-specific functions

To demonstrate how the path specific functions of Section 5.1.2 can be used to tailor an implementation of the framework to a particular dataset, we repeated the experiments on the poker hands dataset with a JSON implementation of the STRLA framework employing path-specific functions. We use the mapping dictionary of Figure 5, where sumTreeLSTM, LSTM, and deepSets correspond to the same container embedding functions described in Section 5.2.2, and catEmbedding corresponds to a categorical embedding function, where each distinct value is mapped to a separate latent vector. The resulting model is relatively simpler than the Set-based and TreeLSTM-based exemplar models, while the path-specific functions allow the permutation-invariance of the cards in the hand to be targeted via a permutation-invariant function. The results for this “Tailored” model are shown in the final column of Table 4.

### 6.2 Reinforcement learning task

We also demonstrate our approach on a toy reinforcement learning task consisting of navigating an avatar on a grid-world to collect various boxes. Each time the environment is reset, between 1 to 4 boxes are randomly placed on a 99 grid, and the avatar is reset to the centre square. One point is obtained for each box the agent collects by navigating to, and the environment is reset when there are no boxes remaining, or after 100 steps. We implemented this task in py-vgdl Schaul (2013), which was adapted to use a modified OpenAI gym interface Brockman et al. (2016). To obtain JSON state-descriptions, we encode the underlying python objects of each game object into corresponding JSON objects using the in-built python JSON parser, where we encode objects by using the __dict__ method to get a dict of attributes of each object. These object-level JSON descriptions are compiled into a JSON list to get a single JSON description of the game state.

We use the fully-observed (i.e. without history based policy) Proximal Policy Optimisation algorithm Schulman et al. (2017), using our JSON network model to encode the environment state into a single latent vector, which we branch off into separate policy and value heads using a single linear transformation. Since the game-state consists of multiple object-level descriptions, for encoding this final list we use the architecture used in Woof and Chen (2018) (which is a variant of the architecture of Zaheer et al. (2017)), which is applied via path-specific function mapping. Additionally, since various object attributes are cosmetic, or otherwise irrelevant, we ignore these via path-specific function mappings. The full list of function mappings is given in Figure 6.

For our baseline we use the object-based method of Woof and Chen (2018) using the same object-level features, but adapted for the PPO algorithm. This uses the same root level architecture, but with hand-defined object-level feature vectors. We also compare to an image-based agent using a Convolutional Neural Network architecture, where input is given as a render of the game-screen. The same hyper-parameters settings were used for all approaches.

Results are given in Figure 7. It should be noted that the training speed of the JSON-based agent was substantially slower (by about 10 times) than the baseline agent.

## 7 Discussion

The experimental results suggest that the proposed approach is competitive with other approaches, and even exceeds the performance of other models on certain datasets. In particular on the car and nursery datasets, both our exemplar JSON models attain near perfect accuracy, while the other models fall short. Both of these datasets are synthetic hierarchical datasets, originally intended to test the hierarchical reasoning powers of expert systems. Hence, this suggests that the proposed framework is able to take advantage of hierarchy in data where it exists. The two proposed models also performed comparably to the JSON-Grinder model, with the exception of the poker-hands dataset, where the relative simplicity of the underlying JSON-Grinder architecture likely helped it avoid overfitting on the smaller dataset fractions. However, the JSON-Grinder model was only applicable to those datasets where the dataset schema was fixed, and couldn’t handle examples with missing attributes or where certain attributes changed types across different data examples, highlighting the advantage of the dynamic architecture construction of the proposed STRLA framework. In addition to the car and nursery datasets, all the JSON models (including the JSON-Grinder model of Pevny and Kovarik (2019)) proved to be much more data-efficient on the poker-hands dataset. This was likely down to the use of permutation invariant functions for representing the cards in the hand in the Set-based and JSON-Grinder models. Meanwhile the MLP baseline uses a fully connected layer with inputs for 5 cards, meaning each permutation of cards is treated separately, increasing the number of different cases the model was required to learn. This was further demonstrated by the tailored model, which used path specific embedding functions to specifically apply a permutation-invariant function to the constituent cards.

However, a significant downside of the proposed approach was its slow iteration-speed compared to other methods. While some of this was down to the greater complexity of the underlying constructed neural network architectures, low CPU/GPU utilisation during training suggests that slow training speeds were largely down to inefficiencies caused by bottlenecks in the framework code. Unfortunately, the use of dynamic construction of the network architecture means that the framework difficult to optimise. However, more careful integration of the framework code with the underlying deep learning framework could help alleviate these bottlenecks.

The importance of differentiating elements by path information was clearly demonstrated in the ablation study, where the pathless model attained lower accuracy across all datasets. However, the same was not true for the use of separate embedding functions for each type, as the model with homogenous embedding functions performed very similarly to the original model. On the other hand, the difference in performance between the Set-based and LSTM-based models on the poker hands data efficiency study suggests that the choice of components matters, at least in certain cases. This suggests that the appropriate choice of function may be less dependent on the specific element type, and more on the actual data of the element itself. While theoretically JSON may only have three primitive types, in practice, JSON elements can take many different forms (for example strings can be used contain plain-text, dates, encoded binary data, etc.), hence using the same function for all instances of a particular type may not be appropriate. This can be addressed using the path-specific functions of Section 5.1.1; by using path-specific functions, the most appropriate choice of embedding function can be used for each element of the data hierarchy rather than relying on the same embedding function for all elements of the same type. However, the appropriate function for each path has to be determined by hand. This reintroduces an unwanted reliance on human input into application of the framework. For future work, one approach would be apply a form of neural architecture search method Elsken et al. (2018), where various choices of function mapping for each path are tested, keeping the best-performing functions.

In Section 5.1 we describe two different simple approaches to incorporating path information into the embedding functions {} and {}, which we use in our exemplar implementations. While easy to implement, these approaches treat paths as discrete identifiers, which ignores a large amount of nuances about paths that could otherwise be exploited. In particular, names in JSON and other semantic tree-structures often comprise of natural language descriptions of the data within; if the names of two elements are similar, then the elements are usually semantically similar. If the semantic related between paths could be better exploited then potentially some learning could be shared between the functions of elements of different, but similar, paths. That is, an update to could also update , where and are semantically related. This could be used in transfer learning, where functions trained on a source dataset could be applied directly to a target dataset, even when the paths of the elements in the different datasets are not exactly identical.

## 8 Conclusion

In this paper we have presented a novel framework for applying end-to-end learning on semantic tree-structured data format such as JSON and XML. We have presented exemplar instantiations of this framework for the JSON format, and evaluated them on a variety of different datasets. Our results demonstrate that the proposed models are comparable with existing approaches based on hand-engineered features, even exceeding them on datasets with innate hierarchicality, while being directly applicable to arbitrary JSON data without requiring additional human intervention. While there are still a number of outstanding issues with our implementations of this framework, we believe that these initial results demonstrate the feasibility of our approach, and the end-to-end learning on semantic tree-structured data is promising for AutoML and worth exploring and developing further.

In future work, we would apply our framework to diversified end-to-end learning tasks on semantic tree-structured data by exploring those proposed improvements to our implementation described in Section 7. Moveover, we are going to explore implementations of our framework for further formats such as XML, HTML, YAML, etc.

## Appendix A JSON and XML Specification

In this appendix, we describe the specification of JSON and XML formats based on the meta-notational scheme described in Section 3.1.

Figure A.1 illustrates the specification of the JSON format with the BNF syntax, which covers all the permissible elements in JSON. and A.2, respectively.

In general, XML consists of many elements. Some elements such as CD data, processing instructions, header and comments are less semantically informative from a supervised learning perspective. Therefore, we ignore such elements and our description focuses on only the main elements in XML. As a result, Figure A.2 illustrates the specification of the core XML format with the BNF syntax.

## Appendix B LSTM and Tree-LSTM Networks

In this appendix, we describe two building blocks, LSTM Hochreiter and Schmidhuber (1997) and Tree-LSTM Tai et al. (2015), used in the implementations of our framework.

### b.1 Lstm

In the LSTM architecture Hochreiter and Schmidhuber (1997), an LSTM unit at each time step consists of several different mechanisms in the vector form including an input gate, , a forget gate, , an output gate, , a memory cell, and a hidden state, . The LSTM unit works with the transition equations as follows:

 it=σ(W(i)xt+V(i)ht−1+b(i)), ft=σ(W(f)xt+V(f)ht−1+b(f)), ot=σ(W(o)xt+V(o)ht−1+b(o)), ut=tanh(W(u)xt+V(u)ht−1+b(u)), ct=it⊙ut+ft⊙ct−1, hLSTMt=ot⊙tanh(cLSTMt),

where is the current input at time step , denotes the elementwise multiplication operator, and are the standard sigmoid and the hyperbolic tangent functions, respectively.

Based on those transition equations described above, we can obtain the memory cell and hidden state vectors of the LSTM unit after a sequence, , is processed:

 hLSTMk⇐LSTM({x1,⋯,xk},ΘLSTM),

where is a collective notation of all the parameters, s, s and s, in the LSTM unit.

### b.2 Tree-LSTM

In general, the LSTM architecture Hochreiter and Schmidhuber (1997) is limited to strictly sequential information propagation. To overcome this limitation, two extensions of the original LSTM architecture, Child-Sum and N-ary Tree-LSTMs have been made in Tai et al. (2015) for exploiting the structural and the semantic information underlying syntactic parse trees. Here, we adapt one of two extensions, Child-Sum Tree-LSTM, for a build block used in our implementation of the container embedding functions. Unlike a syntactic parse tree, there is no external input to branch nodes in any semantic tree defined in Section 3. Therefore, the external input in the Child-Sum Tree-LSTM architecture is omitted in our description below.

Likewise, a Child-Sum Tree-LSTM (SumLSTM) unit consists of the same mechanisms in the LSTM unit as described in Section B.1. A main difference is that all the gates or cell receive the a sum of children’s hidden states in the SumLSTM instead of a single one in the LSTM. Assume that there are children linked to SumLSTM unit , and let denote the sum of its children’s hidden states where . With the same notation used in Section B.1, the SumLSTM unit works with the transition equations as follows:

 ij=σ(V(i)~hj+b(i)), fjn=σ(V(f)hn+b(f)), oj=σ(V(o)~hj+b(o)), uj=tanh(V(u)~hj+b(u)), cSumLSTMj=ij⊙uj+ne∑n=1fjn⊙cn, hSumLSTMj=oj⊙tanh(cSumLSTMj),

Based on those transition equations described above, we can obtain the memory cell and hidden state vectors of SumLSTM unit after all the children’s memory cell and hidden state vectors, , are processed:

 (cSumLSTMj,hSumLSTMj)⇐LSTM({(c1,h1),⋯,(cne,hne)},ΘSumLSTM),

where is a collective notation of all the parameters, s and s, in the SumLSTM unit. It is worth clarifying that unlike the LSTM, a Tree-LSTM unit requires both memory cell and hidden state vectors of its children’s, .

## Appendix C XML Recursive Networks

In this appendix we describe an exmplar implementation for the XML format as described in Figure A.2.

As illustrated in Figure A.2, XML consists of three components: primitive, container and entity-reference. As the entity-reference type may are semantically irrelevant to a supervised learning task, we consider only the primitive and the container components for the XML format.

In the XML, the primitive component has only one element: string. Therefore, we can use the exactly same method presented in Section 5.2.1 to carry out the string embedding function for the XML format (see Eq.(5) and the relevant description for details).

In the XML, there is only one container element: the tagged element. As illustrated in Figures A.1 and A.2, however, the container elements in the JSON and XML differ as the XML wrapper provides an option for describing a branch node with a list of attributes. Thus, we can adapt our implementation of the JSON’s array embedding function for this requirement. Here, we present an implementation of this container embedding function for the XML format by making an extension of the LSTM-based method presented in Section 5.2.2. For a branch node, , it has element path, , children and a list of attributes, . As each attribute value, , is a string for , we can use the same method described Section 5.2.1 to encode such information as follows:

 fatr(vj|Θatr,idj)=1|vj||vj|∑i=1hLSTMi, (A.1)

where is the collective notation of all the learnable parameters in the LSTM network (see Appendix B.1 for details) for attribute and is the hidden state vector when character is sequentially input to the LSTM network, which is obtained by

 hLSTMi⇐LSTM({lin(vj1,θidj),⋯,lin(vji,θidj)},Θatr,idj),

where is the collective notation of the parameters in the linear transformation. Thus, the tag embedding function is carried out with another LSTM as follows:

 ftag({h1,⋯,hne},{id1=v1,⋯,idm=vm}|Θtag,pe)=hLSTMne+m∑j=1fatr(vj|Θatr,idj), (A.2)

where is the collective notation of all the parameters in this LSTM for the element path, . is achieved recurrently via

 hLSTMk⇐LSTM({h1,⋯,hk},ΘLSTM),

where is the latent representation of child .

## Appendix F Examples of constructed JSON entries for UCI datasets

### f.1 Car evaluation

{
"PRICE": {
"buying": "vhigh",
"maint": "vhigh"
},
"TECH": {
"COMFORT": {
"doors": 2,
"persons": 2,
"lug_boot": "small"
},
"safety": "low"
}
}

### f.2 Nursery evaluation

{
"EMPLOY": {
"parents": "usual",
"has_nurs": "proper"
},
"STRUCT_FINAN": {
"STRUCTURE": {
"form": "complete",
"children": 1
},
"housing": "convenient",
"finance": "convenient",
},
"SOC_HEALTH": {
"social": "nonprob",
"health": "recommended"
}
}

### f.3 Poker hands

[
{
"suit": "Hearts",
"rank": 10
},
{
"suit": "Hearts",
"rank": "Jack"
},
{
"suit": "Hearts",
"rank": "King"
},
{
"suit": "Hearts",
"rank": "Queen"
},
{
"suit": "Hearts",
"rank": "Ace"
}
]

### f.4 Mushroom

{
"cap": {
"shape": "convex",
"surface": "smooth",
"color": "brown"
},
"gill": {
"attachment": "free",
"spacing": "close",
"size": "narrow",
"color": "black"
},
"stalk": {
"shape": "enlarging",
"root": "equal",
"surface": {
"above-ring": "smooth",
"below-ring": "smooth"
},
"color": {
"above-ring": "white",
"below-ring": "white"
}
},
"veil": {
"type": "partial",
"color": "white"
},
"ring": {
"type": "pendant",
"number": 1
},
"bruising": true,
"odor": "pungent",
"spore-print-color": "black",
"population": "scattered",
"habitat": "urban"
}

### f.5 Seismic bumps

{
"work-shift": "N",
"assessments": [
{
"type": "seismic",
"result": "a"
},
{
"type": "acoustic",
"result": "a"
},
{
"type": "geophone",
"readings": {
"total-energy": 15180,
"deviation-energy": -72,
"number-pulses": 48,
"deviation-pulses": -72
},
"result": "a"
}
],
"readings": {
"total-energy": 0,
"max-energy": 0,
"bumps": [
{
"range-start": 10e2,
"range-end": 10e3,
"total-bumps": 0
},
{
"range-start": 10e3,
"range-end": 10e4,
"total-bumps": 0
},
{
"range-start": 10e4,
"range-end": 10e5,
"total-bumps": 0
},
{
"range-start": 10e5,
"range-end": 10e6,
"total-bumps": 0
},
{
"range-start": 10e6,