Data processing method and device, computer device and readable storage medium

By using a matrix labeling model to preprocess and extract entities from text data, the problem of time-consuming manual extraction of target entities is solved, and the construction of entities and triples is automated, thus improving the efficiency of data processing.

CN119647468BActive Publication Date: 2026-08-04CHINA TELECOM CLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM CLOUD TECH CO LTD
Filing Date
2024-12-06
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing data processing methods are inefficient when dealing with large amounts of text data. They require a significant amount of time to manually extract target entities with target relationships.

Method used

A matrix tagging model is used to preprocess the text data to be processed, generate a list of word tags, extract entities through a relation matrix, and determine the target entity group based on the relation threshold in the matrix tagging model. Triples are then constructed to build a knowledge graph.

Benefits of technology

It enables automated extraction of target entity groups and automated construction of triples, improving the efficiency of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119647468B_ABST
    Figure CN119647468B_ABST
Patent Text Reader

Abstract

The application relates to a data processing method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: obtaining text data to be processed, and preprocessing the text data to be processed to obtain a word identifier list; determining a relationship matrix based on a matrix marking model and the word identifier list; extracting each entity in the relationship matrix according to the matrix marking model, and determining a target entity group corresponding to a target relationship according to the target relationship represented by the relationship matrix and a relationship threshold value in the matrix marking model; constructing a triple according to the target entity group and the target relationship; and the triple is used for constructing a knowledge graph. The method can improve the data processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of big data technology, and in particular to a data processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] With the rapid development of internet technology, users can search for the knowledge they need online. When users search for entity data, the search results include a knowledge graph of the entity, which contains the relationships between the entity and other entities.

[0003] Current data processing methods pre-determine the target relations to be extracted. The text data to be processed is acquired, containing initial sentences. For each target relation, the staff extracts the target entities existing in the target relation from each initial sentence and constructs triples of target entity-target relation-target entity. Then, a knowledge graph is built based on these triples.

[0004] However, current data processing methods are inefficient when dealing with large amounts of text data, as manually extracting target entities with established relationships is extremely time-consuming. Summary of the Invention

[0005] Therefore, it is necessary to provide a data transmission method, apparatus, computer equipment, computer-readable storage medium, and computer program product to address the aforementioned technical problems.

[0006] In a first aspect, this application provides a data transmission method, including:

[0007] Obtain the text data to be processed, and preprocess the text data to obtain a list of word identifiers;

[0008] The relation matrix is ​​determined based on the matrix tagging model and the word identifier list;

[0009] Extract each entity from the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model;

[0010] Triples are constructed based on the target entity group and the target relation; the triples are used to construct a knowledge graph.

[0011] In one embodiment, the preprocessing of the text data to be processed to obtain a word identifier list includes:

[0012] For each initial sentence in the text data to be processed, a header marker is added at the beginning of the initial sentence and a tail marker is added at the end of the initial sentence to obtain the sentence;

[0013] The sentences are preprocessed according to a preset sentence length, and a word identifier list is constructed based on each preprocessed sentence.

[0014] In one embodiment, determining the relation matrix based on the matrix tagging model and the word identifier list includes:

[0015] Feature extraction is performed on the word identifier list based on the matrix tagging model to obtain a first word vector matrix and a second word vector matrix; the matrix tagging model includes a reference matrix of the target relationship;

[0016] Add the word vector of the head tag unit in the first word vector matrix to each word vector in the second word vector matrix to obtain the head vector matrix, and determine the first word vector matrix as the tail vector matrix;

[0017] The similarity of the reference matrix, the head vector matrix, and the tail vector matrix of the target relationship is calculated to obtain a similarity matrix, and the similarity matrix is ​​normalized to obtain a relationship matrix.

[0018] In one embodiment, the entity includes a head entity and a tail entity, and the step of extracting each entity in the relation matrix according to the matrix labeling model includes:

[0019] Based on the entity threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain an entity binarized matrix;

[0020] The entity binarization matrix is ​​reduced in dimensionality to obtain the head entity vector and the tail entity vector;

[0021] Extract the head entity and tail entity corresponding to each sentence based on the head entity vector and the tail entity vector.

[0022] In one embodiment, each entity includes a head entity and a tail entity corresponding to each sentence. Determining the target entity group corresponding to the target relationship based on the target relationship represented by the relationship matrix and the relationship threshold in the matrix labeling model includes:

[0023] Based on the relation threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain a relation binarized matrix;

[0024] For each sentence, combine the head entities and tail entities corresponding to the sentence to obtain the entity groups corresponding to the sentence;

[0025] Based on the target relation represented by the relation binarization matrix, each entity group is filtered to obtain the target entity group corresponding to the target relation.

[0026] In one embodiment, the step of filtering each entity group based on the target relation represented by the relation binarization matrix to obtain the target entity group corresponding to the target relation includes:

[0027] In the relation binarization matrix, determine the relation binarization submatrix corresponding to each entity group;

[0028] Determine whether the value of the binary submatrix of the relation satisfies the filtering conditions corresponding to the target relation;

[0029] If the value of the binary submatrix of the relation satisfies the filtering condition, the entity group is determined as the target entity group corresponding to the target relation.

[0030] Secondly, this application also provides a data processing apparatus, comprising:

[0031] The acquisition module is used to acquire the text data to be processed and preprocess the text data to obtain a list of word identifiers;

