## 4 Representation Learning Methods for Traffic Accident Knowledge Graphs
### Representation Learning of the Traffic Accident Knowledge Graph Based on the Improved TransD Model
In the traffic accident domain, inherent attributes of entities--such as Collision Severity or Road Surface--are also critical for representation learning. To explicitly incorporate these attributes into the projection process, this study extends the baseline TransD model by introducing an attribute projection vector \(a_{p}\in\mathbb{R}^{d}\) for each entity. The mapping matrices are thus expanded to  
\[M_{r,a}^{h}=r_{p}\otimes h_{p}^{\mathrm{T}}+a_{p}\otimes a_{p}^{\mathrm{T}}+I \tag{6}\]  
\[M_{r,a}^{t}=r_{p}\otimes t_{p}^{\mathrm{T}}+a_{p}\otimes a_{p}^{\mathrm{T}}+I \tag{7}\]  
Here, the attribute projection vector \(a_{p}\) is derived via a dedicated mapping network that encodes supplemental attributes (e.g., accident severity levels). This outer-product term creates a low-rank adjustment that complements the identity component, enabling the mapping matrix to capture fine-grained, attribute-specific transformations while preserving the core features of the original embedding. These enriched mapping matrices enable the model to capture both the relational and attribute-level nuances of entities within the traffic accident knowledge graph. This construction fully leverages entity and relation projection vectors: the low-rank matrices generated by their outer products perform relation-specific transformations on entity embeddings, dynamically capturing interactions among diverse traffic accident attributes--such as jurisdiction, road conditions, and collision severity. Consequently, inherent entity attributes are explicitly modeled within the projection matrices, enabling embeddings to reflect fine-grained factors like \"accident severity\" and \"road slipperiness\". (3) Projected Entity Representations and Scoring Function  
Using the dynamic mapping matrices defined above, the original entity embeddings can be projected into the relation-specific subspaces. Concretely, for a given relation \(r\), the projected representations of the head and tail entities are computed as:  
\[ht=M_{r,a}^{h}h \tag{8}\]  
\[tt=M_{r,a}^{t}t \tag{9}\]  
In the constructed traffic accident knowledge graph, this implies, for example, that the embedding of an Accident node is infused with features pertinent to the \"Collision Severity\" relation, thereby more accurately reflecting the various factors involved in each incident. For any triple (\(h\), \(r\), \(t\)), the TransD-based scoring function is then defined as:  
\[f_{r}(h,t)=\left\|h^{t}+r-t^{t}\right\|_{2}^{2}=\left\|\left(r_{p}h_{p}^{ \mathrm{T}}+a_{p}a_{p}^{\mathrm{T}}+I\right)h+r-\left(r_{p}t_{p}^{\mathrm{T}} +a_{p}a_{p}^{\mathrm{T}}+I\right)t\right\|_{2}^{2} \tag{10}\]This scoring function measures the distance between the relation-transformed head embedding (plus the relation vector) and the relation-transformed tail embedding. In the traffic accident knowledge graph, each triple--such as (Accident, HAS_COLLISION_SEVERITY, Collision Severity)--is evaluated using this function, enabling the model to separate true triples from corrupted (negative) ones in the embedding space as effectively as possible. To compute the distance between the relation-transformed head embedding and the relation-transformed tail embedding, we adopt the Euclidean (L2) norm. In practice, this means that for any difference vector, we take each of its components, square them, sum all of those squares, and then extract the square root of that sum--thus obtaining the straight-line distance in the embedding space. This choice ensures a smooth, differentiable measure that is widely used for geometric similarity and yields stable gradients during optimization. Moreover, to guard against over-fitting and to keep embedding magnitudes under control, we apply independent L2 regularization on all embedding and projection vectors by adding the sum of their squared lengths (multiplied by a small weight factor) to the overall loss. This penalty encourages the model to learn more compact representations without interfering with the primary ranking objective.