Text data processing method, device, medium and program product

By decomposing the global feature vector of text data into subject, object, and shared feature vectors and performing feature fusion, the problem of low accuracy in extracting relation triples in existing technologies is solved, achieving higher accuracy and finer-grained analysis.

CN119807442BActive Publication Date: 2025-11-11BANK OF COMMUNICATIONS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411995229.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-11-11
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

Existing technologies have low accuracy in extracting relation triples from text data, and are prone to errors in subject or object identification, leading to incorrect relation matching.

Method used

The global feature vector is decomposed into subject feature vector, object feature vector and shared feature vector by adopting the subject-object partitioning model. The feature is then fused by the subject-object filtering model to enhance the representation of subject and object information, filter out unnecessary information and improve the accuracy of relation triples.

Benefits of technology

Feature fusion improves the accuracy of relation triple extraction, reduces the probability of incorrect subject/object identification or relation matching, and achieves fine-grained and highly accurate text data analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807442B_ABST
    Figure CN119807442B_ABST
Patent Text Reader

Abstract

This application provides a text data processing method, device, medium, and program product. The method includes: inputting the global feature vector corresponding to the text data to be processed into a subject-object partitioning model to obtain a subject feature vector, an object feature vector, and a shared feature vector; wherein the shared feature vector is the portion of the global feature vector excluding the subject and object feature vectors; inputting the subject, object, and shared feature vectors into a subject-object filtering model; fusing the subject and shared feature vectors to obtain a filtered subject feature vector; and fusing the object and shared feature vectors to obtain a filtered object feature vector; and obtaining relation triples in the text data based on the filtered subject and object feature vectors. This method can improve the accuracy of extracting relation triples from text data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology, and in particular to a text data processing method, device, medium, and program product. Background Technology

[0002] In the field of natural language processing, a relation triple can refer to a structural form that represents knowledge through three components, and such knowledge can also be called a relation triple or a triple.

[0003] A triple consists of three parts: a subject, a predicate, and an object. The subject can also be called the first entity, the head entity, etc.; the predicate can be called the verb, the relation, etc.; and the object can be called the second entity, the tail entity, etc. This structure can be used to represent the relationship between entities. Both the subject and the object are entities, which can be understood as concrete things such as products, services, or events. For example, extracting the triple from the text data "A deposits money into Bank B", where "A" is the subject, "Bank B" is the object, and "deposit money" is the relation, then "A-deposit money-Bank B" constitutes a relational triple structure, meaning a triple has been extracted from the text data.

[0004] Existing methods for processing text data to obtain relation triples involve using a pre-trained network model to extract features from the text data and then performing classification predictions based on these features to obtain relation triples. However, this method has a high probability of extracting incorrect subjects or objects, resulting in low accuracy in extracting relation triples. Summary of the Invention

[0005] This application provides a text data processing method, device, medium, and program product to improve the accuracy of extracting relation triples from text data.

[0006] In a first aspect, embodiments of this application provide a text data processing method, the method comprising: inputting a global feature vector corresponding to the text data to be processed into a subject-object partitioning model to obtain a subject feature vector, an object feature vector, and a shared feature vector; wherein, the subject-object partitioning model is a network model used to distinguish the subject and object in a relation triplet of input information, the subject feature vector is the part of the global feature vector corresponding to the subject, the object feature vector is the part of the global feature vector corresponding to the object, and the shared feature vector is the part of the global feature vector excluding the subject feature vector and the object feature vector; inputting the subject feature vector, the object feature vector, and the shared feature vector into a subject-object filtering model, performing feature fusion on the subject feature vector and the shared feature vector to obtain a filtered subject feature vector, and performing feature fusion on the object feature vector and the shared feature vector to obtain a filtered object feature vector; wherein, the subject-object filtering model is a network model used to perform feature fusion on the input information; and obtaining the relation triplet in the text data based on the filtered subject feature vector and the filtered object feature vector.

[0007] In one possible implementation, the subject-object partitioning model includes a subject gate and an object gate. The subject gate is a sub-model in the subject-object partitioning model used to determine the subject feature vector through a gating mechanism, and the object gate is a sub-model in the subject-object partitioning model used to determine the object feature vector through a gating mechanism. The step of inputting the global feature vector corresponding to the text data to be processed into the subject-object partitioning model to obtain the subject feature vector, object feature vector, and shared feature vector includes: inputting the global feature vector corresponding to the text data to be processed into the subject gate to obtain the subject feature vector, and inputting the global feature vector corresponding to the text data to be processed into the object gate to obtain the object feature vector; and determining the portion of the global feature vector other than the subject feature vector and the object feature vector as the shared feature vector.

[0008] In one possible implementation, the main gate satisfies the following formula when processing the global feature vector: Where, x t h represents the t-th element in the global feature vector. t-1 This represents the hidden state at the previous time step. This represents the weight matrix of the main gate. The weight matrix represents the hidden state of the main gate. This represents the bias vector of the main gate, and cummax represents the cumulative sum operation. This represents the feature vector corresponding to the t-th element in the main feature vector; the object gate satisfies the formula when processing the global feature vector: in, This represents the weight matrix of the object gate. The weight matrix represents the hidden state of the object gate. This represents the bias vector of the object gate. This represents the feature vector corresponding to the t-th element in the object feature vector.

[0009] In one possible implementation, the step of fusing the subject feature vector and the shared feature vector to obtain the filtered subject feature vector includes: adding the subject feature vector and the shared feature vector and then processing the data through a hyperbolic tangent activation function to obtain the filtered subject feature vector; the step of fusing the object feature vector and the shared feature vector to obtain the filtered object feature vector includes: adding the object feature vector and the shared feature vector and then processing the data through a hyperbolic tangent activation function to obtain the filtered subject feature vector.

[0010] In one possible implementation, obtaining relation triples in the text data based on the filtered subject feature vector and the filtered object feature vector includes: processing the shared feature vector using a hyperbolic tangent activation function to obtain a processed shared feature vector; inputting the feature vector resulting from concatenating the filtered subject feature vector and the processed shared feature vector into a subject extraction model to obtain the subject in the text data, wherein the subject extraction model is a network model used to decode the input information; inputting the feature vector resulting from concatenating the filtered object feature vector and the processed shared feature vector into an object extraction model to obtain the object in the text data, wherein the object extraction model is a network model used to decode the input information; and obtaining relation triples in the text data based on the subject and the object.

[0011] In one possible implementation, the method further includes: inputting the text data to be processed into an encoder for encoding feature vectors of the input information to obtain a text feature vector corresponding to the text data; fusing the text feature vector with multiple pre-encoded relation feature vectors using a multi-head attention mechanism to obtain a global feature vector corresponding to the text data, wherein any one of the relation feature vectors is used to characterize a relation in a relation triplet.

[0012] In one possible implementation, the relation triple is used for public opinion analysis of the bank, and the method further includes: acquiring text data associated with the bank; performing data preprocessing on the text data associated with the bank to obtain preprocessed text data, wherein the data preprocessing includes at least one of character correction and text length adjustment; and determining the preprocessed text data as text data to be processed.

[0013] Secondly, embodiments of this application provide a text data processing apparatus, the apparatus comprising: a first processing module, configured to input a global feature vector corresponding to the text data to be processed into a subject-object partitioning model to obtain a subject feature vector, an object feature vector, and a shared feature vector; wherein, the subject-object partitioning model is a network model used to distinguish the subject and object in a relation triplet of input information, the subject feature vector is the part of the global feature vector corresponding to the subject, the object feature vector is the part of the global feature vector corresponding to the object, and the shared feature vector is the part of the global feature vector excluding the subject feature vector and the object feature vector. The part other than the feature vector; the first processing module is further configured to input the subject feature vector, the object feature vector and the shared feature vector into the subject-object filtering model, perform feature fusion on the subject feature vector and the shared feature vector to obtain the filtered subject feature vector, and perform feature fusion on the object feature vector and the shared feature vector to obtain the filtered object feature vector; wherein, the subject-object filtering model is a network model used for feature fusion of input information; the second processing module is configured to obtain the relation triplet in the text data based on the filtered subject feature vector and the filtered object feature vector.