[0032] The determination module is used to determine the relation matrix based on the matrix labeling model and the word identifier list;

[0033] The extraction module is used to extract each entity in the relation matrix according to the matrix labeling model, and to determine the target entity group corresponding to the target relation according to the target relation represented by the relation matrix and the relation threshold in the matrix labeling model;

[0034] A construction module is used to construct triples based on the target entity group and the target relationship; the triples are used to construct a knowledge graph.

[0035] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0036] Obtain the text data to be processed, and preprocess the text data to obtain a list of word identifiers;

[0037] The relation matrix is ​​determined based on the matrix tagging model and the word identifier list;

[0038] Extract each entity from the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model;

[0039] Triples are constructed based on the target entity group and the target relation; the triples are used to construct a knowledge graph.

[0040] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0041] Obtain the text data to be processed, and preprocess the text data to obtain a list of word identifiers;

[0042] The relation matrix is ​​determined based on the matrix tagging model and the word identifier list;

[0043] Extract each entity from the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model;

[0044] Triples are constructed based on the target entity group and the target relation; the triples are used to construct a knowledge graph.

[0045] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0046] Obtain the text data to be processed, and preprocess the text data to obtain a list of word identifiers;

[0047] The relation matrix is ​​determined based on the matrix tagging model and the word identifier list;

[0048] Extract each entity from the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model;

[0049] Triples are constructed based on the target entity group and the target relation; the triples are used to construct a knowledge graph.

[0050] The aforementioned data processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire text data to be processed and preprocess the text data to obtain a word identifier list; determine a relation matrix based on a matrix labeling model and the word identifier list; extract each entity in the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation according to the target relation represented by the relation matrix and the relation threshold in the matrix labeling model; construct triples according to the target entity group and the target relation; the triples are used to construct a knowledge graph. Using this method, a relation matrix is ​​determined through a matrix labeling model and the text data to be processed, and entities in the relation matrix are extracted according to the matrix labeling model, obtaining each entity that may have a target relation. Then, the target entity group with the target relation is determined through the target relation represented by the relation matrix and the relation threshold, realizing automated extraction of the target entity group. Furthermore, triples are constructed based on the target entity group and the target relation, realizing automated triple construction and improving the efficiency of the data processing method. Attached Figure Description

[0051] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is a flowchart illustrating a data processing method in one embodiment;

[0053] Figure 2 This is a flowchart illustrating the process of constructing a word identifier list in one embodiment;

[0054] Figure 3 This is a flowchart illustrating the process of determining the relation matrix in one embodiment;

[0055] Figure 4 This is a flowchart illustrating the process of determining a matrix labeling model in an exemplary embodiment;

[0056] Figure 5 This is a flowchart illustrating the process of extracting the head and tail entities in one embodiment;

[0057] Figure 6 This is a flowchart illustrating the process of determining a target entity group in one embodiment;

[0058] Figure 7 This is a flowchart illustrating the process of filtering target entity groups in one embodiment;

[0059] Figure 8 A flowchart illustrating an exemplary method for extracting entity relationships;

[0060] Figure 9 A flowchart illustrating data processing as an exemplary embodiment;

[0061] Figure 10 This is a structural block diagram of a data processing device in one embodiment;

[0062] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0063] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0064] In one embodiment, such as Figure 1 As shown, a data processing method is provided. This application embodiment uses the application of this method to a computer device as an example for illustration. This application embodiment does not limit the execution device for performing the data processing method, and includes the following steps:

[0065] Step 102: Obtain the text data to be processed and preprocess it to obtain a list of word identifiers.

[0066] In practice, the computer device retrieves the text data to be processed from the database. This text data includes initial sentences. The computer device preprocesses the length and format of each initial sentence to obtain a list of word identifiers.

[0067] Specifically, the computer device crawls the initial text data to be processed from web pages and divides the initial text data into initial sentences. Then, the computer device stores each initial sentence in a database. The computer device retrieves each initial sentence from the database and uses each initial sentence to construct the text data to be processed. Then, the computer device adds a tag to each initial sentence to obtain sentences, and preprocesses the sentences to obtain processed sentences. Finally, the computer device constructs a word tag list based on each processed sentence.

[0068] Optionally, the computer device may obtain initial text data from journals, papers, and web pages, but this application embodiment does not limit the source of the initial text data.

[0069] Step 104: Determine the relation matrix based on the matrix tagging model and the word identifier list.

[0070] The matrix tagging model is obtained by training the language representation model based on a set of sample sentences. The set of sample sentences contains each sample sentence and the corresponding binary matrix of each sample matrix.

[0071] In implementation, the computer device extracts features from the word identifier list based on a matrix tagging model, obtaining a head vector matrix and a tail vector matrix. Then, the computer device determines the relation matrix based on the reference matrix, head vector matrix, and tail vector matrix in the matrix tagging model.

[0072] Specifically, a language representation model is pre-set in the computer device. The target relation is the relationship between the entities to be extracted. The computer device trains the language representation model based on a set of sample sentences and the target relation until the trained language representation model meets a preset training stopping condition. The computer device then identifies the trained language representation model as a matrix labeling model. Based on the matrix labeling model, the computer device extracts features from the word identifier list, obtaining a head vector matrix and a tail vector matrix. Then, based on the reference matrix of the target relation in the matrix labeling model, the computer device performs matrix operations on the head vector matrix and the tail vector matrix to obtain a relation matrix. This relation matrix represents the fit between each sentence in the word identifier list and the target relation.

