# Using Graph Embedding Techniques in Process-Oriented Case-Based Reasoning
## 4 Neural-Network-Based Semantic Graph Similarity Measure
### Adapted Neural Network Structure
#### 4.2.1 Adapted Embedder  
Introduced in Section 3.2, the embedder creates initial embeddings for nodes and edges. [PERSON] et al. (2019) assume nodes and edges to be represented by a simple feature vector, which is expressed by the functions \(\textit{feat}_{\text{node}}:N\rightarrow\mathbb{R}^{l_{a}}\) and \(\textit{feat}_{\text{edge}}:E\rightarrow\mathbb{R}^{l_{e}}\). The challenge for processing our semantic graph format with sGEM and sGMN is how to bridge the gap between our more complex encoded information, i.e., one-hot encoded types and tree- or sequence-encoded semantic descriptions, to the simple one-dimensional feature vector. To achieve this, the adapted embedder embeds the information of semantic descriptions and types separated from each other and concatenates both vectors to form a single feature vector for a node or an edge. \[\textit{feat}_{\text{node}}(v)= h_{v}^{(0)}=\big{[}h_{v}^{\text{type}},h_{v}^{\text{sem}} \big{]},\quad\forall v\in N \tag{8}\] \[\textit{feat}_{\text{edge}}(v,w)= h_{v,w}=\big{[}h_{v,w}^{\text{type}},h_{v,w}^{\text{sem}} \big{]},\quad\forall(v,w)\in E\]  
Equation (8) shows how the embeddings of types, i.e., \(h_{v}^{\text{type}}\) and \(h_{v,w}^{\text{type}}\), and semantic descriptions, i.e., \(h_{v}^{\text{sem}}\) and \(h_{v,w}^{\text{sem}}\), are combined for each node and edge. This shows how the features of nodes and edges are put together from the available information. In the following, the embedding of types and semantic descriptions is described. The types are embedded as shown in Equation (9):  
\[ \begin{split} h_{v}^{\text{type}}=&\text{MLP}_{ \text{nType}}(\textit{enc}_{\text{type}}(T(v))),\quad\forall v\in N\\ h_{v,w}^{\text{type}}=&\text{MLP}_{\text{eType}}( \textit{enc}_{\text{type}}(T(v,w))),\quad\forall(v,w)\in E\end{split}  \tag{9}\]  
The equation shows the process of embedding node types (\(h_{v}^{\text{type}}\)) and edge types (\(h_{v,w}^{\text{type}}\)). Nodes and edges utilize separate Multi-Layer Perceptrons (MLPs) in this process, i.e., \(\text{MLP}_{\text{nType}}\) for node types and \(\text{MLP}_{\text{eType}}\) for edge types, which are applied to the one-hot encoded type vectors. The second part of the combined feature vectors deals with embedding the semantic description of a node or an edge. Since we propose two different encoding methods for semantic descriptions, i.e., a sequence encoding and a tree encoding (see Section 4.1.2), these two encodings are also handled differently. \[ \begin{split} h_{v}^{\text{sem}}=&\text{RNN}_{ \text{nSem}}(\textit{enc}_{\text{seq}}(S(v))),\quad\forall v\in N\\ h_{v,w}^{\text{sem}}=&\text{RNN}_{\text{eSem}}( \textit{enc}_{\text{seq}}(S(v,w))),\quad\forall(v,w)\in E\end{split}  \tag{10}\]  
Equation (10) shows the embedding of semantic descriptions of nodes (\(h_{v}^{\text{sem}}\)) and edges (\(h_{v,w}^{\text{sem}}\)) that are encoded as a sequence. The sequence structure of the semantic description's encodings is processed by an unrolled RNN (e.g., (45; 46)). An RNN can handle sequences of inputs with different lengths, as they are present in the encodings of semantic descriptions. We use the output state of the last step as the result of the unrolled RNN, which is a single vector. Please note that the sequence contains concatenations of content and data type of semantic description entries (see Section 4.1.2) such that the respective embedding vector captures this information. When using semantic descriptions that are encoded with the tree encoding method, the embedding step is not implemented with RNNs. Instead, we process the graph \(G_{\text{sem}}=(N_{\text{comp}},N_{\text{atom}},E_{\text{sem}})\) (introduced in Section 4.1.2) by utilizing a simple GNN that is similar to the GNN architecture that also processes the entire semantic graph. Therefore, the reader can consult the explanations in Section 3 for more details on certain steps.