[0014] In one possible implementation, the subject-object partitioning model includes a subject gate and an object gate. The subject gate is a sub-model in the subject-object partitioning model used to determine the subject feature vector through a gating mechanism, and the object gate is a sub-model in the subject-object partitioning model used to determine the object feature vector through a gating mechanism. The first processing module is specifically used to: input the global feature vector corresponding to the text data to be processed into the subject gate to obtain the subject feature vector, and input the global feature vector corresponding to the text data to be processed into the object gate to obtain the object feature vector; and determine the portion of the global feature vector other than the subject feature vector and the object feature vector as the shared feature vector.

[0015] In one possible implementation, the main gate satisfies the following formula when processing the global feature vector: Where, x t h represents the t-th element in the global feature vector. t-1 This represents the hidden state at the previous time step. This represents the weight matrix of the main gate. The weight matrix represents the hidden state of the main gate. This represents the bias vector of the main gate, and cummax represents the cumulative sum operation. This represents the feature vector corresponding to the t-th element in the main feature vector; the object gate satisfies the formula when processing the global feature vector: in, This represents the weight matrix of the object gate. The weight matrix represents the hidden state of the object gate. This represents the bias vector of the object gate. This represents the feature vector corresponding to the t-th element in the object feature vector.

[0016] In one possible implementation, the first processing module is specifically used to: add the subject feature vector and the shared feature vector and then process the data through a hyperbolic tangent activation function to obtain the filtered subject feature vector; the first processing module is specifically used to: add the object feature vector and the shared feature vector and then process the data through a hyperbolic tangent activation function to obtain the filtered subject feature vector.

[0017] In one possible implementation, the second processing module is specifically used for: processing the shared feature vector using a hyperbolic tangent activation function to obtain a processed shared feature vector; inputting the feature vector resulting from concatenating the filtered subject feature vector and the processed shared feature vector into a subject extraction model to obtain the subject in the text data, wherein the subject extraction model is a network model used to decode the input information; inputting the feature vector resulting from concatenating the filtered object feature vector and the processed shared feature vector into an object extraction model to obtain the object in the text data, wherein the object extraction model is a network model used to decode the input information; and obtaining relation triples in the text data based on the subject and the object.

[0018] In one possible implementation, the first processing module is further configured to: input the text data to be processed into an encoder for encoding the input information into feature vectors to obtain a text feature vector corresponding to the text data; fuse the text feature vector with multiple pre-encoded relation feature vectors using a multi-head attention mechanism to obtain a global feature vector corresponding to the text data, wherein any one of the relation feature vectors is used to characterize a relation in a relation triplet.

[0019] In one possible implementation, the relation triple is used for public opinion analysis of the bank, and the first processing module is further configured to: acquire text data associated with the bank; perform data preprocessing on the text data associated with the bank to obtain preprocessed text data, wherein the data preprocessing includes at least one of character correction and text length adjustment; and determine the preprocessed text data as text data to be processed.

[0020] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.

[0021] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.

[0022] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.

[0023] The text data processing method, device, medium, and program products provided in this application embodiment involve inputting the global feature vector corresponding to the text data to be processed into a subject-object partitioning model to perform feature partitioning, thereby obtaining a subject feature vector, an object feature vector, and a shared feature vector. The shared feature vector is the portion of the global feature vector excluding the subject and object feature vectors. Since this shared feature vector may contain information representing the subject, the object, or the subject-object relationship, it is a feature vector that helps enhance information representation and is not discarded in subsequent processing. Furthermore, by inputting the subject feature vector, object feature vector, and shared feature vector into a subject-object filtering model, feature fusion can be performed on the subject feature vector and the shared feature vector. This enhances the expression of subject information in the subject feature vector through the shared feature vector while filtering out the expression of object information, thus improving the representation strength of the subject information in the filtered subject feature vector. Similarly, feature fusion can be performed on the object feature vector and the shared feature vector to enhance the expression of object information in the object feature vector while filtering out the expression of subject information, thus improving the representation strength of the object information in the filtered object feature vector. Based on the filtered subject feature vector and filtered object feature vector with improved representation strength, the probability of incorrect subject identification, incorrect object identification, or incorrect relation matching when obtaining relation triples can be reduced, thereby improving the accuracy of relation triple extraction. Attached Figure Description

[0024] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0025] Figure 1 A schematic diagram illustrating an application scenario provided in an embodiment of this application;

[0026] Figure 2 A flowchart illustrating the text data processing method provided in the embodiments of this application. Figure 1 ;

[0027] Figure 3 A schematic diagram of the subject-object encoding module provided in an embodiment of this application;

[0028] Figure 4 A schematic diagram illustrating the partitioning and filtering process provided in this application embodiment;

[0029] Figure 5 This is a schematic diagram of the structure of the text-relation encoding module provided in an embodiment of this application;

[0030] Figure 6 A flowchart illustrating the text data processing method provided in the embodiments of this application. Figure 2;

[0031] Figure 7 This is a schematic diagram of the structure of the text data processing apparatus provided in the embodiments of this application;

[0032] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0033] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0034] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0035] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and purpose. For example, "first electronic device" and "second electronic device" are used only to distinguish different electronic devices and do not limit their order of execution. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.

[0036] In this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0037] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following associated objects have an "or" relationship.

[0038] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solutions of this application comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0039] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0040] With the development of the internet and social media, the public can express their opinions and feelings about an organization's products or services online. The text data carrying these opinions and feelings is an effective reference for organizations to analyze whether their products or services meet user needs.

[0041] Taking banks as an example, users' opinions and emotional expressions regarding banks, financial products, or services are characterized by their massive volume, multiple sources, and dynamic nature. For banks, accurately extracting useful information from this vast amount of text data is of great significance for understanding market dynamics, optimizing product services, and managing public relations crises.

[0042] However, existing text data processing methods, such as keyword search and sentiment analysis, have limitations in deeply understanding text content and capturing specific opinions. For example, keyword search methods rely on predefined lists of keywords and cannot capture the complex relationships within text data. Sentiment analysis methods, typically based on dictionaries or machine learning models, can identify the overall sentiment tendency of text but struggle to capture specific opinions and relationships between entities.

[0043] For example, sentiment analysis-based methods typically analyze the sentiment of comment texts using dictionary matching, treating each comment text as a unit. For instance, three sentiment types are defined: positive, neutral, and negative. Based on a positive / negative sentiment dictionary, positive words in the comment text are assigned an initial weight of 1, and negative words are assigned an initial weight of -1. The total sentiment weight of the comment text is then calculated, yielding the corresponding sentiment analysis result.

[0044] This method, when performing sentiment analysis, neglects the complexity and multidimensionality of emotions, leading to overly simplistic results. For example, the sentiment analysis result can only indicate the overall sentiment tendency of the comment text as positive, negative, or neutral, making it difficult to clearly identify the specific object or theme to which the sentiment points. This makes it difficult to capture the user's specific emotional inclination towards an organization's products, services, or events within the comment text, resulting in low precision in the sentiment analysis results. Furthermore, the sentiment analysis result may not reflect the true sentiment within the comment text. For instance, a comment text may simultaneously contain praise for one aspect and criticism for another; in such cases, the sentiment analysis result might be neutral, which does not match the true sentiment within the comment text.

[0045] Furthermore, this method fails to consider the individual entities within the comment text and the relationships between them. Therefore, it cannot distinguish the emotional differences of the same entity across different aspects, such as product design or customer service. Information about relationships between entities significantly impacts the accuracy and complexity of understanding public opinion. For long texts containing multiple sentences or paragraphs, without accurately identifying the entities and their relationships, sentiment analysis struggles to capture the overall emotional tone. When sentiment shifts within the text, obtaining fine-grained and accurate analysis results becomes even more difficult. Therefore, this method is ill-suited for handling long texts and complex textual data.

[0046] To better process text data and achieve fine-grained analysis, natural language text data can be processed using relation triple extraction methods to obtain one or more relation triples. By analyzing the subjects, objects, and relationships between them in the relation triples, we can understand the public opinion information such as users' opinions, emotions, and attitudes towards various entities related to the organization, thereby improving the accuracy and granularity of the organization's acquisition of public opinion information.

