Document processing method and device, computer device, storage medium and program product

CN117033996BActive Publication Date: 2026-09-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211078845.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-05
Publication Date
2026-09-22
Estimated Expiration
2042-09-05

AI Technical Summary

Technical Problem

[0003]目前,端到端的方法是情感原因对提取任务的主流方法,所谓端到端的方法是指:训练一个文档处理模型,将文档作为文档处理模型的输入,文档处理模型执行情感原因对提取任务,并输出从文档中提取的情感原因对;在采用端到端的方法提取情感原因对时,提取的情感原因对的准确率取决于文档处理模型的训练效果,训练效果差的文档处理模型进行情感原因对提取的准确率不高

Benefits of technology

[0061]本申请实施例中,提出提取情感原因对的两个方向,两个方向包括第一方向和第二方向,两个方向中的第一方向是指以情感句为依据提取情感原因对的方向,即从情感句到原因句的方向,两个方向中的第二方向是指以原因句为依据提取情感原因对的方向,即从原因句到情感句的方向;通过调用文档处理模型按照两个方向,从样本文档中提取情感原因对所产生的处理损失,对文档处理模型进行训练,可以提升文档处理模型的训练效果,从而可以提升文档处理模型提取情感原因对的准确率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117033996B_ABST
    Figure CN117033996B_ABST
Patent Text Reader

Abstract

The document processing method, device, computer device, storage medium and program product provided in the embodiments of the present application can be applied to the natural language processing technology branch in the field of artificial intelligence technology. The document processing method comprises the following steps: calling a document processing model to extract a sentiment reason pair from a sample document in a first direction, and obtaining a processing loss of the document processing model in the first direction during the extraction of the sentiment reason pair; calling the document processing model to extract the sentiment reason pair from the sample document in a second direction, and obtaining a processing loss of the document processing model in the second direction during the extraction of the sentiment reason pair; and training the document processing model based on the processing loss in the first direction and the processing loss in the second direction. By using the embodiments of the present application, the training effect of the document processing model can be improved, and the accuracy of the document processing model in extracting the sentiment reason pair can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more particularly to the field of artificial intelligence technology, specifically to a document processing method, a document processing device, a computer equipment, a computer-readable storage medium, and a computer program product. Background Technology

[0002] With the rapid development of computer technology, more and more online participants are publishing emotionally charged documents on online platforms (such as social platforms, online shopping platforms, and dialogue systems). Analyzing the reasons behind these emotions helps us understand why online participants generate these emotions, which can promote improvements to online platforms and enable them to better serve online participants. Therefore, extracting emotional reasons from documents has become an important task in natural language processing technology.

[0003] Currently, end-to-end methods are the mainstream approach for sentiment cause pair extraction. An end-to-end method involves training a document processing model, taking documents as input, having the model perform the sentiment cause pair extraction task, and outputting the extracted sentiment cause pairs. When using end-to-end methods to extract sentiment cause pairs, the accuracy of the extracted pairs depends on the training performance of the document processing model; a poorly trained model will have low accuracy in sentiment cause pair extraction. Therefore, improving the training performance of document processing models used for sentiment cause pair extraction has become a current research hotspot. Summary of the Invention

[0004] This application provides a document processing method, apparatus, computer equipment, storage medium, and program product, which can improve the training effect of document processing models, thereby improving the accuracy of document processing models in extracting sentiment reason pairs.

[0005] On the one hand, embodiments of this application provide a document processing method, which includes:

[0006] Obtain sample documents for training the document processing model;

[0007] The document processing model is invoked to extract sentiment cause pairs from the sample documents in the first direction. During the extraction of sentiment cause pairs, the processing loss of the document processing model in the first direction is obtained. A sentiment cause pair is a sentence pair consisting of a sentiment sentence and a cause sentence. The first direction refers to the direction in which sentiment cause pairs are extracted based on the sentiment sentence.

[0008] The document processing model is invoked to extract sentiment cause pairs from the sample documents in the second direction, and the processing loss of the document processing model in the second direction is obtained during the extraction of sentiment cause pairs; the second direction refers to the direction of extracting sentiment cause pairs based on the cause sentences.

[0009] The document processing model is trained based on the processing loss in the first direction and the processing loss in the second direction. The trained document processing model is used to extract sentiment cause pairs in the first direction and the second direction, respectively.

[0010] Accordingly, embodiments of this application provide a document processing apparatus, which includes:

[0011] The acquisition unit is used to acquire sample documents for training the document processing model;

[0012] The processing unit is used to call the document processing model to extract sentiment cause pairs from the sample document in the first direction, and to obtain the processing loss of the document processing model in the first direction during the extraction of sentiment cause pairs; a sentiment cause pair refers to a pair of sentences consisting of a sentiment sentence and a cause sentence; the first direction refers to the direction in which sentiment cause pairs are extracted based on the sentiment sentence;

[0013] The processing unit is also used to call the document processing model to extract sentiment cause pairs from the sample document in the second direction, and to obtain the processing loss of the document processing model in the second direction during the extraction of sentiment cause pairs; the second direction refers to the direction of extracting sentiment cause pairs based on the cause sentences.

[0014] The processing unit is also used to train the document processing model based on the processing loss in the first direction and the processing loss in the second direction; the trained document processing model is used to extract sentiment cause pairs according to the first direction and the second direction respectively.

[0015] In one implementation, the processing unit is used to invoke the document processing model to extract sentiment cause pairs from the sample document in a first direction, and during the extraction of sentiment cause pairs, when obtaining the processing loss of the document processing model in the first direction, it is specifically used to perform the following steps:

[0016] Call the document processing model to predict sentiment sentences in the sample documents and obtain the sentiment sentence prediction loss generated by the sentiment sentence prediction.

[0017] The document processing model is invoked to predict the cause sentences in the sample documents based on the labeled sentiment sentences, and the cause sentence prediction loss generated by the cause sentence prediction is obtained.

[0018] The loss for predicting sentiment sentences and the loss for predicting causes are summed to obtain the processing loss of the document processing model in the first direction.

[0019] In one implementation, the sample document includes multiple document sentences; the processing unit, used to call the document processing model to predict the sentiment sentences of the sample document and obtain the sentiment sentence prediction loss generated by the sentiment sentence prediction, specifically performs the following steps:

[0020] Retrieve sentiment query statements;

[0021] The document processing model is invoked to predict the sentiment of each document statement in the sample document based on the sentiment query statement, thereby obtaining the sentiment prediction probability of each document statement in the sample document.

[0022] The sentiment prediction loss is calculated based on the sentiment classification type and sentiment prediction probability of each document sentence.

[0023] In one implementation, the processing unit, used to invoke the document processing model and predict the sentiment of each document statement in the sample document based on the sentiment query statement, specifically performs the following steps when obtaining the sentiment prediction probability of each document statement in the sample document:

[0024] The sentiment query statement is vector-encoded to obtain a vector representation of the sentiment query statement; and the statements in each document in the sample document are vector-encoded to obtain a vector representation of each document statement.

[0025] Context features are extracted from the vector representation of sentiment query statements to obtain the context features of sentiment query statements; and context features are extracted from the vector representation of statements in each document to obtain the context features of statements in each document.

[0026] The context features of the sentiment query statement are concatenated with the context features of each document statement to obtain the concatenated context features of each document statement.

[0027] Based on the splicing context features of each document statement, sentiment prediction is performed on the corresponding document statements to obtain the sentiment prediction probability of each document statement in the sample documents.

[0028] In one implementation, the acquisition unit is also used to acquire non-sentimental sentences and non-causal sentences from the sample document; the non-sentimental sentences are used to simulate the situation where the document processing model extracts incorrect sentimental sentences during the test, and the non-causal sentences are used to simulate the situation where the document processing model extracts incorrect causal sentences during the test.

[0029] The processing unit is also used to call the document processing model to extract sentiment cause pairs corresponding to non-sentiment sentences from the sample document, and to obtain the test simulation loss of the document processing model for non-sentiment sentences during the extraction of sentiment cause pairs.

[0030] The processing unit is also used to call the document processing model to extract sentiment cause pairs corresponding to non-cause sentences from the sample document, and to obtain the test simulation loss of the document processing model for non-cause sentences during the extraction of sentiment cause pairs.

[0031] The processing unit, when training the document processing model based on the processing loss in the first direction and the processing loss in the second direction, specifically performs the following steps: training the document processing model based on the processing loss in the first direction, the processing loss in the second direction, the test simulation loss for non-sentimental sentences, and the test simulation loss for non-causal sentences.

[0032] In one implementation, the sample document includes multiple document sentences; the processing unit is used to call the document processing model to extract sentiment cause pairs corresponding to non-sentiment sentences from the sample document, and during the extraction of sentiment cause pairs, when obtaining the test simulation loss of the document processing model for non-sentiment sentences, it is specifically used to perform the following steps:

[0033] Generate the reason query statement corresponding to the non-sentiment sentence;

[0034] The document processing model is invoked to predict the cause of each document statement in the sample document based on the cause query statement corresponding to the non-sentiment sentence, thereby obtaining the cause prediction probability of each document statement in the sample document under the non-sentiment sentence.

[0035] Based on the cause classification type and cause prediction probability of each document sentence under non-sentimental sentences, calculate the test simulation loss of the document processing model for non-sentimental sentences.

[0036] In one implementation, the acquisition unit is also used to acquire the target document to be processed;

[0037] The processing unit is also used to call the trained document processing model to extract sentiment cause pairs from the target document in the first direction to obtain the first sentiment cause pair set;

[0038] The processing unit is also used to call the trained document processing model to extract sentiment cause pairs from the target document in the second direction to obtain a second sentiment cause pair set;

[0039] The processing unit is also used to determine the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set.

[0040] In one implementation, the target document includes multiple document statements; the processing unit, used to call a trained document processing model, extracts sentiment cause pairs from the target document according to a first direction, and when obtaining the first set of sentiment cause pairs, specifically performs the following steps:

[0041] The trained document processing model is invoked to predict the sentiment sentence for each document sentence in the target document, thus obtaining the predicted sentiment sentence in the target document.

[0042] The trained document processing model is invoked to predict the cause sentences of each document statement in the target document based on the predicted sentiment sentence, thereby obtaining the predicted cause sentences corresponding to the predicted sentiment sentences.

[0043] The predicted sentiment sentence is combined with the corresponding predicted cause sentence to obtain the first sentiment cause pair set.

[0044] In one implementation, each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; the target sentiment cause pair is any sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set.

[0045] The processing unit, when determining the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set, specifically performs the following steps:

[0046] If both the first set of sentiment cause pairs and the second set of sentiment cause pairs contain the target sentiment cause pair, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document;

[0047] If the first set of emotional cause pairs or the second set of emotional cause pairs contains the target emotional cause pair, then the confidence level of the target emotional cause pair is compared with the confidence threshold.

[0048] If the confidence level of the target sentiment cause pair is greater than the confidence level threshold, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document.

[0049] In one implementation, each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; the processing unit, when determining the sentiment cause pair corresponding to the target document in the first sentiment cause pair set and the second sentiment cause pair set, specifically performs the following steps:

[0050] Within the first set of emotional cause pairs and the second set of emotional cause pairs, determine the set of credible emotional cause pairs and the set of uncredible emotional cause pairs;

[0051] All sentiment cause pairs in the credible sentiment cause pair set are identified as the sentiment cause pairs corresponding to the target document;

[0052] In the set of untrusted sentiment cause pairs, those with a confidence level greater than the confidence threshold are identified as the sentiment cause pairs corresponding to the target document.

[0053] In one implementation, the processing unit, when determining the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set, specifically performs the following steps:

[0054] The common emotional reason pairs existing in both the first and second emotional reason pairs sets are identified as the emotional reason pairs corresponding to the target document; or,

[0055] The sentiment cause pairs in the first sentiment cause pair set and the second sentiment cause pair set are all identified as the sentiment cause pairs corresponding to the target document.

[0056] Accordingly, embodiments of this application provide a computer device, which includes:

[0057] A processor is a tool for implementing computer programs.

[0058] A computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the above-described document processing method.

[0059] Accordingly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when read and executed by a processor of a computer device, causes the computer device to perform the aforementioned document processing method.

[0060] Accordingly, embodiments of this application provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the document processing method described above.

[0061] In this embodiment, two directions for extracting sentiment cause pairs are proposed. These two directions include a first direction and a second direction. The first direction refers to the direction of extracting sentiment cause pairs based on sentiment sentences, i.e., the direction from sentiment sentences to cause sentences. The second direction refers to the direction of extracting sentiment cause pairs based on cause sentences, i.e., the direction from cause sentences to sentiment sentences. By calling the document processing model to extract the processing loss generated by extracting sentiment cause pairs from sample documents according to the two directions, the document processing model can be trained, thereby improving the training effect of the document processing model and thus improving the accuracy of the document processing model in extracting sentiment cause pairs. Attached Figure Description

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

