A multi-source road traffic accident knowledge extraction method and system

By using a multi-source road traffic accident knowledge extraction method, and reconstructing triples using entity-relation type constraints and comprehensive functions, the problems of error accumulation and insufficient entity type recognition in existing technologies are solved, and a highly robust knowledge graph construction is achieved.

CN120975099BActive Publication Date: 2026-01-23BEIJING PEOPLE'S POLICE COLLEGE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511500399.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-21
Publication Date
2026-01-23
Estimated Expiration
2045-10-21

AI Technical Summary

Technical Problem

Existing technologies for extracting knowledge from road traffic accidents suffer from problems such as error accumulation and insufficient entity type recognition. Pipeline methods lack correlation considerations, and joint extraction methods fail to effectively utilize the correlation between accident entities and relationships, leading to extraction errors and redundancy.

Method used

A multi-source road traffic accident knowledge extraction method is adopted. By preprocessing text, segmenting words, generating feature vectors, combining sine and cosine positional encoding and relation extraction models, introducing entity-relation type constraints, and using loss functions and comprehensive functions for triple labeling and reconstruction, a highly robust knowledge graph is constructed.

Benefits of technology

It significantly reduces mislabeling and omissions in triple extraction, improves the logical consistency and semantic integrity of knowledge graphs, and realizes the construction of high-quality knowledge from unstructured text to semantically clear text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120975099B_ABST
    Figure CN120975099B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of knowledge extraction, and discloses a multi-source road traffic accident knowledge extraction method and system, which comprises the following steps: determining a joint feature vector based on an accident knowledge triple tuple mark matrix, constructing a comprehensive function based on the joint feature vector, assigning marks to the accident knowledge triple tuple mark matrix by using the comprehensive function, obtaining an accident knowledge triple tuple optimization mark matrix, decoding the accident knowledge triple tuple optimization mark matrix, and obtaining an extraction result containing knowledge triple tuples. The application solves the problem of implicit error accumulation caused by semantic ambiguity in the model, realizes higher robustness of knowledge extraction, provides complete and reliable structured input for subsequent construction of nodes in a knowledge graph according to types, and truly realizes high-quality construction of a multi-source road traffic accident knowledge graph from unstructured text to semantic explicitness and logic consistency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of knowledge extraction, and in particular to a multi-source road traffic accident knowledge extraction method and system. BACKGROUND

[0002] Traditional road traffic accident extraction technology mainly adopts a pipeline extraction method to separate and execute two sub-tasks of accident entity recognition and accident relationship type extraction. This method is prone to error accumulation because errors in the former sub-task directly affect the results of the subsequent sub-task. In addition, the pipeline method does not effectively utilize the association and mutual constraints between accident entity recognition and accident relationship type extraction. For example, the head and tail entity types of the "driving" accident relationship type can only be "person" and "vehicle", while the "vehicle" and "person" entities can have "collision", "carrying" and other accident relationship types, but cannot have "education", "household registration" and other accident relationship types. The pipeline method lacks consideration of such associations and constraints, and is more likely to extract incorrect and redundant accident knowledge.

[0003] In the road traffic accident knowledge extraction technology, there are a few multi-module methods (such as CasRel) in the joint extraction method, which integrate accident entity recognition and accident relationship type extraction as two modules into the same model, but still need to identify a certain entity first and then predict another entity in combination with the accident relationship type within the model. There is still a lack of association mining between entities and relationships, and error accumulation cannot be completely avoided. The single-module joint extraction method (such as TPLinker and OneRel) commonly used in information extraction technology, although it realizes the simultaneous processing of entity recognition and relationship extraction in the same task, solves the problem of error accumulation, but if it is applied to the road traffic accident knowledge extraction task, this type of method cannot add accident entity type information to the method, and cannot identify the accident entity type. For example, for the accident description "Zhu Changyi drives a car", only the knowledge of [Zhu Changyi, driving, car] can be extracted, and the "Zhu Changyi" is "person" and the "car" is "vehicle type" cannot be identified. Since different types of accident nodes need to be established for different accident entities according to the accident entity type when building a road traffic accident knowledge graph, the problem of not being able to identify the accident entity type is unacceptable. SUMMARY

[0004] The embodiments of the present application provide a multi-source road traffic accident knowledge extraction method and system, which aims to at least solve one of the technical problems in the related art to some extent.

[0005] In a first aspect, the present application provides a multi-source road traffic accident knowledge extraction method, comprising:

[0006] Extract the text content in the original road traffic accident judgment and preprocess it, and perform sentence segmentation on the preprocessed text content to obtain multiple sentences;

[0007] Subword segmentation is performed on each of the sentences by a pre-trained language model to obtain a subword sequence, head and tail accident vocabulary units are determined based on the subword sequence, and a head accident vocabulary unit feature vector and a tail accident vocabulary unit feature vector are generated according to the head and tail accident vocabulary units respectively;

[0008] The head and tail accident vocabulary units are determined to obtain a positive and negative sine position encoding vector, and the positive and negative sine position encoding vector is fused with the head accident vocabulary unit feature vector and the tail accident vocabulary unit feature vector to generate an accident vocabulary unit combined feature vector;

[0009] The accident vocabulary unit combined feature vector is input into a relation extraction model to generate an accident knowledge triple tag matrix for each predefined accident relationship type; the predefined accident relationship type includes entity-relationship type and relationship-relationship type;

[0010] Based on the accident knowledge triple tag matrix, a joint feature vector is determined, a comprehensive function is constructed based on the joint feature vector, the comprehensive function is used to assign a label to the accident knowledge triple tag matrix to obtain an optimized accident knowledge triple tag matrix, and the optimized accident knowledge triple tag matrix is decoded to obtain an extraction result containing knowledge triples.

[0011] Further, the training method of the relation extraction model comprises:

[0012] A training set is obtained based on a plurality of road traffic accident judgments, and a triple including entity boundary, entity type and relationship is extracted from a plurality of the road traffic accident judgments, and the triple is converted into a label matrix;

[0013] The training set is batch input into a relation extraction model for prediction to obtain a predicted label matrix;

[0014] The first loss value and the second loss value are calculated based on the label matrix and the predicted label matrix;

[0015] It is determined whether the entity types of the head entity and the tail entity of the triple belong to the legal head entity type and the legal tail entity type corresponding to the accident relationship type in the predefined accident relationship type mapping table respectively, if yes, it is determined that the entity type of the triple is a legal entity type and the penalty value is defined as 0; if not, it is determined that the entity type of the triple is a violation entity type and the penalty value is defined as A, A>0;

[0016] Construct a loss function based on the penalty value, the first loss value and the second loss value and calculate a loss value, and adjust parameters of the relation extraction model based on the loss value.

[0017] Further, the joint feature vector is determined based on the accident knowledge triple labeling matrix, including:

[0018] According to the accident knowledge triple labeling matrix, a feature vector M of each accident vocabulary unit combination is determined T , and an overall feature vector M of all accident vocabulary unit combinations in each row is determined R .