[0047] The method for extracting relation triples can process natural language text data, identifying and extracting "subject-relation-object" relation triples from the text data. In some scenarios of this application's embodiments, the text data can be text content obtained from the network or on-site, or text content converted from speech content, etc. The subject in the relation triple can be, for example, a user or other user, the object can be, for example, an organization or other service provider, and the relation can be, for example, the subject's action, emotion, claim, and / or intention towards the object. For example, if the text data is an evaluation text of "a user expressing liking or disliking a certain organization," then from this evaluation text, a "user-emotion-organization" type relation triple can be extracted. Based on this relation triple, the user's emotion towards the organization can be analyzed. For example, it can be analyzed whether the user's emotion towards the organization is indifferent, like, dislike, anger, disappointment, or other emotions. Based on this, the organization can understand the user's degree of liking or disliking them in a more granular way.

[0048] Taking text data related to banks as an example, extracting relational triples from the text data "Mr. A is willing to deposit money in Bank B, but the staff at Bank B refuse to process his / her deposit," yields two relational triples: "Mr. A - willing to deposit money - Bank B" and "Personnel at Bank B - refuse to process - give to Mr. A." If this text data is processed using the aforementioned sentiment analysis method, the canceling effect of the keywords "willing" and "refuse" with different sentiment tendencies might result in an overall neutral sentiment analysis result. However, by obtaining the two relational triples through relational triple extraction and analyzing each relational triple, the complex relationships between the entities can be revealed, leading to public opinion information that more accurately reflects users' true feelings.

[0049] By extracting relation triples, we can more accurately understand the relationships between entities in text data, thus providing a richer and more refined information foundation for advanced text data analysis tasks such as sentiment analysis and topic recognition. Relation triple extraction methods can not only identify entities and their relationships in text data, but also capture complex relationships and subtle sentiment changes, providing deeper public opinion analysis. Furthermore, relation triple extraction methods can be combined with natural language processing and machine learning methods, maintaining efficiency and accuracy when processing large amounts of unstructured text data. For institutions such as banks, this enables them to promptly acquire and analyze massive amounts of text data related to their public opinion.

[0050] Existing methods for extracting relation triples from text data typically begin by using a neural network model that embeds the text data to extract global features, resulting in a global feature vector. This global feature vector is then input into a pre-trained keyword prediction model to predict the parts representing keywords. The predicted keywords are then decoded to extract the keywords corresponding to entities and relational keywords. These keywords are then arranged according to their positions in the text data to obtain one or more relation triples. However, this method does not focus heavily on the relationships between the input elements when processing the global feature vector. Therefore, it fails to fully explore the connections between elements, preventing the network model from deeply understanding and analyzing the semantic relationships between different parts of the text data. This leads to errors in keyword identification (subject, object, or relation) or inaccurate matching between entity relations, increasing the probability of incorrect relation triples and reducing the accuracy of relation triple extraction.

[0051] In view of this, embodiments of this application provide a text data processing method. This method inputs the global feature vector corresponding to the text data into a subject-object partitioning model to perform feature partitioning and obtain three parts: a subject feature vector, an object feature vector, and a shared feature vector. The shared feature vector is the part of the global feature vector other than the subject and object feature vectors. Since this shared feature vector may contain information representing the subject, the object, or the subject-object relationship, it is a feature vector that helps enhance information representation and is not discarded in subsequent processing. Furthermore, by inputting the subject feature vector, object feature vector, and shared feature vector into a subject-object filtering model, feature fusion can be performed on the subject feature vector and the shared feature vector. This enhances the expression of subject information in the subject feature vector through the shared feature vector while filtering out the expression of object information, thereby improving the representation strength of the subject information in the filtered subject feature vector. Similarly, feature fusion can be performed on the object feature vector and the shared feature vector. This enhances the expression of object information in the object feature vector through the shared feature vector while filtering out the expression of subject information, thereby improving the representation strength of the object information in the filtered object feature vector. By using filtered subject and object feature vectors with enhanced representation strength, the probability of incorrect subject identification, incorrect object identification, or incorrect relation matching when obtaining relation triples can be reduced, thereby improving the accuracy of relation triple extraction. Based on this, fine-grained and highly accurate text data analysis can be achieved to obtain more refined and reliable public opinion information.

[0052] Figure 1 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application, such as... Figure 1As shown, a large amount of text data related to Bank A can be obtained from internet nodes such as social networking sites or posting platforms. For example, text data related to comments about Bank A's products, branches, services, and events can be obtained.

[0053] When processing this text data, any given text data is input into a feature extraction model for tokenization, breaking down paragraphs or sentences into words or sub-words to obtain multiple tokens. The feature extraction model can be a neural network model used to encode natural language text data. This model then embeds each token to obtain feature vectors corresponding to the text data, achieving the transformation from text data to vectors (numerical arrays). This allows the triplet extraction model to understand, perceive, and process the text data. The triplet extraction model can be a pre-trained neural network model for extracting relational triples.

[0054] After obtaining the feature vectors corresponding to the text data, they can be input into a triplet extraction model to process the feature vectors and obtain the relation triples contained in the text data. In some implementations, the triplet extraction model and the feature extraction model can also be integrated into two parts of a single neural network model. After obtaining each triplet, sentiment analysis methods can be used to understand and analyze each relation triplet to obtain the sentiment information about Bank A contained in the text data. For example, analyzing the text data can reveal users' attitudes, opinions, user experiences, and suggestions for improvement regarding Bank A, so that Bank A can use this sentiment information to improve its products or services.

[0055] The technical solutions of this application will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0056] Figure 2 A flowchart illustrating the text data processing method provided in the embodiments of this application. Figure 1 The execution subject of this method can be an electronic device with corresponding data storage and computing capabilities, such as a computer, server, or server cluster. Figure 2 As shown, the method includes:

[0057] S201, input the global feature vector corresponding to the text data to be processed into the subject-object partitioning model to obtain the subject feature vector, object feature vector and shared feature vector; wherein, the subject-object partitioning model is a network model used to distinguish the subject and object in the relation triple of the input information, the subject feature vector is the part of the global feature vector corresponding to the subject, the object feature vector is the part of the global feature vector corresponding to the object, and the shared feature vector is the part of the global feature vector other than the subject feature vector and the object feature vector.

[0058] For example, the text data can be any natural language text data, such as comment text or event description text obtained from the Internet. The global feature vector can be a feature representation of the text data at the entire text data level, obtained after word segmentation and embedding processing. This global feature vector can semantically express the text data in the feature space in the form of a vector. The obtained global features help machine learning neural network models understand the overall content and structure of the text data, rather than being limited to understanding only the local word relationships in the text data.

[0059] The subject-object partitioning model can be a network model used to distinguish the subject and object in a relation triple based on input information. For example, this model can be obtained by training an initial network model using supervised training.

[0060] For example, the subjects and objects in multiple training text datasets are labeled. For instance, for words corresponding to entities, the start and end tokens of that entity can be labeled as 1, and all other tokens in between can be labeled as 0. For words not corresponding to entities, their corresponding tokens can be labeled as 0, thus obtaining the training text data and its corresponding labels. The training text data is then input into an initial network model for prediction processing, outputting the current prediction result. Based on the predicted subjects and objects and labels in this prediction result, the loss function value corresponding to the current training epoch is calculated, and backpropagation is performed based on this loss function value to adjust the model parameters, achieving one epoch of model training. After multiple epochs of training, if the loss function value of the current epoch meets the convergence condition, then the model corresponding to the model parameters of the current epoch can be a trained subject-object partitioning model.

[0061] Based on this subject-object partitioning model, the global feature vector corresponding to the text data to be processed can be processed to obtain subject feature vector, object feature vector, and shared feature vector. It should be noted that if the trained subject-object partitioning model can obtain the subject and object through decoding, then the subject feature vector can be the hidden state vector of the subject corresponding to the previous hidden layer of the decoded subject, and the object feature vector can be the hidden state vector of the object corresponding to the previous hidden layer of the decoded object.