[0063] Figure 1 This is a schematic diagram of an emotion reason pair extraction task provided in an embodiment of this application;

[0064] Figure 2a This is a schematic diagram of a model training process provided in an embodiment of this application;

[0065] Figure 2b This is a schematic diagram of a model application provided in an embodiment of this application;

[0066] Figure 3 This is a schematic diagram of the architecture of a document processing system provided in an embodiment of this application;

[0067] Figure 4 This is a flowchart illustrating a document processing method provided in an embodiment of this application;

[0068] Figure 5 This is a schematic diagram of the structure of a document processing model provided in an embodiment of this application;

[0069] Figure 6 This is a flowchart illustrating another document processing method provided in an embodiment of this application;

[0070] Figure 7a This is a schematic diagram illustrating the process of determining sentiment cause pairs under an intersection strategy provided in an embodiment of this application;

[0071] Figure 7b This is a schematic diagram illustrating the process of determining sentiment cause pairs under a union strategy provided in an embodiment of this application;

[0072] Figure 7c This is a schematic diagram illustrating the process of determining the sentiment cause pair under a complementary strategy provided in an embodiment of this application;

[0073] Figure 7d This is a schematic diagram illustrating the process of determining the emotional cause pair under a reconciliation strategy provided in an embodiment of this application;

[0074] Figure 8 This is an exemplary schematic diagram of a document processing model provided in this application embodiment during the model application process;

[0075] Figure 9 This is a schematic diagram of the structure of a document processing device provided in an embodiment of this application;

[0076] Figure 10 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0077] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0078] To better understand the technical solutions provided in the embodiments of this application, some key terms involved in the embodiments of this application will be introduced first:

[0079] (1) Artificial Intelligence Technology. Artificial Intelligence (AI) technology refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results. In other words, artificial intelligence is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can react in a way similar to human intelligence. Artificial intelligence studies the design principles and implementation methods of various intelligent machines, enabling them to have the functions of perception, reasoning, and decision-making. Artificial intelligence technology is a comprehensive discipline involving a wide range of fields, including both hardware and software technologies. Basic AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, mechatronics, and other technologies. AI software technologies mainly include computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, and intelligent transportation.

[0080] (2) Natural Language Processing (NLP) Technology. NLP is an important field within computer science and artificial intelligence. It studies various theories and methods that enable effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language, that is, the language people use in daily life, and thus it has a close relationship with linguistic research. NLP technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.

[0081] (3) Emotion-Cause Pair. An emotion-cause pair is a sentence pair consisting of an emotion sentence and a cause sentence. In an emotion-cause pair, the content of the emotion sentence expresses a certain emotion (e.g., happy, sad, angry, etc.), and the content of the cause sentence expresses the reason for this emotion. The task of extracting emotion-cause pairs generally requires extracting emotion-cause pairs from a document, for example, extracting all emotion-cause pairs that exist in the document. Figure 1 The diagram illustrates an emotion pair extraction task. The document contains five document statements (c1, c2, c3, c4, and c5). Two emotion cause pairs are extracted from the document. In the first emotion cause pair (c2, c2), both the emotion statement and the cause statement are document statement c2. The content of document statement c2 expresses both the emotion of boredom and the reason for the boredom: "always going to the same restaurant." In the second emotion cause pair (c5, c4), the content of emotion statement c5 expresses the emotion of aversion, and the content of cause statement c4 expresses the reason for the aversion: "But my friend said this restaurant is affordable."

[0082] (4) Reading Comprehension Framework. A reading comprehension framework, also known as a QA (question-answer) reading comprehension framework, refers to a document processing method that, given a question (or query), finds the answer to that question within the document by understanding its content. For example, when extracting sentiment sentences from a document, a sentiment query can be given: "Find sentiment sentences." Based on this query, all document statements in the document are binary classified. Document statements labeled with a sentiment tag (e.g., "1") are considered sentiment sentences, meaning they are the answers to the sentiment query. Document statements labeled without a sentiment tag (e.g., "0") are considered non-sentiment sentences, meaning they are not the answers to the sentiment query.

[0083] Based on the above introduction of key terms, this application proposes a model training process and a model application process (also known as a model testing process) based on a bidirectional reading comprehension framework. "Bidirectional" refers to two directions, including a first direction (emotion → cause direction) and a second direction (cause → emotion direction). Specifically:

[0084] like Figure 2aAs shown, in the model training process: the main task of the model training process is to train the document processing model, which is used to extract sentiment cause pairs from documents. The loss used to train the document processing model mainly consists of the following three parts: ① the loss generated when calling the document processing model to extract sentiment cause pairs from the document in the first direction; ② the loss generated when calling the document processing model to extract sentiment cause pairs from the document in the second direction; ③ the loss generated when simulating the case where the model extracts incorrect sentiment sentences and cause sentences during the model testing process, and calling the document processing model to extract the sentiment cause pairs corresponding to the incorrect sentiment sentences and cause sentences from the document respectively.

[0085] In the model training results, calling the document processing model to extract sentiment cause-effect pairs from the document in the first direction mainly involves two stages: the first stage is to extract sentiment sentences from the document based on the QA reading comprehension framework, and the second stage is to extract the cause sentences corresponding to the ground-truth sentiment sentences from the document based on the QA reading comprehension framework. Similarly, calling the document processing model to extract sentiment cause-effect pairs from the document in the second direction mainly involves two stages: the first stage is to extract cause sentences from the document based on the QA reading comprehension framework, and the second stage is to extract the sentiment sentences corresponding to the ground-truth cause sentences from the document based on the QA reading comprehension framework. The model training process based on the bidirectional reading comprehension framework considers both directions of sentiment cause-effect pair extraction and the model's error situation in the test case, thus greatly improving the training effect of the document processing model.

[0086] like Figure 2b As shown, in the model application process: the main task of the model application process is to extract sentiment reason pairs from the document using the trained document processing model. Specifically, the trained document processing model can be invoked to extract sentiment reason pairs from the document in the first direction. Then, the final sentiment reason pair can be determined from the sentiment reason pairs extracted in the first direction and the sentiment reason pairs extracted in the second direction.

[0087] Unlike the model training process, in the second stage of model application—extracting sentiment cause pairs from the document in the first direction—the model extracts the cause sentences corresponding to the sentiment sentences extracted in the first stage based on the QA reading comprehension framework, rather than extracting the cause sentences corresponding to the labeled sentiment sentences. Similarly, in the second stage of model application—extracting sentiment cause pairs from the document in the second direction—the model extracts the sentiment sentences corresponding to the cause sentences extracted in the first stage based on the QA reading comprehension framework, rather than extracting the sentiment sentences corresponding to the labeled cause sentences. This bidirectional reading comprehension framework-based model application process considers both directions of sentiment cause pair extraction, and finally determines the final sentiment cause pairs from the extraction results of both directions. This significantly improves the accuracy of the document processing model in extracting sentiment cause pairs.

[0088] The following section describes the document processing system provided in the embodiments of this application, as well as the application scenarios to which the embodiments of this application are applicable.

[0089] Figure 3 The document processing system shown may include a server 301 and a terminal device 302. This application embodiment does not limit the number of terminal devices 302; there may be one or more terminal devices 302. The server 301 may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This application embodiment does not limit this. The terminal device 302 may be a smartphone, tablet, laptop, desktop computer, smart voice interaction device, smartwatch, vehicle terminal, smart home appliance, aircraft, etc., but is not limited to these. The server 301 and the terminal device 302 may establish a direct communication connection via wired communication or an indirect communication connection via wireless communication. This application embodiment does not limit this.

[0090] exist Figure 3 In the document processing system shown, regarding the model training process:

[0091] The model training process can be executed by server 301 or terminal device 302. Server 301 or terminal device 302 can acquire multiple sample documents and train the document processing model based on these sample documents to obtain a trained document processing model. For any sample document, the three loss components mentioned above (i.e., the loss generated from extracting sentiment cause pairs in the first direction, the loss generated from extracting sentiment cause pairs in the second direction, and the loss generated from extracting sentiment cause pairs in the simulated model test scenario) can be obtained during the extraction of sentiment cause pairs from the sample document. These components together constitute the loss used to train the document processing model, and the document processing model is then trained based on this loss.

[0092] exist Figure 3 In the document processing system shown, the model application process is as follows:

[0093] The model application process can be executed by the terminal device 302. That is, the trained document processing model can be deployed in the terminal device 302. When there is a target document to be processed in the terminal device 302, the terminal device 302 can call the trained document processing model to extract sentiment cause pairs from the target document in two directions, and determine the final sentiment cause pair from the sentiment cause pairs extracted in the two directions.

[0094] Alternatively, the model application process can be executed interactively by server 301 and terminal device 302. The trained document processing model can be deployed on server 301. When there is a target document to be processed in terminal device 302, terminal device 302 can send the target document to server 301. Server 301 can call the trained document processing model to extract sentiment cause pairs from the target document in two directions, and determine the final sentiment cause pair from the sentiment cause pairs extracted in the two directions. Then, server 301 can send the final sentiment cause pair to terminal device 302.

[0095] It is understood that the document processing system described in the embodiments of this application is for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and does not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0096] The document processing solution provided in this application can be applied to scenarios requiring sentiment analysis, such as social networking, online shopping, and dialogue systems. For example, in a social networking scenario, the social platform can extract sentiment pairs from trending comments posted by social users. Based on these sentiment pairs, it can analyze the social user's feelings towards trending topics and the reasons for those feelings. Furthermore, it can recommend more trending topics that the social user expresses liking to. Similarly, in an online shopping scenario, the platform can extract sentiment pairs from product reviews. Based on these sentiment pairs, it can analyze why the product buyer likes or dislikes the product, which helps the seller improve the product and better meet the buyer's needs. Furthermore, in a dialogue system scenario, the system can extract sentiment pairs from conversation documents. Based on these sentiment pairs, it can analyze the conversation participant's feelings during the conversation and the reasons for those feelings, facilitating the generation of dialogue feedback that matches the sentiment.

[0097] It should be noted that in the various embodiments of this application, data such as documents of the target are involved. When the various embodiments of this application are applied to specific products or technologies, permission or consent from the target is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0098] The document processing method provided in the embodiments of this application will be described in more detail below with reference to the accompanying drawings.

[0099] This application provides a document processing method, which mainly describes the training process of a document processing model. This document processing method can be executed by a computer device, which can be a server 301 or a terminal device 302 in the aforementioned document processing system. Figure 4 As shown, this document processing method may include, but is not limited to, the following steps S401-S404:

[0100] S401, Obtain sample documents for training the document processing model.

[0101] Sample documents are used to train the document processing model. A sample document can include multiple document clauses, which can be separated by punctuation marks. For example, a sample document might be "At first I thought this restaurant was great, but I got tired of always going to the same restaurant. I wanted to try a different restaurant, but my friend said this restaurant was very affordable, which annoyed me." This sample document could include 5 document clauses: clause 1 "At first I thought this restaurant was great," clause 2 "But I got tired of always going to the same restaurant," clause 3 "I wanted to try a different restaurant," clause 4 "But my friend said this restaurant was very affordable," and clause 5 "This annoyed me."

[0102] S402, invoke the document processing model to extract sentiment cause pairs from the sample document in the first direction, and obtain the processing loss of the document processing model in the first direction during the extraction of sentiment cause pairs.

[0103] After obtaining sample documents for training the document processing model, the model can be invoked to extract sentiment cause pairs from the sample documents along the first direction. During the extraction process, the processing loss of the document processing model in the first direction is obtained. A sentiment cause pair can be a sentence pair consisting of a sentiment sentence and a cause sentence. The sentiment sentence expresses a certain emotion (e.g., happiness, sadness, anger, etc.), and the cause sentence expresses the reason for this emotion. The first direction can refer to the direction from the sentiment sentence to the cause sentence when extracting sentiment cause pairs.

[0104] The process of extracting sentiment cause pairs from sample documents using a document processing model along the first direction can be divided into two stages: the first stage is the extraction of sentiment sentences from the sample documents, i.e., the stage where the document processing model predicts sentiment sentences in the sample documents; the second stage is the extraction of cause sentences corresponding to the labeled sentiment sentences from the sample documents, i.e., the stage where the document processing model predicts cause sentences in the sample documents based on the labeled sentiment sentences. The labeled sentiment sentences refer to the correct sentiment sentences in the sample documents. Each stage has its own corresponding loss: the loss for the first stage is the sentiment sentence prediction loss, i.e., the loss incurred by predicting sentiment sentences in the sample documents using the document processing model; the loss for the second stage is the cause sentence prediction loss, i.e., the loss incurred by predicting cause sentences in the sample documents based on the labeled sentiment sentences. The sentiment sentence prediction loss of the first stage and the cause sentence prediction loss of the second stage together constitute the processing loss of the document processing model in the first direction. The processing loss of the document processing model in the first direction can be obtained by summing the sentiment sentence prediction loss of the first stage and the cause sentence prediction loss of the second stage. The two stages of the first direction are described below:

[0105] (1) The first stage of the first direction:

[0106] The first stage is the sentiment extraction stage. In this stage, the sentiment query is obtained, and the document processing model is invoked to predict the sentiment of each document statement in the sample document based on the sentiment query. This yields the sentiment prediction probability for each document statement. Then, the sentiment prediction loss is calculated based on the sentiment classification type and the sentiment prediction probability of each document statement. The sentiment prediction probability of a document statement can include the probability that the document statement is predicted as a sentiment statement and the probability that the document statement is predicted as a non-sentiment statement. When calculating the sentiment prediction loss, if the sentiment classification type of the document statement is sentiment (i.e., if the sentiment label of the document statement is a sentiment statement label, such as "1"), the probability that the document statement is predicted as a sentiment statement can be used to calculate the sentiment prediction loss. If the sentiment classification type of the document statement is non-sentiment (i.e., if the sentiment label of the document statement is a non-sentiment statement label, such as "0"), the probability that the document statement is predicted as a non-sentiment statement can be used to calculate the sentiment prediction loss. The calculation process for the sentiment prediction loss in the first stage can be seen in the following formula 1:

[0107]

[0108] In Formula 1 above: L EC1The first stage represents the sentiment sentence prediction loss; N represents the number of document sentences in the sample document, where N is an integer greater than 1. This represents the sentiment tag of the i-th document statement in the sample document, that is, the sentiment classification type of the i-th document statement, where i is a positive integer less than or equal to N; This represents the sentiment prediction probability of the i-th document statement in the sample document.

[0109] (2) The second phase of the first direction:

[0110] The second stage is the cause extraction stage for a given sentiment sentence. In this stage, given a labeled sentiment sentence, an Emotion-Specific Cause Extraction Query (ESM) can be generated. Similar to the first stage of the first direction, the document processing model can be invoked to predict the cause of each document sentence in the sample document based on the ESM corresponding to the labeled sentiment sentence. This yields the cause prediction probability for each document sentence in the sample document. Then, the cause prediction loss can be calculated based on the cause classification type and cause prediction probability of each document sentence under the labeled sentiment sentence. The probability of predicting the cause of a document statement under a sentiment-labeled sentence can include: the probability that the document statement is predicted as a cause sentence corresponding to the sentiment-labeled sentence, and the probability that the document statement is predicted as a non-cause sentence corresponding to the sentiment-labeled sentence. When calculating the cause sentence prediction loss, if the cause classification type of the document statement under the sentiment-labeled sentence is cause sentence, that is, if the cause label of the document statement under the sentiment-labeled sentence is cause sentence label (for example, it could be "1"), then the cause sentence prediction loss can be calculated using the probability that the document statement is predicted as a cause sentence corresponding to the sentiment-labeled sentence; if the cause classification type of the document statement under the sentiment-labeled sentence is non-cause sentence, that is, if the cause label of the document statement under the sentiment-labeled sentence is non-cause sentence label (for example, it could be "0"), then the cause sentence prediction loss can be calculated using the probability that the document statement is predicted as a non-cause sentence corresponding to the sentiment-labeled sentence.

[0111] It should be noted that the number of labeled sentiment sentences given in the second stage can be one or more. When there are multiple labeled sentiment sentences, a cause sentence extraction needs to be performed for each labeled sentiment sentence to generate a cause sentence prediction loss for each labeled sentiment sentence. The cause sentence prediction loss in the second stage can be the sum of the cause sentence prediction losses for each labeled sentiment sentence given in the second stage. The calculation process for the cause sentence prediction loss in the second stage can be found in Formula 2 below:

[0112]

[0113] In formula 2 above: L EC2The second-stage causal sentence prediction loss is represented by N; N represents the number of document sentences in the sample documents, where N is an integer greater than 1; L e This represents a given set of labeled sentiment sentences, which may include one or more labeled sentiment sentences; c j This represents the j-th labeled sentiment sentence in a given set of labeled sentiment sentences; This represents the reason label of the i-th document statement under the j-th sentiment-annotated sentence in the sample document, that is, the reason classification type of the i-th document statement under the j-th sentiment-annotated sentence, where i is a positive integer less than or equal to N; This represents the probability of cause prediction for the i-th document statement under the j-th labeled sentiment statement.

[0114] Based on the two stages of the first direction mentioned above, the processing loss of the document processing model in the first direction can be obtained by summing the sentiment sentence prediction loss of the first stage of the first direction and the causal sentence prediction loss of the second stage of the first direction. See Formula 3 below for details:

[0115]

[0116] In formula 3 above: L EC L represents the processing loss of the document processing model in the first direction. EC1 The sentiment sentence predicts loss in the first stage of the first direction; L EC2 The sentence indicating the second stage in the first direction predicts the loss.

[0117] The first stage mentioned above involves calling a document processing model to predict sentiment sentences, and the second stage involves calling a document processing model to predict causal sentences based on a given labeled sentiment sentence. The execution processes of these two processes are similar. This application embodiment focuses on the process of calling a document processing model to predict sentiment sentences. For the process of calling a document processing model to predict causal sentences based on a given labeled sentiment sentence, please refer to the process of calling a document processing model to predict sentiment sentences. This application embodiment will not repeat the details.

[0118] Before introducing the sentiment prediction process of document processing models, let's first combine... Figure 5The document processing model can be structured as follows: It includes a language encoding module, a vector aggregation module, a context feature extraction module, and a binary classification module. The language encoding module encodes each word (token) in a sentence, obtaining a vector representation of each word. This encoding can be achieved using the BERT model (a pre-trained language model). The vector aggregation module aggregates the vector representations of each word in the sentence, obtaining the sentence's vector representation. This aggregation can be achieved using an attention mechanism. The context feature extraction module extracts the context features of the sentence, which can be implemented through the interaction of multiple LSTM (Long Short-Term Memory) sub-modules. The binary classification module concatenates the context features of the query statement with the context features of each document statement in the sample documents. Then, it predicts the sentiment of each document statement based on the concatenated context features, obtaining the sentiment prediction probability for each document statement.

[0119] After introducing the structure of the document processing model, the following section will combine... Figure 5 The process of calling the document processing model to predict the sentiment of each document statement in the sample document based on the sentiment query is described below:

[0120] ①Language encoding module:

[0121] The language encoding module of the document processing model can be called to perform vector encoding on each word in the sentiment query, resulting in a vector representation of each word in the sentiment query; for example... Figure 5 q in m This represents the m-th word in the sentiment query. The processing of individual document statements in the sample document is similar to that of the sentiment query. For each document statement in the sample document, the language encoding module of the document processing model can be called to perform vector encoding on each word in the document statement, obtaining the vector representation of each word in the document statement; for example... Figure 5 In This represents the j-th word in the i-th document statement of the sample document.

[0122] It should be added that, such as Figure 5As shown, special symbols can also be added to the beginning and / or end of the statement to participate in vector encoding. For example, the special symbol added to the beginning of the statement is [CLS], and the special symbol added to the end of the statement is [SEP]. After adding special symbols, each word in the sentiment query statement and the special symbols in the sentiment query statement need to be vector-encoded, and each word in the document statement and the special symbols in the document statement need to be vector-encoded.

[0123] ② Vector aggregation module:

[0124] The vector aggregation module of the document processing model can be used to perform vector aggregation on the vector representations of each word in the sentiment query statement to obtain the vector representation of the sentiment query statement. The processing method for individual document statements in the sample document is similar to that for sentiment queries. For each document statement in the sample document, the vector aggregation module of the document processing model can be used to perform vector aggregation on the vector representations of each word in the document statement to obtain the vector representation of the document statement. Taking document statements as an example, the vector set processing method for document statements can be seen in Formulas 4 and 5 below:

[0125]

[0126]

[0127] In formula 4 above: h i The vector representation of the i-th document statement in the sample document; The vector representation of the j-th word in the i-th document statement; This represents the aggregation weight of the j-th word in the i-th document statement; Formula 4 above shows that the vector representation of the i-th document statement is the result of a weighted sum of the vector representations of each word in the i-th document statement using the aggregation weights of each word. In Formula 5 above: w t Let represent any initial weight; Formula 5 above is the calculation process of the aggregate weight of the j-th word in the i-th document statement. The aggregate weight of the j-th word in the i-th document statement can be equal to the proportion of the vector representation of the j-th word in the i-th document statement in the sum of the vector representations of all words in the i-th document statement.

[0128] It should be noted that, for cases where special symbols are added at the beginning and / or end of a statement, the vector representation of a sentiment query statement can be the result of vector aggregation processing of the vector representations of each word in the sentiment query statement and the vector representations of the added special symbols; the vector representation of a document statement can be the result of vector aggregation processing of the vector representations of each word in the document statement and the vector representations of the added special symbols.

[0129] ③ Context feature extraction module:

[0130] The context feature extraction module of the document processing model can be used to extract context features from the vector representation of the sentiment query statement, thus obtaining the context features of the sentiment query statement. The processing method for individual document statements in the sample document is similar to that for sentiment queries. For each document statement in the sample document, the context feature extraction module of the document processing model can be used to extract context features from the vector representation of each document statement in the sample document, thus obtaining the context features of each document statement.

[0131] ④ Binary classification module:

[0132] The binary classification module of the document processing model can be called to concatenate the context features of the sentiment query statement with the context features of each document statement to obtain the concatenated context features of each document statement. Then, based on the concatenated context features of each document statement, sentiment prediction can be performed on the corresponding document statement to obtain the sentiment prediction probability of each document statement in the sample document.

[0133] S403, invoke the document processing model to extract sentiment cause pairs from the sample document in the second direction, and obtain the processing loss of the document processing model in the second direction during the extraction of sentiment cause pairs.

[0134] In step S403, the document processing model can be invoked to extract sentiment cause pairs from the sample document in the second direction. During the extraction of sentiment cause pairs, the processing loss of the document processing model in the second direction can be obtained. The second direction can refer to the direction of extracting sentiment cause pairs based on the cause sentence, that is, the direction from the cause sentence to the sentiment sentence.

[0135] The process of extracting sentiment cause pairs in the first direction is similar to that in the second direction. Using a document processing model to extract sentiment cause pairs from sample documents in the second direction can include two stages: the first stage is extracting cause sentences from the sample documents, i.e., using the document processing model to predict cause sentences in the sample documents; the second stage is extracting the corresponding sentiment sentences from the sample documents given labeled cause sentences, i.e., using the document processing model to predict sentiment sentences in the sample documents based on the labeled cause sentences. The labeled cause sentences refer to the correct cause sentences in the sample documents. Furthermore, each stage corresponds to its own loss. The loss corresponding to the first stage is the cause sentence prediction loss, which is the loss generated by calling the document processing model to predict the cause sentences of the sample documents. The loss corresponding to the second stage is the sentiment sentence prediction loss, which is the loss generated by calling the document processing model to predict the sentiment sentences of the sample documents based on the labeled cause sentences. The cause sentence prediction loss of the first stage and the sentiment sentence prediction loss of the second stage together constitute the processing loss of the document processing model in the second direction. The processing loss of the document processing model in the second direction can be obtained by summing the cause sentence prediction loss of the first stage and the sentiment sentence prediction loss of the second stage.

[0136] The two phases of the second direction are similar to those of the first direction. A brief description of each phase of the second direction follows:

[0137] (1) The first stage of the second direction:

[0138] The first stage is the cause extraction stage. In this stage, the cause extraction query is obtained, and the document processing model is invoked to predict the cause of each document statement in the sample document based on the cause extraction query. This yields the cause prediction probability for each document statement in the sample document. Then, the cause prediction loss is calculated based on the cause classification type and cause prediction probability of each document statement. The cause prediction probability of a document statement can include the probability that the document statement is predicted as a cause statement and the probability that the document statement is predicted as a non-cause statement. When calculating the cause prediction loss, if the cause classification type of the document statement is cause statement (i.e., if the cause label of the document statement is cause statement label, such as "1"), then the cause prediction loss can be calculated using the probability that the document statement is predicted as cause statement. If the cause classification type of the document statement is non-cause statement (i.e., if the cause label of the document statement is non-cause statement label, such as "0"), then the cause prediction loss can be calculated using the probability that the document statement is predicted as non-cause statement.