[0019] A query vector is determined from the feature vector M T , a key vector and a value vector are determined from the overall feature vector M R , and an attention weight is determined according to the query vector, the key vector and the value vector.

[0020] The attention weighted row feature vector is obtained by combining the attention weight and the value vector, and the attention weighted column feature vector is obtained by combining the attention weight and the query vector.

[0021] The feature vector M T , the attention weighted row feature vector and the attention weighted column feature vector are added to obtain an attention weighted accident knowledge triple labeling matrix.

[0022] The attention weighted head accident entity feature vector, the attention weighted tail accident entity feature vector and the accident entity type embedding vector are obtained based on the attention weighted accident knowledge triple labeling matrix.

[0023] The joint feature vector is obtained according to the attention weighted head accident entity feature vector, the attention weighted tail accident entity feature vector and the accident entity type embedding vector.

[0024] Further, the comprehensive function is constructed based on the joint feature vector, including:

[0025] The rationality scoring item of the accident relation type is determined based on a pre-defined accident relation type mapping table.

[0026] The comprehensive function is obtained based on the joint feature vector and the rationality scoring item, and the comprehensive score of the accident knowledge triple is calculated through the comprehensive function.

[0027] If the comprehensive score of the accident knowledge triple is greater than or equal to a target threshold, the accident knowledge triple is determined as a reasonable triple.

[0028] If the comprehensive score of the accident knowledge triple is less than a target threshold, the accident knowledge triple is determined as an unreasonable triple, semantic analysis and reconstruction are performed on the unreasonable triple to obtain an accident knowledge reconstructed triple, and the accident knowledge reconstructed triple is re-assigned a label.

[0029] Further, the semantic analysis and reconstruction of the unreasonable triple to obtain an accident knowledge reconstructed triple, and the re-assignment of a label to the accident knowledge reconstructed triple, include

[0030] A candidate accident relationship type matching the accident relationship type of the unreasonable triple is extracted from a predefined accident relationship type knowledge base, the candidate accident relationship type and the accident relationship type of the unreasonable triple are combined as a matching accident relationship type, a matching accident relationship type vector difference is determined, and the accident relationship type knowledge base includes a plurality of accident relationship types.

[0031] Based on the matching accident relationship type vector difference, projection analysis is performed on the accident relationship type of the unreasonable triple to obtain an accident knowledge reconstructed triple.

[0032] It is determined whether the semantics of the accident knowledge reconstructed triple is reasonable, if yes, the accident knowledge reconstructed triple is re-assigned a label, if no, entity replacement analysis is performed on the accident knowledge reconstructed triple to obtain an accident knowledge modified triple.

[0033] It is determined whether the semantics of the accident knowledge modified triple is reasonable, if yes, the accident knowledge modified triple is re-assigned a label, if no, the accident knowledge reconstructed triple is determined as an unreasonable triple and is eliminated.

[0034] Further, the projection analysis of the accident relationship type of the unreasonable triple based on the matching accident relationship type vector difference to obtain an accident knowledge reconstructed triple includes

[0035] A direction consistency index is determined according to the matching accident relationship type vector difference and an accident evolution direction vector, the accident evolution direction vector is determined based on an accident evolution axis, and the accident evolution axis is used to indicate the development degree of the accident relationship type in the accident relationship type knowledge base.

[0036] If the direction consistency index is less than a direction consistency threshold, it represents that the vector difference is consistent with the direction of the accident evolution axis.

[0037] The semantic similarity of the accident relationship type of the unreasonable triple and the accident relationship type of a predefined accident relationship type mapping table is determined and is ranked from high to low to obtain a semantic similarity ranking result.

[0038] Based on the semantic similarity ranking result, it is judged whether the accident relationship type in the pre-defined accident relationship type mapping table corresponding to the top X semantic similarity is the candidate accident relationship type; X is a positive integer greater than 1;

[0039] If yes, according to the pre-defined corpus statistics, the occurrence frequency of the unreasonable triple and the semantic coherence of the tail entity after the accident relationship type, if the occurrence frequency and the semantic coherence reach the target interval and the syntax of the unreasonable triple is correct, the accident relationship type of the unreasonable triple is replaced by the candidate accident relationship type.

[0040] Further, the joint feature vector is represented as follows:

[0041] ,

[0042] Wherein, represents the joint feature vector of the head accident entity H and the tail accident entity B in the given accident relationship type , represents the attention weighted head accident entity feature vector of the head accident entity H in the given accident relationship type , represents the attention weighted tail accident entity feature vector of the tail accident entity B in the given accident relationship type , represents the accident entity type embedding vector of the head accident entity, represents the accident entity type embedding vector of the tail accident entity, W1 represents the sixth weight matrix, and b represents the bias term, represents the activation function, Drop represents the random drop strategy, and T represents the transpose processing.

[0043] Further, the comprehensive function is:

[0044] ,

[0045] Wherein, f represents the comprehensive score, W2 represents the seventh weight matrix, represents the rationality score item of the head accident entity H and the tail accident entity B in the given accident relationship type , represents the adjustment coefficient, is 2, and T represents the transpose processing.

[0046] Further, the loss function is represented as follows:

[0047] ,

[0048] Wherein, represents the loss function, represents the first loss value, representing a second loss value, representing a penalty value.

[0049] Further, the extraction result includes first type triplets and second type triplets; the first type triplets are triplets under the relationship-relation type, and the second type triplets are triplets under the entity-relation type;

[0050] After obtaining the extraction result including the knowledge triplets, the following is further included:

[0051] An accident entity node is created for each head accident entity and tail accident entity appearing in the first type triplets, wherein each accident entity node takes the entity name as a unique identifier and is stored in a graph database;

[0052] Based on the first type triplets, an edge of the accident relation type is established between the corresponding accident entity nodes to generate an initial graph structure;

[0053] According to all second type triplets, an accident entity type attribute is added to the accident entity nodes with the same entity name in the graph database;

[0054] An accident entity that does not appear as a head entity or a tail entity in the first type triplets is identified, and a new accident entity node is created based on the name, and an accident entity type attribute is assigned according to the second type triplets.

[0055] In a second aspect, the present application provides a multi-source road traffic accident knowledge extraction system, comprising:

[0056] A text extraction module is used to extract and preprocess the text content in the original road traffic accident judgment book, and the preprocessed text content is processed by sentence to obtain a plurality of sentences;

[0057] A subword segmentation module is used to segment the subwords of each sentence by a pre-trained language model to obtain a subword sequence, determine a head accident lexical unit and a tail accident lexical unit based on the subword sequence, and generate a head accident lexical unit feature vector and a tail accident lexical unit feature vector according to the head accident lexical unit and the tail accident lexical unit;

[0058] A feature fusion module is used to determine the positive and negative sine position encoding vectors of the head accident lexical unit and the tail accident lexical unit, fuse the positive and negative sine position encoding vectors with the head accident lexical unit feature vector and the tail accident lexical unit feature vector, and generate an accident lexical unit combined feature vector;