[0062] For example, in neural network models, gating mechanisms can be used to process sequential data such as natural language and / or time series. Gating mechanisms control the flow of information and the updating of its state. For instance, gating mechanisms are employed in Long Short-Term Memory (LSTM) networks by introducing different types of gates (such as input gates, forget gates, and output gates) to determine which information should be retained, updated, or discarded, thereby more effectively capturing long-range dependencies in sequential data. Capturing these long-range dependencies can effectively enhance the representation of feature vectors, thus improving the accuracy of the output information.

[0063] In one possible implementation, the subject-object partitioning model includes a subject gate and an object gate. The subject gate is a sub-model in the subject-object partitioning model used to determine the subject feature vector through a gating mechanism, and the object gate is a sub-model in the subject-object partitioning model used to determine the object feature vector through a gating mechanism. When inputting the global feature vector corresponding to the text data to be processed into the subject-object partitioning model to obtain the subject feature vector, object feature vector, and shared feature vector, specifically: the global feature vector corresponding to the text data to be processed is input into the subject gate to obtain the subject feature vector, and the global feature vector corresponding to the text data to be processed is input into the object gate to obtain the object feature vector; the portion of the global feature vector other than the subject and object feature vectors is determined as the shared feature vector.

[0064] For example, the subject-object partitioning model can also be called a subject-object encoding module. The subject gate and object gate included in the subject-object encoding module can be two sub-models with the same model structure or two sub-models with different model structures, and each can have its own corresponding model parameters. The subject gate can extract the subject feature vector from the input global feature vector using a preset activation function, and the object gate can also extract the object feature vector from the input global feature vector using the same activation function. After obtaining the subject feature vector and object feature vector, the portion of the global feature vector other than the subject and object feature vectors can be determined as the shared feature vector.

[0065] In one possible implementation, the main gate satisfies the following formula when processing global feature vectors: Where, x t h represents the t-th element in the global feature vector. t-1 This represents the hidden state at the previous time step. This represents the weight matrix of the main gate. The weight matrix representing the hidden states of the main gate. This represents the bias vector of the main gate, and cummax represents the cumulative sum operation. This represents the eigenvector corresponding to the t-th element in the subject eigenvector; the object gate satisfies the formula when processing the global eigenvector: in, The weight matrix of the object gate, The weight matrix representing the hidden states of the object gate. The bias vector representing the object gate. This represents the eigenvector corresponding to the t-th element in the object's eigenvector.

[0066] For example, `cummax` can be an activation function representing a cumulative sum operation. For instance, `gate = cummax(·) = cumsum(softmax(·))`, and correspondingly, `cummax(x1, x2, ..., x...)`. n )=(x1,x1+x2,...,x1+x2+...+x n ), where "gate" can be understood as either a subject door or an object door, x n This can be understood as the information corresponding to the nth token in the global feature vector.