[0139] (2) The second phase of the second direction:

[0140] The second stage is the sentiment extraction stage for the given cause sentence. In this stage, given the labeled cause sentence, a corresponding sentiment query can be generated. Similar to the first stage, the document processing model can be invoked to predict the sentiment of each document sentence in the sample document based on the sentiment query corresponding to the labeled cause sentence. This yields the sentiment prediction probability for each document sentence in the sample document. Then, the sentiment prediction loss can be calculated based on the sentiment classification type and sentiment prediction probability of each document sentence under the labeled cause sentence. The sentiment prediction probability of a document statement under the labeled cause sentence can include: the probability that the document statement is predicted as the sentiment sentence corresponding to the labeled cause sentence, and the probability that the document statement is predicted as the non-sentiment sentence corresponding to the labeled cause sentence. When calculating the sentiment sentence prediction loss, if the sentiment classification type of the document statement under the labeled cause sentence is sentiment sentence, that is, if the sentiment label of the document statement under the labeled cause sentence is sentiment sentence label (for example, it could be "1"), then the probability that the document statement is predicted as the sentiment sentence corresponding to the labeled cause sentence can be used to calculate the sentiment sentence prediction loss; if the sentiment classification type of the document statement under the labeled cause sentence is non-sentiment sentence, that is, if the sentiment label of the document statement under the labeled cause sentence is non-sentiment sentence label (for example, it could be "0"), then the probability that the document statement is predicted as the non-sentiment sentence corresponding to the labeled cause sentence can be used to calculate the sentiment sentence prediction loss.

[0141] It should be noted that the number of labeled reason sentences given in the second stage can be one or more. When there are multiple labeled reason sentences, sentiment sentence extraction needs to be performed for each labeled reason sentence to generate the sentiment sentence prediction loss corresponding to each labeled reason sentence. The sentiment sentence prediction loss in the second stage can be the sum of the sentiment sentence prediction losses corresponding to each labeled reason sentence given in the second stage.

[0142] Based on the two stages of the second direction described above, the processing loss of the document processing model in the second direction can be obtained by summing the causal sentence prediction loss of the first stage of the second direction and the sentiment sentence prediction loss of the second stage of the second direction. It should be noted that the process of calling the document processing model to predict sentiment and causal sentences in step S403 is similar to the process of calling the document processing model to predict sentiment and causal sentences in step S402 described above. For details, please refer to the description in step S402 above; this embodiment will not repeat it further.

[0143] S404 trains the document processing model based on the processing loss in the first direction and the processing loss in the second direction.

[0144] As can be seen from steps S402 and S403 above, during model training, corresponding cause sentences can be extracted based on given labeled sentiment sentences, and corresponding sentiment sentences can be extracted based on given labeled cause sentences. However, during model testing, there are no given labeled sentiment sentences or given labeled cause sentences. Instead, the corresponding cause sentences are queried based on the sentiment sentences extracted in the first stage, or the corresponding sentiment sentences are queried based on the cause sentences extracted in the first stage. This leads to inconsistencies between the model training process and the model testing process. To ensure consistency between the model training process and the model prediction process, this embodiment randomly samples non-sentiment sentences and non-cause sentences from the sample documents with a certain probability. Non-sentiment sentences can be used to simulate the situation where the document processing model extracts incorrect sentiment sentences during testing, and non-cause sentences can be used to simulate the situation where the document processing model extracts incorrect cause sentences during testing. Therefore, the document processing model can be trained by combining the loss generated by extracting the sentiment cause pairs corresponding to non-sentiment sentences and the loss generated by extracting the sentiment cause pairs corresponding to non-cause sentences with the processing loss in the first direction and the processing loss in the second direction. Specifically:

[0145] (1) For non-sentimental sentences, the document processing model can be invoked to extract the sentiment cause pairs corresponding to the non-sentimental sentences from the sample documents. During the extraction of sentiment cause pairs, the test simulation loss of the document processing model for non-sentimental sentences can be obtained. Specifically, the cause query statements corresponding to the non-sentimental sentences can be generated. Then, the document processing model can be invoked to predict the cause sentences of each document statement in the sample documents based on the cause query statements corresponding to the non-sentimental sentences. The cause prediction probability of each document statement in the sample documents under non-sentimental sentences can be obtained. Then, the test simulation loss of the document processing model for non-sentimental sentences can be calculated based on the cause classification type and cause prediction probability of each document statement under non-sentimental sentences.

[0146] The probability of predicting the cause of a document statement under a non-sentimental sentence can include: the probability that the document statement is predicted as a cause sentence corresponding to a non-sentimental sentence, and the probability that the document statement is predicted as a non-cause sentence corresponding to a non-sentimental sentence. When calculating the test simulation loss for non-sentimental sentences, if the cause classification type of the document statement under a non-sentimental sentence is cause sentence, that is, if the cause label of the document statement under a non-sentimental sentence is cause sentence label (e.g., it could be "1"), then the probability that the document statement is predicted as a cause sentence corresponding to a non-sentimental sentence can be used to calculate the test simulation loss for non-sentimental sentences. If the cause classification type of the document statement under a non-sentimental sentence is non-cause sentence, that is, if the cause label of the document statement under a non-sentimental sentence is non-cause sentence label (e.g., it could be "0"), then the probability that the document statement is predicted as a non-cause sentence corresponding to a non-sentimental sentence can be used to calculate the test simulation loss for non-sentimental sentences. Theoretically, non-sentimental sentences do not contain causal sentences. Therefore, the causal classification type of each document statement in the sample document under non-sentimental sentences should be non-causal sentences. That is, the causal label of each document statement in the sample document under non-sentimental sentences should be non-causal sentence label (e.g., it can be "0"). Thus, the test simulation loss of non-sentimental sentences can be calculated by using the probability that each document statement in the sample document is predicted as a non-causal sentence corresponding to a non-sentimental sentence.

[0147] It should be noted that the number of non-sentimental sentences randomly sampled from the sample documents can be one or more. When there are multiple non-sentimental sentences, a cause sentence extraction needs to be performed for each non-sentimental sentence to generate the test simulation loss corresponding to each non-sentimental sentence, and the sum of the simulation test losses corresponding to each non-sentimental sentence should be calculated. The calculation process of the test simulation loss of non-sentimental sentences can be found in Formula 6 below:

[0148]

[0149] In formula 6 above: L CON1 L' represents the test simulation loss for non-sentimental sentences; N represents the number of document sentences in the sample document, where N is an integer greater than 1; L' e This represents the set of non-sentimental sentences sampled from the sample document; the set of non-sentimental sentences may include one or more non-sentimental sentences; c j This represents the j-th non-emotional sentence in the set of non-emotional sentences; The label represents the reason label of the i-th document statement in the j-th non-sentimental sentence, i.e., the reason classification type of the i-th document statement in the j-th non-sentimental sentence, where i is a positive integer less than or equal to N; This represents the probability of causal prediction for the i-th document statement under the j-th non-sentimental statement.

[0150] (2) For non-causal sentences: Similar to the case of non-sentiment sentences, the document processing model can be called to extract the sentiment cause pairs corresponding to the non-causal sentences from the sample documents. In the process of extracting the sentiment cause pairs, the test simulation loss of the document processing model for non-causal sentences can be obtained. Specifically, the sentiment query statement corresponding to the non-causal sentence can be generated. Then, the document processing model can be called to predict the sentiment of each document statement in the sample document based on the sentiment query statement corresponding to the non-causal sentence, and obtain the sentiment prediction probability of each document statement in the sample document under the non-causal sentence. Then, the test simulation loss of the document processing model for non-causal sentences can be calculated according to the sentiment classification type and sentiment prediction probability of each document statement under the non-causal sentence.

[0151] The sentiment prediction probability of a document statement under a non-causal sentence can include: the probability that the document statement is predicted as a sentiment sentence corresponding to a non-causal sentence, and the probability that the document statement is predicted as a non-sentiment sentence corresponding to a non-causal sentence. When calculating the test simulation loss of a non-causal sentence, if the sentiment classification type of the document statement under a non-causal sentence is sentiment sentence, that is, if the sentiment label of the document statement under a non-causal sentence is sentiment sentence label (e.g., it could be "1"), then the probability that the document statement is predicted as a sentiment sentence corresponding to a non-causal sentence can be used to calculate the test simulation loss of the non-causal sentence; if the sentiment classification type of the document statement under a non-causal sentence is non-sentiment sentence, that is, if the sentiment label of the document statement under a non-causal sentence is non-sentiment sentence label (e.g., it could be "0"), then the probability that the document statement is predicted as a non-sentiment sentence corresponding to a non-causal sentence can be used to calculate the test simulation loss of the non-causal sentence. Theoretically, non-causal sentences do not contain sentiment sentences. Therefore, the sentiment classification type of each document statement in the sample document under non-causal sentences should be non-sentiment sentences. That is, the sentiment label of each document statement in the sample document under non-causal sentences should be a non-sentiment sentence label (e.g., it can be "0"). Thus, the test simulation loss of non-causal sentences can be calculated by using the probability that each document statement in the sample document is predicted as a non-sentiment sentence corresponding to a non-causal sentence.

[0152] It should be noted that the number of non-causal sentences randomly sampled from the sample documents can be one or more. When there are multiple non-causal sentences, sentiment sentence extraction needs to be performed for each non-causal sentence to generate the test simulation loss corresponding to each non-causal sentence, and the sum of the simulation test losses corresponding to each non-causal sentence should be calculated. The calculation process of the test simulation loss for non-causal sentences can be found in Formula 7 below:

[0153]

[0154] In formula 7 above: L CON2 L' represents the test simulation loss for non-causal sentences; N represents the number of document sentences in the sample document, where N is an integer greater than 1; L'c This represents the set of non-causal sentences sampled from the sample document; the set of non-causal sentences may include one or more non-causal sentences; c j This represents the j-th non-causal sentence in the set of non-causal sentences; This represents the sentiment label of the i-th document statement in the j-th non-causal sentence, i.e., the sentiment classification type of the i-th document statement under the j-th non-causal sentence, where i is a positive integer less than or equal to N; This represents the sentiment prediction probability of the i-th document statement under the j-th non-causal statement.

[0155] Based on the test simulation losses for non-sentimental sentences and non-causal sentences mentioned above, the processing loss (also known as consistency loss) for the simulated test scenario can be determined jointly by the test simulation losses for non-sentimental sentences and non-causal sentences. The processing loss for the simulated test scenario can be equal to the sum of the test simulation losses for non-sentimental sentences and non-causal sentences, as detailed in Formula 8 below:

[0156]

[0157] In formula 8 above: L CON L represents the processing loss in the simulated test scenario. CON1 The test simulation loss represents the loss of non-emotional sentences; L CON2 This represents the test simulation loss for non-causal sentences.

[0158] Based on the above content regarding the processing loss in the simulated test scenario, in step S404, the document processing model can be trained according to the processing loss in the first direction, the processing loss in the second direction, and the processing loss in the simulated test scenario (including the simulated test loss for non-sentimental sentences and the simulated test loss for non-sentimental sentences). Specifically, the bidirectional loss can be determined based on the processing loss in the first direction and the processing loss in the second direction, and the bidirectional loss can be equal to the sum of the processing loss in the first direction and the processing loss in the second direction; then, the loss information of the document processing model can be determined based on the bidirectional loss and the processing loss in the simulated test scenario. See Formulas 9 and 10 below for details:

[0159] L DUAL =L EC +L CE Formula 9

[0160] L = L DUAL +L CON Formula 10

[0161] Formula 9 above describes the calculation process for bidirectional loss, L DUAL L represents a two-way loss. ECL represents the processing loss in the first direction. VE This represents the processing loss in the second direction. Formula 10 above describes the calculation process of the loss information for the document processing model, where L represents the loss information of the document processing model. DUAL L represents a two-way loss. CON This represents the processing loss in the simulated test scenario.

[0162] After determining the loss information of the document processing model, the model parameters can be optimized in the direction of reducing the loss information to train the document processing model. It should be noted that "in the direction of reducing loss information" means optimizing the model with the goal of minimizing the loss information; by optimizing the model in this direction, the loss information generated by the optimized document processing model should be less than the loss information generated by the original document processing model. For example, if the loss information of the document processing model calculated in this case is 0.85, then after optimizing the document processing model in the direction of reducing loss information, the loss information generated by the optimized document processing model should be less than 0.85.

[0163] It should be noted that the process of calling the document processing model to predict sentiment sentences and cause sentences in step S404 is similar to the process of calling the document processing model to predict sentiment sentences and cause sentences in step S402 above. For details, please refer to the description in step S402 above. This application embodiment will not repeat it here.

