Multi-source road traffic accident knowledge extraction method and system
By using a multi-source road traffic accident knowledge extraction method, utilizing a pre-trained language model and entity-relation type constraints, and explicitly introducing entity type embedding vectors, the problems of error accumulation and insufficient entity type recognition in existing technologies are solved, and high-quality knowledge graph construction is achieved.
Patent Information
- Application Number
- CN202511500399.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-10-21
AI Technical Summary
Existing technologies for extracting knowledge from road traffic accidents suffer from problems such as error accumulation and insufficient entity type recognition. Pipeline methods and joint extraction methods cannot effectively utilize the relationships between accident entities and relationships, leading to the extraction of erroneous and redundant knowledge.
A multi-source road traffic accident knowledge extraction method is adopted. By preprocessing the text content, a pre-trained language model is used for word segmentation and feature vector generation. Combined with sine and cosine positional encoding and relation extraction model, entity-relation type constraints and penalty terms are introduced to construct a comprehensive function and a multi-level semantic reconstruction mechanism. Entity type embedding vectors are explicitly introduced for triple labeling and reconstruction.
It significantly suppresses error accumulation, improves the robustness and accuracy of knowledge extraction, ensures the logical consistency and semantic integrity of the knowledge graph, and realizes the construction of high-quality knowledge graphs from unstructured text to semantically explicit text.
Smart Images