[0073] Optionally, the target relationship may be, but is not limited to, one; the number of target relationships is not limited in the embodiments of this application.

[0074] Step 106: Extract each entity in the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model.

[0075] The matrix labeling model includes entity thresholds and relationship thresholds.

[0076] In implementation, the computer device extracts entities from the relation matrix based on entity thresholds in the matrix labeling model. Then, the computer device combines these entities to obtain entity groups. Based on the target relation represented by the relation matrix and the relation thresholds in the matrix labeling model, the computer device selects the target relation entity group corresponding to the target relation from each entity group.

[0077] Specifically, the computer device binarizes the relation matrix according to the entity threshold in the matrix labeling model, obtaining an entity binarization matrix. Then, the computer device extracts each entity from the entity binarization matrix. Next, the computer device binarizes the relation matrix according to the relation threshold, obtaining a relation binarization matrix. Then, the computer device combines the entities to obtain entity groups. Finally, the computer device filters the entity groups according to the target relation represented by the relation binarization matrix, obtaining the target entity group corresponding to the target relation.

[0078] Step 108: Construct triples based on the target entity group and the target relationship.

[0079] Among them, triples are used to construct knowledge graphs.

[0080] In implementation, the computer device combines target entity groups and target relationships to obtain triples. The computer device then constructs a knowledge graph based on each triple.

[0081] In an exemplary embodiment, if there are target relations and multiple target entity groups, the computer device constructs each target entity group and target relation into a triple. The computer device then determines knowledge triples containing knowledge entities within each triple. Knowledge entities are entities for which a knowledge graph needs to be constructed. Based on the target relations in each knowledge triple, the computer device connects the entities in each knowledge triple to obtain a knowledge graph of the knowledge entities.

[0082] In the aforementioned data processing method, a relation matrix is ​​determined using a matrix labeling model and the text data to be processed. Entities in the relation matrix are then extracted based on the matrix labeling model, resulting in entities that may have target relations. Next, the target entity groups with target relations are identified using the target relations represented by the relation matrix and relation thresholds, achieving automated extraction of target entity groups. Furthermore, triples are constructed based on the target entity groups and target relations, achieving automated triple construction and improving the efficiency of the data processing method.

[0083] In one exemplary embodiment, such as Figure 2 As shown, the specific processing steps for preprocessing the text data to be processed in step 102 to obtain the word identifier list include steps 202 to 204. Wherein:

[0084] Step 202: For each initial sentence in the text data to be processed, add a header marker at the beginning of the initial sentence and a tail marker at the end of the initial sentence to obtain the sentence.

[0085] In practice, for each initial sentence in the text data to be processed, the computer adds a header marker at the beginning of the initial sentence. Simultaneously, the computer adds a tail marker at the end of the initial sentence, thus obtaining the sentence. By adding header and tail markers, the matrices can be segmented, and the matrix marker model can clearly identify each sentence.

[0086] Optionally, the sentence beginning marker may be, but is not limited to, the [cls] marker, and the sentence ending marker may be, but is not limited to, the [sep] marker. The sentence beginning marker and sentence ending marker are set according to the processing requirements of the word identifier list. This application embodiment does not limit the sentence beginning marker and sentence ending marker.

[0087] Step 204: Preprocess the sentences according to the preset sentence length, and construct a word identifier list based on each preprocessed sentence.

[0088] In implementation, the computer device pre-sets sentence lengths. For each sentence, the computer device determines whether its length matches the preset sentence length. If the sentence length matches the preset sentence length, the computer device does not preprocess the sentence. If the sentence length is less than the preset sentence length, the computer device adds placeholders to the sentence according to the preset sentence length. If the sentence length is greater than the preset sentence length, the computer device prunes the sentence according to the preset sentence length. The computer device combines the preprocessed sentences using a model dictionary to obtain a word identifier list.

[0089] In an exemplary embodiment, the sentence length is 7 characters. The text data to be processed contains three sentences: [cls]Little Head Dad is Big Head Son's Dad [sep], [cls]Hehe is a single word [sep], and [cls]Jin Yong is the author [sep]. The computer device prunes the sentence [cls]Little Head Dad is Big Head Son's Dad [sep] to a length of 7 characters, resulting in [cls]Little Head Dad is Big Head Son [sep]. Since the sentence [cls]Hehe is a single word [sep] has a length of 7 characters, i.e., the sentence length, the computer device does not preprocess this sentence. The computer device then adds two placeholders after the sentence [cls]Jin Yong is the author [sep], resulting in the preprocessed sentence: [cls]Jin Yong is the author [sep]XX. Here, XX represents a placeholder. The computer equipment combination [cls] Little Head Dad is Big Head [sep], [cls] Hee Hee is a word [sep], and [cls] Jin Yong is the author [sep] XX are three sentences that give a list of word identifiers.

[0090] Optionally, the sentence length is determined according to the processing requirements; however, this embodiment does not limit the sentence length.

[0091] In this embodiment, sentences are obtained by adding a sentence beginning identifier and a sentence ending identifier to each initial sentence. The sentences are then preprocessed according to their length to obtain a word identifier list, which facilitates the subsequent processing of the word identifier list by the matrix tagging model.