[0164] Steps S401-S404 above use a sample document as an example to introduce a training process of the document processing model. In the actual training process of the document processing model, it is necessary to continuously train the document processing model by acquiring sample documents. Each time it is trained, the model parameters of the document processing model are optimized once. If the loss information generated by the document processing model after multiple optimizations is less than the loss threshold, it can be determined that the training process of the document processing model has ended. The document processing model obtained by the last optimization can be determined as the trained document processing model. The trained document processing model is used to extract sentiment reason pairs according to the first direction and the second direction respectively.

[0165] In this embodiment, two directions for extracting sentiment cause pairs are proposed, including a first direction and a second direction. By calling the document processing model to extract sentiment cause pairs from sample documents according to these two directions and applying the processing loss generated, the document processing model can be trained, thereby improving its training effect and the accuracy of sentiment cause pair extraction. Furthermore, this embodiment considers the inconsistency between model training and testing during model training and designs a consistency loss based on this inconsistency to train the document processing model. This allows the document processing model to better serve the model application process, further improving its training effect and the accuracy of sentiment cause pair extraction.

[0166] This application provides a document processing method, which mainly describes the testing (application) process of a document processing model. This document processing method can be executed by a computer device, which can be a server 301 or a terminal device 302 in the aforementioned document processing system. Figure 6 As shown, this document processing method may include, but is not limited to, the following steps S601-S608:

[0167] S601, Obtain sample documents for training the document processing model.

[0168] S602, call the document processing model to extract sentiment cause pairs from the sample document in the first direction, and obtain the processing loss of the document processing model in the first direction during the extraction of sentiment cause pairs.

[0169] S603, call the document processing model to extract sentiment cause pairs from the sample document in the second direction, and obtain the processing loss of the document processing model in the second direction during the extraction of sentiment cause pairs.

[0170] S604 trains the document processing model based on the processing loss in the first direction and the processing loss in the second direction.

[0171] In this embodiment, steps S601-S604 involve the model training process, and details of the model training process can be found above. Figure 4 The embodiments shown are described herein and will not be repeated in the embodiments of this application.

[0172] S605, Obtain the target document to be processed.

[0173] The target document is the document from which sentiment cause pairs are to be extracted, and it may include multiple document statements. Similar to the model training process, during model application, when it is necessary to extract sentiment cause pairs from the target document, sentiment cause pairs can be extracted from the target document in two directions (i.e., the first direction and the second direction) first. Then, according to the inference strategy, the final sentiment cause pairs of the target document are determined from the sentiment cause pairs in the first direction and the sentiment cause pairs in the second direction. The following describes the process of extracting sentiment cause pairs from the target document in the first direction in conjunction with step S606, the process of extracting sentiment cause pairs from the target document in the second direction in conjunction with step S607, and the process of determining the final sentiment cause pairs of the target document from the sentiment cause pairs in both directions in conjunction with step S608.

[0174] S606, call the trained document processing model, extract sentiment cause pairs from the target document according to the first direction, and obtain the first sentiment cause pair set.

[0175] The pre-trained document processing model is invoked to extract sentiment reason pairs from the target document in the first direction, which can be divided into two stages:

[0176] The first stage of the first approach involves extracting sentiment sentences from the target document. Specifically, a pre-trained document processing model can be invoked to predict the sentiment of each document statement in the target document, yielding the predicted sentiment sentence. This process of using the pre-trained document processing model to predict the sentiment of each document statement in the target document is similar to the process of using the document processing model to predict the sentiment of each document statement in the sample document during model training. Both require obtaining the sentiment query statement, representing the sentiment query statement and each document statement in the sample document as vectors, extracting contextual features, and concatenating the contextual features of the sentiment query statement with each document statement in the sample document. For details, please refer to the above. Figure 4 The relevant description of the illustrated embodiment.

[0177] This section focuses on the difference between the model application process and the model training process: Based on the concatenated context features of each document sentence, sentiment prediction is performed on the corresponding document sentences. This yields the sentiment prediction probability of each document sentence in the target document. The sentiment prediction probability of a document sentence can include: the probability that the document sentence is predicted as a sentiment sentence and the probability that the document sentence is predicted as a non-sentiment sentence. If the probability that a document sentence is predicted as a sentiment sentence is greater than the probability that the document sentence is predicted as a non-sentiment sentence, then the document sentence can be identified as a predicted sentiment sentence. In this case, the probability that the document sentence is predicted as a sentiment sentence can be called the sentiment prediction probability of the predicted sentiment sentence. If the probability that a document sentence is predicted as a sentiment sentence is less than or equal to the probability that the document sentence is predicted as a non-sentiment sentence, then the document sentence can be identified as a predicted non-sentiment sentence.

[0178] The second stage of the first direction involves extracting the predicted cause sentences corresponding to the predicted sentiment sentences from the target document. Specifically, a pre-trained document processing model can be invoked to predict cause sentences for each document statement in the target document based on the predicted sentiment sentence, thus obtaining the predicted cause sentences corresponding to the predicted sentiment sentence. This process of invoking the pre-trained document processing model to predict cause sentences for each document statement in the target document based on the predicted sentiment sentence is similar to the process of invoking the document processing model during model training to predict cause sentences for each document statement in the sample document based on a given labeled sentiment sentence. Both require generating corresponding query statements (generating the cause query statements corresponding to the predicted sentiment sentences during the model application stage). This involves vector representation of the cause query statements and each document statement in the sample document, extraction of contextual features, and concatenation of the contextual features of the cause query statements with each document statement in the sample document. For details, please refer to the above. Figure 4 The relevant description of the illustrated embodiment.

[0179] This section focuses on the differences between the model training and application processes: Based on the concatenated context features of each document statement, causal sentence prediction is performed on the corresponding document statements. This yields the causal prediction probability of each document statement in the target document under the predicted sentiment sentence. The causal prediction probability of a document statement under the predicted sentiment sentence can include: the probability that the document statement is predicted as the causal sentence corresponding to the predicted sentiment sentence and the probability that the document statement is predicted as the non-causal sentence corresponding to the predicted sentiment sentence. If the probability that the document statement is predicted as the causal sentence corresponding to the predicted sentiment sentence is greater than the probability that the document statement is predicted as the non-causal sentence corresponding to the predicted sentiment sentence, then the document statement can be identified as the predicted causal sentence corresponding to the predicted sentiment sentence. In this case, the probability that the document statement is predicted as the causal sentence corresponding to the predicted sentiment sentence can be called the causal prediction probability of the causal sentence. If the probability that the document statement is predicted as the causal sentence corresponding to the predicted sentiment sentence is less than or equal to the probability that the document statement is predicted as the non-causal sentence corresponding to the predicted sentiment sentence, then the document statement can be identified as the predicted non-causal sentence corresponding to the predicted sentiment sentence.

[0180] It should be noted that the number of predicted sentiment sentences obtained from the first stage prediction in the first direction can be one or more. When there are multiple predicted sentiment sentences, a cause sentence prediction needs to be performed for each predicted sentiment sentence to obtain the corresponding predicted cause sentence for each predicted sentiment sentence. Thus, the predicted sentiment sentences and their corresponding predicted cause sentences can be combined to obtain a first set of sentiment cause pairs, which may include one or more sentiment cause pairs.

[0181] S607, call the trained document processing model, extract sentiment cause pairs from the target document in the second direction, and obtain the second sentiment cause pair set;

[0182] Similar to the first direction, the pre-trained document processing model is invoked to extract sentiment cause pairs from the target document according to the second direction, which can specifically include two stages:

[0183] The first stage of the second direction involves extracting causal sentences from the target document. Specifically, a trained document processing model can be invoked to predict causal sentences for each document statement in the target document, resulting in predicted causal sentences. This process of invoking the trained document processing model to predict causal sentences for each document statement in the target document is similar to the process of invoking the document processing model to predict causal sentences for each document statement in the sample document during model training. Both require obtaining the causal query statement, representing the causal query statement and each document statement in the sample document as vectors, extracting contextual features, and concatenating the contextual features of the causal query statement with each document statement in the sample document. For details, please refer to the above. Figure 4 The relevant description of the illustrated embodiment.

[0184] This section focuses on the difference between the model application process and the model training process: Based on the concatenated context features of each document statement, causal sentence prediction is performed on the corresponding document statements. This yields the causal prediction probability of each document statement in the target document. The causal prediction probability of a document statement can include: the probability that the document statement is predicted as a causal sentence and the probability that the document statement is predicted as a non-causal sentence. If the probability that a document statement is predicted as a causal sentence is greater than the probability that the document statement is predicted as a non-causal sentence, then the document statement can be identified as a predicted causal sentence. In this case, the probability that the document statement is predicted as a causal sentence can be called the causal prediction probability of the predicted causal sentence. If the probability that a document statement is predicted as a causal sentence is less than or equal to the probability that the document statement is predicted as a non-causal sentence, then the document statement can be identified as a predicted non-causal sentence.

[0185] The second stage of the second direction involves extracting the predicted sentiment sentences corresponding to the predicted cause sentences from the target document. Specifically, a pre-trained document processing model can be invoked to predict the sentiment of each document statement in the target document based on the predicted cause sentence, thus obtaining the predicted sentiment sentence corresponding to the predicted cause sentence. This process of invoking the pre-trained document processing model to predict the sentiment of each document statement in the target document based on the predicted cause sentence is similar to the process of invoking the document processing model during model training to predict the sentiment of each document statement in the sample document based on the given labeled cause sentence. Both require generating corresponding query statements (generating the sentiment query statement corresponding to the predicted cause sentence during the model application stage), performing vector representation on the sentiment query statement and each document statement in the sample document, extracting contextual features, and concatenating the contextual features of the sentiment query statement with each document statement in the sample document. For details, please refer to the above. Figure 4 The relevant description of the illustrated embodiment.

[0186] This section focuses on the differences between the model training and application processes: Based on the concatenated context features of each document statement, sentiment prediction is performed on the corresponding document statements. This yields the sentiment prediction probability of each document statement in the target document under the prediction cause statement. The sentiment prediction probability of a document statement under the prediction cause statement can include: the probability that the document statement is predicted as the sentiment sentence corresponding to the prediction cause statement and the probability that the document statement is predicted as the non-sentiment sentence corresponding to the prediction cause statement. If the probability that the document statement is predicted as the sentiment sentence corresponding to the prediction cause statement is greater than the probability that the document statement is predicted as the non-sentiment sentence corresponding to the prediction cause statement, then the document statement can be identified as the predicted sentiment sentence corresponding to the prediction cause statement. In this case, the probability that the document statement is predicted as the sentiment sentence corresponding to the prediction cause statement can be called the sentiment prediction probability of the predicted sentiment sentence. If the probability that the document statement is predicted as the sentiment sentence corresponding to the prediction cause statement is less than or equal to the probability that the document statement is predicted as the non-sentiment sentence corresponding to the prediction cause statement, then the document statement can be identified as the predicted non-sentiment sentence corresponding to the prediction cause statement.

[0187] It should be noted that the number of predicted cause sentences obtained from the first stage prediction in the second direction can be one or more. When there are multiple predicted cause sentences, sentiment sentence prediction needs to be performed for each predicted sentiment cause sentence to obtain the corresponding predicted sentiment sentence for each predicted cause sentence. Thus, the predicted cause sentences and their corresponding predicted sentiment sentences can be combined to obtain a second set of sentiment cause pairs, which may include one or more sentiment cause pairs.

[0188] S608, in the first set of sentiment cause pairs and the second set of sentiment cause pairs, determine the sentiment cause pair corresponding to the target document.

[0189] Determining the sentiment cause pair corresponding to the target document from the first and second sentiment cause pair sets can be done using inference strategies, which may include any of the following: intersection strategy, union strategy, complementarity strategy, and reconciliation strategy. The following sections describe these four inference strategies in detail:

[0190] (1) Intersection strategy:

[0191] The intersection strategy specifically refers to taking the intersection of the first set of sentiment cause pairs and the second set of sentiment cause pairs as the sentiment cause pairs corresponding to the target document. In other words, common sentiment cause pairs existing in both the first and second sets of sentiment cause pairs are identified as the sentiment cause pairs corresponding to the target document. For example... Figure 7aAs shown, the first set of sentiment cause pairs includes sentiment cause pair A, sentiment cause pair B, and sentiment cause pair E, and the second set of sentiment cause pairs includes sentiment cause pair B, sentiment cause pair C, and sentiment cause pair D. The intersection of the first set of sentiment cause pairs and the second set of sentiment cause pairs is sentiment cause pair B. Therefore, sentiment cause pair B can be identified as the sentiment cause pair corresponding to the target document.