[0059] The label matrix generation module is configured to input the accident vocabulary unit combined feature vector into a relation extraction model, and generate an accident knowledge triple label matrix for each predefined accident relation type; the predefined accident relation type includes an entity-relation type and a relation-relation type.

[0060] The knowledge extraction module is configured to determine a joint feature vector based on the accident knowledge triple label matrix, construct a comprehensive function based on the joint feature vector, assign labels to the accident knowledge triple label matrix by using the comprehensive function to obtain an accident knowledge triple optimized label matrix, and decode the accident knowledge triple optimized label matrix to obtain an extraction result containing knowledge triples.

[0061] The embodiment of the application has the following technical effects:

[0062] The application introduces entity-relation type constraints into the accident knowledge triple label matrix explicitly, and fuses accident entity type embedding vectors in the joint feature vector, thereby fundamentally suppressing the error accumulation problem. When constructing the relation label matrix, the legal head-tail entity type combination associated with each accident relation type is preset as an accident relation type mapping table and is used as a constraint condition. In addition, when generating the head-tail entity joint representation, an entity type embedding vector is introduced, which is concatenated with the context semantic vector and jointly participates in relation prediction, so that the model not only analyzes whether the head entity and the tail entity coexist in the same relation scenario when judging the triple, but also verifies whether the entity belongs to the corresponding entity type, thereby significantly enhancing the model's ability to distinguish error candidates. Further, by adding a penalty term to the loss function, the model continuously learns the legal type path during the training process, thereby strengthening the consistency between the type and the relation. Therefore, not only the advantage of avoiding external error transmission is achieved, but also the implicit error accumulation caused by semantic ambiguity in the model is solved through the embedded type information guidance, thereby achieving more robust knowledge extraction. Complete and reliable structured input is provided for subsequent construction of nodes in the knowledge graph according to the type, and high-quality construction of a multi-source road traffic accident knowledge graph from unstructured text to semantic explicit and logically consistent is truly achieved.

[0063] 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

[0064] 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:

[0065] Figure 1 This is a flowchart of a multi-source road traffic accident knowledge extraction method provided in an embodiment of the present invention;

[0066] 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;

[0067] 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;

[0068] 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.

[0069] 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;

[0070] Figure 6 This is a block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0071] Embodiments of the present application are described below in detail with reference to the accompanying drawings, examples of which are shown in the drawings, wherein the same or similar notations represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by reference to the drawings are exemplary and are intended to explain the present application, and cannot be understood as limiting the present application.

[0072] A multi-source road traffic accident knowledge extraction method and system are described below with reference to the accompanying drawings.

[0073] Figure 1 A flowchart of a multi-source road traffic accident knowledge extraction method provided by an embodiment of the present application.

[0074] It should be noted that the execution subject of the multi-source road traffic accident knowledge extraction method of the embodiments of the present application is the multi-source road traffic accident knowledge extraction system of the embodiments of the present application, which can be configured in an electronic device to enable the electronic device to perform the multi-source road traffic accident knowledge extraction function.

[0075] As shown in Figure 1 The multi-source road traffic accident knowledge extraction method includes the following steps:

[0076] Step 1, extracting the text content in the original road traffic accident judgment book and performing preprocessing, performing sentence processing on the preprocessed text content, and obtaining a plurality of sentences.

[0077] The text content directly related to the accident fact is extracted from the original road traffic accident judgment book, and the descriptive paragraphs describing the accident process, the behavior of the parties, the state of the vehicle and the scene environment, such as “the driver drives the vehicle to collide with another vehicle at a certain road section” and other specific fact descriptions, are mainly retained; non-factual content such as legal provisions, court procedural statements, and responsibility determination conclusions are removed, and the retained text is uniformly formatted and standardized; then, based on the syntactic boundary recognition ability of the Chinese natural language processing tool, combined with the punctuation symbol and semantic integrity judgment, the preprocessed text is divided into sentences, and a plurality of independent sentences with complete semantics are generated.

[0078] Step 2, performing subword segmentation on each sentence by a pre-trained language model to obtain a subword sequence, determining a head accident vocabulary unit and a tail accident vocabulary unit based on the subword sequence, and generating a head accident vocabulary unit feature vector and a tail accident vocabulary unit feature vector according to the head accident vocabulary unit and the tail accident vocabulary unit.

[0079] The preprocessed sentence is input into the pre-trained Chinese language model (BERT) in sequence, the sentence is sub-word segmented, and a sub-word sequence is obtained, wherein each Chinese character is a sub-word, and each sub-word is taken as a lexical unit. Taking the sentence containing key accident information "Zhu Changyi drove a black car" as an example, the WordPiece algorithm is used for segmentation according to the segmentation specification of BERT, and a [CLS] mark is added at the beginning of the sentence and a [SEP] mark is added at the end of the sentence, and the part less than the maximum length (set to 128) is filled with [PAD]. Finally, the sub-word sequence is obtained as: ["[CLS]", "Zhu", "Chang", "Yi", "drove", "a", "black", "car", "[SEP]"]. The sub-word sequence is input into the BERT model to obtain the context feature vector corresponding to each lexical unit in the sequence.

[0080] On this basis, the head accident entity and the tail accident entity in the sentence are identified by the named entity recognition module, and the head accident lexical unit and the tail accident lexical unit are determined. Specifically, first, the start position and the end position of the head accident entity and the tail accident entity in the sub-word sequence are located. For the head accident entity "Zhu Changyi", the start position is 1 and the end position is 3 in the sub-word sequence, so the lexical units covered by it are "Zhu", "Chang", and "Yi", and these three lexical units jointly constitute the head accident lexical unit. For the tail accident entity "car", the start position is 10 and the end position is 11, so the lexical units covered by it are "car" and "car", and these two lexical units jointly constitute the tail accident lexical unit.

[0081] The context feature vectors corresponding to "Zhu", "Chang", and "Yi" in the head accident lexical unit are averaged element by element to obtain a vector with the same dimension as the head accident lexical unit feature vector; similarly, the context feature vectors corresponding to "car" and "car" in the tail accident lexical unit are averaged element by element to obtain the tail accident lexical unit feature vector.

[0082] Step 3, determine the head accident lexical unit and the tail accident lexical unit, and fuse the head accident lexical unit feature vector and the tail accident lexical unit feature vector to generate the accident lexical unit combination feature vector.

[0083] Before generating the combined feature vectors of accident vocabulary units, 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, standard sine and cosine functions are used to generate absolute position encoding vectors for each vocabulary unit. Subsequently, they are added to the feature vectors of the corresponding vocabulary units and used as the input to the BERT model, enabling the model to perceive the position of each vocabulary unit when encoding context information. Further, triple position encoding vectors for relationship modeling are generated: 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 feature vectors of the head accident vocabulary unit and the tail accident vocabulary unit, they are concatenated with the aforementioned triple position encoding vectors to form high-dimensional combined feature vectors of accident vocabulary units.