[0092] In one exemplary embodiment, such as Figure 3 As shown, the specific processing procedure of step 204 includes steps 302 to 306. Wherein:

[0093] Step 302: Extract features from the word identifier list based on the matrix tagging model to obtain the first word vector matrix and the second word vector matrix.

[0094] The matrix labeling model includes a reference matrix of the target relationship. The matrix labeling model contains a multi-layer Transformer encoder.

[0095] In practice, the computer device inputs the word identifier list into the matrix tagging model, and extracts features from the word identifier list through the matrix tagging model to obtain the first word vector matrix and the second word vector matrix.

[0096] Specifically, the computer device inputs a list of word identifiers into a matrix labeling model. The model then extracts features from the list using multiple Transformer encoders and obtains the outputs of the last two Transformer encoder layers. The computer device uses the output of the last Transformer encoder layer as the first word vector matrix and the output of the penultimate Transformer encoder layer as the second word vector matrix. By using the outputs of the last two layers of the matrix labeling model as word vector matrices, richer information can be obtained.

[0097] In an optional embodiment, the computer device is pre-configured with a BERT (Bidirectional Encoder Representations from Transformers, a pre-trained natural language processing model). The computer device acquires sample sentences and preprocesses them to obtain a list of sample word identifiers. Simultaneously, the computer device labels each sample sentence using a 0-1 labeling method to obtain a sample binary matrix. Specifically, the computer device pre-configures the target relations to be extracted. The computer device assigns each sample sentence as a row in the sample binary matrix and each word in the sample sentence as a column. The computer device determines whether an entity representing the target relation exists in each sample sentence. If an entity representing the target relation exists, the computer device marks the position of the entity with the target relation as 1, and marks the positions of the remaining words without the target relation as 0, thereby obtaining the sample binary matrix of the target relation. The position (i, j) in the sample binary matrix corresponds to the word pair formed by word i and word j. If word i is a word in the head entity of the target relation triple and word j is a word in the tail entity of the same triple, then the position is marked as 1; otherwise, it is marked as 0. The computer device inputs the sample word label list into the BERT model and fine-tunes the parameters of the BERT model based on the sample binary matrix and the weighted cross-entropy loss function until the trained BERT model meets the preset training stopping condition. The computer device then determines the trained BERT model as the matrix labeling model.

[0098] Optionally, the target relationship may be limited to parent-child, master-disciple, etc. This application is private and does not limit the target relationship.

[0099] Step 304: Add the word vector of the head marker unit in the first word vector matrix to each word vector in the second word vector matrix to obtain the head vector matrix, and determine the first word vector matrix as the tail vector matrix.

[0100] The first word vector matrix contains word vectors. Each word vector contains the word vector of the head marker unit, the word vector of the tail marker unit, and the remaining word vectors.

[0101] In implementation, the computer device adds the word vectors of the head marker units in the first word vector matrix to each word vector in the second word vector matrix, obtaining a head vector matrix, thereby enabling better learning of the relationship between the head and tail. The computer device determines the first word vector matrix as the tail vector matrix. The head entity word vector in the head vector matrix represents the probability of a word being the head. The head is the first target entity in the target triple. The tail entity word vector in the tail vector matrix represents the probability of a word being the tail. The tail is the second target entity in the target triple.

[0102] Step 306: Calculate the similarity of the reference matrix, head vector matrix, and tail vector matrix of the target relationship to obtain the similarity matrix, and then normalize the similarity matrix to obtain the relationship matrix.

[0103] In implementation, the computer device calculates the similarity of the reference matrix, head vector matrix, and tail vector matrix of the target relation, obtaining a similarity matrix representing the target relation. Then, the computer device normalizes the values ​​of the similarity matrix into probability values, obtaining a relation matrix representing the target relation. The relation matrix represents the probability that each sentence in the word identifier list fits this relation.

[0104] Specifically, the computer device performs a linear transformation on each head entity word vector in the head vector matrix based on the reference matrix, obtaining a linearly transformed head entity vector. Simultaneously, the computer device performs a linear transformation on each tail entity vector in the tail vector matrix based on the reference matrix, obtaining a linearly transformed tail entity vector. The computer device calculates the normalized inner product of each linearly transformed head entity vector and each linearly transformed tail entity vector, obtaining the inner product results, and constructs a similarity matrix based on these results. The inner product results represent the probability that the head entity vector and tail entity vector are the head and tail entity words (the first and second entities) of the same triplet. Then, the computer device normalizes the values ​​of the similarity matrix into probability values, obtaining a relation matrix representing the target relationship.

[0105] In one exemplary embodiment, the computer device includes multiple reference matrices of target relationships. The computer device performs similarity calculations on the reference matrix, head vector matrix, and tail vector matrix of each target relationship to obtain a similarity matrix representing the target relationship. Then, the computer device normalizes the values ​​of each similarity matrix to probability values ​​to obtain a relationship matrix of the target relationships.

[0106] In an optional embodiment, Figure 4 This is a schematic diagram illustrating the process of determining a matrix labeling model in an exemplary embodiment. For example... Figure 4 As shown, the process for determining the matrix labeling model includes:

[0107] Step 401: Obtain each sample sentence.

[0108] Step 402: Label each sample sentence based on the 0-1 labeling method to obtain the sample binary matrix of the target relation.