[0192] (2) Union strategy:

[0193] The union strategy specifically refers to taking the union of the first set of sentiment cause pairs and the second set of sentiment cause pairs as the sentiment cause pairs corresponding to the target document. In other words, sentiment cause pairs from both the first and second sets of sentiment cause pairs can be identified as the sentiment cause pairs corresponding to the target document. For example... Figure 7b As shown, the first set of sentiment cause pairs includes sentiment cause pair A, sentiment cause pair B, and sentiment cause pair E, and the second set of sentiment cause pairs includes sentiment cause pair B, sentiment cause pair C, and sentiment cause pair D. All five sentiment cause pairs, from sentiment cause pair A to sentiment cause pair E, can be identified as the sentiment cause pairs corresponding to the target document.

[0194] Before introducing complementary and reconciliation strategies, we will first introduce the concept of confidence. The confidence involved in the embodiments of this application may include: the confidence of the set of emotional cause pairs and the confidence of the emotional cause pairs.

[0195] in:

[0196] The confidence level of an emotional cause pair refers to the degree of certainty that the predicted emotional cause pair is correct. The higher the confidence level of an emotional cause pair, the higher the certainty that the predicted emotional cause pair is correct. The confidence level of an emotional cause pair can be determined based on the emotional prediction probability of the predicted emotional sentence that makes up the emotional cause pair, and / or the causal prediction probability of the predicted cause sentence. For example, the emotional prediction probability of the predicted emotional sentence can be used as the confidence level of the emotional cause pair, or the causal prediction probability of the predicted cause sentence can be used as the confidence level of the emotional cause pair, or the sum of the emotional prediction probability of the predicted emotional sentence and the causal prediction probability of the predicted cause sentence can be used as the confidence level of the emotional cause pair, or the product of the emotional prediction probability of the predicted emotional sentence and the causal prediction probability of the predicted cause sentence can be used as the confidence level of the emotional cause pair, and so on.

[0197] The confidence level of a sentiment prediction set refers to the degree of credibility of the sentiment cause set. A higher confidence level indicates a higher degree of credibility of the sentiment cause set. The confidence level of a sentiment cause set can be determined based on the confidence levels of all sentiment cause pairs within the set. For example, the sum of the confidence levels of all sentiment cause pairs in the first sentiment cause set can be used to determine the confidence level of the first sentiment cause set.

[0198] Based on the concept of confidence level mentioned above, the complementary strategy and the reconciliation strategy will be introduced below:

[0199] (3) Complementary strategy:

[0200] The complementary strategy refers to: identifying all sentiment cause pairs in the set of sentiment cause pairs corresponding to the credible direction (i.e., the credible sentiment cause pair set) as the sentiment cause pairs corresponding to the target document, and identifying sentiment cause pairs with high confidence in the set of sentiment cause pairs corresponding to the untrusted direction (i.e., the untrusted sentiment cause pair set) as the sentiment cause pairs corresponding to the target document. Specifically, the credible and untrusted sentiment cause pair sets can be determined from the first and second sentiment cause pair sets. These sets can be randomly determined or specified; for example, the first sentiment cause pair set in the first direction can be designated as the credible sentiment cause pair set, and the second sentiment cause pair set in the second direction can be designated as the untrusted sentiment cause pair set. Alternatively, they can be determined based on the confidence level of the sentiment cause pair sets; for example, the set of sentiment cause pairs with high confidence can be designated as the credible sentiment cause pair set. Then, all sentiment cause pairs in the credible sentiment cause pair set can be identified as the sentiment cause pairs corresponding to the target document, and the sentiment cause pairs in the untrusted sentiment cause pair set with confidence levels greater than a confidence threshold can be identified as the sentiment cause pairs corresponding to the target document.

[0201] like Figure 7cAs shown, the first set of sentiment cause pairs includes sentiment cause pair A (confidence 0.9), sentiment cause pair B (confidence 0.8), and sentiment cause pair E (confidence 0.7), while the second set of sentiment cause pairs includes sentiment cause pair B (confidence 0.8), sentiment cause pair C (confidence 0.7), and sentiment cause pair D (0.6). The confidence level of the first set of sentiment cause pairs is higher than that of the second set of sentiment cause pairs, so the first set of sentiment cause pairs can be considered a credible set of sentiment cause pairs, and the second set of sentiment cause pairs can be considered an uncredible set of sentiment cause pairs. Therefore, all sentiment cause pairs in the credible set of sentiment cause pairs (i.e., sentiment cause pair A, sentiment cause pair B, and sentiment cause pair E) can be identified as the sentiment cause pairs corresponding to the target document, and sentiment cause pairs B and C in the uncredible set of sentiment cause pairs with a confidence level greater than the confidence threshold (0.6) can be identified as the sentiment cause pairs corresponding to the target document.

[0202] (4) Reconciliation strategy:

[0203] The reconciliation strategy refers to identifying common sentiment cause pairs that exist in both the first and second sentiment cause pair sets as the sentiment cause pairs corresponding to the target document. For non-common sentiment cause pairs in the first and second sentiment cause pair sets (e.g., sentiment cause pairs that exist only in the first sentiment cause pair set or only in the second sentiment cause pair set), the non-common sentiment cause pairs with a confidence level higher than the confidence level threshold are identified as the sentiment cause pairs corresponding to the target document. Specifically, the target sentiment cause can be any sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set. If both the first and second sentiment cause pair sets contain the target sentiment cause pair, that is, the target sentiment cause pair is a common sentiment cause pair, then the target sentiment cause pair can be determined as the sentiment cause pair corresponding to the target document. If either the first or second sentiment cause pair set contains the target sentiment cause pair, that is, the target sentiment cause pair is not a common sentiment cause pair, then the confidence level of the target sentiment cause pair can be compared with the confidence level threshold. If the confidence level of the target sentiment cause pair is greater than the confidence level threshold, then the target sentiment cause pair can be determined as the sentiment cause pair corresponding to the target document.

[0204] For example, such as Figure 7dAs shown, the first set of sentiment cause pairs includes sentiment cause pair A (confidence 0.9), sentiment cause pair B (confidence 0.8), and sentiment cause pair E (confidence 0.7), and the second set of sentiment cause pairs includes sentiment cause pair B (confidence 0.8), sentiment cause pair C (confidence 0.7), and sentiment cause pair D (0.6). Sentiment cause pair B is a common sentiment cause pair in the first and second sets of sentiment cause pairs, and can be identified as the sentiment cause pair corresponding to the target document. For non-common sentiment cause pairs (including sentiment cause pair A, sentiment cause pair E, sentiment cause pair C, and sentiment cause pair D), sentiment cause pair A, sentiment cause pair E, and sentiment cause pair C with a confidence level greater than the confidence threshold (0.6) can be identified as the sentiment cause pair corresponding to the target document.

[0205] The intersection strategy identifies the common sentiment cause pairs predicted in both directions as the sentiment cause pairs of the target document; the union strategy identifies both common sentiment cause pairs predicted in both directions as the sentiment cause pairs of the target document; the complementarity strategy, considering the credibility of one direction, identifies all sentiment cause pairs predicted in the credible direction as the final sentiment cause pairs of the target document, and identifies sentiment cause pairs predicted in the uncredible direction with a confidence level greater than a confidence threshold as the sentiment cause pairs of the target document; the reconciliation strategy identifies the common sentiment cause pairs predicted in both directions as the sentiment cause pairs of the target document, and identifies sentiment cause pairs among the non-common sentiment cause pairs with a confidence level greater than a confidence threshold as the sentiment cause pairs of the target document; and the inference strategy further selects the sentiment cause pairs predicted in both directions, which helps improve the accuracy of the document processing model in extracting sentiment cause pairs.

[0206] Figure 8A specific example of the model application process is shown: the target document includes 5 document statements. In the first stage of the first direction, the predicted sentiment statements extracted based on the sentiment query statement "find sentiment statement" are document statements c2 and c5; in the second stage of the first direction, the predicted cause statement extracted based on the cause query statement "find cause statement corresponding to sentiment statement c2" is document statement c2, and the predicted cause statement extracted based on the cause query statement "find cause statement corresponding to sentiment statement c5" is document statement c4; thus, the first set of sentiment cause pairs extracted in the first direction includes: sentiment cause pair (c2, c2) and sentiment cause pair (c5, c4). In the first stage of the second direction, the predicted cause sentences extracted based on the cause query statement "found cause sentence" are document statements c2 and c4. In the second stage of the second direction, the predicted sentiment sentence extracted based on the sentiment query statement "found sentiment sentence corresponding to cause sentence c2" is document statement c2, and the predicted sentiment sentence extracted based on the sentiment query statement "found sentiment sentence corresponding to cause sentence c4" is document statement c5. Therefore, the second set of sentiment cause pairs extracted in the first direction includes sentiment cause pair (c2, c2) and sentiment cause pair (c5, c4). The sentiment cause pairs contained in the first and second sets of sentiment cause pairs are the same. Therefore, the sentiment cause pairs corresponding to the target document determined by the intersection or union strategy are both sentiment cause pair (c2, c2) and sentiment cause pair (c5, c4).

[0207] In this embodiment, the model application process considers two directions for extracting sentiment cause pairs. Finally, the final sentiment cause pair is determined from the extraction results of the two directions according to the inference strategy. The inference strategy considers factors such as common sentiment cause pairs in the two directions, the confidence of the sentiment cause pair, or the confidence of the two directions. This can make the credibility of the determined sentiment cause pairs of the target document higher and greatly improve the accuracy of the document processing model in extracting sentiment cause pairs.

[0208] The methods of the embodiments of this application have been described in detail above. In order to facilitate better implementation of the above solutions of the embodiments of this application, the apparatus of the embodiments of this application is provided below.

[0209] Please see Figure 9 , Figure 9 This is a schematic diagram of a document processing device provided in an embodiment of this application. The document processing device can be installed in a computer device provided in the embodiment of this application. The computer device can be the server 301 or the terminal device 302 mentioned in the above method embodiment. Figure 9The document processing apparatus shown may be a computer program (including program code) running on a computer device, which can be used to execute... Figure 4 or Figure 6 Some or all of the steps in the method embodiments shown. Please refer to [link / reference]. Figure 9 The document processing apparatus may include the following units:

[0210] Acquisition unit 901 is used to acquire sample documents for training the document processing model;

[0211] Processing unit 902 is used to call the document processing model to extract sentiment cause pairs from the sample document in a first direction, and to obtain the processing loss of the document processing model in the first direction during the extraction of sentiment cause pairs; a sentiment cause pair refers to a pair of statements consisting of a sentiment sentence and a cause sentence; the first direction refers to the direction in which sentiment cause pairs are extracted based on the sentiment sentence;

[0212] The processing unit 902 is also used to call the document processing model to extract sentiment cause pairs from the sample document in the second direction, and to obtain the processing loss of the document processing model in the second direction during the extraction of sentiment cause pairs; the second direction refers to the direction of extracting sentiment cause pairs based on the cause sentences;

[0213] The processing unit 902 is also used to train the document processing model based on the processing loss in the first direction and the processing loss in the second direction; the trained document processing model is used to extract sentiment reason pairs according to the first direction and the second direction respectively.

[0214] In one implementation, the processing unit 902 is used to invoke the document processing model to extract sentiment cause pairs from the sample document in a first direction, and during the extraction of sentiment cause pairs, when obtaining the processing loss of the document processing model in the first direction, it is specifically used to perform the following steps:

[0215] Call the document processing model to predict sentiment sentences in the sample documents and obtain the sentiment sentence prediction loss generated by the sentiment sentence prediction.

[0216] The document processing model is invoked to predict the cause sentences in the sample documents based on the labeled sentiment sentences, and the cause sentence prediction loss generated by the cause sentence prediction is obtained.

[0217] The loss for predicting sentiment sentences and the loss for predicting causes are summed to obtain the processing loss of the document processing model in the first direction.

[0218] In one implementation, the sample document includes multiple document sentences; the processing unit 902, used to call the document processing model to predict the sentiment sentences of the sample document and obtain the sentiment sentence prediction loss generated by the sentiment sentence prediction, specifically performs the following steps:

[0219] Retrieve sentiment query statements;

[0220] The document processing model is invoked to predict the sentiment of each document statement in the sample document based on the sentiment query statement, thereby obtaining the sentiment prediction probability of each document statement in the sample document.

[0221] The sentiment prediction loss is calculated based on the sentiment classification type and sentiment prediction probability of each document sentence.

[0222] In one implementation, the processing unit 902 is used to invoke the document processing model to predict the sentiment of each document statement in the sample document based on the sentiment query statement, and to obtain the sentiment prediction probability of each document statement in the sample document, specifically to perform the following steps:

[0223] The sentiment query statement is vector-encoded to obtain a vector representation of the sentiment query statement; and the statements in each document in the sample document are vector-encoded to obtain a vector representation of each document statement.

[0224] Context features are extracted from the vector representation of sentiment query statements to obtain the context features of sentiment query statements; and context features are extracted from the vector representation of statements in each document to obtain the context features of statements in each document.

[0225] The context features of the sentiment query statement are concatenated with the context features of each document statement to obtain the concatenated context features of each document statement.

[0226] Based on the splicing context features of each document statement, sentiment prediction is performed on the corresponding document statements to obtain the sentiment prediction probability of each document statement in the sample documents.

[0227] In one implementation, the acquisition unit 901 is also used to acquire non-sentimental sentences and non-causal sentences in the sample document; the non-sentimental sentences are used to simulate the situation where the document processing model extracts incorrect sentimental sentences during the test, and the non-causal sentences are used to simulate the situation where the document processing model extracts incorrect causal sentences during the test.

[0228] The processing unit 902 is also used to call the document processing model to extract the sentiment cause pairs corresponding to non-sentiment sentences from the sample document, and to obtain the test simulation loss of the document processing model for non-sentiment sentences during the extraction of sentiment cause pairs.

[0229] The processing unit 902 is also used to call the document processing model to extract the sentiment cause pairs corresponding to non-cause sentences from the sample document, and to obtain the test simulation loss of the document processing model for non-cause sentences during the extraction of sentiment cause pairs.

[0230] The processing unit 902 is used to train the document processing model based on the processing loss in the first direction and the processing loss in the second direction. Specifically, it is used to perform the following steps: train the document processing model based on the processing loss in the first direction, the processing loss in the second direction, the test simulation loss of non-sentimental sentences, and the test simulation loss of non-causal sentences.

[0231] In one implementation, the sample document includes multiple document sentences; the processing unit 902 is used to call the document processing model to extract sentiment cause pairs corresponding to non-sentiment sentences from the sample document, and during the extraction of sentiment cause pairs, when obtaining the test simulation loss of the document processing model for non-sentiment sentences, it is specifically used to perform the following steps:

[0232] Generate the reason query statement corresponding to the non-sentiment sentence;

[0233] The document processing model is invoked to predict the cause of each document statement in the sample document based on the cause query statement corresponding to the non-sentiment sentence, thereby obtaining the cause prediction probability of each document statement in the sample document under the non-sentiment sentence.

[0234] Based on the cause classification type and cause prediction probability of each document sentence under non-sentimental sentences, calculate the test simulation loss of the document processing model for non-sentimental sentences.

[0235] In one implementation, the acquisition unit 901 is also used to acquire the target document to be processed;

[0236] The processing unit 902 is also used to call the trained document processing model to extract sentiment cause pairs from the target document in the first direction to obtain the first sentiment cause pair set;

[0237] The processing unit 902 is also used to call the trained document processing model to extract sentiment cause pairs from the target document in the second direction to obtain a second sentiment cause pair set.

[0238] The processing unit 902 is further configured to determine the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set.

[0239] In one implementation, the target document includes multiple document statements; the processing unit 902, used to call a trained document processing model to extract sentiment cause pairs from the target document according to a first direction, specifically performs the following steps when obtaining the first sentiment cause pair set:

[0240] The trained document processing model is invoked to predict the sentiment sentence for each document sentence in the target document, thus obtaining the predicted sentiment sentence in the target document.

[0241] The trained document processing model is invoked to predict the cause sentences of each document statement in the target document based on the predicted sentiment sentence, thereby obtaining the predicted cause sentences corresponding to the predicted sentiment sentences.

[0242] The predicted sentiment sentence is combined with the corresponding predicted cause sentence to obtain the first sentiment cause pair set.

[0243] In one implementation, each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; the target sentiment cause pair is any sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set.

[0244] Processing unit 902, when determining the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set, specifically performs the following steps:

[0245] If both the first set of sentiment cause pairs and the second set of sentiment cause pairs contain the target sentiment cause pair, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document;

[0246] If the first set of emotional cause pairs or the second set of emotional cause pairs contains the target emotional cause pair, then the confidence level of the target emotional cause pair is compared with the confidence threshold.

[0247] If the confidence level of the target sentiment cause pair is greater than the confidence level threshold, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document.

[0248] In one implementation, each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; the processing unit 902, when determining the sentiment cause pair corresponding to the target document in the first sentiment cause pair set and the second sentiment cause pair set, specifically performs the following steps:

[0249] Within the first set of emotional cause pairs and the second set of emotional cause pairs, determine the set of credible emotional cause pairs and the set of uncredible emotional cause pairs;

[0250] All sentiment cause pairs in the credible sentiment cause pair set are identified as the sentiment cause pairs corresponding to the target document;

[0251] In the set of untrusted sentiment cause pairs, those with a confidence level greater than the confidence threshold are identified as the sentiment cause pairs corresponding to the target document.

[0252] In one implementation, when processing unit 902 determines the sentiment reason pair corresponding to the target document from the first sentiment reason pair set and the second sentiment reason pair set, it specifically performs the following steps:

[0253] The common emotional reason pairs existing in both the first and second emotional reason pairs sets are identified as the emotional reason pairs corresponding to the target document; or,

[0254] The sentiment cause pairs in the first sentiment cause pair set and the second sentiment cause pair set are all identified as the sentiment cause pairs corresponding to the target document.

[0255] According to another embodiment of this application, Figure 9 The various units in the document processing apparatus shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above-mentioned units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the document processing apparatus may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.

[0256] According to another embodiment of this application, the following can be achieved by running on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), a device capable of performing operations such as... Figure 4 or Figure 6 The computer program (including program code) for each step involved in some or all of the methods shown, to construct such... Figure 9 The document processing apparatus shown herein, and the document processing method for implementing the embodiments of this application, are described. A computer program may be recorded on, for example, a computer-readable storage medium, loaded onto the aforementioned computing device via the computer-readable storage medium, and executed therein.

[0257] In this embodiment, two directions for extracting sentiment cause pairs are proposed. These two directions include a first direction and a second direction. The first direction refers to the direction of extracting sentiment cause pairs based on sentiment sentences, i.e., the direction from sentiment sentences to cause sentences. The second direction refers to the direction of extracting sentiment cause pairs based on cause sentences, i.e., the direction from cause sentences to sentiment sentences. By calling the document processing model to extract the processing loss generated by extracting sentiment cause pairs from sample documents according to the two directions, the document processing model can be trained, thereby improving the training effect of the document processing model and thus improving the accuracy of the document processing model in extracting sentiment cause pairs.

[0258] Based on the above methods and apparatus embodiments, this application provides a computer device, which may be the aforementioned server 301 or terminal device 302. Please refer to... Figure 10 , Figure 10 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 10 The computer device shown includes at least a processor 1001, an input interface 1002, an output interface 1003, and a computer-readable storage medium 1004. The processor 1001, input interface 1002, output interface 1003, and computer-readable storage medium 1004 can be connected via a bus or other means.

[0259] The computer-readable storage medium 1004 can be stored in the memory of a computer device. The computer-readable storage medium 1004 is used to store computer programs, including computer instructions. The processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1004. The processor 1001 (or CPU (Central Processing Unit)) is the computing and control core of the computer device, suitable for implementing one or more computer instructions, specifically suitable for loading and executing one or more computer instructions to achieve corresponding method flows or corresponding functions.

[0260] This application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both built-in storage media in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the operating system of the computer device. Furthermore, the storage space also stores one or more computer instructions suitable for loading and execution by a processor. These computer instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device; optionally, it can also be at least one computer-readable storage medium located remotely from the aforementioned processor.

[0261] In some embodiments, the processor 1001 may load and execute one or more computer instructions stored in the computer-readable storage medium 1004 to implement the aforementioned related... Figure 4 or Figure 6 The corresponding steps of the document processing method shown are as follows. In a specific implementation, the computer instructions in the computer-readable storage medium 1004 are loaded by the processor 1001 and executed as follows:

[0262] Obtain sample documents for training the document processing model;

[0263] The document processing model is invoked to extract sentiment cause pairs from the sample documents in the first direction. During the extraction of sentiment cause pairs, the processing loss of the document processing model in the first direction is obtained. A sentiment cause pair is a sentence pair consisting of a sentiment sentence and a cause sentence. The first direction refers to the direction in which sentiment cause pairs are extracted based on the sentiment sentence.

[0264] The document processing model is invoked to extract sentiment cause pairs from the sample documents in the second direction, and the processing loss of the document processing model in the second direction is obtained during the extraction of sentiment cause pairs; the second direction refers to the direction of extracting sentiment cause pairs based on the cause sentences.

[0265] The document processing model is trained based on the processing loss in the first direction and the processing loss in the second direction. The trained document processing model is used to extract sentiment cause pairs in the first direction and the second direction, respectively.

[0266] In one implementation, the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to call the document processing model to extract sentiment cause pairs from the sample document in a first direction. Specifically, during the extraction of sentiment cause pairs, when obtaining the processing loss of the document processing model in the first direction, the instructions are used to perform the following steps:

[0267] Call the document processing model to predict sentiment sentences in the sample documents and obtain the sentiment sentence prediction loss generated by the sentiment sentence prediction.

[0268] The document processing model is invoked to predict the cause sentences in the sample documents based on the labeled sentiment sentences, and the cause sentence prediction loss generated by the cause sentence prediction is obtained.

[0269] The loss for predicting sentiment sentences and the loss for predicting causes are summed to obtain the processing loss of the document processing model in the first direction.

[0270] In one implementation, the sample document includes multiple document sentences; when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to call the document processing model, perform sentiment sentence prediction on the sample document, and obtain the sentiment sentence prediction loss generated by the sentiment sentence prediction, the following steps are specifically performed:

[0271] Retrieve sentiment query statements;

[0272] The document processing model is invoked to predict the sentiment of each document statement in the sample document based on the sentiment query statement, thereby obtaining the sentiment prediction probability of each document statement in the sample document.

[0273] The sentiment prediction loss is calculated based on the sentiment classification type and sentiment prediction probability of each document sentence.

[0274] In one implementation, when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to call the document processing model and predict the sentiment of each document statement in the sample document based on the sentiment query statement, and to obtain the sentiment prediction probability of each document statement in the sample document, the instructions specifically perform the following steps:

[0275] The sentiment query statement is vector-encoded to obtain a vector representation of the sentiment query statement; and the statements in each document in the sample document are vector-encoded to obtain a vector representation of each document statement.

[0276] Context features are extracted from the vector representation of sentiment query statements to obtain the context features of sentiment query statements; and context features are extracted from the vector representation of statements in each document to obtain the context features of statements in each document.

[0277] The context features of the sentiment query statement are concatenated with the context features of each document statement to obtain the concatenated context features of each document statement.

[0278] Based on the splicing context features of each document statement, sentiment prediction is performed on the corresponding document statements to obtain the sentiment prediction probability of each document statement in the sample documents.

[0279] In one implementation, the computer instructions in the computer-readable storage medium 1004 are loaded by the processor 1001 and are also used to perform the following steps:

[0280] Obtain non-sentimental sentences and non-causal sentences from the sample document; non-sentimental sentences are used to simulate the situation where the document processing model extracts incorrect sentimental sentences during the test, and non-causal sentences are used to simulate the situation where the document processing model extracts incorrect causal sentences during the test.

[0281] The document processing model is invoked to extract sentiment cause pairs corresponding to non-sentiment sentences from sample documents, and during the extraction of sentiment cause pairs, the test simulation loss of the document processing model for non-sentiment sentences is obtained;

[0282] The document processing model is invoked to extract sentiment cause pairs corresponding to non-cause sentences from sample documents, and during the extraction of sentiment cause pairs, the test simulation loss of the document processing model for non-cause sentences is obtained;

[0283] When the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to train the document processing model based on the processing loss in the first direction and the processing loss in the second direction, they are specifically used to perform the following steps: training the document processing model based on the processing loss in the first direction, the processing loss in the second direction, the test simulation loss of non-sentimental sentences, and the test simulation loss of non-causal sentences.

[0284] In one implementation, the sample document includes multiple document sentences; computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to call the document processing model to extract sentiment cause pairs corresponding to non-sentiment sentences from the sample document, and during the extraction of sentiment cause pairs, when obtaining the test simulation loss of the document processing model for non-sentiment sentences, specifically, the following steps are performed:

[0285] Generate the reason query statement corresponding to the non-sentiment sentence;

[0286] The document processing model is invoked to predict the cause of each document statement in the sample document based on the cause query statement corresponding to the non-sentiment sentence, thereby obtaining the cause prediction probability of each document statement in the sample document under the non-sentiment sentence.