[0084] Step 4: Input the combined feature vectors of accident vocabulary units 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.

[0085] 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:

[0086] 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;

[0087] Input the training set into the relation extraction model in batches for prediction to obtain a predicted label matrix;

[0088] Calculate the first loss value and the second loss value based on the label matrix and the predicted label matrix;

[0089] Judge whether the entity types of the head entity and the tail entity of the triple respectively belong to the legal head entity types and legal tail entity types corresponding to the accident relation types in the predefined accident relation type mapping table. If so, determine that the entity type of the triple is a legal entity type and define the penalty value as 0; if not, determine that the entity type of the triple is an illegal entity type and define the penalty value as A, where A > 0;

[0090] Construct a loss function based on the penalty value, the first loss value, and the second loss value and calculate the loss value, and adjust the parameters of the relation extraction model based on the loss value.

[0091] In some embodiments, the relation extraction model is preferably OneRel model. First, define the accident sentence , t represents a lexical unit in the accident sentence, and L represents the number of lexical units in the accident sentence. The set of accident relation types , represents the Kth accident relation type, and K represents the number of accident relation types. For the combination of accident lexical units [t i ,t j ] in the accident knowledge triple label matrix of the accident relation type , the true label classification score is represented as , and the model classification score is represented as , wherein t i, t j ∈L, t i is the i th lexical unit (head entity) in the accident sentence, and t j is the j th lexical unit (tail entity) in the accident sentence.

[0092] Secondly, calculate the first loss value L1: ;

[0093] Thirdly, calculate the second loss value L2 based on the FocalLoss mechanism: ;

[0094] Finally, according to the first loss value L1, the second loss value L2 and the penalty value , the loss function is constructed: ;

[0095] Wherein, represents the loss function, represents the first loss value, represents the second loss value, represents the penalty value. is a balance factor, , is the label classification probability of the triple, is the focal adjustment probability.

[0096] Wherein, the definition process of the penalty value is as follows: a pre-defined accident relation type mapping table is defined, which defines the legal head entity type and tail entity type combination for each accident relation type. For example, the head entity type of the "driving" relation is "person", and the tail entity type is "vehicle". The head entity type of the "gender", "age", "occupation" and other attribute relations is "person". The tail entity type of the "vehicle type", "vehicle brand" and other attribute relations is "vehicle". The "collision" relation can exist between "vehicle-vehicle" or "vehicle-environment facilities" or "vehicle-person" and the like; "occurrence" is used for "accident-time" or "accident-place" and the like.

[0097] The definition process of the penalty value of the triple containing the illegal entity type is as follows: based on the pre-defined accident corpus, the first triple with the head entity as the tail entity and the tail entity as the head entity is identified; based on the first triple, the second triple of the head entity type and the tail entity type is screened, which is consistent with the accident relationship type mapping table; the number of the second triple with the head entity of the current accident knowledge triple as the tail entity in the second triple is taken as the forward reachability score based on the second triple; the number of the second triple with the tail entity of the current accident knowledge triple as the head entity is taken as the backward reachability score; the context matching degree is calculated based on the forward reachability score and the backward reachability score, and the penalty value is determined based on the context matching degree;

[0098]

[0099] wherein M is the matching degree, is the forward reachability score of the i-th head entity, is the backward reachability score of the j-th tail entity. In the process of generating the accident knowledge triple labeling matrix for each pre-defined accident relationship type, the entity types of different accident entities are obtained while extracting the accident knowledge triples, the accident entity type information is introduced into the task under the premise of ensuring the labeling strategy and the number of labeling categories unchanged, the interaction between the accident entities and the accident relationship types is enhanced, and the diversity and accuracy of the road traffic accident knowledge extraction results are improved.

[0100] The embodiment also designs a matrix form of road traffic accident knowledge triple labeling strategy, labels each element in the matrix as a different type to represent the start and end positions of the head and tail accident entities, and thus converts the accident knowledge triple extraction task into an accident matrix element labeling classification task. The specific labeling strategy is as follows:

[0101] The labeling strategy assigns a label to each element to represent whether the element corresponds to the start or end position of an entity, as shown in FIG. 1. For example: the accident knowledge triple labeling matrix labels the accident knowledge triple [Zhu Changyi, driving, car] existing in the accident description "Zhu Changyi drives a car" under the "driving" accident relationship type, wherein the label is divided into four categories: Figure 2

[0102] (1) HB-TB: represents the start boundary of the head accident entity and the tail accident entity, and in the example, the word unit combination [Zhu, car] is assigned a label "HB-TB";