[0109] Step 403: Preprocess each sample sentence to obtain a sample word identifier list x={x1,x2,x3,…,xn}. Here, x represents the sample word identifier list, and n represents the number of words in the list. x1 represents the preprocessed word ID.

[0110] Step 404: Input the sample word identifier list into the BERT model, and extract features from the sample word identifier list based on the BERT model to obtain the sample output.

[0111] Step 405: Calculate the loss value of the sample binary matrix and sample output based on the weighted cross-entropy loss function, and fine-tune the relation matrix of the BERT model according to the calculated loss value until the trained BERT model meets the preset training stopping condition, and determine the trained BERT model as a matrix labeling model.

[0112] In this embodiment, features of the word identifier list are extracted using a matrix tagging model to obtain a head vector matrix and a tail vector matrix. The relation matrix is ​​determined based on the head vector matrix, the tail vector matrix, and the reference matrix of the target relation. This clarifies the fit of each sentence in the word vector matrix to the target relation, facilitating the subsequent extraction of target entity groups that fit the target relation.

[0113] In one exemplary embodiment, the entity includes a head entity and a tail entity, such as Figure 5 As shown, the specific processing steps for extracting entities from the relation matrix based on the matrix labeling model in step 206 include steps 502 to 506. Wherein:

[0114] Step 502: Based on the entity threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain the entity binarized matrix.

[0115] The matrix labeling model includes an entity threshold. The relation matrix contains the feature values ​​corresponding to each sentence in the word identifier list, and the entity binarization matrix after binarization contains the binary entity feature values ​​corresponding to each sentence.

[0116] In implementation, for each value in the relation matrix, the computer device determines whether the value is greater than or equal to an entity threshold. If the value is greater than or equal to the entity threshold, the computer device updates the value to 1. If the value is less than the entity threshold, the computer device updates the value to 0. The computer device then constructs an entity binarization matrix based on the updated values.

[0117] Step 504: Dimensionality reduction is performed on the entity binarization matrix to obtain the head entity vector and the tail entity vector.

[0118] In practice, the computer equipment performs summation and dimensionality reduction on the entity binarization matrix in both row and column directions to obtain the head entity vector and the tail entity vector.

[0119] Specifically, the computer device performs summation and dimensionality reduction on the entity binarization matrix along the row direction to obtain the head entity vector. Simultaneously, the computer device performs summation and dimensionality reduction on the entity binarization matrix along the column direction to obtain the tail entity vector.

[0120] In an exemplary embodiment, if there are multiple entity binarization matrices corresponding to target relationships, the computer device performs summation and dimensionality reduction processing on each entity binarization matrix along the row direction to obtain the head vector entity. Simultaneously, the computer device performs summation and dimensionality reduction processing on the entity binarization matrix along the column direction to obtain the tail entity vector.

[0121] Step 506: Extract the head entity and tail entity corresponding to each sentence based on the head entity vector and tail entity vector.

[0122] In implementation, the head entity vector contains the vector values ​​of each sentence. The tail entity vector also contains the vector values ​​of each sentence. For each sentence in the head entity vector, the computer device identifies words within that sentence whose vector values ​​are consecutively greater than 1 as head entities. Similarly, for each sentence in the tail entity vector, the computer device identifies words within that sentence whose vector values ​​are consecutively greater than 1 as tail entities.

[0123] In an exemplary embodiment, the vector value of a sentence in the head entity vector is [101101110]. The computer device identifies the word corresponding to the first "1" in the vector value as the head entity. Then, the computer device combines the words corresponding to the third and fourth "1"s in the head entity vector into a head entity. The computer device combines the words corresponding to the sixth, seventh, and eighth "1"s in the head entity vector into a head entity. The vector value of a sentence in the tail entity vector is [01110001]. The computer device combines the words corresponding to the second, third, and fourth "1"s in the tail entity vector into a tail entity. The computer device identifies the word corresponding to the last "1" in the tail entity vector as a tail entity.

[0124] In this embodiment, entities for each sentence in the relation matrix are extracted using a matrix labeling model, resulting in entities that may contain the target relation. Furthermore, by simultaneously extracting entities and target relations from the relation matrix, the propagation error of relation extraction is reduced compared to extracting target relations and entities separately. Moreover, this application's simultaneous extraction of target relations and entities upgrades the traditional sequence labeling problem of triples to a matrix labeling problem of relations, effectively solving the problem of overlapping triples and improving the accuracy of the data processing method.

[0125] In an exemplary embodiment, each entity includes a header entity and a tail entity corresponding to each sentence, such as... Figure 6 As shown, step 206, which involves determining the target entity group corresponding to the target relationship based on the target relationship represented by the relationship matrix and the relationship threshold in the matrix labeling model, includes steps 602 to 606. Wherein:

[0126] Step 602: Based on the relation threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain the relation binarized matrix.

[0127] The matrix labeling model includes a relation threshold. The values ​​for the relation threshold and the entity threshold are different.

[0128] In implementation, for each value in the relation matrix, the computer device determines whether the value is greater than or equal to a relation threshold. If the value is greater than or equal to the relation threshold, the computer device updates the value to 1. If the value is less than the relation threshold, the computer device updates the value to 0. The computer device then constructs a relation binarization matrix based on the updated values.

[0129] Step 604: For each sentence, combine the head entities and tail entities corresponding to the sentence to obtain the entity groups corresponding to the sentence.