[0287] Based on the cause classification type and cause prediction probability of each document sentence under non-sentimental sentences, calculate the test simulation loss of the document processing model for non-sentimental sentences.

[0288] In one implementation, the computer instructions in the computer-readable storage medium 1004 are loaded by the processor 1001 and are also used to perform the following steps:

[0289] Obtain the target document to be processed;

[0290] The trained document processing model is invoked to extract sentiment cause pairs from the target document in the first direction, thus obtaining the first sentiment cause pair set.

[0291] The trained document processing model is invoked to extract sentiment cause pairs from the target document in the second direction, thus obtaining the second sentiment cause pair set.

[0292] In the first set of sentiment cause pairs and the second set of sentiment cause pairs, determine the sentiment cause pair corresponding to the target document.

[0293] In one implementation, the target document includes multiple document statements; when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to call the trained document processing model to extract sentiment cause pairs from the target document in a first direction to obtain a first set of sentiment cause pairs, the following steps are specifically performed:

[0294] The trained document processing model is invoked to predict the sentiment sentence for each document sentence in the target document, thus obtaining the predicted sentiment sentence in the target document.

[0295] The trained document processing model is invoked to predict the cause sentences of each document statement in the target document based on the predicted sentiment sentence, thereby obtaining the predicted cause sentences corresponding to the predicted sentiment sentences.

[0296] The predicted sentiment sentence is combined with the corresponding predicted cause sentence to obtain the first sentiment cause pair set.

[0297] In one implementation, each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; the target sentiment cause pair is any sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set.

[0298] When the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001, and when determining the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set, they are specifically used to perform the following steps:

[0299] If both the first set of sentiment cause pairs and the second set of sentiment cause pairs contain the target sentiment cause pair, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document;

[0300] If the first set of emotional cause pairs or the second set of emotional cause pairs contains the target emotional cause pair, then the confidence level of the target emotional cause pair is compared with the confidence threshold.

[0301] If the confidence level of the target sentiment cause pair is greater than the confidence level threshold, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document.

[0302] In one implementation, each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to determine the sentiment cause pair corresponding to the target document in the first sentiment cause pair set and the second sentiment cause pair set, they are specifically used to perform the following steps:

[0303] Within the first set of emotional cause pairs and the second set of emotional cause pairs, determine the set of credible emotional cause pairs and the set of uncredible emotional cause pairs;

[0304] All sentiment cause pairs in the credible sentiment cause pair set are identified as the sentiment cause pairs corresponding to the target document;

[0305] In the set of untrusted sentiment cause pairs, those with a confidence level greater than the confidence threshold are identified as the sentiment cause pairs corresponding to the target document.

[0306] In one implementation, when the computer instructions in the computer-readable storage medium 1004 are loaded and executed by the processor 1001 to determine the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set, they are specifically used to perform the following steps:

[0307] The common emotional reason pairs existing in both the first and second emotional reason pairs sets are identified as the emotional reason pairs corresponding to the target document; or,

[0308] The sentiment cause pairs in the first sentiment cause pair set and the second sentiment cause pair set are all identified as the sentiment cause pairs corresponding to the target document.

[0309] In this embodiment, two directions for extracting sentiment cause pairs are proposed. These two directions include a first direction and a second direction. The first direction refers to the direction of extracting sentiment cause pairs based on sentiment sentences, i.e., the direction from sentiment sentences to cause sentences. The second direction refers to the direction of extracting sentiment cause pairs based on cause sentences, i.e., the direction from cause sentences to sentiment sentences. By calling the document processing model to extract the processing loss generated by extracting sentiment cause pairs from sample documents according to the two directions, the document processing model can be trained, thereby improving the training effect of the document processing model and thus improving the accuracy of the document processing model in extracting sentiment cause pairs.

[0310] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the document processing methods provided in the various alternative embodiments described above.

[0311] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A document processing method, characterized in that, The method includes: Obtain sample documents for training the document processing model; The document processing model is invoked to extract sentiment cause pairs from the sample document in a first direction, and the processing loss of the document processing model in the first direction is obtained during the extraction of sentiment cause pairs; the sentiment cause pair refers to a pair of statements consisting of a sentiment sentence and a cause sentence; the first direction refers to the direction in which sentiment cause pairs are extracted based on the sentiment sentence; The document processing model is invoked to extract sentiment cause pairs from the sample document in a second direction, and the processing loss of the document processing model in the second direction is obtained during the extraction of sentiment cause pairs; the second direction refers to the direction of extracting sentiment cause pairs based on cause sentences; The document processing model is trained based on the processing loss in the first direction and the processing loss in the second direction; the trained document processing model is used to extract sentiment reason pairs according to the first direction and the second direction, respectively.

2. The method as described in claim 1, characterized in that, The step of calling the document processing model to extract sentiment cause pairs from the sample document in a first direction, and obtaining the processing loss of the document processing model in the first direction during the extraction of sentiment cause pairs, includes: The document processing model is invoked to predict the sentiment sentences of the sample documents, and the sentiment sentence prediction loss generated by the sentiment sentence prediction is obtained. The document processing model is invoked to predict the cause sentences in the sample document based on the labeled sentiment sentences, and the cause sentence prediction loss generated by the cause sentence prediction is obtained. The loss of the sentiment sentence prediction and the loss of the cause sentence prediction are summed to obtain the processing loss of the document processing model in the first direction.

3. The method as described in claim 2, characterized in that, The sample document includes multiple document sentences; the step of calling the document processing model to predict the sentiment sentences in the sample document and obtaining the sentiment sentence prediction loss generated by the sentiment sentence prediction includes: Retrieve sentiment query statements; The document processing model is invoked to predict the sentiment of each document statement in the sample document based on the sentiment query statement, thereby obtaining the sentiment prediction probability of each document statement in the sample document. The sentiment prediction loss is calculated based on the sentiment classification type and sentiment prediction probability of each document sentence.

4. The method as described in claim 3, characterized in that, The step of calling the document processing model to predict the sentiment of each document statement in the sample document based on the sentiment query statement, and obtaining the sentiment prediction probability of each document statement in the sample document, includes: The sentiment query statement is vector-encoded to obtain a vector representation of the sentiment query statement; and each document statement in the sample document is vector-encoded to obtain a vector representation of each document statement. Context features are extracted from the vector representation of the sentiment query statement to obtain the context features of the sentiment query statement; and context features are extracted from the vector representation of each document statement to obtain the context features of each document statement. The context features of the sentiment query statement are concatenated with the context features of each document statement to obtain the concatenated context features of each document statement. Based on the splicing context features of each document statement, sentiment prediction is performed on the corresponding document statements to obtain the sentiment prediction probability of each document statement in the sample document.

5. The method as described in claim 1, characterized in that, The method further includes: Obtain non-sentimental sentences and non-causal sentences from the sample document; the non-sentimental sentences are used to simulate the situation where the document processing model extracts incorrect sentimental sentences during the test, and the non-causal sentences are used to simulate the situation where the document processing model extracts incorrect causal sentences during the test; The document processing model is invoked to extract the sentiment cause pairs corresponding to the non-sentiment sentences from the sample documents, and during the extraction of sentiment cause pairs, the test simulation loss of the document processing model for the non-sentiment sentences is obtained; The document processing model is invoked to extract the sentiment cause pairs corresponding to the non-cause sentences from the sample documents, and during the extraction of sentiment cause pairs, the test simulation loss of the document processing model for the non-cause sentences is obtained; The step of training the document processing model based on the processing loss in the first direction and the processing loss in the second direction includes: training the document processing model based on the processing loss in the first direction, the processing loss in the second direction, the test simulation loss of the non-sentimental sentence, and the test simulation loss of the non-causal sentence.

6. The method as described in claim 5, characterized in that, The sample document includes multiple document sentences; the step of calling the document processing model to extract the sentiment cause pairs corresponding to the non-sentiment sentences from the sample document, and obtaining the test simulation loss of the document processing model for the non-sentiment sentences during the extraction of sentiment cause pairs, includes: Generate the reason query statement corresponding to the non-emotional sentence; The document processing model is invoked, and the cause sentence prediction is performed on each document sentence in the sample document based on the cause query statement corresponding to the non-sentiment sentence, so as to obtain the cause prediction probability of each document sentence in the sample document under the non-sentiment sentence; Based on the cause classification type and cause prediction probability of each document statement under the non-sentimental sentence, the test simulation loss of the document processing model for the non-sentimental sentence is calculated.

7. The method as described in claim 1, characterized in that, The method further includes: Obtain the target document to be processed; The trained document processing model is invoked to extract sentiment cause pairs from the target document in the first direction, thereby obtaining a first set of sentiment cause pairs. The trained document processing model is invoked to extract sentiment cause pairs from the target document in the second direction, thereby obtaining a second sentiment cause pair set. In the first set of sentiment cause pairs and the second set of sentiment cause pairs, determine the sentiment cause pair corresponding to the target document.

8. The method as described in claim 7, characterized in that, The target document includes multiple document statements; the step of calling the trained document processing model to extract sentiment cause pairs from the target document according to the first direction, resulting in a first set of sentiment cause pairs, includes: The trained document processing model is invoked to predict the sentiment sentence for each document sentence in the target document, thereby obtaining the predicted sentiment sentence in the target document. The trained document processing model is invoked to predict the cause sentences for each document statement in the target document based on the predicted sentiment sentence, thereby obtaining the predicted cause sentence corresponding to the predicted sentiment sentence. The predicted sentiment sentence is combined with the predicted cause sentence corresponding to the predicted sentiment sentence to obtain the first sentiment cause pair set.

9. The method as described in claim 7, characterized in that, Each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; the target sentiment cause pair is any sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set. The step of determining the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set includes: If both the first set of sentiment cause pairs and the second set of sentiment cause pairs contain the target sentiment cause pair, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document; If the first set of emotional cause pairs or the second set of emotional cause pairs contains the target emotional cause pair, then the confidence level of the target emotional cause pair is compared with the confidence level threshold. If the confidence level of the target sentiment cause pair is greater than the confidence level threshold, then the target sentiment cause pair is determined as the sentiment cause pair corresponding to the target document.

10. The method as described in claim 7, characterized in that, Each sentiment cause pair in the first sentiment cause pair set and the second sentiment cause pair set corresponds to its respective confidence level; determining the sentiment cause pair corresponding to the target document in the first sentiment cause pair set and the second sentiment cause pair set includes: In the first set of emotional cause pairs and the second set of emotional cause pairs, determine the set of credible emotional cause pairs and the set of uncredible emotional cause pairs; All sentiment cause pairs in the set of credible sentiment cause pairs are identified as the sentiment cause pairs corresponding to the target document; The sentiment cause pairs in the set of untrusted sentiment cause pairs with a confidence level greater than the confidence level threshold are identified as the sentiment cause pairs corresponding to the target document.

11. The method as described in claim 7, characterized in that, The step of determining the sentiment cause pair corresponding to the target document from the first sentiment cause pair set and the second sentiment cause pair set includes: The common emotional reason pairs existing in both the first set of emotional reason pairs and the second set of emotional reason pairs are determined as the emotional reason pairs corresponding to the target document; or... The emotional reason pairs in both the first set of emotional reason pairs and the second set of emotional reason pairs are determined as the emotional reason pairs corresponding to the target document.

12. A document processing apparatus, characterized in that, The device includes: The acquisition unit is used to acquire sample documents for training the document processing model; The processing unit is configured to invoke the document processing model to extract sentiment cause pairs from the sample document in a first direction, and to obtain the processing loss of the document processing model in the first direction during the extraction of sentiment cause pairs; the sentiment cause pair refers to a pair of statements consisting of a sentiment sentence and a cause sentence; the first direction refers to the direction in which sentiment cause pairs are extracted based on the sentiment sentence; The processing unit is further configured to invoke the document processing model to extract sentiment cause pairs from the sample document in a second direction, and to obtain the processing loss of the document processing model in the second direction during the extraction of sentiment cause pairs; the second direction refers to the direction in which sentiment cause pairs are extracted based on cause sentences; The processing unit is further configured to train the document processing model based on the processing loss in the first direction and the processing loss in the second direction; the trained document processing model is used to extract sentiment reason pairs according to the first direction and the second direction respectively.

13. A computer device, characterized in that, The computer device includes: A processor is a tool for implementing computer programs. A computer-readable storage medium storing a computer program adapted to be loaded by the processor and executed as described in any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and executed by the document processing method as described in any one of claims 1 to 11.

15. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the document processing method as described in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Text classification method and device, storage medium and equipment

    CN111444709A

  • Document data retrieval method and device based on MRC, equipment and storage medium

    CN111930895A