[0103] ​​​(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 combination of the lexical units [zhu, che] is assigned the label "HB-TE";

[0104] (3) HE-TE: represents the end boundary of the head accident entity and the end boundary of the tail accident entity, in the example, the combination of the lexical units [yi, che] is assigned the label "HE-TE";

[0105] (4) Others: can be marked with any special symbol (such as "-"), indicating a non-accident knowledge triple lexical unit combination.

[0106] In order to extract the accident knowledge triples in the form of [head accident entity, accident relation type, tail accident entity] while obtaining the entity types of different accident entities, first, the accident relation 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 relation type named "vehicle-entity" is added, and a new accident knowledge triple [sedan, vehicle-entity, sedan] is added, which indicates that the entity type of "sedan" is "vehicle". In this embodiment, this accident relation type is named "entity-relation type", and other accident relation types are named "relation-relation type". For the entity-relation type, the same marking strategy is used as for other accident knowledge triples, and the corresponding accident knowledge triple marking matrix is shown in Table 2. Figure 3 By adding the entity-relation type, the accident entity type information is introduced into the task without changing the marking strategy and the number of marking categories, the interaction between the accident entity and the accident relation type is enhanced, and the diversity and accuracy of the road traffic accident knowledge extraction result are improved.

[0107] Suppose the accident relation type r K is an entity-relation type, for the accident knowledge triple marking matrix belonging to r K , the accident lexical unit combination [t p , t q ] in the pth row and the qth column indicates the start position of a certain accident entity, which is marked as HB-TB, then when the accident entity is the head accident entity or the tail accident entity in other relation-relation types r K-1 , the accident lexical unit combination [t K-1 , t q ] or [t x , t x ] in the pth row or the qth column of the relation-relation type r q marking matrix must also have the same marking HB-TB, and the specific corresponding relationship is shown in Table 3. Figure 4as shown.

[0108] Step 5, based on the accident knowledge triple tagging matrix, determine the joint feature vector, based on the joint feature vector, construct the comprehensive function, use the comprehensive function to assign labels to the accident knowledge triple tagging matrix, obtain the accident knowledge triple optimization tagging matrix, decode the accident knowledge triple optimization tagging matrix, and obtain the extraction result containing the knowledge triple.

[0109] In the entity-relation type accident knowledge triple tagging matrix of "vehicle type-entity", the label HB-TB located in the 5th row and the 1st column can express the starting position of the tail accident entity "car". In the relation-relation type accident knowledge triple tagging matrix of "driving", "car" is also the tail accident entity of the accident knowledge triple [Zhu Changyi, driving, car]. Obviously, the label HB-TB expressing the starting position of the tail accident entity is also located in the 5th row. According to this rule, for the element [t p ,t q ] in the entity-relation type accident knowledge triple tagging matrix, the attention weight of each row and each column in the overall feature vector of the relation-relation type accident knowledge triple tagging matrix can be calculated, so as to obtain the overall feature information of the pth row and the qth column in the relation-relation type accident knowledge triple tagging matrix by attention weighting. For the combination of accident vocabulary units in the relation-relation type accident knowledge triple tagging matrix, the attention weight of the corresponding row and column in the entity-relation type accident knowledge triple tagging matrix is calculated. This information interaction between the accident entity type and the accident relation type can not only complement each other in label classification, improve the recall rate of the model, but also make the extraction results of the two as consistent as possible, improve the accuracy of the model. However, attention calculation for each element in the matrix will greatly increase the memory occupation, therefore, the embodiment makes the following adjustment: the calculation dimension of the attention mechanism is raised from the element to the row and the column. For a certain row / column in the entity / relation-relation type tagging matrix, the attention weight and weighted value of each row / column in the corresponding relation / entity-relation type tagging matrix are calculated. In this way, the demand of the model for memory can be greatly reduced, and the extraction efficiency can be improved.

[0110] Based on the accident knowledge triple tagging matrix, the joint feature vector is determined, including:

[0111] Step 501, according to the accident knowledge triple tagging matrix, determine the feature vector M T of each accident vocabulary unit combination and the overall feature vector M R。

[0112] M T =M×W T, M R =M x W R ; wherein M is generating an accident knowledge triple label matrix for each predefined accident relationship type, W T is a first weight matrix, and W R is a second weight matrix.

[0113] Step 502, determining a query vector from the feature vector M T , determining a key vector and a value vector from the overall feature vector M R , and determining an attention weight according to the query vector, the key vector and the value vector.

[0114] The query vector Q T is an overall feature vector combining all accident vocabulary units in each row, which is mapped to Query space through linear transformation, and is prepared for subsequent attention calculation with the key vector K R and the value vector V R ; Q T =M T x W q , K R =M R x W k , and V R =M R x W v ; W q is a third weight matrix, W k is a fourth weight matrix, and W v is a fifth weight matrix. The scaled dot-product attention weight is calculated by the query vector Q T , the key vector K R and the value vector V R :

[0115] ,

[0116] wherein, is the attention weight, T is the transpose operation, and d k is the dimension of the key vector K R .

[0117] Step 503, combining the attention weight with the value vector to obtain an attention weighted row feature vector, and combining the attention weight with the query vector to obtain an attention weighted column feature vector.

[0118] Combining the attention weight with the value vector to obtain an attention weighted row feature vector, and combining the attention weight with the query vector to obtain an attention weighted column feature vector.

[0119] The attention weight and the value vector V RPerform matrix multiplication to obtain attention-weighted row eigenvectors. , Perform the same operation along the column dimension to obtain the attention-weighted column feature vector. .

[0120] 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.

[0121] 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 .

[0122] 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.

[0123] 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.

[0124] 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," etc.); then, a trainable embedding matrix is ​​initialized. For the head and tail entities of any triple, based on their pre-labeled types (such as "Zhang Mou" belonging to "person," and "car" belonging to "vehicle"), the corresponding embedding vector is retrieved from the embedding matrix by looking up the ID corresponding to that 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.

[0125] 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.

[0126] The joint eigenvector is represented as follows:

[0127] ,

[0128] 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.

[0129] The traditional joint feature vector only relies on the semantic representation of the lexical unit, although it can capture local context information, but lacks prior constraints on the semantic roles of entities. To this end, the entity type information of the head and tail entities is added to the traditional joint feature vector to form the joint feature vector of the embodiment. By introducing the embedding representation of the head entity and the tail entity type, the model not only obtains the semantic features at the lexical level, but also integrates structured domain knowledge, so as to more accurately determine which entity combination is legal under a specific accident relationship type. For example, the "driving" relationship requires the head entity to be "person" and the tail entity to be "vehicle". If the model only relies on the surface features of the text, it may misjudge due to ambiguous expression or omission of the subject; but when the entity type information is explicitly encoded into the feature vector, the model can effectively exclude unreasonable combinations such as "vehicle-driving-person" through type matching mechanism, and improve the classification accuracy.

[0130] Based on the joint feature vector, a comprehensive function is constructed, including:

[0131] In step 511, based on the pre-defined accident relationship type mapping table, the rationality score item of the accident relationship type is determined.

[0132] The accident relationship type rationality score item is determined by judging whether 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, then the accident relationship type rationality score item is assigned +1.0, indicating that the triple completely conforms to the legal mode 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, then the accident relationship type rationality score item is assigned -10.0. In this case, the triple seriously violates common sense or law, and belongs to an impossible relationship, such as "pedestrian driving a truck", "person suspected of flying", etc. If the direction of the triple is wrong (such as "car driving person"), then the accident relationship type rationality score item is assigned -5.0. This case is obviously not logical and needs to be corrected.

[0133] The traffic accident field has the characteristics of high structure and strong rules. Many relationships are strictly limited by physical laws, legal provisions and human common sense, and cannot be inferred only by the surface semantics of the text. By setting a clear and reasonable scoring system, this embodiment can accurately distinguish between illegal, incorrect and compliant triples in the scoring stage. On the one hand, it greatly reduces the risk of generating triples that violate common sense due to context ambiguity or training data noise; on the other hand, among multiple candidate relationships, it can prioritize legal combinations that comply with domain specifications, effectively guiding the model from language similarity to logical correctness. Especially when dealing with omitted subjects, inverted sentences or non-standard expressions, this explicit judgment mechanism based on predefined rules makes up for the shortcomings of pure data-driven methods in semantic depth understanding, achieving collaborative optimization of knowledge guidance and model learning, and significantly enhancing the reliability, explainability and practicality of accident knowledge graph construction.

[0134] Step 512, based on the joint feature vector and the rationality score item, a comprehensive function is obtained, and the comprehensive score of the accident knowledge triple is calculated through the comprehensive function.

[0135] The comprehensive function is:

[0136]

[0137] Where f represents the comprehensive score, W2 represents the seventh weight matrix, represents the rationality score item of the head accident entity H and the tail accident entity B in the given accident relationship type , represents the adjustment coefficient, is 2, and T represents the transpose processing.

[0138] Step 513, if the comprehensive score of the accident knowledge triple is greater than or equal to the target threshold, the accident knowledge triple is determined to be a reasonable triple; if the comprehensive score of the accident knowledge triple is less than the target threshold, the accident knowledge triple is determined to be an unreasonable triple, the accident knowledge triple is reconstructed through semantic analysis and reconstruction, and the accident knowledge reconstructed triple is obtained. And the accident knowledge reconstructed triple is re-assigned a label.

[0139] The target threshold is composed of two sub-thresholds Tvec and Trule. Only when the joint feature vector and the rationality score item meet the sub-thresholds respectively, the accident knowledge triple is determined to be reasonable, otherwise it is considered to be unreasonable and triggers the subsequent semantic repair mechanism.

[0140] ​wherein the determination of Tvec depends on the analysis of the output distribution of the model on the validation set: by performing forward reasoning on a large number of labeled reasonable and unreasonable triples, the score distribution of the joint feature vector is counted, and it is found that the joint feature vector of the reasonable triple is mostly concentrated in the interval [0.5, 5.0], while the unreasonable triple is widely distributed in [-3.0, 2.0], especially below 0 in the case of direction error or type mismatch; therefore, Tvec is set to 0, which means that the model must give non-negative support to the semantic matching of entities and relations to enter the next round of judgment, thereby filtering out triples with obvious semantic conflicts. At the same time, the setting of Trule depends on the rule system in the accident relationship type knowledge base: since the value of the reasonableness score item is defined as +1.0, -5.0 and -10.0, by introducing a regulation coefficient, the rule item can be amplified to {-20.0, -10.0, +2.0}; on this basis, Trule is set to -1.0, which means that as long as the reasonableness score item is -10, less than Trule, no matter how high the model confidence is, the triple will be directly rejected, embodying the safety design principle of rule priority. Finally, the target threshold is: when the joint feature vector is greater than or equal to Tvec and the reasonableness score item is greater than or equal to Trule, the triple is considered reasonable; otherwise, if either condition is not met, it is determined to be an unreasonable triple.

[0141] wherein the semantic analysis and reconstruction are performed on the unreasonable triple to obtain an accident knowledge reconstruction triple, and the accident knowledge reconstruction triple is re-assigned a label, including.

[0142] Step 513.1, extracting a candidate accident relationship type matching the accident relationship type of the unreasonable triple from a pre-defined accident relationship type knowledge base, combining the candidate accident relationship type and the accident relationship type of the unreasonable triple into a matching accident relationship type, determining a matching accident relationship type vector difference, the accident relationship type knowledge base including a plurality of accident relationship types.

[0143] The accident relationship type knowledge base is semantically expanded based on an accident relationship type mapping table to form a semantic vector containing the development path and intermediate state relationship of the accident relationship type. The development path of the accident relationship type describes the reasonable evolution sequence of a certain relationship in the accident evolution process, for example, "driving, fatigue driving, operation error, collision, escape", forming a dynamic chain from normal behavior to illegal consequences. The intermediate state relationship records the transition relationship that is not directly occurred but can be logically deduced between two entities, for example, there is no direct "driving" relationship between "person" and "environmental facilities", but an indirect association can be established through "person-driving-vehicle-collision-environmental facilities".

[0144] Extract the candidate accident relation type matching the current unreasonable relation type from the accident relation type knowledge base. Based on type matching and semantic coherence, the most reasonable candidate accident relation type is selected: (person, drive, vehicle), and combined with the original unreasonable relation to form a matching accident relation type pair: [(vehicle, drive, person) - (person, drive, vehicle)], and the vector difference of the matching accident relation type pair is calculated, representing the semantic correction direction from the error mode to the correct mode.

[0145] Step 513.2, based on the matching accident relation type vector difference, the accident relation type of the unreasonable triple is projected and analyzed, and the accident knowledge reconstruction triple is obtained, including:

[0146] Step 513.21, according to the matching accident relation type vector difference and the accident evolution direction vector, determine the direction consistency index, the accident evolution direction vector is determined based on the accident evolution axis, and the accident evolution axis is used to indicate the development degree of the accident relation type in the accident relation type knowledge base.

[0147] The construction of the accident evolution axis is based on the reasonable development sequence reflecting the dynamic evolution of the event in the accident relation type knowledge base, which embodies the causal evolution path of the accident from normal behavior to serious consequences. To formalize this semantic trend, the semantic vector difference between the start relation and the end relation in the sequence is defined as the accident evolution direction vector. This vector represents the main direction of the increase in accident severity in the semantic space, i.e. the accident evolution axis.

[0148] The direction consistency index is calculated by calculating the cosine angle between the vector difference and the accident evolution direction vector.

[0149] ,

[0150] Where, represents the direction consistency index (cosine angle), represents the vector difference, represents the accident evolution direction vector.

[0151] 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 accident evolution axis.

[0152] Since the typical directional error is negatively related to the accident evolution axis when it is repaired, the correction process is a reverse recovery of semantic logic, i.e. from the error structure back to the initial reasonable state, and the correlation is concentrated in the [-0.8, -0.5] interval. Therefore, the direction consistency threshold is set to -0.6. When the direction consistency index is greater than or equal to the direction consistency threshold, the automatic repair process is terminated, and manual review or elimination of unreasonable triples is performed; when the direction consistency index is less than the direction consistency threshold, the next step is performed.

[0153] Step 513.23, determine the semantic similarity of the accident relation type of the unreasonable triple with the accident relation types in the predefined accident relation type mapping table, and sort from high to low to obtain a semantic similarity sorting result.

[0154] Step 513.24, based on the semantic similarity sorting result, judge whether the accident relation types corresponding to the top X semantic similarities in the predefined accident relation type mapping table are candidate accident relation types; X is a positive integer greater than 1.

[0155] If the semantic similarity of the accident relation type of the unreasonable triple and the candidate accident relation type does not exist in the top X semantic similarities, terminate the automatic repair process, and manually review or eliminate the unreasonable triple. Among them, the semantic similarity of 0.8 is used as the basis for judging the accident relation types in the accident relation type mapping table corresponding to the top X semantic similarities, and preferably X≥5.

[0156] Step 513.25, if yes, according to the predefined corpus, the occurrence frequency of the unreasonable triple and the semantic coherence of the tail entity after the accident relation type, if the occurrence frequency and the semantic coherence reach the target interval and the syntax of the unreasonable triple is correct, replace the accident relation type of the unreasonable triple with the candidate accident relation type.

[0157] The construction of the corpus is based on real traffic accident texts, including public judgments, police reports, news reports, and insurance claims records, etc. After preprocessing steps such as text cleaning, entity recognition and relationship annotation, the subject-predicate-object structure and triple pattern are extracted, the co-occurrence frequency of various relations and entities is counted, and the semantic coherence is evaluated using a language model, finally forming a structured domain corpus. Among them, the target interval includes the frequency interval and the coherence interval. The frequency interval includes the high frequency interval (more than 1000 times), the medium frequency interval (100-1000 times) and the low frequency interval (less than 100 times), and the coherence interval is [0.6, 1].

[0158] The frequency of occurrence refers to the statistical frequency of the triplet in the real text in the constructed accident corpus. Only when the similar error pattern or candidate relationship belongs to medium frequency and above, it is considered to have a realistic basis and is worth repairing. Semantic coherence not only evaluates whether the sentence itself is smooth, but more importantly, it judges whether the triplet can be reasonably connected to the subsequent accident development path, i.e., whether the tail entity can trigger subsequent typical consequences. For example, after the triplet (Zhang, fatigue driving, truck), if the text appears "vehicle out of control" "hit the guardrail" and other results, it means that the relationship has high semantic coherence; on the contrary, if the relationship cannot be connected to the subsequent event (such as "Zhang drives the traffic light"), there is no reasonable consequence, and the coherence is very low. The semantic coherence of the sentence is calculated by pre-training the language model. Only when the frequency is above medium frequency, the semantic coherence score is ≥0.6, and the grammar is correct, the context test passes, allowing the unreasonable triplet to be replaced by the candidate accident relationship type.

[0159] Step 513.3, judge whether the semantic of the accident knowledge reconstruction triplet is reasonable, if yes, then reassign the label to the accident knowledge reconstruction triplet; if not, then perform entity replacement analysis on the accident knowledge reconstruction triplet to obtain an accident knowledge modified triplet;

[0160] Semantic analysis is achieved by combining pre-trained embedding models and domain rule verification. First, input the accident knowledge reconstruction triplet into the model, calculate the scoring function score, which reflects the semantic matching degree of the accident knowledge reconstruction triplet in the vector space. If the score is higher than the target threshold, it is considered to be structurally reasonable. At the same time, rule verification is performed: each relationship has a predefined domain and value domain, representing its legal head entity type and tail entity type, for example, the domain of the relationship "driving accident relationship type" is "person", and the value domain is "vehicle". If the head entity is not of the "person" type (such as "traffic light"), or the tail entity is not of the "vehicle" type (such as "pedestrian"), it violates the type constraint; in addition, it also checks whether it involves illegal combination (such as "child" as the subject of "driving"). Only when the model score meets the standard and the type constraint is satisfied, it is determined to be semantically reasonable and enters the label assignment stage; otherwise, it is determined to be unreasonable and will try to replace the next candidate entity until a reasonable triplet is found or the candidate pool is exhausted, and finally the one that cannot pass the verification is eliminated.

[0161] Next, entity replacement analysis is performed on the accident knowledge reconstruction triple until the semantics are reasonable or defined as unreasonable and removed, mainly including: querying the accident relationship type mapping table to determine the entity type set allowed as the head entity and the entity type set of the tail entity of the accident knowledge reconstruction triple. The entity type of the head entity and the entity type of the tail entity of the accident knowledge reconstruction triple are compared with the entity type set to determine the compliance of the entity type. Among them, if the entity type of the head entity of the accident knowledge reconstruction triple does not exist in the allowed head entity entity type set and / or the tail entity does not exist in the allowed tail entity entity type set, it represents that the head entity and / or tail entity of the accident knowledge reconstruction triple is not compliant.

[0162] According to the accident relationship type of the accident knowledge reconstruction triple and in combination with the accident relationship type mapping table, the candidate entity set corresponding to the non-compliant head entity and / or tail entity is determined from the entity type set. For each candidate entity in the candidate entity set, calculate the reasonable replacement index, and replace the non-compliant head entity and / or tail entity with the candidate entity. Get the semantic vector of each candidate entity and the non-compliant head entity and / or tail entity to calculate the semantic similarity index. If the semantic similarity index is less than 0.5, the embodiment considers that there is a large semantic difference between the candidate entity and the non-compliant head entity and / or tail entity, 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 triple structure of the candidate entity is counted in the accident corpus, and is marked as the context co-occurrence index. Based on the candidate entity and / or head entity or tail entity, the target successor relationship and the target successor tail entity, a semantic search template is constructed, and matching sentences that meet the semantic search template are searched in the accident corpus. The number of matching sentences is counted and marked as the path connectivity index. When the number of matching sentences is greater than or equal to 3, the path connectivity index is defined as 1, and when the number of matching sentences is less than 3, the path connectivity index is defined as 0.

[0163] Finally, the reasonable replacement index is obtained by weighted summation according to the semantic similarity index, the context co-occurrence index and the path connectivity index. The reasonable replacement index of each candidate entity is arranged in descending order, and the non-compliant head entity and / or tail entity is replaced with the candidate entity to obtain the accident knowledge modification triple. The accident knowledge modification triple is substituted into the comprehensive function to calculate the comprehensive score, and the target threshold is used to determine whether the current accident knowledge modification triple is a reasonable triple. If not, the same process is used to test the next candidate entity. For all accident knowledge modification triples that pass the test, the accident knowledge modification triple composed of the candidate entity with the largest reasonable replacement index is selected as the final triple, and the remaining accident knowledge modification triples that pass the test but are not selected are marked as alternative paths for traceability.

[0164] Step 513.4, judging whether the semantics of the accident knowledge revision triple is reasonable, if yes, reassigning the mark for the accident knowledge revision triple; if no, determining that the accident knowledge reconstruction triple is an unreasonable triple and eliminating it.

[0165] If the head entity in the accident knowledge revision triple first appears in the main path, assign a start boundary mark HB-TB, indicating that it is the starting point of the path; if the head entity has been marked as HB-TB or HB-TE in other triples, the original mark is used to ensure the consistency of cross relations; for the tail entity, if it is first appeared, assign an end boundary mark HE-TE; if the tail entity has been marked in the mark matrix, keep the original mark unchanged. To verify the assumption that introducing accident entity type information can improve the effect of accident knowledge extraction, the present embodiment constructs an accident entity type-free data set that only retains relation-relation type accident knowledge triples based on the original training and verification data set, compares the evaluation indicators of the relation-relation type extraction results of the OneRel model on this data set, and the evaluation indicators of the relation-relation type extraction results of the OneRel model and the road traffic accident knowledge extraction method proposed in the present embodiment on the original training and verification data set containing entity-relation type accident knowledge triples, and the experimental results are shown in the following table.

[0166] Extraction experimental results of relation-relation type accident knowledge triples before and after introducing accident entity type

[0167]

[0168] According to the experimental results in the above table, it is shown that after adding entity-relation type accident knowledge triples to the data set, that is, introducing accident entity type information, the extraction effect of the model on the relation-relation type accident knowledge triples is obviously improved in the overall and most types. Only the extraction results of the OneRel model on the two data sets are compared. Although the overall recall rate decreased from 92.7 to 92.3, a decrease of 0.4, after the introduction of accident entity type information, the overall precision rate increased from 88.5 to 91.0, an increase of 2.5. For some relation-relation types that have better evaluation indicators without introducing accident entity type information, the recall rate of “violation” and “collision” accident relation types is the highest, but the difference between the recall rate and other models is very small. For example, the recall rate of the “collision” accident relation type is 96.4, while the recall rate of other models is 96.2, only 0.2 apart, which can be considered within the error range of model training; the precision rate of the “liable” accident relation type is 3.6 higher than that of other models, but the recall rate of all models is 100.0, which may be the reason for the introduction of accident entity type information, which 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 rate.

[0169] The extraction result includes first type triples and second type triples; the first type triples are relation-relation type triples, and the second type triples are entity-relation type triples;

[0170] After obtaining the extraction result including the knowledge triples, the following is also included:

[0171] An accident entity node is created for each head accident entity and tail accident entity appearing in the first type triples, wherein each accident entity node takes the entity name as a unique identifier and is stored in a graph database;

[0172] Based on the first type triples, edges of the accident relation type are established between the corresponding accident entity nodes to generate an initial graph structure;

[0173] According to all second type triples, an accident entity type attribute is added to the accident entity nodes with the same entity name in the graph database;

[0174] An accident entity that does not appear as a head entity or a tail entity in the first type triples is identified, and a new accident entity node is created based on the name, and an accident entity type attribute is assigned according to the second type triples.

[0175] As shown in Figure 5 The embodiment also discloses a multi-source road traffic accident knowledge extraction system, which comprises the following modules:

[0176] The text extraction module 501 is configured to extract text content in the original road traffic accident judgment and perform preprocessing, perform sentence segmentation on the preprocessed text content, and obtain a plurality of sentences.

[0177] The subword segmentation module 502 is configured to determine the positive sine position encoding vectors of the head accident vocabulary unit and the tail accident vocabulary unit, fuse the positive sine position encoding vectors with the head accident vocabulary unit feature vector and the tail accident vocabulary unit feature vector, and generate the accident vocabulary unit combined feature vector.

[0178] The feature fusion module 503 is configured to determine the positive sine position encoding vectors of the head accident vocabulary unit and the tail accident vocabulary unit, fuse the positive sine position encoding vectors with the head accident vocabulary unit feature vector and the tail accident vocabulary unit feature vector, and generate the accident vocabulary unit combined feature vector.

[0179] The label matrix generation module 504 is configured to input the accident vocabulary unit combined feature vector into a relation extraction model, and generate an accident knowledge triple label matrix for each pre-defined accident relation type. The pre-defined accident relation type includes an entity-relation type and a relation-relation type.

[0180] The knowledge extraction module 505 is configured to determine a joint feature vector based on the accident knowledge triple label matrix, construct a comprehensive function based on the joint feature vector, assign a label to the accident knowledge triple label matrix using the comprehensive function, obtain an accident knowledge triple optimized label matrix, and decode the accident knowledge triple optimized label matrix to obtain an extraction result containing a knowledge triple.

[0181] To achieve the above-mentioned embodiments, the present application further provides an electronic device. Please refer to Figure 6 , Figure 6 is a structural schematic diagram of the electronic device provided by the embodiments of the present application. As shown in Figure 6 , the electronic device 600 includes a processor 601 and a memory 602 connected with the processor 601; the memory 602 stores computer execution instructions; the processor 601 executes the computer execution instructions stored in the memory to implement the method provided by the foregoing embodiments.

[0182] To achieve the above-mentioned embodiments, the present application further provides a computer readable storage medium, which stores computer execution instructions. When the processor executes the computer execution instructions, the method provided by the foregoing embodiments is implemented.

[0183] To achieve the above-mentioned embodiments, the present application further provides a computer program product, which includes a computer program. When the processor executes the computer program, the method provided by the foregoing embodiments is implemented.

[0184] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the present application comply with relevant laws and regulations and do not violate public order and good customs.

[0185] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and not shared or sold outside these legitimate uses. In addition, such collection / sharing should be carried out after the user's informed consent is received, including but not limited to informing the user to read the user agreement / user notice before the user uses the function, and signing the agreement / authorization including authorization of relevant user information. In addition, any necessary steps should be taken to protect and secure access to such personal information data and ensure that other people with access to personal information data comply with their policies and processes.

[0186] The present application is expected to provide embodiments in which users can selectively prevent the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. By limiting data collection and deleting data, the risk can be minimized once the personal information data is no longer needed.

[0187] In the foregoing embodiment descriptions, the description with reference to the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the present specification and the features of the different embodiments or examples, without contradiction.

[0188] In addition, the terms "first", "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "a plurality of" is at least two, for example, two, three, etc., unless otherwise explicitly specified.

[0189] Any processes or methods described in the flowcharts or otherwise described herein can be understood as representing modules, segments, or portions of code that include one or more executable instructions for implementing specific logical functions or steps, and the various embodiments of the application can include additional or fewer steps performing the same or equivalent functions as those shown or discussed, in different orders, including substantially simultaneous execution of the functions described with respect to particular steps, and the like.

[0190] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a list of executable instructions for implementing the logic function, and can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor- containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can specifically include the following, which are non-exhaustive listings: electrical connections (electrical apparatus), portable computer disks (magnetic apparatus), random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fiber devices, and portable compact disk read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable medium upon which the program can be printed, as the program can be electronically captured, for example, via the optical scanning of the paper or other medium, followed by the electronic conversion of the optically scanned program into a form that can be edited, compiled, or interpreted or otherwise processed into an electronically usable form by a suitable processing device, and then stored in a computer memory.

[0191] It should be understood that portions of the application can be implemented in hardware, software, firmware, or combinations thereof. In the above embodiments, the various steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. As such, if implemented in hardware, the various steps or methods can be implemented in any one or combination of the following technologies, which are all well known in the art: discrete logic circuitry having logic gates for implementing logic functions upon data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), and the like.