[0130] Each sentence contains a header entity and a tail entity.

[0131] In practice, the computer equipment combines each head entity with each tail entity corresponding to the sentence to form an entity group.

[0132] In an exemplary embodiment, the word identifier list contains two sentences. The first sentence has head entities "Big Head Son" and "Jin Yong," and tail entities "Small Head Dad" and "Author." The second sentence has a head entity "XiXi" and a tail entity "Word." For the first sentence, the computer device combines "Big Head Son" with the corresponding tail entities "Small Head Dad" and "Author" to obtain two entity groups: "Big Head Son" and "Small Head Dad," and "Big Head Son" and "Author." Then, the computer device combines "Jin Yong" with the corresponding tail entities "Small Head Dad" and "Author" to obtain two entity groups: "Jin Yong" and "Small Head Dad," and "Jin Yong" and "Author." For the second sentence, the computer device combines the head entity "XiXi" and the tail entity "Word" to obtain the entity group "XiXi" and "Word."

[0133] Step 606: Based on the target relation represented by the relation binarization matrix, filter each entity group to obtain the target entity group corresponding to the target relation.

[0134] In practice, the computer equipment determines the binarized submatrix corresponding to each entity group in the relation binarization matrix, and filters each entity group according to the value of the binarized submatrix to obtain the entity group corresponding to the target relation.

[0135] Specifically, the computer device determines the relation binarization submatrix corresponding to each entity group in the relation binarization matrix. Then, the computer device determines whether the relation binarization submatrix represents the target relation. If the relation binarization submatrix represents the target relation, the computer device determines the entity group as the target entity group corresponding to the target relation.

[0136] In this embodiment, entity pairs and their relationships are jointly extracted from unstructured text, thereby reducing the propagation error of relationship extraction. Furthermore, by simultaneously extracting target relationships and entities, the traditional triple sequence labeling problem is upgraded to a matrix labeling problem of relationships, effectively solving the problem of overlapping triples and improving the accuracy of the data processing method.

[0137] In one exemplary embodiment, such as Figure 7 As shown, the specific processing procedure of step 606 includes steps 702 to 706. Wherein:

[0138] Step 702: Determine the relation binarization submatrix corresponding to each entity group in the relation binarization matrix.

[0139] In practice, the computer equipment determines the corresponding relation binarization submatrix in the relation binarization matrix based on the position of each entity group in the head entity vector and tail entity vector.

[0140] Specifically, for each entity group, the computer device determines the range of rows in the relation binarization submatrix within the relation binarization matrix based on the position of the head entity vector containing the entity group. Then, the computer device determines the range of columns in the relation binarization submatrix within the relation binarization matrix based on the position of the tail entity vector containing the entity group.

[0141] In an exemplary embodiment, the entity group is Jin Yong and the author. Jin Yong is the word corresponding to the first "1" in the head entity vector. The author is the word corresponding to the eighth "1" in the tail entity vector. The computer device determines the relation binarization matrix corresponding to the entity group Jin Yong and the author in the first row, eighth value of the relation binarization matrix.

[0142] Step 704: Determine whether the value of the binary submatrix of the relation satisfies the filtering conditions corresponding to the target relation.

[0143] The filtering condition for the target relation is that the values ​​of all binary submatrices of the relation are 1.

[0144] In implementation, the computer device determines whether all values ​​in the binary submatrix of the relation are 1. If all values ​​in the binary submatrix of the relation are 1, the computer device determines that the values ​​in the binary submatrix of the relation satisfy the filtering conditions corresponding to the target relation, and determines that the binary submatrix of the relation represents the target relation.

[0145] In an optional embodiment, if the values ​​of the relation binarization submatrix are not all 1, the computer device determines that the values ​​of the relation binarization submatrix do not meet the filtering conditions corresponding to the target relation, and determines that the relation binarization submatrix does not represent the target relation.

[0146] Step 706: If the value of the binary submatrix of the relation satisfies the filtering conditions, the entity group is determined as the target entity group corresponding to the target relation.

[0147] In practice, if the value of the binary submatrix of the relation satisfies the screening conditions of the target relation, the computer device determines the entity group as the target entity group corresponding to the target relation, and then constructs the triplet of the target relation based on the target entity group.

[0148] In this embodiment, the automatic extraction of target entity groups is achieved by using the relation binarization submatrix corresponding to each entity group and determining whether an entity group is the target entity group based on the value of the relation binarization matrix. Furthermore, triples are constructed based on the target entity groups and target relations, achieving automatic triple construction and improving the efficiency of the data processing method.

[0149] In one exemplary embodiment, Figure 8 This is a flowchart illustrating an exemplary method for extracting entity relationships. Figure 8 As shown, the method for extracting entity relationships includes:

[0150] Step 801: Obtain the word identifier list x.

[0151] Step 802: Based on the matrix tagging model with 768 encoding units, feature extraction is performed on the word tag list to obtain the first word vector matrix Etail and the second word vector matrix Ehead. Here, Ehead and Etail ∈ Rl*768. Rl is the BERT encoder in the matrix tagging model.

[0152] Step 803: Add the word vector of the head marker unit (the word vector of [cls]) in the first word vector matrix to each word vector in the second word vector matrix to obtain the head vector matrix Ehead', and determine the first word vector matrix as the tail vector matrix Etail.