Figure CN120975099A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge extraction technology, and in particular to a method and system for extracting knowledge about road traffic accidents from multiple sources. Background Technology
[0002] Traditional road traffic accident extraction techniques primarily employ a pipelined extraction approach, separating accident entity identification and accident relationship type extraction into two subtasks. This method is prone to error accumulation, as errors in the preceding subtask directly impact the results of subsequent subtasks. Furthermore, the pipelined approach fails to effectively utilize the relationships and constraints between accident entity identification and accident relationship type extraction. For example, the initial and final entity types for the "driving" accident relationship type can only be "person" and "vehicle." While there might be accident relationship types like "collision" or "carrying" between "vehicle" and "person," they cannot be related to accident relationship types like "education level" or "household registration." The pipelined approach lacks consideration for such relationships and constraints, making it more susceptible to extracting erroneous and redundant accident knowledge.
[0003] In road traffic accident knowledge extraction technology, a few multi-module methods (such as CasRel) in joint extraction methods are used. Although they integrate accident entity identification and accident relationship type extraction into the same model as two modules, the model still needs to identify one entity first and then predict another entity based on the accident relationship type. This still has shortcomings in the mining of the association between entities and relationships and cannot completely avoid error accumulation. Single-module joint extraction methods commonly used in information extraction technology (such as TPLinker and OneRel), while achieving simultaneous processing of entity identification and relationship extraction in the same task and solving the error accumulation problem, cannot identify accident entity types when applied to road traffic accident knowledge extraction tasks because they do not incorporate accident entity type information into the method. For example, for the accident description "Zhu Changyi drove a car," only the knowledge of [Zhu Changyi, driving, car] can be extracted, but it cannot identify that "Zhu Changyi" is a "person" and "car" is a "vehicle type." Since different types of accident nodes need to be created for different accident entities based on their accident entity types when constructing a road traffic accident knowledge graph, the inability to identify accident entity types is unacceptable. Summary of the Invention
[0004] This invention provides a method and system for extracting multi-source road traffic accident knowledge, aiming to at least partially solve one of the technical problems in related technologies.
[0005] In a first aspect, the present invention provides a method for extracting multi-source road traffic accident knowledge, including: The text content of the original road traffic accident judgment is extracted and preprocessed. The preprocessed text content is then segmented into sentences to obtain multiple sentences. Each of the sentences is segmented into sub-words by a pre-trained language model to obtain a sub-word sequence. The head accident lexical unit and the tail accident lexical unit are determined based on the sub-word sequence. The head accident lexical unit feature vector and the tail accident lexical unit feature vector are generated according to the head accident lexical unit and the tail accident lexical unit, respectively. Determine the sine and cosine position encoding vectors of the head accident lexical unit and the tail accident lexical unit, and fuse the sine and cosine position encoding vectors with the feature vectors of the head accident lexical unit and the tail accident lexical unit to generate a combined feature vector of the accident lexical unit. The feature vector of the accident vocabulary unit combination is input into the relation extraction model to generate an accident knowledge triplet label matrix for each predefined accident relation type; the predefined accident relation types include: entity-relation type and relation-relation type. Based on the accident knowledge triplet label matrix, a joint feature vector is determined. Based on the joint feature vector, a synthesis function is constructed. The synthesis function is used to assign labels to the accident knowledge triplet label matrix to obtain an optimized accident knowledge triplet label matrix. The optimized accident knowledge triplet label matrix is then decoded to obtain the extraction result containing knowledge triplets.
[0006] Furthermore, the training method for the relation extraction model includes: A training set is obtained based on multiple road traffic accident judgments, and triples consisting of entity boundaries, entity types and relationships are extracted from the multiple road traffic accident judgments. The triples are then converted into a label matrix. The training set is batch-input into the relation extraction model for prediction to obtain the prediction label matrix; Calculate the first loss value and the second loss value based on the label matrix and the prediction label matrix; Determine whether the entity type of the head entity and the entity type of the tail entity of the triple belong to the legal head entity type and legal tail entity type corresponding to the accident relationship type in the predefined accident relationship type mapping table, respectively. If yes, the entity type of the triple is determined to be a legal entity type and a penalty value of 0 is defined; otherwise, the entity type of the triple is determined to be a non-compliant entity type and a penalty value of A is defined, where A>0. A loss function is constructed based on the penalty value, the first loss value, and the second loss value, and the loss value is calculated. The parameters of the relation extraction model are then adjusted based on the loss value.
[0007] Furthermore, determining the joint feature vector based on the accident knowledge triplet label matrix includes: Based on the accident knowledge triplet label matrix, determine the feature vector M for each accident vocabulary unit combination. T and the overall feature vector M of all accident vocabulary units combined in each row. R ; The feature vector M T The query vector is determined by the overall feature vector M. R Determine the key vector and value vector, and determine the attention weights based on the query vector, key vector, and value vector; By combining the attention weights and the value vector, an attention-weighted row feature vector is obtained; by combining the attention weights and the query vector, an attention-weighted column feature vector is obtained. The feature vector M T The attention-weighted row feature vectors and attention-weighted column feature vectors are added together to obtain the attention-weighted incident knowledge triplet label matrix. Based on the attention-weighted incident knowledge triplet labeling matrix, the attention-weighted head incident entity feature vector, the attention-weighted tail incident entity feature vector, and the incident entity type embedding vector are obtained respectively. A joint feature vector is obtained based on the attention-weighted head event entity feature vector, the attention-weighted tail event entity feature vector, and the event entity type embedding vector.
[0008] Furthermore, the construction of the comprehensive function based on the joint feature vector includes: Based on a predefined accident relationship type mapping table, determine the reasonableness scoring items for accident relationship types; Based on the joint feature vector and the rationality scoring item, a comprehensive function is obtained, and the comprehensive score of the accident knowledge triple is calculated through the comprehensive function. If the overall score of the accident knowledge triplet is greater than or equal to the target threshold, the accident knowledge triplet is determined to be a reasonable triplet. If the overall score of the accident knowledge triple is less than the target threshold, the accident knowledge triple is judged as an unreasonable triple. The unreasonable triple is then subjected to semantic analysis and reconstruction to obtain the accident knowledge reconstruction triple, and a label is reassigned to the accident knowledge reconstruction triple.
[0009] Furthermore, the unreasonable triples are semantically analyzed and reconstructed to obtain accident knowledge reconstruction triples, and labels are reassigned to the accident knowledge reconstruction triples, including... Candidate accident relationship types that match the accident relationship types of the unreasonable triples are extracted from a predefined accident relationship type knowledge base. The candidate accident relationship types are combined with the accident relationship types of the unreasonable triples to form matching accident relationship types. The matching accident relationship type vector difference is determined. The accident relationship type knowledge base includes multiple accident relationship types. Based on the matching accident relationship type vector difference, the accident relationship type projection analysis of the unreasonable triplet is performed to obtain the accident knowledge reconstruction triplet. Determine whether the semantics of the accident knowledge reconstruction triplet are reasonable. If so, reassign the label to the accident knowledge reconstruction triplet; otherwise, perform entity substitution analysis on the accident knowledge reconstruction triplet to obtain the accident knowledge correction triplet. Determine whether the semantics of the accident knowledge correction triplet are reasonable. If so, the accident knowledge correction triplet is reassigned with a label. If not, the accident knowledge reconstruction triplet is determined to be an unreasonable triplet and is removed.
[0010] Furthermore, the step of projecting the accident relationship type of the unreasonable triples onto the matched accident relationship type vector difference to obtain the accident knowledge reconstruction triples includes: Based on the difference between the matching accident relationship type vectors and the accident evolution direction vector, a directional consistency index is determined. The accident evolution direction vector is determined based on the accident evolution axis, which is used to indicate the degree of development of accident relationship types in the accident relationship type knowledge base. If the direction consistency index is less than the direction consistency threshold, it means that the vector difference is consistent with the direction of the accident evolution axis; Determine the semantic similarity between the accident relationship type of the unreasonable triplet and the accident relationship type of the predefined accident relationship type mapping table, and sort them from high to low to obtain the semantic similarity ranking result; Based on the semantic similarity ranking results, determine whether the accident relationship type in the predefined accident relationship type mapping table corresponding to the top X semantic similarities is a candidate accident relationship type; X is a positive integer greater than 1; If so, based on the frequency of occurrence of unreasonable triples and the semantic coherence of the entities following the accident relationship type according to the predefined corpus statistics, if the frequency of occurrence and semantic coherence reach the target range and the grammar of the unreasonable triples is correct, the accident relationship type of the unreasonable triples is replaced with the candidate accident relationship type.
[0011] Furthermore, the joint feature vector is represented as follows: , in, Representing the head accident entity H and the tail accident entity B in a given accident relationship type The joint eigenvectors, The head event entity H represents the event with a given event relationship type. Attention-weighted head accident entity feature vector, Entity B, representing the tail event, in a given event relationship type Attention-weighted tail accident entity feature vector, The embedding vector representing the type of the head accident entity. The embedding vector represents the event entity type of the tail event entity, W1 represents the sixth weight matrix, and b represents the bias term. represents the activation function, Drop represents the random drop policy, and T represents the transpose.
[0012] Furthermore, the synthesis function is: , Where f represents the overall score, and W2 represents the seventh weight matrix. Representing the head accident entity H and the tail accident entity B in a given accident relationship type Reasonableness scoring items Represents the adjustment factor. The value is 2, and T represents transpose processing.
[0013] Furthermore, the loss function is expressed as follows: , in, Represents the loss function. Represents the first loss value. Represents the second loss value. This represents the penalty value.
[0014] Furthermore, the extraction results include a first type of triplet and a second type of triplet; the first type of triplet is a relation-relation type triplet, and the second type of triplet is an entity-relation type triplet; After obtaining the extraction results including knowledge triples, it also includes: For each head and tail incident entity that appears in the first type of triple, an incident entity node is created, where each incident entity node is uniquely identified by the entity name and stored in the graph database. Based on the first type of triplet, edges of type accident relationship are established between the corresponding accident entity nodes to generate an initial graph structure; Based on all the second-class triples, add an accident entity type attribute to the accident entity nodes with the same entity name in the graph database; Identify the incident entities that do not appear as head or tail entities in the first type of triples, create new incident entity nodes based on their names, and assign the incident entity type attribute according to the second type of triples.
[0015] Secondly, the present invention provides a multi-source road traffic accident knowledge extraction system, comprising: Text extraction module: used to extract the text content from the original road traffic accident judgment and preprocess it, and then segment the preprocessed text content into sentences to obtain multiple sentences; Sub-word segmentation module: used to segment each of the sentences into sub-words using a pre-trained language model to obtain a sub-word sequence, determine the head accident lexical unit and the tail accident lexical unit based on the sub-word sequence, and generate the head accident lexical unit feature vector and the tail accident lexical unit feature vector according to the head accident lexical unit and the tail accident lexical unit respectively. Feature fusion module: used to determine the sine and cosine position encoding vectors of the head accident lexical unit and the tail accident lexical unit, and fuse the sine and cosine position encoding vectors with the feature vectors of the head accident lexical unit and the tail accident lexical unit to generate a combined feature vector of the accident lexical unit; The label matrix generation module is used to input the feature vector of the accident vocabulary unit into the relation extraction model to generate an accident knowledge triple label matrix for each predefined accident relation type; the predefined accident relation types include: entity-relation type and relation-relation type; Knowledge extraction module: Based on the accident knowledge triplet label matrix, it determines a joint feature vector, constructs a synthesis function based on the joint feature vector, assigns labels to the accident knowledge triplet label matrix using the synthesis function to obtain an optimized accident knowledge triplet label matrix, and decodes the optimized accident knowledge triplet label matrix to obtain the extraction result containing knowledge triplets.
[0016] The embodiments of the present invention have the following technical effects: This invention fundamentally suppresses the error accumulation problem by explicitly introducing entity-relationship type constraints into the accident knowledge triplet labeling matrix and fusing accident entity type embedding vectors into the joint feature vector. When constructing the relation labeling matrix, the legal head and tail entity type combinations associated with each accident relationship type are preset as an accident relationship type mapping table and used as constraints. Secondly, when generating the joint head and tail entity representation, entity type embedding vectors are introduced and concatenated with the context semantic vector to participate in relation prediction. This allows the model to not only analyze whether the head and tail entities co-occur in the same relation scenario when judging triples, but also simultaneously verify whether the entities belong to the corresponding entity type, significantly enhancing the model's ability to distinguish erroneous candidates. Furthermore, by adding a penalty term to the loss function, the model continuously learns legal type paths during training, strengthening the synergistic consistency between type and relation. Therefore, it not only avoids the advantage of external error propagation but also solves the problem of implicit error accumulation caused by semantic ambiguity within the model through embedded type information guidance, achieving more robust knowledge extraction. This provides a complete and reliable structured input for building nodes by type in the subsequent knowledge graph, and truly realizes the high-quality construction of a multi-source road traffic accident knowledge graph that is semantically clear and logically consistent, from unstructured text.
[0017] This invention effectively addresses the insufficient post-processing capabilities of triple extraction in existing technologies by constructing a knowledge base for accident relationship types that includes the accident evolution axis and development direction, and combining joint feature vectors, a comprehensive scoring function, and a multi-level semantic reconstruction mechanism. At the feature level, this scheme fuses the context vector representations of the head and tail entities with the entity type embedding vectors, enabling the model to learn the reasonable distribution patterns of accident entity types in different accident relationship types during training, thus enhancing the mutual constraints between types and relationships. Furthermore, by introducing projection analysis based on vector differences and a direction consistency index, it can identify and map semantically similar but differently expressed accident relationship types, achieving intelligent reconstruction of unreasonable triples rather than simple elimination. Combined with proximity checks and contextual semantic coherence verification, it ensures that the reconstruction results are reasonable and reliable at the semantic, syntactic, and pragmatic levels. Ultimately, this scheme not only significantly reduces mislabeling and omissions in triple extraction but also improves the logical consistency and semantic integrity of the knowledge graph, achieving a technological leap from passive filtering to active repair. It demonstrates superior accuracy, robustness, and interpretability in the automated construction of knowledge in the field of traffic accidents. Attached Figure Description
[0018] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a flowchart of a multi-source road traffic accident knowledge extraction method provided in an embodiment of the present invention; Figure 2 This is an example diagram of a road traffic accident knowledge triplet labeling strategy provided by an embodiment of the present invention for a multi-source road traffic accident knowledge extraction method; Figure 3 This is an example diagram of the entity-relationship type accident knowledge triplet labeling matrix of a multi-source road traffic accident knowledge extraction method provided in this embodiment of the invention; Figure 4 This is an example diagram illustrating the labeling strategy pattern of accident entity relationship constraints in a multi-source road traffic accident knowledge extraction method provided in this embodiment of the invention. Figure 5 This is a structural diagram of a multi-source road traffic accident knowledge extraction system provided in an embodiment of the present invention; Figure 6 This is a block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0020] The following description, with reference to the accompanying drawings, illustrates a method and system for extracting multi-source road traffic accident knowledge according to an embodiment of this application.
[0021] Figure 1 This is a flowchart illustrating a multi-source road traffic accident knowledge extraction method provided in an embodiment of this application.
[0022] It should be noted that the execution subject of the multi-source road traffic accident knowledge extraction method in this application embodiment is the multi-source road traffic accident knowledge extraction system in this application embodiment. The multi-source road traffic accident knowledge extraction system can be configured in an electronic device so that the electronic device can perform the multi-source road traffic accident knowledge extraction function.
[0023] like Figure 1 As shown, this multi-source road traffic accident knowledge extraction method includes the following steps: Step 1: Extract the text content from the original road traffic accident judgment and preprocess it. Then, segment the preprocessed text content into sentences to obtain multiple sentences.
[0024] Extract the text content directly related to the accident facts from the original road traffic accident judgment, and focus on retaining the narrative paragraphs describing the accident process, the behavior of the parties, the vehicle status, and the scene environment, such as specific fact descriptions like "The driver's vehicle collided with another vehicle at a certain section." Remove non-factual content such as legal provisions citations, court procedural statements, and liability determination conclusions, and perform format unification and character standardization processing on the retained text. Subsequently, based on the syntactic boundary recognition ability of Chinese natural language processing tools, combined with punctuation marks and semantic integrity judgment, the preprocessed text is segmented into sentences to generate multiple independently semantically complete sentences.
[0025] Step 2: Perform sub-word segmentation on each sentence through a pre-trained language model to obtain a sub-word sequence. Based on the sub-word sequence, determine the head accident vocabulary unit and the tail accident vocabulary unit, and generate the head accident vocabulary unit feature vector and the tail accident vocabulary unit feature vector respectively according to the head accident vocabulary unit and the tail accident vocabulary unit.
[0026] Input each preprocessed sentence into the pre-trained Chinese language model (BERT) in turn to perform sub-word segmentation on the sentence to obtain a sub-word sequence, where each Chinese character is used as a sub-word, and each sub-word is used as a vocabulary unit. Take the sentence "Zhu Changyi drives a black sedan" containing key accident information as an example. Perform segmentation using the WordPiece algorithm according to the tokenization specification of BERT, add the [CLS] token at the beginning of the sentence and the [SEP] token at the end of the sentence, and pad the part that is less than the maximum length (set to 128) with [PAD]. Finally, the obtained sub-word sequence is: ["[CLS]", "Zhu", "Chang", "Yi", "drives", "a", "black", "sedan", "[SEP]"]. Input this sub-word sequence into the BERT model to obtain the context feature vector corresponding to each vocabulary unit in the sequence.
[0027] On this basis, identify the head accident entity and the tail accident entity in the sentence through the named entity recognition module, and determine the head accident vocabulary unit and the tail accident vocabulary unit. Specifically, first locate the start position and end position of the head accident entity and the tail accident entity in the sub-word sequence. For the head accident entity "Zhu Changyi", its start position in the sub-word sequence is 1 and the end position is 3. Therefore, the vocabulary units it covers are "Zhu", "Chang", and "Yi", and these three vocabulary units together constitute the head accident vocabulary unit. For the tail accident entity "sedan", its start position is 10 and the end position is 11. Therefore, the vocabulary units it covers are "jiao" and "che", and these two vocabulary units together constitute the tail accident vocabulary unit.
[0028] Perform element-wise averaging on the context feature vectors corresponding to "Zhu", "Chang", and "Yi" in the head accident vocabulary unit to obtain a vector with the same dimension, which serves as the head accident vocabulary unit feature vector; similarly, perform element-wise averaging on the context feature vectors corresponding to "Jiao" and "Che" in the tail accident vocabulary unit to obtain the tail accident vocabulary unit feature vector.
[0029] Step 3, determine the sine-cosine position encoding vectors of the head accident vocabulary unit and the tail accident vocabulary unit, and fuse the sine-cosine position encoding vectors with the head accident vocabulary unit feature vector and the tail accident vocabulary unit feature vector to generate the accident vocabulary unit combined feature vector.
[0030] Before generating the accident vocabulary unit combined feature vector, it is necessary to generate absolute position encoding and relative position encoding for the head accident vocabulary unit and the tail accident vocabulary unit: Each sub-word is assigned a consecutive absolute position index starting from 0, where [CLS] corresponds to index 0, "Zhu" corresponds to index 1, "Chang" corresponds to index 2, and so on until [SEP] corresponds to index 12. Based on the above position indices, use the standard sine-cosine function to generate the absolute position encoding vector for each vocabulary unit. Subsequently, add it to the feature vector of the corresponding vocabulary unit as the input of the BERT model, enabling the model to perceive the position of each vocabulary unit when encoding context information. Further generate a triple position encoding vector for relationship modeling: one is the absolute position encoding vector of the position where the head entity is located, the second is the absolute position encoding vector of the position where the tail entity is located, and the third is the relative position encoding vector corresponding to the difference between the starting positions of the head and tail entities. Next, based on the head accident vocabulary unit feature vector and the tail accident vocabulary unit feature vector, splice them with the aforementioned triple position encoding vector to form a high-dimensional accident vocabulary unit combined feature vector.
[0031] Step 4, input the accident vocabulary unit combined feature vector into the relation extraction model to generate an accident knowledge triple label matrix for each predefined accident relation type; the predefined accident relation types include: entity-relation type and relation-relation type.
[0032] Before the relation extraction model generates the accident knowledge triple label matrix, it needs to be trained. The training method of the relation extraction model includes: Obtain a training set based on multiple road traffic accident judgments, and extract triples including entity boundaries, entity types, and relations from multiple road traffic accident judgments, and convert the triples into a label matrix; Batch input the training set into the relation extraction model for prediction to obtain a predicted label matrix; Calculate the first loss value and the second loss value based on the label matrix and the predicted label matrix; Determine whether the entity types of the head entity and tail entity of the triple belong to the legal head entity type and legal tail entity type corresponding to the accident relationship type in the predefined accident relationship type mapping table, respectively. If yes, the entity type of the triple is determined to be a legal entity type and a penalty value of 0 is defined; otherwise, the entity type of the triple is determined to be a non-compliant entity type and a penalty value of A is defined, where A>0. A loss function is constructed based on the penalty value, the first loss value, and the second loss value, and the loss value is calculated. The parameters of the relation extraction model are then adjusted based on the loss value.
[0033] In some embodiments, the relation extraction model is preferably the OneRel model. First, define the incident statement. t represents a lexical unit in the incident statement, and L represents the number of lexical units in the incident statement. Set of incident relation types. , This represents the Kth accident relationship type, where K represents the number of accident relationship types. For accident relationship types... The combination of accident vocabulary units in the accident knowledge triplet tag matrix [t] i ,t j The true label classification score is represented as: The model classification score is represented as , where t i, t j ∈L,t i For the i-th lexical unit (head entity) in the incident statement, t j This refers to the j-th lexical unit (tail entity) in the incident statement.
[0034] Next, calculate the first loss value L1: ; Next, calculate the second loss value L2 based on the FocalLoss mechanism: ; Finally, based on the first loss value L1, the second loss value L2, and the penalty value... Construct the loss function: ; in, Represents the loss function. Represents the first loss value. Represents the second loss value. This represents the penalty value. As a balance factor, , The label classification probability of the triple. Adjust the probability for the focus.
[0035] The penalty value is defined as follows: A predefined accident relationship type mapping table predefines the legal head entity type and tail entity type combinations for each accident relationship type. For example, the head entity type for the "driving" relationship is "person" and the tail entity type is "vehicle". The head entity type for attribute relationships such as "gender", "age", and "occupation" is "person". The tail entity type for attribute relationships such as "vehicle type" and "vehicle brand" is "vehicle". The "collision" relationship can exist between "vehicle-vehicle", "vehicle-environmental facilities", or "vehicle-person", etc.; "occurrence" is used for "accident-time" or "accident-location", etc.
[0036] The process for defining the penalty value for triples containing non-compliant entity types is as follows: Based on a predefined incident corpus, identify first triples with head entities as tail entities and tail entities as head entities; based on the first triples, filter second triples whose head entity type and tail entity type match the incident relationship type mapping table; use the number of second triples in which the head entity of the current incident knowledge triple is used as the tail entity as the forward reachability score; use the number of second triples in which the tail entity of the current incident knowledge triple is used as the head entity as the head entity as the backward reachability score; calculate the context matching degree based on the forward and backward reachability scores, and determine the penalty value based on the context matching degree. , , Where M is the matching degree, The forward reachability score for the i-th head entity. The backward reachability score is given for the j-th tail entity. During the process of generating an accident knowledge triplet label matrix for each predefined accident relationship type, the entity types of different accident entities are obtained simultaneously when extracting the accident knowledge triplet. While ensuring that the labeling strategy and the number of label categories remain unchanged, accident entity type information is introduced into the task, enhancing the interaction between accident entities and accident relationship types, and improving the diversity and accuracy of road traffic accident knowledge extraction results.
[0037] This embodiment also designs a matrix-based road traffic accident knowledge triple labeling strategy, which labels each element in the matrix with a different type to represent the start and end positions of the head and tail accident entities, thereby transforming the accident knowledge triple extraction task into an accident matrix element labeling and classification task. The specific labeling strategy is as follows: The tagging strategy assigns a tag to each element, indicating whether the corresponding event vocabulary unit combination is the start or end position of an entity, such as... Figure 2As shown below. For example, the accident knowledge triple tagging matrix tags the accident knowledge triple [Zhu Changyi, driving, sedan] that exists in the accident description "Zhu Changyi drives a sedan" under the accident relationship type of "driving". The tags are divided into four categories: (1)HB-TB: Represents the start boundaries of the head accident entity and the tail accident entity. In the example, the lexical unit combination [Zhu, sedan] is assigned the tag "HB-TB"; (2)HB-TE: Represents the start boundary of the head accident entity and the end boundary of the tail accident entity. In the example, the lexical unit combination [Zhu, car] is assigned the tag "HB-TE"; (3)HE-TE: Represents the end boundaries of the head accident entity and the tail accident entity. In the example, the lexical unit combination [Yi, car] is assigned the tag "HE-TE"; (4)Others: Can be tagged with any special symbol (such as "-") to represent a lexical unit combination that is not an accident knowledge triple.
[0038] In order to obtain the entity types of different accident entities while extracting accident knowledge triples in the form of [head accident entity, accident relationship type, tail accident entity], first, the accident relationship types are extended according to the predefined accident entity types. For example, for the entity type "vehicle" of the accident entity "sedan", a new accident relationship type is named "vehicle - entity", and a corresponding accident knowledge triple [sedan, vehicle - entity, sedan] with the same head and tail accident entities is added, indicating that the entity type of "sedan" is "vehicle". In this embodiment, this accident relationship type is named "entity - relationship type", and other accident relationship types are named "relationship - relationship type". For the entity - relationship type, it is tagged according to the same tagging strategy as other accident knowledge triples. The corresponding accident knowledge triple tagging matrix is as Figure 3 shown. By adding the entity - relationship type, while ensuring that the tagging strategy and the number of tagging categories remain unchanged, the accident entity type information is introduced into the task, enhancing the interaction between accident entities and accident relationship types, and improving the diversity and accuracy of road traffic accident knowledge extraction results.
[0039] Suppose the accident relationship type r K is the entity - relationship type. For the accident knowledge triple tagging matrix belonging to r K , if the accident lexical unit combination [t p , t q in the p - th row and q - th column represents the start position of an accident entity and is tagged as HB - TB, then when this accident entity serves as the head accident entity or the tail accident entity in other relationship - relationship types r K-1 , it belongs to the relationship - relationship type r K-1In the p-th row or q-th column of the marker matrix, there must also exist a combination of accident vocabulary units [t] at some position [q,x] or [x,q]. q ,t x ] or [t x ,t q The marking for ] is also HB-TB, and the specific correspondence is shown in the example below. Figure 4 As shown.
[0040] Step 5: Based on the accident knowledge triplet label matrix, determine the joint feature vector; based on the joint feature vector, construct a synthesis function; use the synthesis function to assign labels to the accident knowledge triplet label matrix to obtain the accident knowledge triplet optimized label matrix; decode the accident knowledge triplet optimized label matrix to obtain the extraction result containing knowledge triplets.
[0041] In the accident knowledge triplet labeling matrix of the "vehicle type-entity" entity-relationship type, the label HB-TB, located in row 5 and column 1, can express the starting position of the tail accident entity "sedan". In the accident knowledge triplet labeling matrix of the "driving" relation-relationship type, "sedan" is also the tail accident entity of the accident knowledge triplet [Zhu Changyi, driving, sedan]. Obviously, the label HB-TB, which expresses the starting position of the tail accident entity, is also located in row 5. Based on this pattern, for the element [t] in the accident knowledge triplet labeling matrix of the entity-relationship type... p ,t q The attention weights of the overall feature vectors of the entity / relationship-type accident knowledge triplet labeling matrix with each row and column can be calculated. This attention weighting allows for the focused acquisition of overall feature information in the p-th row and q-th column of the related entity / relationship-type accident knowledge triplet labeling matrix. For accident lexical unit combinations under the entity / relationship-type accident knowledge triplet labeling matrix, the attention weights of their corresponding rows and columns in the entity / relationship-type accident knowledge triplet labeling matrix are calculated. This information interaction between accident entity types and accident relationship types can complement labeling and classification, improving model recall, and also ensure consistency in extraction results, improving model accuracy. However, calculating attention for each element in the matrix individually would significantly increase memory usage. Therefore, this embodiment makes the following adjustment: the computational dimension of the attention mechanism is increased from elements to rows and columns. For a row / column in the entity / relationship-type labeling matrix, the attention weights and weighted values with each row / column in the corresponding relationship / entity / relationship-type labeling matrix are calculated. This significantly reduces the model's memory requirements and improves extraction efficiency.
[0042] Based on the accident knowledge triplet label matrix, the joint feature vector is determined, including: Step 501: Based on the accident knowledge triplet label matrix, determine the feature vector M for each accident vocabulary unit combination. T and the overall feature vector M of all accident vocabulary units combined in each row. R。
[0043] M T =M×W T M R =M×W R Where M generates an accident knowledge triplet label matrix for each predefined accident relationship type, and W... T W is the first weight matrix. R This is the second weight matrix.
[0044] Step 502, based on the feature vector M T The query vector is determined by the overall feature vector M. R Determine the key vector and value vector, and then determine the attention weights based on the query vector, key vector, and value vector.
[0045] Query vector Q T This involves mapping the overall feature vector of all accident-related vocabulary units in each line to the Query space through a linear transformation, which then serves as the basis for subsequent mappings to the key vector K. R Sum vector V R Prepare for attention calculations; Q T =M T ×W q K R =M R ×W k V R =M R ×W v W q W is the third weight matrix. k W is the fourth weight matrix. v This is the fifth weight matrix. It is obtained by querying the vector Q. T Key vector K R Sum vector V R Calculate the scaled dot product attention weights: , in, Here, T represents the attention weights, T represents the transpose operation, and d represents the attention weights. k For the key vector K R Dimensions.
[0046] Step 503: Combine the attention weights and the value vector to obtain the attention-weighted row feature vector, and combine the attention weights and the query vector to obtain the attention-weighted column feature vector.
[0047] By combining the attention weights and the value vector, an attention-weighted row feature vector is obtained; by combining the attention weights and the query vector, an attention-weighted column feature vector is obtained.
[0048] Attention weights Sum vector V R Perform matrix multiplication to obtain attention-weighted row eigenvectors. , Perform the same operation along the column dimension to obtain the attention-weighted column feature vector. .
[0049] Step 504, convert the feature vector M T The attention-weighted row feature vectors and attention-weighted column feature vectors are added together to obtain the attention-weighted incident knowledge triplet label matrix.
[0050] Combine each accident vocabulary unit into a feature vector M T Attention-weighted row feature vectors Attention-weighted column feature vectors Obtain the attention-weighted accident knowledge triplet label matrix .
[0051] Step 505: Based on the attention-weighted incident knowledge triplet label matrix, obtain the attention-weighted head incident entity feature vector, the attention-weighted tail incident entity feature vector, and the incident entity type embedding vector, respectively.
[0052] Among them, based on accident relationship type Accident knowledge triplet tag matrix accident vocabulary unit combination [t] p ,t q Taking the labeling and classification process of accident vocabulary units as an example. If the accident vocabulary unit combination [t] p ,t q If ] is marked as HB-TB (head and tail entity start), then t p t represents the starting position of the head entity. q The starting position of the tail entity, combined with the output of the named entity recognition module, is determined based on t. p The head entity at the starting position and t q For the tail entity at the starting position, determine the complete span of the head and tail entities to obtain the head incident entity and the tail incident entity. Extract the feature vectors of all lexical units within the span of the head entity and the feature vectors of all lexical units within the span of the tail entity, and obtain the attention-weighted head incident entity feature vector and the attention-weighted tail incident entity feature vector through average pooling, respectively.
[0053] This embodiment also constructs a vocabulary of entity types in the field of traffic accidents, assigning a unique ID to each entity type (such as "person", "vehicle", "road facility", "weather condition", "damage type", "behavior action", etc.); then, a trainable embedding matrix is initialized. For the head and tail entities of any triple, according to their pre-labeled types (such as "Zhang Mou" belonging to "person", "car" belonging to "vehicle"), the corresponding embedding vector is retrieved from the embedding matrix by looking up the ID corresponding to the type, and then concatenated with the head attention-weighted head accident entity feature vector and the attention-weighted tail accident entity feature vector to obtain the corresponding entity type embedding vector.
[0054] Step 506: Obtain the joint feature vector based on the attention-weighted head accident entity feature vector, the attention-weighted tail accident entity feature vector, and the accident entity type embedding vector.
[0055] The joint eigenvector is represented as follows: , in, Representing the head accident entity H and the tail accident entity B in a given accident relationship type The joint eigenvectors, The head event entity H represents the event with a given event relationship type. Attention-weighted head accident entity feature vector, Entity B, representing the tail event, in a given event relationship type Attention-weighted tail accident entity feature vector, The embedding vector representing the type of the head accident entity. The embedding vector represents the event entity type of the tail event entity, W1 represents the sixth weight matrix, and b represents the bias term. represents the activation function, Drop represents the random drop policy, and T represents the transpose.
[0056] Traditional joint feature vectors rely solely on the semantic representation of lexical units. While they can capture local contextual information, they lack prior constraints on the semantic roles of entities. To address this, this embodiment adds entity type information for the head and tail entities to the traditional joint feature vector, forming the joint feature vector of this embodiment. By introducing embedded representations of head and tail entity types, the model not only obtains semantic features at the lexical level but also integrates structured domain knowledge, thereby more accurately determining which entity combinations are legitimate under specific accident relationship types. For example, the "driving" relationship requires the head entity to be "person" and the tail entity to be "vehicle." If the model relies only on surface-level text features, it may misjudge due to ambiguous expression or omission of the subject. However, when entity type information is explicitly encoded into the feature vector, the model can effectively eliminate unreasonable combinations such as "vehicle-driving-person" through a type matching mechanism, improving classification accuracy.
[0057] Based on the joint feature vector, a comprehensive function is constructed, including:
[0058] Step 511: Based on the predefined accident relationship type mapping table, determine the rationality scoring item for the accident relationship type.
[0059] The reasonableness score for accident relationship types is determined by checking if the accident relationship type of the triple exists in the accident relationship type mapping table: If the accident relationship type of the triple exists in the accident relationship type mapping table, the reasonableness score is +1.0, indicating that the triple fully conforms to the legal pattern in the accident knowledge system and belongs to a semantically reasonable and acceptable structure. If the accident relationship type of the triple does not exist in the accident relationship type mapping table, the reasonableness score is -10.0. In this case, the triple seriously violates common sense or law and is an impossible relationship, such as "pedestrian driving a truck" or "person suspected of flying". If the direction of the triple is incorrect (such as "vehicle driver"), the reasonableness score is -5.0. This situation is clearly illogical and needs to be corrected.
[0060] The field of traffic accidents is highly structured and rule-based, with many relationships strictly constrained by physical laws, legal provisions, and common sense, making inferences based solely on surface-level semantics insufficient. By establishing a clearly defined tiered reasonableness score, this embodiment can accurately distinguish between illegal, directionally incorrect, and compliant triples during the scoring phase. On one hand, this significantly reduces the risk of the model generating erroneous triples that violate common sense due to contextual ambiguity or training data noise; on the other hand, among multiple candidate relationships, it prioritizes and retains legal combinations that conform to domain norms, effectively guiding the model from linguistic similarity to logical correctness. Especially when dealing with omitted subjects, inverted sentences, or non-standard expressions, this explicit judgment mechanism based on predefined rules compensates for the shortcomings of purely data-driven methods in semantic depth understanding, achieving synergistic optimization of knowledge guidance and model learning, and significantly enhancing the reliability, interpretability, and practicality of accident knowledge graph construction.
[0061] Step 512: Based on the joint feature vector and the rationality scoring item, a comprehensive function is obtained. The comprehensive score of the accident knowledge triple is calculated using the comprehensive function.
[0062] The synthesis function is: , Where f represents the overall score, and W2 represents the seventh weight matrix. Representing the head accident entity H and the tail accident entity B in a given accident relationship type Reasonableness scoring items Represents the adjustment factor. The value is 2, and T represents transpose processing.
[0063] Step 513: If the overall score of the accident knowledge triplet is greater than or equal to the target threshold, the accident knowledge triplet is judged as a reasonable triplet; if the overall score of the accident knowledge triplet is less than the target threshold, the accident knowledge triplet is judged as an unreasonable triplet. Semantic analysis and reconstruction are performed on the unreasonable triplet to obtain the accident knowledge reconstruction triplet, and the label is reassigned to the accident knowledge reconstruction triplet.
[0064] The target threshold is composed of two sub-thresholds, Tvec and True. Only when the joint feature vector and the reasonable scoring item satisfy the sub-thresholds is the accident knowledge triple considered reasonable; otherwise, it is considered unreasonable and triggers the subsequent semantic repair mechanism.
[0065] The determination of Tvec depends on the analysis of the model's output distribution on the validation set: by performing forward inference on a large number of labeled reasonable and unreasonable triples, and statistically analyzing the score distribution of the joint feature vector, it was found that the joint feature vectors of reasonable triples are mostly concentrated in the interval [0.5, 5.0], while unreasonable triples are widely distributed in the interval [-3.0, 2.0], especially in the case of incorrect direction or type mismatch, they are often below 0; therefore, setting Tvec to 0 means that the model must provide non-negative support for the semantic matching of entities and relations in order to enter the next round of judgment, thereby filtering out triples with obvious semantic conflicts. Meanwhile, the setting of True relies on the rule system in the accident relationship type knowledge base: since the reasonableness score is explicitly defined as +1.0, -5.0, and -10.0, by introducing an adjustment coefficient, the rule can be amplified to {-20.0, -10.0, +2.0}; based on this, setting True=-1.0 means that as long as the reasonableness score is -10, which is less than True, the triple will be directly rejected regardless of the model confidence level, reflecting the rule-first safety design principle. Ultimately, the target threshold is: a triple is considered reasonable only when the joint feature vector is greater than or equal to Tvec and the reasonableness score is greater than or equal to True; otherwise, if either condition is not met, it is judged as an unreasonable triple.
[0066] In this process, semantic analysis and reconstruction are performed on unreasonable triples to obtain accident knowledge reconstruction triples, and labels are reassigned to the accident knowledge reconstruction triples, including...
[0067] Step 513.1: Extract candidate accident relationship types that match the accident relationship types of unreasonable triples from the predefined accident relationship type knowledge base, combine the candidate accident relationship types with the accident relationship types of unreasonable triples to form matching accident relationship types, and determine the vector difference of matching accident relationship types. The accident relationship type knowledge base includes multiple accident relationship types.
[0068] The accident relationship type knowledge base is semantically extended based on the accident relationship type mapping table, forming a semantic vector containing the development path and intermediate state relationships of accident relationship types. The development path of an accident relationship type describes the reasonable evolution sequence of a relationship in the accident evolution process, such as "driving, fatigued driving, operational error, collision, escape", forming a dynamic chain from normal behavior to illegal consequences. Intermediate state relationships record the transitional relationship between two entities that does not occur directly but can be logically deduced. For example, although there is no direct "driving" relationship between "person" and "environmental facility", an indirect association can be established through "person-driving-vehicle-collision-environmental facility".
[0069] Candidate accident relationship types matching the current unreasonable relationship type are extracted from the accident relationship type knowledge base. Based on type matching and semantic coherence, the most reasonable candidate accident relationship type is selected: (person, driver, vehicle), and this is combined with the original unreasonable relationship to form a matching accident relationship type pair: [(vehicle, driver, person) - (person, driver, vehicle)]. The vector difference of this matching accident relationship type pair is calculated, which represents the semantic correction direction from the incorrect pattern to the correct pattern.
[0070] Step 513.2, based on the vector difference of matching accident relationship types, performs projection analysis on the accident relationship types of unreasonable triples to obtain accident knowledge reconstruction triples, including:
[0071] Step 513.21: Determine the directional consistency index based on the difference between the matching accident relationship type vectors and the accident evolution direction vector. The accident evolution direction vector is determined based on the accident evolution axis, which is used to indicate the degree of development of accident relationship types in the accident relationship type knowledge base.
[0072] The accident evolution axis is constructed based on a reasonable development sequence reflecting the dynamic evolution of events in the accident relationship type knowledge base, embodying the causal evolution path of an accident gradually escalating from normal behavior to serious consequences. To formalize this semantic trend, the semantic vector difference between the initial and final relationships in this sequence is defined as the accident evolution direction vector. This vector represents the main direction of increasing accident severity in the semantic space, i.e., the accident evolution axis.
[0073] The directional consistency index is obtained by calculating the angle between the vector difference and the cosine of the accident evolution direction vector.
[0074] , in, Represents the consistency index of direction (cosine angle). Represents vector difference, This represents the vector indicating the direction of accident evolution.
[0075] Step 513.22: If the direction consistency index is less than the direction consistency threshold, it means that the vector difference is consistent with the direction of the accident evolution axis.
[0076] Since the vector difference of typical directional errors is negatively correlated with the accident evolution axis during repair, the correction process involves reverse recovery of semantic logic, i.e., returning from the erroneous structure to the initial reasonable state, and its correlation is concentrated in the range of [-0.8, -0.5]. Therefore, the directional consistency threshold is set to -0.6. When the directional consistency index is greater than or equal to the directional consistency threshold, the automatic repair process is terminated, and manual review or removal of unreasonable triples is performed; when the directional consistency index is less than the directional consistency threshold, the next step is executed.
[0077] Step 513.23: Determine the semantic similarity between the accident relationship type of the unreasonable triplet and the accident relationship type of the predefined accident relationship type mapping table, and sort them from high to low to obtain the semantic similarity ranking result.
[0078] Step 513.24: Based on the semantic similarity ranking results, determine whether the accident relationship type in the predefined accident relationship type mapping table corresponding to the top X semantic similarities is a candidate accident relationship type; X is a positive integer greater than 1.
[0079] If the semantic similarity between the accident relationship type of an unreasonable triplet and the candidate accident relationship type does not exist in the first X semantic similarities, the automatic repair process is terminated, and manual review or removal of unreasonable triplets is initiated. Specifically, a semantic similarity of 0.8 is used as the basis for determining the accident relationship type in the accident relationship type mapping table corresponding to the first X semantic similarities; preferably, X ≥ 5.
[0080] Step 513.25: If yes, based on the predefined corpus, count the frequency of occurrence of unreasonable triples and the semantic coherence of the appended entities after the accident relationship type. If the frequency of occurrence and semantic coherence reach the target range and the grammar of the unreasonable triples is correct, replace the accident relationship type of the unreasonable triples with the candidate accident relationship type.
[0081] The corpus is constructed based on real traffic accident texts, including publicly available judgments, traffic police reports, news reports, and insurance claim records. After preprocessing steps such as text cleaning, entity recognition, and relation annotation, subject-verb-object structures and triplet patterns are extracted. The co-occurrence frequencies of various relations and entities are statistically analyzed, and semantic coherence is evaluated using a language model, ultimately forming a structured domain corpus. The target interval includes frequency intervals and coherence intervals. The frequency intervals include high-frequency intervals (greater than 1000 times), mid-frequency intervals (100-1000 times), and low-frequency intervals (less than 100 times), while the coherence interval is [0.6, 1].
[0082] Frequency of occurrence refers to the statistical frequency of triples appearing in real text within the constructed accident corpus. Only when similar error patterns or candidate relations are at or above the mid-frequency level are they considered to have a realistic basis and worth fixing. Semantic coherence not only assesses whether the sentence itself is fluent, but more importantly, it determines whether the triple can reasonably connect to the subsequent accident development path, that is, whether the tail entity is likely to cause subsequent typical consequences. For example, if the text contains results such as "vehicle out of control" or "collision with guardrail" after the triple (Zhang, fatigued driving, truck), it indicates that the relation has high semantic coherence; conversely, if the relation cannot connect to subsequent events (such as "Zhang driving the traffic light" without reasonable consequences), then the coherence is extremely low. The semantic coherence of sentences is calculated using a pre-trained language model. Only when the frequency is above the mid-frequency level, the semantic coherence score is ≥0.6, and the grammar is correct, does the context check pass, allowing unreasonable triples to be replaced with candidate accident relation types.
[0083] Step 513.3: Determine whether the semantics of the accident knowledge reconstruction triple is reasonable. If so, reassign the label to the accident knowledge reconstruction triple; otherwise, perform entity replacement analysis on the accident knowledge reconstruction triple to obtain the accident knowledge correction triple. Semantic analysis is achieved by combining a pre-trained embedding model with domain rule verification. First, the accident knowledge reconstruction triples are input into the model, and a scoring function score is calculated. This score reflects the semantic matching degree of the accident knowledge reconstruction triples in the vector space. If the score is higher than a target threshold, the structure is considered reasonable. Simultaneously, rule verification is performed: each relation has a predefined domain and range, representing its valid head entity type and tail entity type, respectively. For example, the domain of the relation "driving accident relation type" is "person" and the range is "vehicle." If the head entity is not of type "person" (e.g., "traffic light"), or the tail entity is not of type "vehicle" (e.g., "pedestrian"), the type constraint is violated. Furthermore, it checks for illegal combinations (e.g., "child" as the subject of "driving"). Only when the model score meets the threshold and the type constraints are satisfied is the structure considered semantically reasonable and proceeds to the labeling stage; otherwise, it is considered unreasonable, and the next candidate entity is tried for replacement until a reasonable triple is found or the candidate pool is exhausted. Ultimately, those that fail verification are eliminated.
[0084] Next, entity replacement analysis is performed on the accident knowledge reconstruction triples until the semantics are deemed reasonable or defined as unreasonable and removed. This mainly includes: querying the accident relationship type mapping table to determine the set of entity types allowed as head entities and tail entities for the accident relationship types of the accident knowledge reconstruction triples. The entity types of the head and tail entities of the accident knowledge reconstruction triples are compared with the entity type sets to determine the compliance of the entity types. Specifically, if the entity type of the head entity of the accident knowledge reconstruction triple does not exist in the set of allowed head entity entity types and / or the entity type of the tail entity does not exist in the set of allowed tail entity entity types, it means that the head entity and / or tail entity of the accident knowledge reconstruction triple are non-compliant.
[0085] Based on accident knowledge, the accident relationship types of triples are reconstructed and combined with the accident relationship type mapping table to determine the candidate entity set corresponding to non-compliant head entities and / or tail entities from the entity type set. For each candidate entity in the candidate entity set, a reasonable replacement index is calculated, and the non-compliant head entities and / or tail entities are replaced with candidate entities. The semantic vectors of each candidate entity and the non-compliant head entities and / or tail entities are obtained to calculate a semantic similarity index. If the semantic similarity index is less than 0.5, this embodiment considers that the candidate entity has a significant semantic difference from the non-compliant head entities and / or tail entities, and the current candidate entity is removed. If the semantic similarity index is greater than or equal to 0.5, the number of sentences based on the candidate entity triple structure is counted in the accident corpus and marked as a context co-occurrence index. Based on candidate entities and / or head or tail entities, target successor relations and target successor tail entities, a semantic retrieval template is constructed. Matching statements that satisfy the semantic search template are retrieved from the accident corpus. The number of matching statements is counted and marked as a path connectivity index. When the number of matching statements is greater than or equal to 3, the path connectivity index is defined as 1. When the number of matching statements is less than 3, the path connectivity index is defined as 0.
[0086] Finally, a reasonable replacement index is obtained by weighted summation of semantic similarity index, context co-occurrence index, and path connectivity index. The reasonable replacement index of each candidate entity is sorted in descending order, and non-compliant head entities and / or tail entities are replaced with candidate entities to obtain incident knowledge correction triplets. The incident knowledge correction triplets are substituted into the comprehensive function to calculate the comprehensive score, and the target threshold is used to determine whether the current incident knowledge correction triplet is a reasonable triplet. If it is not reasonable, the same process is used to check the next candidate entity. For all incident knowledge correction triplets that pass the check, the incident knowledge correction triplet composed of the candidate entity with the largest reasonable replacement index is selected as the final triplet. The remaining incident knowledge correction triplets that pass the check but are not selected are marked as alternative paths for interpretability tracing.
[0087] Step 513.4: Determine whether the semantics of the accident knowledge correction triplet are reasonable. If so, reallocate the label for the accident knowledge correction triplet; otherwise, determine that the accident knowledge reconstruction triplet is an unreasonable triplet and remove it.
[0088] If the head entity in the accident knowledge correction triplet appears for the first time in the main path, a starting boundary label HB-TB is assigned, indicating that it is the starting point of the path. If the head entity has already been labeled as HB-TB or HB-TE in other triplets, its original label is retained to ensure consistency across relations. For the tail entity, if it appears for the first time, an ending boundary label HE-TE is assigned. If the tail entity has already been labeled in the label matrix, its original label remains unchanged. To verify the hypothesis that introducing accident entity type information can improve the accident knowledge extraction effect, this embodiment constructs an accident entity type-free dataset that retains only relation-relation type accident knowledge triplets based on the original training and validation datasets. The evaluation metrics of the OneRel model's relation-relation type extraction results on this dataset are compared, as are the evaluation metrics of the OneRel model and the road traffic accident knowledge extraction method proposed in this embodiment on the original training and validation datasets containing entity-relation type accident knowledge triplets. The experimental results are shown in the table below.
[0089] Results of the experiment on the relationship before and after introducing accident entity types - relationship type accident knowledge triplet extraction
[0090] The experimental results in the table above show that adding entity-relationship type accident knowledge triples to the dataset, i.e., introducing accident entity type information, significantly improves the model's extraction performance for relation-relationship type accident knowledge triples in both the overall dataset and most types. Comparing the extraction results of the OneRel model on the two datasets, although the overall recall decreased from 92.7 to 92.3 after introducing accident entity type information, a decrease of 0.4, the overall precision increased from 88.5 to 91.0, an increase of 2.5. For some relation-relationship types that achieve better evaluation metrics without introducing accident entity type information, the recall rates for the "violation" and "collision" accident relation types are the highest, but the difference between them and the recall rates of other models is very small. For example, the recall rate of the "collision" accident relation type is 96.4, while the recall rate of this accident relation type in other models is 96.2, a difference of only 0.2, which can be considered within the error range of model training. The precision rate of the "negative" accident relation type is 3.6 higher than that of other models, but the recall rate of all models is 100.0. The reason for this phenomenon may be that the introduction of accident entity type information increases the complexity of model training. Although the model can still completely extract the target accident knowledge triples, it is also easy to extract more redundant triples, resulting in a decrease in precision.
[0091] The extraction results include three-pair pairs of type I and three-pair pairs of type II; three-pair pairs of type I are relation-relation pairs, and three-pair pairs of type II are entity-relation pairs. After obtaining the extraction results including knowledge triples, it also includes: For each head and tail incident entity that appears in the first type of triple, an incident entity node is created, where each incident entity node is uniquely identified by the entity name and stored in the graph database. Based on the first type of triplet, edges of type accident relationship are established between the corresponding accident entity nodes to generate an initial graph structure; Based on all the second-class triples, add an accident entity type attribute to the accident entity nodes with the same entity name in the graph database; Identify the incident entities that do not appear as head or tail entities in the first type of triples, create new incident entity nodes based on their names, and assign the incident entity type attribute according to the second type of triples.
[0092] like Figure 5 As shown, this embodiment also discloses a multi-source road traffic accident knowledge extraction system, including the following modules: Text extraction module 501: used to extract the text content from the original road traffic accident judgment and preprocess it, and to segment the preprocessed text content into multiple sentences; Sub-word segmentation module 502: used to determine the sine and cosine position encoding vectors of the head accident word unit and the tail accident word unit, and to fuse the sine and cosine position encoding vectors with the feature vectors of the head accident word unit and the tail accident word unit to generate the combined feature vector of the accident word unit. Feature fusion module 503: used to determine the sine and cosine position encoding vectors of the head accident lexical unit and the tail accident lexical unit, and to fuse the sine and cosine position encoding vectors with the feature vectors of the head accident lexical unit and the tail accident lexical unit to generate a combined feature vector of the accident lexical unit. Label matrix generation module 504: used to input the feature vector of accident vocabulary unit combination into the relation extraction model, and generate an accident knowledge triple label matrix for each predefined accident relation type; the predefined accident relation types include: entity-relation type and relation-relation type; Knowledge extraction module 505: is used to determine the joint feature vector based on the accident knowledge triplet label matrix, construct a comprehensive function based on the joint feature vector, assign labels to the accident knowledge triplet label matrix using the comprehensive function to obtain the accident knowledge triplet optimized label matrix, decode the accident knowledge triplet optimized label matrix to obtain the extraction result containing knowledge triplet.
[0093] To implement the above embodiments, this application also proposes an electronic device. Please see [link to relevant documentation]. Figure 6 , Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of this application. For example... Figure 6 As shown, the electronic device 600 includes: a processor 601, and a memory 602 communicatively connected to the processor 601; the memory 602 stores computer-executable instructions; the processor 601 executes the computer-executable instructions stored in the memory to implement the method provided in the foregoing embodiments.
[0094] To implement the above embodiments, this application also proposes a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided in the foregoing embodiments.
[0095] To implement the above embodiments, this application also proposes a computer program product, including a computer program that, when executed by a processor, implements the methods provided in the foregoing embodiments.
[0096] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0097] It should be noted that personal information collected from users should be used for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. Furthermore, such collection / sharing should only be conducted after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign an agreement / authorization that includes authorization of relevant user information before the user uses the function. In addition, any necessary steps must be taken to protect and safeguard access to such personal information data and ensure that others with access to personal information data comply with their policies and procedures.
[0098] This application is intended to provide an implementation scheme for users to selectively prevent the use or access to their personal information data. That is, this disclosure is intended to provide hardware and / or software to prevent or block access to such personal information data. Once personal information data is no longer needed, risks can be minimized by restricting data collection and deleting data.
[0099] In the foregoing descriptions of the embodiments, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0100] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0101] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0102] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0103] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0104] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0105] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0106] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for extracting knowledge about road traffic accidents from multiple sources, characterized in that, include: The text content of the original road traffic accident judgment is extracted and preprocessed. The preprocessed text content is then segmented into sentences to obtain multiple sentences. Each of the sentences is segmented into sub-words by a pre-trained language model to obtain a sub-word sequence. The head accident lexical unit and the tail accident lexical unit are determined based on the sub-word sequence. The head accident lexical unit feature vector and the tail accident lexical unit feature vector are generated according to the head accident lexical unit and the tail accident lexical unit, respectively. Determine the sine and cosine position encoding vectors of the head accident lexical unit and the tail accident lexical unit, and fuse the sine and cosine position encoding vectors with the feature vectors of the head accident lexical unit and the tail accident lexical unit to generate a combined feature vector of the accident lexical unit. The feature vector of the accident vocabulary unit combination is input into the relation extraction model to generate an accident knowledge triplet label matrix for each predefined accident relation type; the predefined accident relation types include: entity-relation type and relation-relation type. Based on the accident knowledge triplet label matrix, a joint feature vector is determined. Based on the joint feature vector, a synthesis function is constructed. The synthesis function is used to assign labels to the accident knowledge triplet label matrix to obtain an optimized accident knowledge triplet label matrix. The optimized accident knowledge triplet label matrix is then decoded to obtain the extraction result containing knowledge triplets.
2. The method for extracting multi-source road traffic accident knowledge according to claim 1, characterized in that, The training method for the relation extraction model includes: A training set is obtained based on multiple road traffic accident judgments, and triples consisting of entity boundaries, entity types and relationships are extracted from the multiple road traffic accident judgments. The triples are then converted into a label matrix. The training set is batch-input into the relation extraction model for prediction to obtain the prediction label matrix; Calculate the first loss value and the second loss value based on the label matrix and the prediction label matrix; Determine whether the entity type of the head entity and the entity type of the tail entity of the triple belong to the legal head entity type and legal tail entity type corresponding to the accident relationship type in the predefined accident relationship type mapping table, respectively. If yes, the entity type of the triple is determined to be a legal entity type and a penalty value of 0 is defined; otherwise, the entity type of the triple is determined to be a non-compliant entity type and a penalty value of A is defined, where A>0. A loss function is constructed based on the penalty value, the first loss value, and the second loss value, and the loss value is calculated. The parameters of the relation extraction model are then adjusted based on the loss value.
3. The method for extracting multi-source road traffic accident knowledge according to claim 1, characterized in that, The determination of the joint feature vector based on the accident knowledge triplet label matrix includes: Based on the accident knowledge triplet label matrix, determine the feature vector M for each accident vocabulary unit combination. T and the overall feature vector M of all accident vocabulary units combined in each row. R ; The feature vector M T The query vector is determined by the overall feature vector M. R Determine the key vector and value vector, and determine the attention weights based on the query vector, key vector, and value vector; By combining the attention weights and the value vector, an attention-weighted row feature vector is obtained; by combining the attention weights and the query vector, an attention-weighted column feature vector is obtained. The feature vector M T The attention-weighted row feature vectors and attention-weighted column feature vectors are added together to obtain the attention-weighted incident knowledge triplet label matrix. Based on the attention-weighted incident knowledge triplet labeling matrix, the attention-weighted head incident entity feature vector, the attention-weighted tail incident entity feature vector, and the incident entity type embedding vector are obtained respectively. A joint feature vector is obtained based on the attention-weighted head event entity feature vector, the attention-weighted tail event entity feature vector, and the event entity type embedding vector.
4. The method for extracting multi-source road traffic accident knowledge according to claim 3, characterized in that, The construction of the comprehensive function based on the joint feature vector includes: Based on a predefined accident relationship type mapping table, determine the reasonableness scoring items for accident relationship types; Based on the joint feature vector and the rationality scoring item, a comprehensive function is obtained, and the comprehensive score of the accident knowledge triple is calculated through the comprehensive function. If the overall score of the accident knowledge triplet is greater than or equal to the target threshold, the accident knowledge triplet is determined to be a reasonable triplet. If the overall score of the accident knowledge triple is less than the target threshold, the accident knowledge triple is judged as an unreasonable triple. The unreasonable triple is then subjected to semantic analysis and reconstruction to obtain the accident knowledge reconstruction triple, and a label is reassigned to the accident knowledge reconstruction triple.
5. The method for extracting multi-source road traffic accident knowledge according to claim 4, characterized in that, The semantic analysis and reconstruction of the unreasonable triples yields reconstructed accident knowledge triples, and the labels are reassigned to these reconstructed accident knowledge triples, including: Candidate accident relationship types that match the accident relationship types of the unreasonable triples are extracted from a predefined accident relationship type knowledge base. The candidate accident relationship types are combined with the accident relationship types of the unreasonable triples to form matching accident relationship types. The matching accident relationship type vector difference is determined. The accident relationship type knowledge base includes multiple accident relationship types. Based on the matching accident relationship type vector difference, the accident relationship type projection analysis of the unreasonable triplet is performed to obtain the accident knowledge reconstruction triplet. Determine whether the semantics of the accident knowledge reconstruction triplet are reasonable. If so, reassign the label to the accident knowledge reconstruction triplet; otherwise, perform entity substitution analysis on the accident knowledge reconstruction triplet to obtain the accident knowledge correction triplet. Determine whether the semantics of the accident knowledge correction triplet are reasonable. If so, the accident knowledge correction triplet is reassigned with a label. If not, the accident knowledge reconstruction triplet is determined to be an unreasonable triplet and is removed.
6. The method for extracting multi-source road traffic accident knowledge according to claim 5, characterized in that, The step of projecting the accident relationship type of the unreasonable triples based on the vector difference of the matched accident relationship types to obtain the accident knowledge reconstruction triples includes: Based on the difference between the matching accident relationship type vectors and the accident evolution direction vector, a directional consistency index is determined. The accident evolution direction vector is determined based on the accident evolution axis, which is used to indicate the degree of development of accident relationship types in the accident relationship type knowledge base. If the direction consistency index is less than the direction consistency threshold, it means that the vector difference is consistent with the direction of the accident evolution axis; Determine the semantic similarity between the accident relationship type of the unreasonable triplet and the accident relationship type of the predefined accident relationship type mapping table, and sort them from high to low to obtain the semantic similarity ranking result; Based on the semantic similarity ranking results, determine whether the accident relationship type in the predefined accident relationship type mapping table corresponding to the top X semantic similarities is a candidate accident relationship type; X is a positive integer greater than 1; If so, based on the frequency of occurrence of unreasonable triples and the semantic coherence of the entities following the accident relationship type according to the predefined corpus statistics, if the frequency of occurrence and semantic coherence reach the target range and the grammar of the unreasonable triples is correct, the accident relationship type of the unreasonable triples is replaced with the candidate accident relationship type.
7. The method for extracting multi-source road traffic accident knowledge according to claim 4, characterized in that, The joint feature vector is represented as follows: , in, Representing the head accident entity H and the tail accident entity B in a given accident relationship type The joint eigenvectors, The head event entity H represents the event with a given event relationship type. Attention-weighted head accident entity feature vector, Entity B, representing the tail event, in a given event relationship type Attention-weighted tail accident entity feature vector, The embedding vector representing the type of the head accident entity. The embedding vector represents the event entity type of the tail event entity, W1 represents the sixth weight matrix, and b represents the bias term. represents the activation function, Drop represents the random drop policy, and T represents the transpose.
8. The method for extracting multi-source road traffic accident knowledge according to claim 4, characterized in that, The synthesis function is expressed as follows: , Where f represents the overall score, and W2 represents the seventh weight matrix. Representing the head accident entity H and the tail accident entity B in a given accident relationship type Reasonableness scoring items Represents the adjustment factor. The value is 2, and T represents transpose processing.
9. The method for extracting multi-source road traffic accident knowledge according to claim 2, characterized in that, The loss function is expressed as follows: , in, Represents the loss function. Represents the first loss value. Represents the second loss value. This represents the penalty value.
10. The method for extracting multi-source road traffic accident knowledge according to claim 1, characterized in that, The extraction results include a first type of triplet and a second type of triplet; the first type of triplet is a relation-relation type triplet, and the second type of triplet is an entity-relation type triplet; After obtaining the extraction results including knowledge triples, it also includes: For each head and tail incident entity that appears in the first type of triple, an incident entity node is created, where each incident entity node is uniquely identified by the entity name and stored in the graph database. Based on the first type of triplet, edges of type accident relationship are established between the corresponding accident entity nodes to generate an initial graph structure; Based on all the second-class triples, add an accident entity type attribute to the accident entity nodes with the same entity name in the graph database; Identify the incident entities that do not appear as head or tail entities in the first type of triples, create new incident entity nodes based on their names, and assign the incident entity type attribute according to the second type of triples.
Citation Information
Patent Citations
Multi-triad joint extraction method based on knowledge graph embedding
CN111444305A
Knowledge graph completion method for automatically extracting relationship based on decision-making text
CN113204648A
Joint relation extraction method based on subtask division network
CN117252197A
Intelligent construction method for legal decision document knowledge graph based on big data
CN118410172A
Knowledge graph construction method and device for electric power operation text, medium and chip
CN118469006A
Cited By
Road intersection hidden danger diagnosis method based on adaptive map and multi-link reasoning
CN121724164A
A Road Intersection Hazard Diagnosis Method Based on Adaptive Graph and Multi-Link Inference
CN121724164B