[0192] Those skilled in the art of the present technology can understand that all or part of the steps carried out by the above-mentioned embodiment method can be completed by programs instructing related hardware, and the programs can be stored in a computer readable storage medium. When the program is executed, it includes one of the steps of the method embodiment or a combination thereof.

[0193] In addition, each functional unit in each embodiment of the present application can be integrated into one processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The integrated module can be realized in the form of hardware or in the form of a software functional module. When the integrated module is realized in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer readable storage medium.

[0194] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it should be understood that the above-mentioned embodiments are exemplary and cannot be understood as limiting the present application, and those skilled in the art can make changes, modifications, replacements and variations to the above-mentioned embodiments within the scope of the present application.

Claims

1. A method for extracting multi-source road traffic accident knowledge, 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. 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.

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 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.

4. The method for extracting multi-source road traffic accident knowledge according to claim 3, 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.

5. The method for extracting multi-source road traffic accident knowledge according to claim 4, 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.

6. The method for extracting multi-source road traffic accident knowledge according to claim 3, 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.

7. The method for extracting multi-source road traffic accident knowledge according to claim 6, 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.

8. 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.

9. 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 its 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

  • Joint relation extraction method based on subtask division network

    CN117252197A

  • Knowledge graph construction method and device for electric power operation text, medium and chip

    CN118469006A