[0153] Step 804: Input the head vector matrix Ehead' and tail vector matrix Etail into the relation calculation layer. Calculate the similarity between the head vector matrix and tail vector matrix using the reference matrix of the target relation to obtain the relation matrix.

[0154] Step 805: Extract each entity from the relation matrix according to the matrix labeling model.

[0155] Step 806: Determine the target entity group corresponding to the target relationship based on the target relationship represented by the relationship matrix and the relationship threshold in the matrix labeling model.

[0156] Step 807: Construct triples based on the target entity group and the target relationship.

[0157] In one exemplary embodiment, Figure 9 This is a flowchart illustrating data processing as an exemplary embodiment. Figure 9 As shown, the data processing method includes:

[0158] Step 901: Obtain the text data to be processed.

[0159] Step 902: Preprocess the text data to be processed to obtain a word identifier list x.

[0160] Step 903: Based on the matrix optimization model, feature extraction is performed on the word identifier list to obtain the first word vector matrix and the second word vector matrix.

[0161] Step 904: Determine the head vector matrix and tail vector matrix based on the first word vector matrix and the second word vector matrix.

[0162] Step 905: Determine the relation matrix based on the reference matrix, head vector matrix, and tail vector matrix of the target relation.

[0163] Step 906: Binarize the relation matrix based on the entity threshold to obtain the entity binarized matrix.

[0164] Step 907: Dimensionality reduction is performed on the entity binarization matrix to obtain the head entity vector and the tail entity vector.

[0165] Step 908: The words with consecutive values ​​greater than 1 in the head entity vector are identified as head entities, and the words with consecutive values ​​greater than 1 in the tail entity vector are identified as tail entities.

[0166] Step 909: Binarize the relation matrix based on the relation threshold to obtain the relation binarized matrix.

[0167] Step 910: Combine the head entities and tail entities to obtain entity groups.

[0168] Step 911: Determine the relation binarization submatrix corresponding to each entity group in the relation binarization matrix, and determine the entity group as the target entity group if the values ​​of the relation binarization submatrix are all 1.

[0169] Step 912: Construct triples based on the target relationship and the target entity group.

[0170] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0171] Based on the same inventive concept, this application also provides a data processing apparatus for implementing the data processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more data processing apparatus embodiments provided below can be found in the limitations of the data processing method described above, and will not be repeated here.

[0172] In one exemplary embodiment, such as Figure 10 As shown, a data processing device 1000 is provided, including: an acquisition module 1001, a determination module 1002, an extraction module 1003, and a construction module 1004, wherein:

[0173] The acquisition module 1001 is used to acquire the text data to be processed and preprocess the text data to obtain a list of word identifiers.

[0174] The determination module 1002 is used to determine the relation matrix based on the matrix labeling model and the word identifier list.

[0175] The extraction module 1003 is used to extract each entity in the relation matrix according to the matrix labeling model, and to determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model.

[0176] Module 1004 is used to construct triples based on target entity groups and target relationships; triples are used to construct knowledge graphs.

[0177] In one exemplary embodiment, the acquisition module 1001 includes a first acquisition submodule and a first processing submodule. The first processing submodule includes:

[0178] The first addition submodule is used to add a header marker at the beginning of each initial sentence in the text data to be processed, and add a tail marker at the end of each initial sentence to obtain the sentence.

[0179] The second processing submodule is used to preprocess sentences according to a preset sentence length and construct a word identifier list based on each preprocessed sentence.

[0180] In one exemplary embodiment, the determining module 1002 includes:

[0181] The first extraction submodule is used to extract features from the word identifier list based on the matrix tagging model to obtain the first word vector matrix and the second word vector matrix; the matrix tagging model includes a reference matrix of the target relationship.

[0182] The second addition submodule is used to add the word vectors of the head marker units in the first word vector matrix to each word vector in the second word vector matrix to obtain the head vector matrix, and to determine the first word vector matrix as the tail vector matrix.

[0183] The first calculation submodule is used to calculate the similarity of the reference matrix, head vector matrix and tail vector matrix of the target relationship, obtain the similarity matrix, and normalize the similarity matrix to obtain the relationship matrix.

[0184] In an exemplary embodiment, the entity includes a head entity and a tail entity, and the extraction module 1003 includes a second extraction submodule and a first determination submodule. The second extraction submodule includes:

[0185] The third processing submodule is used to binarize the relation matrix according to the entity threshold in the matrix labeling model to obtain the entity binarized matrix.

[0186] The fourth processing submodule is used to reduce the dimensionality of the entity binarization matrix to obtain the head entity vector and the tail entity vector.

[0187] The second extraction submodule is used to extract the head entity and tail entity corresponding to each sentence based on the head entity vector and tail entity vector.

[0188] In an exemplary embodiment, each entity includes a header entity and a tail entity corresponding to each sentence, and the extraction module 1003 includes a second extraction submodule and a first determination submodule. The first determination submodule includes:

[0189] The fourth processing submodule is used to binarize the relation matrix according to the relation threshold in the matrix labeling model to obtain the relation binarized matrix.

[0190] The combination submodule is used to combine the head entities and tail entities corresponding to each sentence to obtain the entity groups corresponding to the sentence.

[0191] The first filtering submodule is used to filter each entity group based on the target relationship represented by the relation binarization matrix, and obtain the target entity group corresponding to the target relationship.