[0067] After processing with the activation function, a vector is obtained, where each element is represented by 0 and 1. Assuming a preset threshold of 0.5, based on cummax(x1,x2,...,x...)... n )=(x1,x1+x2,...,x1+x2+...+x n After calculation, if the calculated value of the nth element is greater than or equal to the threshold of 0.5, then the vector element value of that element in the gate's representation vector is represented as 1; if the calculated value of the nth element is less than the threshold of 0.5, then the vector element value of that element in the gate's representation vector is represented as 0. Thus, the gate's representation vector is obtained. The output form of the cummax activation function can be represented as gate = (0,...,0,1,...,1), where the ellipsis between 0 and 0 represents 0, and the ellipsis between 1 and 1 represents 1. If 1 represents the vector element corresponding to an entity, then the portion of the global feature vector corresponding to consecutive 1s is the feature vector corresponding to the object or the subject.

[0068] Based on this, the state in the global feature vector can be divided into a 0-represented part and a 1-represented part using cummax. Then, different update rules can be applied to update the subject feature vector and the object feature vector in the subject-object partitioning model. Different update rules can be understood as update rules set separately for the subject gate and the object gate. For example, the update rule for the subject gate can be set as gate = (0,...,0,1,...,1), and the update rule for the object gate can be set as gate = (1,...,1,0,...,0).

[0069] For example, it can be done through the main gate and object gate The information in the global feature vector is divided into two segments, resulting in the subject feature vector, the object feature vector, and the shared feature vector. (In the formula...) and middle, This can also be understood as the main feature vector corresponding to the t-th token obtained through the main gate; This can also be understood as the object feature vector corresponding to the t-th token obtained through the object gate; x t This can also be understood as the information corresponding to the t-th token in the global feature vector; h t-1 It can also be understood as the hidden state obtained based on the tokens before the t-th token, that is, the hidden state at the previous time step. The hidden state can also be understood as the hidden state vector. and All of these can be model parameters obtained through training. During processing, the time corresponding to processing each token can be understood as a time step. For example, the time to process the information corresponding to the nth token is the nth time step, which can be represented as t. n .

[0070] For example, different update rules can be used through the subject gate or object gate to update the feature information of a specific task that determines the subject feature vector or the object feature vector, ultimately resulting in three specific partition representations: the subject partition, the object partition, and the shared feature vector. These three specific partitions are respectively the current subject feature vector, the current object feature vector, and the current shared feature vector. The subject partition ρ can be obtained as shown in the following formula. s Object partitioning ρ o Shared partition ρ so .

[0071]

[0072]

[0073]

[0074]

[0075]

[0076]

[0077] in, This indicates the shared partition corresponding to the previous time step; This indicates the main partition corresponding to the previous time step; This indicates the object partition corresponding to the previous time step; This represents the main feature vector output by the main gate corresponding to the previous time step; c represents the object feature vector output by the object gate at the previous time step; t-1 This represents the current feature vector corresponding to the previous time step; This represents the candidate values ​​for the subject gate and the object gate at the current time step, which can be obtained using the hyperbolic tangent function; This represents the information input to the currently determined subject characteristic vector; This represents the information input to the currently determined object characteristic vector; This represents the information currently used to determine the shared characteristic vector input.

[0078] Based on this, the subject and object in the global feature vector can be determined by using subject gates and object gates with gating mechanisms. In the process of determination, the gating mechanism can capture long-term dependent information in the global feature vector, so that the information between the subject, object and shared information can be interacted. Therefore, useful information can be retained and useless information can be discarded, thereby improving the accuracy of the determined subject feature vector and object feature vector.

[0079] S202, the subject feature vector, object feature vector and shared feature vector are input into the subject-object filtering model, the subject feature vector and shared feature vector are fused to obtain the filtered subject feature vector, and the object feature vector and shared feature vector are fused to obtain the filtered object feature vector; wherein, the subject-object filtering model is a network model used to perform feature fusion on the input information.

[0080] For example, a subject-object filtering model can be a network model used to fuse subject feature vectors, object feature vectors, and shared feature vectors. The subject-object filtering model can be obtained through training. Feature fusion can involve performing operations such as convolution, addition, concatenation, or other operations on the feature vectors that need to be processed.

[0081] The shared feature vector may contain some information about the relationship between the subject and the object. Therefore, by fusing the subject feature vector and the shared feature vector to obtain the filtered subject feature vector, the information related to the relationship in the subject feature vector can be strengthened, while the information unrelated to the relationship in the subject feature vector can be weakened. Similarly, by fusing the object feature vector and the shared feature vector to obtain the filtered object feature vector, the information related to the relationship in the object feature vector can be strengthened, while the information unrelated to the relationship in the object feature vector can be weakened.

[0082] In one possible implementation, when fusing the subject feature vector and the shared feature vector to obtain the filtered subject feature vector, it can be achieved as follows: the subject feature vector and the shared feature vector are added together and then processed through a hyperbolic tangent activation function to obtain the filtered subject feature vector; when fusing the object feature vector and the shared feature vector to obtain the filtered object feature vector, it can be achieved as follows: the object feature vector and the shared feature vector are added together and then processed through a hyperbolic tangent activation function to obtain the filtered subject feature vector.

[0083] For example, the subject-object partitioning model and the subject-object filtering model can be included in the subject-object encoding module.

[0084] Figure 3 A schematic diagram of the subject-object encoding module provided in the embodiments of this application is shown below. Figure 3 As shown, t1, t2, t3...t n To represent different time steps, and each time step will process information corresponding to a token in the global feature vector, for example, t n Each time step processes the information corresponding to the t-th token in the global feature vector. A semicircle represents the object feature vector, a square represents the subject feature vector, and a parallelogram represents the shared feature vector. At each time step, the subject-object encoding module partitions and filters the information corresponding to the token in the global feature vector to update and obtain the updated subject feature vector, object feature vector, and shared feature vector for the current time step.

[0085] In the filtering step of the subject-object filtering model, each feature vector obtained after filtering can be stored in a memory block used to store the corresponding feature vector.

[0086] Figure 4 This is a schematic diagram illustrating the partitioning and filtering process provided in an embodiment of this application. Figure 4 As shown, the memory block includes the main memory block μ s , object memory block μ o and shared memory blocks μ soIn μ s In this process, by fusing information from specific subject partitions and shared partitions, subject-related partitions μ can be obtained. s This filters out information from the object partition. o This logic also applies; information about the subject can be filtered out, while other feature information is retained, resulting in the object-related partition μ. o For μ so Then, the shared partition representation obtained in the partitioning step can be used directly. The information in the shared memory block can be accessed by both the subject extraction task and the object extraction task, which can be expressed by the formula: μ s =ρ s +ρ so μ o =ρ o +ρ so μ so =ρ so Based on this, it is possible to improve the representational power of the filtered feature vectors without discarding any useful information.

[0087] After adding the subject feature vector and the shared feature vector, the filtered subject feature vector can be obtained by data processing using the hyperbolic tangent activation function; similarly, after adding the object feature vector and the shared feature vector, the filtered subject feature vector can be obtained by data processing using the hyperbolic tangent activation function.

[0088] For example, after each piece of information stored in memory is updated, a subject-related feature vector h can be generated. s , object-related feature vector h o and shared feature vector h so The data processing for the hyperbolic tangent activation function can be expressed as the following formula: h s =tanh(μ s );h o =tanh(μ o );h so =tanh(μ so ), where h s h represents the filtered main feature vector. o h represents the filtered object feature vector. so This indicates that the processed vectors are shared. The filtering process can also be understood as a noise reduction process.

[0089] After partitioning and denoising, c can be obtained from the information stored in the three memory blocks. t This refers to the current feature vector, which can be understood as a feature vector obtained at the current time step, composed of the subject feature vector, shared feature vector, and object feature vector. The current feature vector c is used to define this feature vector.t It can generate the hidden layer state h at the current time step. t This refers to the current hidden state vector, which can be used to partition and filter tokens for the next time step. It can be expressed by the formula: c t =Linear([μ s,t μ o,t μ so,t ]), where Linear represents a linear layer, μ s,t μ represents the subject-related partition corresponding to time step t. o,t μ represents the object-related partition corresponding to time step t. so,t This represents the shared partition corresponding to time step t. For the current feature vector c... t Data processing using the hyperbolic tangent activation function can yield the hidden layer state h. t , i.e. h t =tanh(c t ).

[0090] Based on this, feature fusion is achieved by adding the subject feature vector and shared feature vector, and the object feature vector and shared feature vector, respectively, and then applying the hyperbolic tangent activation function. The non-linear activation effect of the hyperbolic tangent activation function (tanh) enhances the representational strength of the fused feature vectors. In the subject-object encoding module, the partitioning and filtering steps enhance the model's semantic mining of various information within the text data. Simultaneously, they enhance the interaction between the semantic vectors of the subject and object in the triplet extraction, improving the model's accuracy in distinguishing between the subject and object.

[0091] S203. Based on the filtered subject feature vector and the filtered object feature vector, obtain the relation triples in the text data.

[0092] For example, after obtaining the filtered subject feature vector and the filtered object feature vector, a model that can decode and classify the feature vector can be used for processing. The classification prediction can then be used to obtain the subject corresponding to the filtered subject feature vector and the object corresponding to the filtered object feature vector.

[0093] For example, a pre-trained classifier model can be used to process the filtered subject feature vectors to decode and obtain one or more subjects in the text data to be processed. Similarly, the same pre-trained classifier model can be used to process the filtered object feature vectors to decode and obtain one or more objects in the text data to be processed.

[0094] For example, a subject classifier model that can classify and predict subjects and an object classifier model that can classify and predict objects can be pre-trained. The filtered subject feature vectors are input into the subject classifier model to classify and predict one or more subjects in the text data to be processed. The subjects can be subjects corresponding to preset relations. If there are m preset relations, the subjects corresponding to each relation can be predicted. For example, m subjects can be predicted, and each of the m subjects corresponds to one of the m relations. The filtered object feature vectors are input into the object classifier model to classify and predict one or more objects in the text data to be processed. The objects can correspond to the predicted subjects and the relations corresponding to the subjects. For example, m objects can be predicted, each corresponding to one of the m subjects and one of the m relations.

[0095] In one possible implementation, when obtaining relation triples in text data based on filtered subject feature vectors and filtered object feature vectors, it can be achieved as follows: The shared feature vector is processed using a hyperbolic tangent activation function to obtain a processed shared feature vector; the feature vector resulting from the concatenation of the filtered subject feature vector and the processed shared feature vector is input into a subject extraction model to obtain the subject in the text data; the subject extraction model is a network model used to decode the input information; the feature vector resulting from the concatenation of the filtered object feature vector and the processed shared feature vector is input into an object extraction model to obtain the object in the text data; the object extraction model is a network model used to decode the input information; and based on the subject and object, relation triples in the text data are obtained.

[0096] For example, the subject extraction model and the object extraction model can be models included in the triple extraction module. The triple extraction module can be a neural network model that extracts triples from the input information.

[0097] During the training and inference phases of the triplet extraction module, h obtained at each time step can be used... s Accumulate to obtain h sub This can be understood as the filtered main feature vector obtained after processing all tokens in the global feature vector. Similarly, h obtained at each time step can be... o Accumulate to obtain h obj This can be understood as the filtered object feature vector obtained after processing all tokens in the global feature vector. Similarly, h obtained at each time step... so By accumulating these features, we can obtain the processed shared feature vector h. share This can be expressed by the formula: Here, `concat` can be used to accumulate consecutive join operations. h represents the time step n. s , h represents the time step n. o , h represents the time step n. so .

[0098] During the training phase, h can be used sub with h share The features are combined to obtain the final input feature vector to the subject extraction model. Based on this input, the subject extraction model can output the predicted subject vector, which is the filtered subject feature vector of the text data samples obtained during the training phase. The feature vector input to the subject extraction model can be expressed by the following formula: h sub_share =concat([h sub h share `concat` is a concatenation operation that adds elements at the same position. sub_share h sub and h share The combined result is then input into the feature vector of the subject extraction model.

[0099] h can be obj with h share The combination yields the final feature vector input to the object extraction model. Based on this input, the object extraction model outputs a predicted object vector, which is the filtered object feature vector of the text data samples obtained during the training phase. The feature vector input to the object extraction model can be expressed by the following formula: h obj_share =concat([h obj h share `concat` is a concatenation operation that adds elements at the same position. obj_share h obj and h share The combined result is then input into the feature vector of the object extraction model.

[0100] The predicted subject vector is compared with the true subject label to calculate the loss value for the subject; the predicted object vector is compared with the true object label to calculate the loss value for the object. Based on the subject loss value, the model parameters of the subject-object encoding module and / or the global feature vector extraction model can be adjusted through backpropagation to optimize the extraction of information about the subject. Similarly, based on the object loss value, the model parameters of the subject-object encoding module and / or the global feature vector extraction model can also be adjusted through backpropagation to optimize the extraction of information about the object.

[0101] For example, during the inference phase of the triplet extraction module, h is extracted using the subject extraction model. subDecode the object using an object extraction model to process h. obj Decoding is performed to convert the numeric pointers into relational triples, thus obtaining the relational triples in the text data to be processed.

[0102] For example, h is extracted using a subject extraction model. sub Decoding is performed, resulting in m initial test subjects, where m can be any positive integer, such as 20. Each initial test subject corresponds to a first probability value representing its credibility; for example, a larger first probability value indicates a higher probability that the corresponding subject is the correct subject, and vice versa. Furthermore, each of these 20 initial test subjects corresponds to a relation, which can be one of a preset set of relations. The first probability values ​​of these 20 initial test subjects are compared using a preset probability threshold. Initial test subjects with first probability values ​​less than the threshold are removed, while those with first probability values ​​greater than or equal to the threshold are retained. For example, if 5 initial test subjects are retained from the 20, then 5 initial test subjects and their corresponding relations are obtained. The object extraction model is then used to analyze h. obj Decoding is performed to predict the objects corresponding to the five initially tested subjects and the second probability value corresponding to each object. This second probability value is used to characterize the credibility of the corresponding object. Each second probability value is compared with a probability threshold that determines whether it is the same as or different from the first probability value. Objects with second probability values ​​less than the threshold are removed, while those with second probability values ​​greater than or equal to the threshold are retained. Thus, if any second probability value is greater than or equal to the threshold, at least one relation triplet can be obtained. Each relation triplet can include a subject, the relation corresponding to the subject, and the object corresponding to the subject. Based on this, the triplet extraction module extracts the feature vectors h representing the semantics of the subjects and objects obtained from the subject extraction model and object extraction model. sub and h obj Decoding yields relational triples that can be used for public opinion analysis.

[0103] The text data processing method provided in this application involves inputting the global feature vector corresponding to the text data to be processed into a subject-object partitioning model to perform feature partitioning, thereby obtaining a subject feature vector, an object feature vector, and a shared feature vector. The shared feature vector is the portion of the global feature vector excluding the subject and object feature vectors. Since this shared feature vector may contain information representing the subject, the object, or the subject-object relationship, it is a feature vector that helps enhance information representation and is not discarded in subsequent processing. Furthermore, by inputting the subject feature vector, object feature vector, and shared feature vector into a subject-object filtering model, feature fusion can be performed on the subject feature vector and the shared feature vector. This enhances the expression of subject information in the subject feature vector through the shared feature vector while filtering out the expression of object information, thus improving the representation strength of the subject information in the filtered subject feature vector. Similarly, feature fusion can be performed on the object feature vector and the shared feature vector to enhance the expression of object information in the object feature vector while filtering out the expression of subject information, thus improving the representation strength of the object information in the filtered object feature vector. Based on the filtered subject feature vector and filtered object feature vector with improved representation strength, the probability of incorrect subject identification, incorrect object identification, or incorrect relation matching when obtaining relation triples can be reduced, thereby improving the accuracy of relation triple extraction.

[0104] In one possible implementation, the method further includes: inputting the text data to be processed into an encoder for encoding the input information into feature vectors to obtain text feature vectors corresponding to the text data; fusing the text feature vectors with multiple pre-encoded relation feature vectors using a multi-head attention mechanism to obtain global feature vectors corresponding to the text data, wherein any relation feature vector is used to characterize a relation in a relation triplet.

[0105] For example, the text-relation encoding module can fuse text feature vectors and relation feature vectors to obtain a global feature vector corresponding to the text data. This text-relation encoding module can be understood as a neural network model that includes at least one encoder.

[0106] Figure 5 This is a schematic diagram of the structure of the text-relation encoding module provided in an embodiment of this application. For example... Figure 5 As shown, the text-relation encoding module may include a bidirectional encoder representation from transformers (BERT) encoder. This BERT encoder can be used to encode the text data to be processed into feature vectors, obtaining the text feature vector H corresponding to the text data, where hn This represents the information corresponding to the nth token in the text feature vector.

[0107] For example, the t after word segmentation of text data can be... i The input is fed into the BERT encoder to obtain the corresponding feature vector representation h. i The formula in the calculation process satisfies: Among them, t i This represents the i-th token obtained after segmenting the text data. This represents the output information of the first layer of the BERT encoder for the i-th token; TRM represents the transformers that include multi-head attention mechanisms, fully connected layers, and normalization layers. This represents the output information of the last layer in the BERT encoder for the i-th token; W represents the output information of layer i-1 in the BERT encoder for the i-th token; e b represents the weight matrix of the BERT encoder; e Represents the bias matrix of the BERT encoder; TRM, W e and b e All of these can be obtained through pre-training on large-scale corpora.

[0108] By combining the output information of each token in the last layer of the BERT encoder, we can obtain the text feature vector H corresponding to the text data, which can be expressed as: Where n represents the length of the input sequence after slicing, which can be understood as the number of tokens obtained after word segmentation, where n is a positive integer. This can be understood as the output information of the last layer in the BERT encoder for the nth token.

[0109] To uncover the relationships between tokens and relations in text data, the obtained text feature vector H and relation feature vector R can be fused using a multi-head attention mechanism to enhance the representation of the text feature vector.

[0110] like Figure 5 As shown, the text-relation encoding module may further include a relation encoder, which can be used to encode the relation into a feature vector to obtain the relation feature vector R corresponding to the relation, where R... m This represents the relation feature vector corresponding to the m-th relation, where m is a positive integer. This relation encoder can be a BERT encoder or an encoder from other model structures.

[0111] For example, a pre-defined set of relationships can be established, such as {like, dislike, good, bad, willing to save money, refuse to process...}. By encoding the feature vectors of each relationship in this set using a relationship encoder, multiple pre-encoded relationship feature vectors can be obtained.

[0112] For example, text feature vectors can be fused with multiple pre-encoded relation feature vectors using a multi-head attention mechanism to obtain a global feature vector corresponding to the text data. Figure 5 As shown, in the text-relation encoding module, the predefined relations are encoded using a relation encoder to obtain m relation feature vectors R. The text data to be processed is then encoded using feature vectors to obtain the text feature vector H. Through the multi-head attention mechanism network structure in the text-relation encoding module, H and R are fused using multi-head attention to obtain the global feature vector H0 of the text data. R , where h Rn Represents the global eigenvector H R The nth element in the vector can also be understood as the global feature vector H. R The information corresponding to the nth token.

[0113] For example, when fusing text feature vector H and relation feature vector R using a multi-head attention mechanism, the following formula is satisfied:

[0114] Q = W q ·H;

[0115] K = W k ·H;

[0116] V = W v ·H;

[0117]

[0118] H R =K·(head1, head2,..., head L )

[0119] Where Q represents the query matrix; W q K represents the weight matrix of the query matrix; W represents the key matrix; k V represents the weight matrix of the key matrix; V represents the value matrix; W represents the weight matrix of the key matrix. v The weight matrix representing the value matrix; head L d represents the output information of the Lth attention head; k W represents the dimension of the key matrix. q W k and W v It can be obtained through model training.

[0120] In multi-head attention mechanisms, input data can be linearly transformed into multiple Q, K, and V vector groups, each called an attention head. These attention heads independently perform attention calculations, capturing different features or patterns. Finally, the output information from all attention heads is concatenated and a linear transformation is performed to generate the final output.

[0121] Based on this, the multi-head attention mechanism allows the text-relation encoding module to simultaneously focus on different parts of the text feature vector. This results in a global feature vector that, compared to the text feature vector itself, is more biased towards the information representation of multiple pre-encoded relation feature vectors. This enhances the representational strength of the global feature vector across the dimensions of the corresponding relations, leading to more accurate results when using the global feature vector for subject-object segmentation and filtering. Therefore, by fusing the text feature vectors of the text data and the relation feature vectors of the relations in the triples through the multi-head attention mechanism of the text-relation encoding module, the accuracy of the model in predicting triples can be improved.

[0122] In one possible implementation, relation triples are used for public opinion analysis of banks. The method further includes: acquiring text data associated with banks; performing data preprocessing on the text data associated with banks to obtain preprocessed text data, wherein the data preprocessing includes at least one of character correction and text length adjustment; and determining the preprocessed text data as the text data to be processed.

[0123] For example, text data associated with a bank may include text data related to information about at least one bank, such as any natural language text data describing a bank's products, branches, services and / or events. The text data may be, for example, comment text or complaint / suggestion text.

[0124] Figure 6 A flowchart illustrating the text data processing method provided in the embodiments of this application. Figure 2 ,like Figure 6 As shown, if the Internet node allows, web crawling technology using programming languages ​​(such as Python) can be used to obtain text data associated with the bank, and the text data can be preprocessed to achieve data cleaning.

[0125] For example, when acquiring text data associated with a bank, text content such as user reviews, user complaints, and user surveys can be collected through the bank's application and identified as text data associated with the bank.

[0126] In some scenarios, text data associated with banks may contain inconsistent characters, garbled text, and / or incorrect characters. Data preprocessing through character correction can unify characters and correct garbled and / or incorrect characters, thereby improving the usability of the text data. For example, when extracting global feature vectors, there may be a limit to the number of input characters. If the character length of the text data exceeds this limit, important information may be missing or global feature extraction may be impossible. Therefore, data preprocessing that adjusts the text length of text data associated with banks can avoid the loss of important information or the inability to extract global features due to the character length exceeding the input character limit, thus improving the applicability of this method. Data preprocessing can be performed manually or through machine learning models; this application embodiment does not impose any limitations on this approach.

[0127] In addition, during the model training phase of the text-relation encoding module, subject-object encoding module, and / or triple extraction module, data annotation can be performed on the preprocessed text data samples to label the real subjects and objects.

[0128] like Figure 6 As shown, after data preprocessing, the preprocessed text data can be identified as the text data to be processed and input into the text-relation encoding module for global feature vector extraction, obtaining the global feature vector corresponding to the text data. Then, this global feature vector can be input into the subject-object encoding module, which uses a subject-object partitioning model to divide the feature vector into subject feature vectors, object feature vectors, and shared feature vectors. Based on the subject-object filtering model, the subject feature vectors and object feature vectors are filtered separately, resulting in filtered subject feature vectors and filtered object feature vectors. The filtered subject feature vectors and filtered object feature vectors are then input into the triplet extraction module to obtain the relation triples in the text data associated with the bank. Based on the obtained relation triples, public opinion analysis can be performed on the bank, yielding public opinion analysis information and other public opinion analysis results.

[0129] For example, after extracting relational triples from a large amount of text data associated with a particular bank, several relational triples can be obtained. The subjects in these triples can be the bank's users or potential users, while the objects can be the bank's brand, its financial products, its service personnel, or its facilities. The relationships in these triples can be the actions, emotions, attitudes, or intentions of the subjects towards the objects. By classifying and statistically analyzing the subjects, objects, and / or relationships within these triples, the public opinion of users or potential users towards the bank can be obtained—that is, the public opinion analysis results. The bank can then adjust its products, services, or facilities based on these results to improve the user experience.

[0130] This embodiment achieves the goal of processing natural language text data to obtain triples, and then analyzing bank public opinion based on the obtained triples. Based on this, it overcomes the limitations of existing public opinion analysis methods such as sentiment analysis, providing a more efficient, accurate, and universal public opinion analysis method, especially suitable for processing text data in professional fields such as bank public opinion and financial commentary. By extracting highly accurate triples, positive and negative sentiment can be obtained from the extracted relationships at a finer granular level, and the subject and object of the sentiment can be clearly identified. Especially when the text data involves different sentiment expressions for multiple objects, accurate triple extraction can accurately identify the sentiment expression for a specific object.

[0131] For example, among the methods related to public opinion analysis, there are also topic-based methods. For instance, public comments often use rather arbitrary words and phrases, and the content is quite scattered. To address this, the themes of comments are mined from a large corpus of comments, using the mainstream Latent Dirichlet Allocation (LDA) model. The basic idea of ​​LDA is to calculate the probability distribution of expected words through probability distributions, thereby reflecting the theme of the comment text. The calculation process first randomly assigns a theme to each word, uses the Gibbs sampling method for sampling, and calculates the probability distribution of each word in each theme. Then, a new theme is assigned to the current word, and the calculation is repeated until Gibbs sampling converges. Finally, the theme and probability distribution of each comment text are determined, and the feature words for each theme are output.

[0132] This method has limitations in semantic understanding. Topic analysis relies primarily on word frequency and co-occurrence statistics, which may be insufficient to accurately understand complex semantic relationships and sentiment. For example, it may struggle to distinguish subtle differences between synonyms or near-synonyms in different contexts. Furthermore, it neglects sentiment details. Topic analysis focuses more on identifying and classifying topics than on in-depth analysis of the details and variations in sentiment within each topic. In contrast, triple extraction combined with sentiment analysis can provide more specific sentiment tendencies and attitudes. Additionally, this method is susceptible to topic ambiguity. In some cases, topic analysis may produce results with blurred topic boundaries, especially when multiple related but not identical topics exist in the text data. This can reduce the interpretability of the analysis results. Moreover, this method relies on large amounts of text data. Topic analysis methods, especially LDA, typically require substantial amounts of text data to generate stable topic models. For smaller datasets or shorter text fragments, the accuracy and stability of topic analysis may be affected.

[0133] For example, when the method provided in this application is applied to a public opinion analysis scenario, it can more accurately identify the relationships between entities. The triplet extraction method can accurately identify the relationships between entities in the text, including subject, predicate, and object, which is crucial for understanding the public opinion attitude and sentiment towards a specific entity. It goes beyond the generalized topic identification of topic analysis, providing more specific relationship details. The method in this application can also perform fine-grained combination of sentiment and topic. Combined with sentiment analysis, the triplet extraction method can provide fine-grained analysis of sentiment tendencies, not only identifying positive or negative sentiments but also clearly identifying the entities and events to which the sentiment is directed. This is more in-depth than simple topic or sentiment analysis and helps to understand the specific reasons behind complex emotions. Furthermore, the method in this application can also identify contextual sensitivity. Triplet extraction can better handle context-sensitive information, accurately capturing the specific context in the text through entity and relationship identification, which is crucial for understanding complex emotional expressions such as irony and sarcasm. In addition, this method has good flexibility and customization. Triple extraction can be customized to meet specific analytical needs, such as focusing on the analysis of specific entities or events, which makes public opinion analysis more focused and efficient.

[0134] Furthermore, the methods provided in the above embodiments can improve the accuracy of identifying triples in text data. In addition to being applicable to public opinion analysis in banking, the models or modules described above can be extended to extract triples and / or perform public opinion analysis on text data in other scenarios by inputting different training data.

[0135] Figure 7 This is a schematic diagram of the structure of the text data processing device provided in the embodiments of this application, as shown below. Figure 7As shown, this application provides a text data processing apparatus, which includes:

[0136] The first processing module 701 is used to input the global feature vector corresponding to the text data to be processed into the subject-object partitioning model to obtain the subject feature vector, the object feature vector, and the shared feature vector; wherein, the subject-object partitioning model is a network model used to distinguish the subject and the object in the relation triplet of the input information, the subject feature vector is the part of the global feature vector corresponding to the subject, the object feature vector is the part of the global feature vector corresponding to the object, and the shared feature vector is the part of the global feature vector other than the subject feature vector and the object feature vector;

[0137] The first processing module 701 is further configured to input the subject feature vector, object feature vector, and shared feature vector into the subject-object filtering model, perform feature fusion on the subject feature vector and shared feature vector to obtain the filtered subject feature vector, and perform feature fusion on the object feature vector and shared feature vector to obtain the filtered object feature vector; wherein, the subject-object filtering model is a network model used to perform feature fusion on the input information;

[0138] The second processing module 702 is used to obtain relation triples in the text data based on the filtered subject feature vector and the filtered object feature vector.

[0139] In one possible implementation, the subject-object partitioning model includes a subject gate and an object gate. The subject gate is a sub-model in the subject-object partitioning model used to determine the subject feature vector through a gating mechanism, and the object gate is a sub-model in the subject-object partitioning model used to determine the object feature vector through a gating mechanism. The first processing module 701 is specifically used to: input the global feature vector corresponding to the text data to be processed into the subject gate to obtain the subject feature vector, and input the global feature vector corresponding to the text data to be processed into the object gate to obtain the object feature vector; and determine the part of the global feature vector other than the subject feature vector and the object feature vector as the shared feature vector.

[0140] In one possible implementation, the main gate satisfies the following formula when processing global feature vectors: Where, x t h represents the t-th element in the global feature vector. t-1 This represents the hidden state at the previous time step. This represents the weight matrix of the main gate. The weight matrix representing the hidden states of the main gate. This represents the bias vector of the main gate, and cummax represents the cumulative sum operation. This represents the eigenvector corresponding to the t-th element in the subject eigenvector; the object gate satisfies the formula when processing the global eigenvector: in, The weight matrix of the object gate, The weight matrix representing the hidden states of the object gate. The bias vector representing the object gate. This represents the eigenvector corresponding to the t-th element in the object's eigenvector.

[0141] In one possible implementation, the first processing module 701 is specifically used to: add the subject feature vector and the shared feature vector and then process the data through the hyperbolic tangent activation function to obtain the filtered subject feature vector; the first processing module 701 is specifically used to: add the object feature vector and the shared feature vector and then process the data through the hyperbolic tangent activation function to obtain the filtered subject feature vector.

[0142] In one possible implementation, the second processing module 702 is specifically used for: processing the shared feature vector using a hyperbolic tangent activation function to obtain a processed shared feature vector; inputting the feature vector obtained by concatenating the filtered subject feature vector and the processed shared feature vector into a subject extraction model to obtain the subject in the text data, wherein the subject extraction model is a network model used to decode the input information; inputting the feature vector obtained by concatenating the filtered object feature vector and the processed shared feature vector into an object extraction model to obtain the object in the text data, wherein the object extraction model is a network model used to decode the input information; and obtaining relation triples in the text data based on the subject and object.

[0143] In one possible implementation, the first processing module 701 is further configured to: input the text data to be processed into an encoder for encoding the input information into feature vectors to obtain the text feature vector corresponding to the text data; fuse the text feature vector with multiple pre-encoded relation feature vectors using a multi-head attention mechanism to obtain the global feature vector corresponding to the text data, wherein any relation feature vector is used to characterize the relation in a relation triplet.

[0144] In one possible implementation, the relation triple is used for public opinion analysis of the bank, and the first processing module 701 is further used to: acquire text data associated with the bank; perform data preprocessing on the text data associated with the bank to obtain preprocessed text data, wherein the data preprocessing includes at least one of character correction and text length adjustment; and determine the preprocessed text data as text data to be processed.

[0145] The text data processing apparatus provided in this application embodiment can be used to execute the technical solution of the text data processing method in any of the above embodiments of this application. Its implementation principle and technical effect are similar, and will not be repeated here.

[0146] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 8 As shown, the electronic device of this embodiment may include: at least one processor 801; and a memory 802 communicatively connected to the at least one processor; wherein the memory 802 stores instructions that can be executed by the at least one processor 801, and the instructions are executed by the at least one processor 801 to cause the electronic device to perform the method as described in any of the above embodiments.

[0147] Optionally, the memory 802 can be either standalone or integrated with the processor 801.

[0148] The implementation principle and technical effects of the electronic device provided in this embodiment can be found in the foregoing embodiments, and will not be repeated here.

[0149] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method described in any of the foregoing embodiments.

[0150] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the methods described in any of the foregoing embodiments.

[0151] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.

[0152] The integrated modules implemented as software functional modules described above can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application.

[0153] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor. The memory may include random access memory (RAM), and may also include non-volatile memory (NVM), such as at least one disk storage device, and may also be a USB flash drive, external hard drive, read-only memory, disk, or optical disc, etc.

[0154] The aforementioned storage media can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage media can be any available medium accessible to general-purpose or special-purpose computers.

[0155] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. The processor and storage medium can reside within an application-specific integrated circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components within an electronic device or host device.

[0156] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0157] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0158] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0159] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

[0160] Other embodiments of the present application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the embodiments of this application that follow the general principles of the embodiments of this application and include common knowledge or customary techniques in the art not disclosed in the embodiments of this application.

[0161] It should be understood that the embodiments of this application are not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from their scope. The scope of the embodiments of this application is limited only by the appended claims.

Claims

1. A text data processing method, characterized in that, The method includes: The global feature vector corresponding to the text data to be processed is input into the subject-object partitioning model to obtain the subject feature vector, the object feature vector, and the shared feature vector. The subject-object partitioning model is a network model used to distinguish the subject and the object in the relation triple of the input information. The subject feature vector is the part of the global feature vector corresponding to the subject. The object feature vector is the part of the global feature vector corresponding to the object. The shared feature vector is the part of the global feature vector other than the subject feature vector and the object feature vector. The subject feature vector, the object feature vector, and the shared feature vector are input into the subject-object filtering model. Feature fusion is performed on the subject feature vector and the shared feature vector to obtain the filtered subject feature vector, and feature fusion is performed on the object feature vector and the shared feature vector to obtain the filtered object feature vector. The subject-object filtering model is a network model used to perform feature fusion on the input information. Based on the filtered subject feature vector and the filtered object feature vector, the relation triples in the text data are obtained.

2. The method according to claim 1, characterized in that, The subject-object partitioning model includes a subject gate and an object gate. The subject gate is a sub-model in the subject-object partitioning model used to determine the subject feature vector through a gating mechanism, and the object gate is a sub-model in the subject-object partitioning model used to determine the object feature vector through a gating mechanism. The step of inputting the global feature vector corresponding to the text data to be processed into the subject-object partitioning model to obtain the subject feature vector, object feature vector, and shared feature vector includes: The global feature vector corresponding to the text data to be processed is input into the subject gate to obtain the subject feature vector, and the global feature vector corresponding to the text data to be processed is input into the object gate to obtain the object feature vector; The portion of the global feature vector excluding the subject feature vector and the object feature vector is determined as the shared feature vector.

3. The method according to claim 2, characterized in that, The main gate satisfies the following formula when processing the global feature vector: Where, x t h represents the t-th element in the global feature vector. t-1 This represents the hidden state at the previous time step. This represents the weight matrix of the main gate. The weight matrix represents the hidden state of the main gate. This represents the bias vector of the main gate, and cummax represents the cumulative sum operation. This represents the feature vector corresponding to the t-th element in the main feature vector; The object gate satisfies the following formula when processing the global feature vector: in, This represents the weight matrix of the object gate. The weight matrix represents the hidden state of the object gate. This represents the bias vector of the object gate. This represents the feature vector corresponding to the t-th element in the object feature vector.

4. The method according to claim 1, characterized in that, The step of fusing the main feature vector and the shared feature vector to obtain the filtered main feature vector includes: The filtered main feature vector is obtained by adding the main feature vector and the shared feature vector and then processing the data through the hyperbolic tangent activation function. The step of fusing the object feature vector and the shared feature vector to obtain the filtered object feature vector includes: The filtered subject feature vector is obtained by adding the object feature vector and the shared feature vector and then processing the data through the hyperbolic tangent activation function.

5. The method according to any one of claims 1-4, characterized in that, The step of obtaining the relation triples in the text data based on the filtered subject feature vector and the filtered object feature vector includes: The shared feature vector is processed by using the hyperbolic tangent activation function to obtain the processed shared feature vector. The filtered main feature vector and the processed shared feature vector are concatenated to form a feature vector, which is then input into the main body extraction model to obtain the main body in the text data. The main body extraction model is a network model used to decode the input information. The filtered object feature vector and the processed shared feature vector are concatenated to form a feature vector, which is then input into the object extraction model to obtain the objects in the text data. The object extraction model is a network model used to decode the input information. Based on the subject and the object, relation triples are obtained in the text data.

6. The method according to any one of claims 1-4, characterized in that, The method further includes: The text data to be processed is input into an encoder used to encode the input information as a feature vector to obtain the text feature vector corresponding to the text data. The text feature vector is fused with multiple pre-encoded relation feature vectors using a multi-head attention mechanism to obtain a global feature vector corresponding to the text data. Any of the relation feature vectors is used to represent the relation in a relation triplet.

7. The method according to any one of claims 1-4, characterized in that, The relation triples are used for public opinion analysis of banks, and the method further includes: Obtain the text data associated with the bank; The text data associated with the bank is preprocessed to obtain preprocessed text data. The preprocessing includes at least one of character correction and text length adjustment. The preprocessed text data is determined as the text data to be processed.

8. An electronic device, characterized in that, include: Memory and processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-7.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-7.

10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Improved hierarchical sequence labeling joint relationship extraction method based on neural network

    CN113221568A

  • Triple extraction model training method, triple extraction method, device and equipment

    CN115033717A