Method, device and equipment for identifying long text and medium
Extracting long text features through dynamic word vectors and attention mechanisms, combined with BERT and LSTM models, solves the shortcomings of deep learning models in long text identification, achieves accurate distinction between generative text and human text, and improves identification accuracy and Generalization ability.
Patent Information
- Application Number
- CN202410848653.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-27
AI Technical Summary
Existing deep learning models perform poorly in long text identification, especially the ability to distinguish generative text from human text, resulting in misleading identification results and inability to accurately distinguish long texts.
By converting each word in the long text into a dynamic word vector, and adjusting based on context, the features of long sentences and paragraphs are extracted, GRU and attention mechanisms are used to determine the weight of words and sentences, and the BERT model and LSTM model are combined for identification.
It improves the identification accuracy of long texts, can more accurately distinguish between generative texts and human texts, enhances generalization capabilities, and avoids misleading identification results caused by the model's neglect of long text features.
Smart Images

Figure CN118734837A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a method, device, equipment and medium for identifying long texts. Background Art
[0002] With the development of deep learning technology and generative models (Artificial Intelligence Generated Content, AIGC), the number and scale of generative texts are also growing. How to better distinguish longer generative texts from human texts has become a major obstacle to the safe use of artificial intelligence. For example, when students use generative text models to obtain generative papers, it is difficult for course teachers to objectively score students' learning outcomes; when corporate employees use generative models to generate financial statements, it may cause corporate leaders to misjudge the market situation; relevant copyright agencies cannot easily determine whether the text applied by the customer is original, etc. This may hinder the further promotion of generative artificial intelligence in society and endanger social security.
[0003] The application of deep learning technology in the field of natural language processing has promoted the birth of a large number of deep learning neural networks. In terms of text label classification tasks, there are deep learning models such as BiLSTM, BiLSTM (Attention), TextCNN, and TextRCNN, but these models are mostly used for short texts such as movie reviews, social media comments, etc., that is, the texts that can be processed are mostly short texts, and they perform poorly on long texts. For example, in the process of converting from text to data, such models mostly use static word vectors, and need to obtain word vectors by learning texts in a specific field, so they show poor generalization ability. In addition, such models lack consideration of the structure of long text paragraphs, and often ignore the important features of long texts in actual use. Therefore, the identification results of such models often mislead users and cannot play a more accurate role in distinction and identification. Summary of the invention
[0004] The purpose of this application is to provide a method, device, equipment and medium for identifying a long text, which can achieve accurate identification of a long text and determine whether it is a generated text or a human text.
[0005] To solve the above technical problems, an embodiment of the present application provides a long text identification method, comprising the following steps:
[0006] Obtaining a target long text to be identified, and converting each word contained in the target long text into a dynamic word vector; wherein the dynamic word vector is dynamically adjusted according to the context of the target long text;
[0007] For each long sentence in the target long text, extract the word vector features of the dynamic word vector corresponding to each word in the long sentence, which are used to reflect the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing the generated text from the human text, so as to obtain the long sentence features of the long sentence;
[0008] For each paragraph in the target long text, determine the weight of the long sentence feature of each long sentence in the paragraph according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph;
[0009] The target long text is identified based on all text features to determine whether the target long text is a generated text or a human text.
[0010] In some optional embodiments, for each long sentence in the target long text, extracting the word vector features of the dynamic word vector corresponding to each word in the long sentence for reflecting the semantic features of the word, and determining the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing the generated text from the human text, so as to obtain the long sentence features of the long sentence, including:
[0011] For each long sentence in the target long text, the dynamic word vector corresponding to each word in the long sentence is input into the first GRU gate circuit to extract the word vector feature of each word in the long sentence;
[0012] Based on the self-attention mechanism, the weight of the word vector feature of each word is determined by distinguishing the contribution of the generated text and the human text through the word pairs;
[0013] The weights of all word vector features in each long sentence are weighted summed to obtain the first long sentence feature of each long sentence.
[0014] In some optional embodiments, the self-attention mechanism is based on the contribution of words to distinguishing between generated text and human text, and determining the weight of the word vector feature of each word, including:
[0015] A sliding window of preset length is selected for each word, and the weight of the word vector feature of each word is determined based on the similarity between the word vector feature of the word and the word vector features of other words in the sliding window.
[0016] In some optional embodiments, for each paragraph in the target long text, determining the weight of the long sentence feature of each long sentence in the paragraph according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph, includes:
[0017] For each paragraph in the target long text, the first long sentence feature of each long sentence in the paragraph is input into the second GRU gate circuit to extract the second long sentence feature of each long sentence in the paragraph;
[0018] Based on the attention mechanism, the weight of the second longest sentence feature of each long sentence is determined by distinguishing the contribution of the generated text and the human text through the long sentence pairs;
[0019] The weights of all the second longest sentence features in each paragraph are weighted summed to obtain the paragraph feature of each paragraph.
[0020] In some optional embodiments, the method of determining the weight of the first long sentence feature of each long sentence based on the attention mechanism and distinguishing the contribution of the long sentence to the generated text and the human text includes:
[0021] For each long sentence, the weight of the second long sentence feature of the long sentence is determined according to the similarity between the first long sentence feature of the long sentence and the first long sentence feature of the long sentence included in the long sentence context.
[0022] In some optional embodiments, the identifying the target long text based on all text segment features includes:
[0023] All text features are input into the trained LSTM model for identification.
[0024] In some optional embodiments, converting each word contained in the target long text into a dynamic word vector includes:
[0025] Input the target long text into the trained BERT model to obtain the dynamic word vector of each word in the target long text.
[0026] The embodiment of the present application also provides a long text identification device, comprising:
[0027] A long text acquisition module, used to acquire a target long text to be identified, and convert each word contained in the target long text into a dynamic word vector; wherein the dynamic word vector is dynamically adjusted according to the context of the target long text;
[0028] The long sentence feature extraction module is used to extract the word vector features of the dynamic word vector corresponding to each word in the long sentence for reflecting the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing the generated text from the human text, so as to obtain the long sentence features of the long sentence;
[0029] A paragraph feature extraction module is used to determine the weight of the long sentence feature of each long sentence in each paragraph in the target long text according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph;
[0030] The long text identification module is used to identify the target long text based on all text features to determine whether the target long text is a generated text or a human text.
[0031] An embodiment of the present application also provides a computer device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned long text identification method.
[0032] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above-mentioned long text identification method when executed by a processor.
[0033] The long text identification method provided by this application has at least the following beneficial effects:
[0034] In this application, each word in a long text is converted into a dynamic word vector, and the dynamic word vector is dynamically adjusted according to the context of the target long text, which means that the same word may have different vector representations in different contexts, which can better capture the semantic differences of words. Therefore, by extracting the features of each dynamic word vector, deeper semantic features can be learned, which is beneficial to the subsequent identification operations of long texts, and is not limited by the text field and has strong generalization ability.
[0035] Furthermore, in this application, according to the hierarchy of the long text, the features of the long text are extracted from two levels (i.e., the long sentence level and the paragraph level) to realize the extraction of features at different levels of the long text. At the same time, in the feature extraction operations at the two levels, the weights of different words in the long sentence and different long sentences in the paragraph are determined based on the contribution of different words and different long sentences to distinguishing between generated text and human text, so that the features finally extracted are more conducive to distinguishing between generated text and human text, thereby improving the accuracy of long text identification and accurately judging whether it is generated text or human text. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] One or more embodiments are exemplarily described by the pictures in the corresponding drawings, and these exemplary descriptions do not constitute limitations on the embodiments.
[0037] Figure 1is a flow chart of a long text identification method provided according to an embodiment of the present application;
[0038] Figure 2 is a schematic diagram of a dynamic word vector generation process provided according to an embodiment of the present application;
[0039] Figure 3 is an architecture diagram of an LSTM model provided according to an embodiment of the present application;
[0040] Figure 4 is a schematic diagram of a long text identification method provided according to an embodiment of the present application;
[0041] Figure 5 It is a model architecture diagram of a long text identification method provided according to an embodiment of the present application;
[0042] Figure 6 is a schematic diagram of a long text identification device provided according to an embodiment of the present application;
[0043] Figure 7 It is a structural diagram of a computer device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0044] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not be limited in any way, and the various embodiments can be combined and referenced with each other without contradiction.
[0045] An embodiment of the present application relates to a method for identifying a long text. The implementation details of the method for identifying a long text of this embodiment are specifically described below. The following content is only the implementation details provided for the convenience of understanding and is not necessary for implementing this solution.
[0046] The specific process of the long text identification method of this embodiment can be as follows: Figure 1 As shown, including:
[0047] Step 101, obtain the target long text to be identified, and convert each word contained in the target long text into a dynamic word vector; wherein the dynamic word vector is dynamically adjusted according to the context of the target long text.
[0048] Specifically, this embodiment obtains the dynamic word vector of each word in the target long text by inputting the target long text into the trained BERT model. The underlying layer of the BERT model uses the masked language model MLM and the next sentence attribute prediction NSP, which can generate specific and dynamic word vectors (i.e., dynamic word vectors) according to different long texts, fully capturing the association between text contexts, semantic features and other long text characteristics, and providing support for subsequent calculations.
[0049] like Figure 2 The long text passengers shown in the figure is divided into several long sentences sentence1, sentence2, sentence3, sentence4... after data cleaning operations such as removing blank lines and tabs. Each long sentence is divided into several words through the BERT model, and the beginning and end of each long sentence are marked with '[CLS]' and '[SEP]' respectively. The tokens_id and attention_mask values in the input text are then calculated, and finally a 768-dimensional word vector is obtained as the output of this module. For the words in each sentence of the long text, the corresponding dynamic word vector is generated after multi-layer bidirectional Transformer training.
[0050] Step 102, for each long sentence in the target long text, extract the word vector features of the dynamic word vector corresponding to each word in the long sentence that are used to reflect the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing between the generated text and the human text, so as to obtain the long sentence features of the long sentence.
[0051] Specifically, this embodiment uses the GRU gate circuit structure and the attention mechanism to extract important features of long texts at the long sentence representation layer (i.e., long sentence features), providing a basis for the operation of the next layer.
[0052] In a specific implementation, for each long sentence in the target long text, the dynamic word vector corresponding to each word in the long sentence is input into the first GRU gate circuit to extract the word vector feature of each word in the long sentence; based on the self-attention mechanism, the weight of the word vector feature of each word is determined by the contribution of word pairs to distinguish between generated text and human text; the weights of all word vector features in each long sentence are weighted and summed to obtain the first long sentence feature of each long sentence. Among them, when determining the weight of the word vector feature of each word based on the self-attention mechanism and distinguishing the contribution of word pairs to generated text and human text, a sliding window of a preset length is selected for each word, and the weight of the word vector feature of each word is determined according to the similarity between the word vector feature of the word and the word vector features of other words in the sliding window.
[0053] Step 103, for each paragraph in the target long text, determine the weight of the long sentence feature of each long sentence in the paragraph according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph.
[0054] Specifically, this embodiment uses the GRU gate circuit structure and the attention mechanism to extract important features of long texts at the paragraph representation layer (i.e., paragraph features), providing a basis for the operation of the next layer.
[0055] In a specific implementation, for each paragraph in the target long text, the first long sentence feature of each long sentence in the paragraph is input into the second GRU gate circuit to extract the second long sentence feature of each long sentence in the paragraph; based on the attention mechanism, the weight of the second long sentence feature of each long sentence is determined by the contribution of the long sentence pair to distinguishing the generated text from the human text; the weights of all the second long sentence features in each paragraph are weighted summed to obtain the paragraph feature of each paragraph. Wherein, when the weight of the first long sentence feature of each long sentence is determined by the contribution of the long sentence pair to distinguishing the generated text from the human text based on the attention mechanism, for each long sentence, the weight of the second long sentence feature of the long sentence is determined according to the similarity between the first long sentence feature of the long sentence and the first long sentence feature of the long sentence contained in the long sentence context.
[0056] The following specifically describes how this embodiment uses the GRU gate circuit structure and the attention mechanism to extract important features of long texts at the long sentence representation layer and the text segment representation layer:
[0057] Assume that the long text text consists of n long sentences, that is, text = {sentence1, sentence2, ..., sentence n}, each long sentence is divided into n words by the tokenizer function, that is, for the i-th long sentence s i It can be expressed as s i ={word i1 , word i2 , ..., word in}, the word vector of each word in each long sentence is obtained through the BERT model. At this time, x it The dynamic word vector represents the tth word in the i-th sentence. The dynamic word vector is input into GRU, and the deep features of the long sentence representation layer are obtained through forward and reverse GRU. The specific calculation process is as follows:
[0058]
[0059] In the formula, represents the forward GRU gate circuit, represents the reverse GRU gate circuit, x it represents the i-th word at time t, It indicates the candidate hidden state of the i-th word output by the forward GRU gate circuit at time t. represents the candidate hidden state of the i-th word output by the reverse GRU gate circuit at time t, h it It represents the hidden state of the i-th word at time t after the comprehensive positive and negative GRU gate circuits.
[0060] Next, we select nodes to update weights autonomously, and combine the relationship between words and semantic associations to determine the words in the sentence that contribute the most to distinguishing generated text from human text. First, we select a length of L = [p i -D,p i +D] = 1 + 2D sliding window, where p i Represents the central word, D represents the set context window size, and the weight α of each word is obtained by calculating the similarity between the central word and the remaining words in the window using the following formula: it :
[0061]
[0062] In the formula, s represents the length of the i-th long sentence, σ represents the sigmoid activation function, and α it represents the weight of the tth word in the ith long sentence, v p 、w p , δ represent the preset model parameters, Represents the hidden state of the context window except the central word.
[0063] Finally, the obtained α it The final long sentence representation s is obtained by weighted summing with the hidden layer state at this time i (i.e. long sentence features):
[0064] s i =∑ L h it α it
[0065] The obtained long sentence is represented as s i Input the next layer of GRU to continue mining the features between paragraphs, and use the following calculation process to extract the features of the entire text information (i.e., the paragraph):
[0066]
[0067] In the formula, s i represents the vector representation of the i-th long sentence, represents the candidate hidden state of the i-th long sentence output by the forward GRU gate circuit, represents the candidate hidden state of the i-th long sentence output by the reverse GRU gate circuit, G i Represents the hidden state of the i-th sentence after the comprehensive positive and negative GRU gate circuits.
[0068] After this calculation process, the ordinary attention mechanism is used again to continue to mine the long sentences in the text representation layer that contribute more to distinguishing generated text from human text. First, G is obtained by using a single-layer perceptron. i The implicit representation H i , then, by calculating H i and the context vector U s The weight of each long sentence is obtained by the similarity of , and this weight will be dynamically updated as the model learns. Finally, the long sentence representation s of each long sentence is i and the corresponding weight α i The final long text vector D is obtained by weighted summation. The specific calculation process is as follows:
[0069] H i =tanh(W s G i +b s )
[0070]
[0071] In the formula, tanh represents the activation function, W s represents the weight matrix, b s Indicates the preset offset value, H i represents the implicit representation after the tanh activation function, is the transposed matrix of this implicit representation, U s represents the context vector, α i represents the weight of the i-th long sentence, and D represents the final text representation vector.
[0072] Step 104 , identifying the target long text based on all the text segment features to determine whether the target long text is a generated text or a human text.
[0073] Specifically, for long text input data, the last level of sequence data obtained after the injury operation is essentially a vector formed by combining the paragraph context relationship in the long text. In this embodiment, the paragraph features of all paragraphs are input into the trained LSTM model for identification, and the identification result is that the target long text is a generative text or a human text. The LSTM model can capture the contextual relationship of the text sequence to predict and generate text, and can also extract the internal features of the text according to the contextual relationship of the text sequence to realize text classification. With the help of the LSTM module system, the contextual dependency in the long text sequence can be smoothly captured, and the final classification can be performed based on this dependency.
[0074] like Figure 3 As shown in the LSTM architecture diagram, in the LSTM workflow, the hidden state of the input gate and the input word pass through the forget gate, the memory gate, and finally pass through the output gate to obtain a new hidden state. In the forget gate, the hidden state of the previous moment and the input word at the current moment are used as input, and the output of the forget gate value f t :
[0075] f t =σ(W f *[h t-1 , x t ]+b f )
[0076] In the formula, x t represents the input at time t, h t-1 represents the hidden state of the previous moment, W f 、b f Respectively represent the weight and bias at the forget gate position, f t Represents the value of the output forget gate.
[0077] Enter the memory gate of LSTM, take the hidden state of the previous moment and the input vector of the current moment as input, and calculate the output i of the memory gate t With temporary status
[0078] i t =σ(W i *[h t-1 , x t ]+b i )
[0079]
[0080] In the formula, i t represents the output of the memory gate, Indicates a temporary state, W i 、b i Respectively represent the weight and bias of the input gate position at this time, WC 、b C They represent the weight and bias of the input gate position of the hidden layer state at this time, h t-1 represents the hidden state of the previous moment, x t Represents the input vector at the current moment.
[0081] Next, use the memory gate value i t and the value f of the forget gate t , Temporary status With the previous state C t-1 As new input, output the current state value C t :
[0082]
[0083] Finally, enter the output gate. Take the hidden state of the previous moment, the input word and state value of the current moment as input, and obtain the value of the output gate o t With the new hidden state h t :
[0084] o t =σ(W o *[h t-1 , x t ]+b o )
[0085] h t =o t *tanh(C t )
[0086] Where W o 、b o Respectively represent the weight and bias of the output gate position at this time, h t-1 represents the hidden state of the previous moment, x t Represents the input vector at the current moment, o t Indicates the value of the output gate at this time, C t Indicates the current state value, h t Represents the new hidden layer state value.
[0087] In this embodiment, by converting each word in the long text into a dynamic word vector, and the dynamic word vector is dynamically adjusted according to the context of the target long text, it means that the same word may have different vector representations in different contexts, which can better capture the semantic differences of the words. Therefore, by extracting the features of each dynamic word vector, deeper semantic features can be learned, which is conducive to the subsequent identification operation of the long text, and is not limited by the text field, and has strong generalization ability. Furthermore, in this embodiment, according to the level of the long text, the features of the long text are extracted from two levels (i.e., the long sentence level and the paragraph level) to achieve the extraction of features of different levels of the long text. At the same time, in the feature extraction operation of the two levels, based on the contribution of different words and different long sentences to distinguishing between generated text and human text, the weights of different words in the long sentence and different long sentences in the paragraph are determined, so that the features finally extracted are more conducive to distinguishing between generated text and human text, thereby improving the accuracy of long text identification and accurately judging whether it is generated text or human text.
[0088] In one embodiment, the implementation process of the long text identification method of the present application is as follows: Figure 4 As shown in Figure 2, the model structure used is as follows: Figure 5 As shown, the specific process includes:
[0089] 1. Text input: the input of the target long text to be identified
[0090] 2. Word vector conversion: that is, each word contained in the target long text is converted into a dynamic word vector through the BERT model. The BERT model includes the masked language model MLM and the next sentence attribute prediction NSP.
[0091] 3. Feature extraction: That is, at the long sentence level, the self-attention mechanism is used to obtain the long sentence representation layer, and at the paragraph level, the attention mechanism is used to obtain the paragraph representation layer.
[0092] 4. Sequence data processing: that is, the vectors extracted from the above features are processed through the LSTM model.
[0093] 5. Output identification result: that is, the target long text is a generated text or a human text.
[0094] The step division of the above methods is only for clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this application; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this application.
[0095] Another embodiment of the present application relates to a long text identification device. The implementation details of the long text identification device of this embodiment are specifically described below. The following content is only for the convenience of understanding the implementation details, and is not necessary for implementing this solution. The schematic diagram of the long text identification device of this embodiment can be as follows Figure 6 As shown, it includes: a long text acquisition module 601, a long sentence feature extraction module 502, a paragraph feature extraction module 603 and a long text identification module 604.
[0096] Specifically, the long text acquisition module 601 is used to acquire the target long text to be identified, and convert each word contained in the target long text into a dynamic word vector; wherein the dynamic word vector is dynamically adjusted according to the context of the target long text.
[0097] The long sentence feature extraction module 602 is used to extract the word vector features of the dynamic word vector corresponding to each word in each long sentence in the target long text, which are used to reflect the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing between the generated text and the human text, so as to obtain the long sentence features of the long sentence.
[0098] The paragraph feature extraction module 603 is used to determine the weight of the long sentence feature of each long sentence in each paragraph in the target long text according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph.
[0099] The long text identification module 604 is used to identify the target long text based on all text segment features to determine whether the target long text is a generated text or a human text.
[0100] It is not difficult to find that this embodiment is a device embodiment corresponding to the above method embodiment, and this embodiment can be implemented in conjunction with the above method embodiment. The relevant technical details and technical effects mentioned in the above embodiment are still valid in this embodiment, and in order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the above embodiment.
[0101] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.
[0102] Another embodiment of the present application relates to a computer device, such as Figure 7As shown, it includes: at least one processor 701; and a memory 702 that is communicatively connected to the at least one processor 701; wherein the memory 702 stores instructions that can be executed by the at least one processor 701, and the instructions are executed by the at least one processor 701 so that the at least one processor 701 can execute the long text identification method in the above-mentioned embodiments.
[0103] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.
[0104] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.
[0105] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program, which implements the above method embodiment when executed by a processor.
[0106] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as: ROM), random access memory (Random Access Memory, referred to as: RAM), disk or optical disk and other media that can store program codes.
[0107] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present application.
Claims
1. A method for identifying a long text, characterized in that: The method comprises: Obtaining a target long text to be identified, and converting each word contained in the target long text into a dynamic word vector; wherein the dynamic word vector is dynamically adjusted according to the context of the target long text; For each long sentence in the target long text, extract the word vector features of the dynamic word vector corresponding to each word in the long sentence, which are used to reflect the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing the generated text from the human text, so as to obtain the long sentence features of the long sentence; For each paragraph in the target long text, determine the weight of the long sentence feature of each long sentence in the paragraph according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph; The target long text is identified based on all text features to determine whether the target long text is a generated text or a human text.
2. The long text identification method according to claim 1, characterized in that: For each long sentence in the target long text, extract the word vector features of the dynamic word vector corresponding to each word in the long sentence for reflecting the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing the generated text from the human text, so as to obtain the long sentence features of the long sentence, including: For each long sentence in the target long text, the dynamic word vector corresponding to each word in the long sentence is input into the first GRU gate circuit to extract the word vector feature of each word in the long sentence; Based on the self-attention mechanism, the weight of the word vector feature of each word is determined by distinguishing the contribution of the generated text and the human text through the word pairs; The weights of all word vector features in each long sentence are weighted summed to obtain the first long sentence feature of each long sentence.
3. The long text identification method according to claim 2, characterized in that: Based on the self-attention mechanism, the weight of the word vector feature of each word is determined by distinguishing the contribution of the word pair to the generated text and the human text, including: A sliding window of preset length is selected for each word, and the weight of the word vector feature of each word is determined based on the similarity between the word vector feature of the word and the word vector features of other words in the sliding window.
4. The long text identification method according to claim 3, characterized in that: For each paragraph in the target long text, according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, the weight of the long sentence feature of each long sentence in the paragraph is determined to obtain the paragraph feature of the paragraph, including: For each paragraph in the target long text, the first long sentence feature of each long sentence in the paragraph is input into the second GRU gate circuit to extract the second long sentence feature of each long sentence in the paragraph; Based on the attention mechanism, the weight of the second longest sentence feature of each long sentence is determined by distinguishing the contribution of the generated text and the human text through the long sentence pairs; The weights of all the second longest sentence features in each paragraph are weighted summed to obtain the paragraph feature of each paragraph.
5. The long text identification method according to claim 4, characterized in that: Based on the attention mechanism, the weight of the first long sentence feature of each long sentence is determined by distinguishing the contribution of the long sentence to the generated text and the human text, including: For each long sentence, the weight of the second long sentence feature of the long sentence is determined according to the similarity between the first long sentence feature of the long sentence and the first long sentence feature of the long sentence included in the long sentence context.
6. The long text identification method according to claim 1, characterized in that: The target long text is identified based on all text features, including: The text features of all text segments are input into the trained LSTM model for identification.
7. The long text identification method according to claim 1, characterized in that: The step of converting each word contained in the target long text into a dynamic word vector includes: Input the target long text into the trained BERT model to obtain the dynamic word vector of each word in the target long text.
8. A long text identification device, characterized in that: The device comprises: A long text acquisition module, used to acquire a target long text to be identified, and convert each word contained in the target long text into a dynamic word vector; wherein the dynamic word vector is dynamically adjusted according to the context of the target long text; The long sentence feature extraction module is used to extract the word vector features of the dynamic word vector corresponding to each word in the long sentence for reflecting the semantic features of the word, and determine the weight of the word vector features of each word in the long sentence according to the contribution of each word to distinguishing the generated text from the human text, so as to obtain the long sentence features of the long sentence; A paragraph feature extraction module is used to determine the weight of the long sentence feature of each long sentence in each paragraph in the target long text according to the contribution of each long sentence in the paragraph to distinguishing the generated text from the human text, so as to obtain the paragraph feature of the paragraph; The long text identification module is used to identify the target long text based on all text features to determine whether the target long text is a generated text or a human text.
9. A computer device, characterized in that: include: at least one processor; And, a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the long text identification method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the long text identification method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Long-text structured text abstract extraction method
CN110781290A
Long text classification method and device
CN112100389A
Natural language model interpretation method and device and storage medium
CN113988049A
Text processing method, model training method, and apparatus
US20220147715A1
Cited By
Long text classification method and apparatus, and device, medium and program product
WO2026124475A1