[0192] In one exemplary embodiment, the first filtering submodule includes:

[0193] The second determination submodule is used to determine the relation binarization submatrix corresponding to each entity group in the relation binarization matrix.

[0194] The first judgment submodule is used to determine whether the value of the binary submatrix of the relation satisfies the filtering conditions corresponding to the target relation.

[0195] The third determination submodule is used to determine the entity group as the target entity group corresponding to the target relation if the value of the relation binarization submatrix satisfies the filtering conditions.

[0196] Each module in the aforementioned data processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0197] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a data processing method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0198] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0199] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0200] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0201] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0202] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0203] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0204] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A data processing method, characterized in that, The method includes: Obtain the text data to be processed, and preprocess the text data to obtain a list of word identifiers; The relation matrix is ​​determined based on the matrix tagging model and the word identifier list; Extract each entity from the relation matrix according to the matrix labeling model, and determine the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model; Triples are constructed based on the target entity group and the target relation; the triples are used to construct a knowledge graph. The determination of the relation matrix based on the matrix tagging model and the word identifier list includes: Based on the matrix tagging model, features are extracted from the word identifier list to obtain the head vector matrix and the tail vector matrix; Based on the reference matrix of the target relationship in the matrix labeling model, the similarity between the head vector matrix and the tail vector matrix is ​​calculated to obtain the relationship matrix; The step of determining the target entity group corresponding to the target relationship based on the target relationship represented by the relationship matrix and the relationship threshold in the matrix labeling model includes: Based on the relation threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain a relation binarized matrix, and the entities are combined to obtain entity groups. Based on the target relation represented by the relation binarization matrix, each entity group is filtered to obtain the target entity group corresponding to the target relation; the value of the relation binarization submatrix corresponding to the target entity group is 1.

2. The method according to claim 1, characterized in that, The preprocessing of the text data to be processed yields a word identifier list, including: For each initial sentence in the text data to be processed, a header marker is added at the beginning of the initial sentence and a tail marker is added at the end of the initial sentence to obtain the sentence; The sentences are preprocessed according to a preset sentence length, and a word identifier list is constructed based on each preprocessed sentence.

3. The method according to claim 1, characterized in that, The determination of the relation matrix based on the matrix tagging model and the word identifier list includes: Feature extraction is performed on the word identifier list based on the matrix tagging model to obtain a first word vector matrix and a second word vector matrix; the matrix tagging model includes a reference matrix of the target relationship; Add the word vector of the head tag unit in the first word vector matrix to each word vector in the second word vector matrix to obtain the head vector matrix, and determine the first word vector matrix as the tail vector matrix; The similarity of the reference matrix, the head vector matrix, and the tail vector matrix of the target relationship is calculated to obtain a similarity matrix, and the similarity matrix is ​​normalized to obtain a relationship matrix.

4. The method according to claim 1, characterized in that, The entity includes a head entity and a tail entity. Extracting each entity from the relation matrix according to the matrix labeling model includes: Based on the entity threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain an entity binarized matrix; The entity binarization matrix is ​​reduced in dimensionality to obtain the head entity vector and the tail entity vector; Extract the head entity and tail entity corresponding to each sentence based on the head entity vector and the tail entity vector.

5. The method according to claim 1, characterized in that, Each entity includes a head entity and a tail entity corresponding to each sentence. The step of determining the target entity group corresponding to the target relation based on the target relation represented by the relation matrix and the relation threshold in the matrix labeling model includes: Based on the relation threshold in the matrix labeling model, the relation matrix is ​​binarized to obtain a relation binarized matrix; For each sentence, combine the head entities and tail entities corresponding to the sentence to obtain the entity groups corresponding to the sentence; Based on the target relation represented by the relation binarization matrix, each entity group is filtered to obtain the target entity group corresponding to the target relation.

6. The method according to claim 5, characterized in that, The step of filtering each entity group based on the target relation represented by the relation binarization matrix to obtain the target entity group corresponding to the target relation includes: In the relation binarization matrix, determine the relation binarization submatrix corresponding to each entity group; Determine whether the value of the binary submatrix of the relation satisfies the filtering conditions corresponding to the target relation; If the value of the binary submatrix of the relation satisfies the filtering condition, the entity group is determined as the target entity group corresponding to the target relation.

7. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire the text data to be processed and preprocess the text data to obtain a list of word identifiers; The determination module is used to determine the relation matrix based on the matrix labeling model and the word identifier list; The extraction module is used to extract each entity in the relation matrix according to the matrix labeling model, and to determine the target entity group corresponding to the target relation according to the target relation represented by the relation matrix and the relation threshold in the matrix labeling model; The construction module is used to construct triples based on the target entity group and the target relation; the triples are used to construct a knowledge graph. The determining module is specifically used to extract features from the word identifier list based on the matrix labeling model to obtain a head vector matrix and a tail vector matrix; and to calculate the similarity between the head vector matrix and the tail vector matrix based on the reference matrix of the target relationship in the matrix labeling model to obtain a relationship matrix. The extraction module is specifically used to binarize the relation matrix according to the relation threshold in the matrix labeling model to obtain a relation binarized matrix, and combine each entity to obtain each entity group; according to the target relation represented by the relation binarized matrix, each entity group is filtered to obtain the target entity group corresponding to the target relation; the value of the relation binarized submatrix corresponding to the target entity group is 1.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.