A method, device, equipment and medium for identifying long text
By extracting features at the sentence level using dynamic word vectors and self-attention mechanism, and processing them at the paragraph level using GRU and attention mechanism, the LSTM model is used to achieve accurate identification of long texts. This solves the problem of inaccurate identification of long texts in existing technologies and improves the accuracy of distinguishing between generative texts and human texts.
Patent Information
- Application Number
- CN202410848653.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-06-27
AI Technical Summary
Existing deep learning models perform poorly in long text identification, lacking consideration of the structure of long texts, resulting in inaccurate identification results and difficulty in distinguishing between generative text and human text.
Dynamic word vectors and self-attention mechanisms are used to extract word features at the long sentence level, and GRU gate circuits and attention mechanisms are combined to extract features at the paragraph level. Finally, an LSTM model is used for identification.
It achieves accurate identification of long texts, improves the ability to distinguish between generated text and human text, and enhances identification accuracy.
Smart Images

Figure CN118734837B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, and particularly relates to a long text identification method and device, equipment and medium. BACKGROUND
[0002] With the development of deep learning technology and artificial intelligence generated content (AIGC), the number and scale of generated texts are also growing. How to better identify longer generated texts and human texts has become a major obstacle to the safe use of artificial intelligence. For example, students use generated text models to obtain generated papers, and course teachers have difficulty objectively scoring students' learning results. Employees use generated models to generate financial statements, which may cause enterprise leaders to misjudge market conditions. Related copyright agencies cannot easily determine whether the client's application text is original. This may hinder the further promotion of generated artificial intelligence in society and endanger social safety.
[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 the text label classification task, there are BiLSTM, BiLSTM (Attention), TextCNN, TextRCNN and other deep learning models, but these models are mostly used in short text fields such as movie reviews and social media comments, that is, the texts they can handle are mostly short texts, and they perform poorly on long texts. For example, in the process of converting text to data, such models mostly use static word vectors, which need to learn the word vectors of a specific field of text, so they have poor generalization ability. In addition, these models lack consideration of the structure of long text paragraphs, and often ignore important features of long texts in actual use, so the identification results of these models often mislead users and cannot accurately distinguish and identify. SUMMARY
[0004] The purpose of the present application is to provide a long text identification method, device, equipment and medium, which can accurately identify long texts and determine whether they are generated texts or human texts.
[0005] To solve the above technical problems, an embodiment of the present application provides a long text identification method, which includes the following steps:
[0006] A target long text to be identified is obtained, and each word contained in the target long text is converted into a dynamic word vector respectively; 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, a word vector feature of a dynamic word vector corresponding to each word in the long sentence is extracted, the word vector feature being used to reflect semantic features of the word, and a weight of the word vector feature of each word in the long sentence is determined according to a size of contribution of the word pair to distinguishing between the generated text and the human text, so as to obtain a long sentence feature of the long sentence.
[0008] For each text segment in the target long text, a weight of the long sentence feature of each long sentence in the text segment is determined according to a size of contribution of the long sentence pair to distinguishing between the generated text and the human text, so as to obtain a text segment feature of the text segment.
[0009] The target long text is discriminated based on all the text segment features, so as to determine whether the target long text is the generated text or the human text.
[0010] In some optional embodiments, the extracting, for each long sentence in the target long text, a word vector feature of a dynamic word vector corresponding to each word in the long sentence, the word vector feature being used to reflect semantic features of the word, and determining a weight of the word vector feature of each word in the long sentence according to a size of contribution of the word pair to distinguishing between the generated text and the human text, so as to obtain a long sentence feature of the long sentence, comprises:
[0011] For each long sentence in the target long text, a word vector feature of a dynamic word vector corresponding to each word in the long sentence is extracted, the word vector feature being used to reflect semantic features of the word, and a weight of the word vector feature of each word in the long sentence is determined according to a size of contribution of the word pair to distinguishing between the generated text and the human text, so as to obtain a long sentence feature of the long sentence.
[0012] The weight of the word vector feature of each word is determined based on a self-attention mechanism, by distinguishing a size of contribution of the word pair to the generated text and the human text.
[0013] The weights of all the word vector features in each long sentence are weighted and summed to obtain a first long sentence feature of each long sentence.
[0014] In some optional embodiments, the determining, based on the self-attention mechanism, the weight of the word vector feature of each word by distinguishing a size of contribution of the word pair to the generated text and the human text, comprises:
[0015] 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 a similarity between the word vector feature of the word and word vector features of other words in the sliding window.
[0016] In some optional embodiments, the determining, for each text segment in the target long text, a weight of the long sentence feature of each long sentence in the text segment according to a size of contribution of the long sentence pair to distinguishing between the generated text and the human text, so as to obtain a text segment feature of the text segment, comprises:
[0017] For each text segment in the target long text, the first long sentence feature of each long sentence in the text segment is input into the second GRU gate circuit to extract the second long sentence feature of each long sentence in the text segment.
[0018] Based on the attention mechanism, the weight of the second long sentence feature of each long sentence is determined by the size of the contribution of the long sentence pair to distinguishing between generated text and human text.
[0019] The weights of all second long sentence features in each text segment are weighted and summed to obtain the text segment feature of each text segment.
[0020] In some optional embodiments, the weight of the first long sentence feature of each long sentence is determined based on the attention mechanism by the size of the contribution of the long sentence pair to distinguishing between generated text and human text, including:
[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 contained in the long sentence context.
[0022] In some optional embodiments, the discrimination of the target long text based on all text segment features includes:
[0023] All text segment features are input into the trained LSTM model for discrimination.
[0024] In some optional embodiments, the conversion of each word contained in the target long text into a dynamic word vector includes:
[0025] The target long text is input into the trained BERT model to obtain the dynamic word vector of each word in the target long text.
[0026] Embodiments of the present application also provide a long text discrimination device, including:
[0027] A long text acquisition module is configured to acquire a target long text to be discriminated, 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] A long sentence feature extraction module is configured to, for each long sentence in the target long text, extract a word vector feature of a dynamic word vector corresponding to each word in the long sentence, which is used to reflect the semantic feature of the word, and determine the weight of the word vector feature of each word in the long sentence according to the size of the contribution of each word to distinguishing between generated text and human text, to obtain the long sentence feature of the long sentence.
[0029] The text feature extraction module is used to determine the weight of the long sentence features of each long sentence in the target long text based on the contribution of each long sentence in the text to distinguish between generative text and human text, so as to obtain the text features of the text.
[0030] The long text identification module is used to identify target long text based on all text segment features in order to determine whether the target long text is generated text or human text.
[0031] Embodiments of this application also provide a computer device, including: 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, the instructions being executed by the at least one processor to enable the at least one processor to perform the above-described long text identification method.
[0032] Embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for identifying long texts.
[0033] The long text identification method provided in 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. This 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 long text identification operation. It is not limited by the text domain and has strong generalization ability.
[0035] Furthermore, this application extracts features from long texts at two levels (sentence level and paragraph level) based on the text's hierarchy, enabling the extraction of features at different levels. Simultaneously, in the feature extraction operations at both levels, the weights of different words in long sentences and different long sentences in paragraphs are determined based on the contribution of different words and sentences to distinguishing between generative and human text. This makes the extracted features more effective in distinguishing between generative and human text, thereby improving the accuracy of long text identification and accurately determining whether it is generative or human text. Attached Figure Description
[0036] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, and these illustrative descriptions do not constitute a limitation on the embodiments.
[0037] Figure 1This is a flowchart of a long text identification method provided according to an embodiment of this application;
[0038] Figure 2 This is a schematic diagram of a dynamic word vector generation process according to an embodiment of this application;
[0039] Figure 3 This is an architecture diagram of an LSTM model provided according to an embodiment of this application;
[0040] Figure 4 This is a schematic diagram of a long text identification method provided according to an embodiment of this application;
[0041] Figure 5 This is a model architecture diagram of a long text identification method provided according to an embodiment of this application;
[0042] Figure 6 This is a schematic diagram of a long text identification device according to an embodiment of this application;
[0043] Figure 7 This is a schematic diagram of the structure of a computer device according to an embodiment of this application. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been presented in the various embodiments of this application to enable readers to better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments. The division of the various embodiments below is for the convenience of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.
[0045] One embodiment of this application relates to a method for identifying long text. The implementation details of the long text identification method of this embodiment are described in detail below. The following implementation details are provided for ease of understanding and are not necessary for implementing this solution.
[0046] The specific process of the long text identification method in this embodiment can be as follows: Figure 1 As shown, it includes:
[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 inputs the target long text into a trained BERT model to obtain dynamic word vectors for each word in the target long text. The underlying layer of the BERT model uses the Masked Language Model (MLM) and Next Sentence Attribute Prediction (NSP), which can generate specific, dynamic word vectors (i.e., dynamic word vectors) based on different long texts, fully capturing the characteristics of long texts such as the relationship between text contexts and semantic features, providing support for subsequent calculations.
[0049] like Figure 2 The long text `passengers` shown is cleaned by removing blank lines and tabs, then divided into several long sentences (sentence1, sentence2, sentence3, sentence4...). Each sentence is further divided into several words using the BERT model, with '[CLS]' and '[SEP]' markers indicating the beginning and end of each sentence, respectively. The Tokens_id and Attention_mask values from the input text are then processed to obtain 768-dimensional word vectors as the output of this module. For each word in each sentence of the long text, a corresponding dynamic word vector is generated after training with a multi-layer bidirectional Transformer.
[0050] Step 102: For each long sentence in the target long text, extract the dynamic word vector features corresponding to each word in the long sentence to reflect the semantic features of the words, 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 generative text and human text, so as to obtain the long sentence features.
[0051] Specifically, this embodiment uses the GRU gate circuit structure and attention mechanism to extract important features (i.e. long sentence features) of long text in the long sentence representation layer, providing a basis for the next layer of operation.
[0052] In the 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 features 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 magnitude of the contribution of word pairs to distinguish between generative 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. Specifically, when determining the weight of the word vector feature of each word based on the self-attention mechanism and the magnitude of the contribution of word pairs to distinguish between generative 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 segment in the target long text, determine the weight of the long sentence feature of each long sentence in the segment based on the contribution of each long sentence in the segment to distinguish between generative text and human text, so as to obtain the segment feature of the segment.
[0054] Specifically, this embodiment uses the GRU gate circuit structure and attention mechanism to extract important features (i.e., text features) of long text at the text representation layer, providing a basis for the next layer of operation.
[0055] In the specific implementation, for each segment in the target long text, the first long sentence feature of each long sentence in the segment is input into the second GRU gate circuit to extract the second long sentence feature of each long sentence in the segment. Based on the attention mechanism, the weight of the second long sentence feature of each long sentence is determined by the magnitude of the contribution of long sentences to distinguishing between generative text and human text. The weights of all second long sentence features in each segment are weighted and summed to obtain the segment feature of each segment. Specifically, when determining the weight of the first long sentence feature of each long sentence based on the magnitude of the contribution of long sentences to distinguishing between generative text and human text, for each long sentence, the weight of the second long sentence feature of the long sentence is determined based on the similarity between the first long sentence feature of the long sentence and the first long sentence feature of the long sentences contained in the context of the long sentence.
[0056] The following section details how this embodiment utilizes the GRU gate circuit structure and attention mechanism to extract important features from long texts at the long sentence representation layer and the segment representation layer:
[0057] Suppose a long text `text` consists of `n` long sentences, i.e., `text = {sentence1, sentence2, ..., sentence...}`. n Each long sentence is divided into n words using the tokenizer function, that is, for the i-th long sentence s i It can be represented as s i ={word i1 word i2 , ..., word in The word vectors for each word in each long sentence are obtained using the BERT model, at which point x... it This represents the dynamic word vector of the t-th word in the i-th sentence. The dynamic word vector is input into a GRU, and deep features of the long sentence representation layer are obtained through forward and reverse GRU operations. The specific calculation process is as follows:
[0058]
[0059] In the formula, This indicates a forward GRU gate circuit. Indicates an inverted GRU gate circuit, x it This represents the i-th word at time t. This represents the candidate hidden state of the i-th word output by the forward GRU gate circuit at time t. h represents the candidate hidden state of the i-th word output by the inverted GRU gate at time t. it This represents the hidden state of the i-th word at time t after synthesizing the positive and negative GRU gate circuits.
[0060] Next, the nodes are autonomously selected to update weights, and combined with inter-word relationships and semantic connections, the words in the sentence that contribute most to distinguishing between generative and human text are determined. First, a length of L = [p] is selected. i -D, p i +D]=1+2D sliding window, where p i Let D represent the center character, and D represent the set size of the context window. The weight α of each character is obtained by calculating the similarity between the center character and the other characters within 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 v represents the weight of the t-th word in the i-th long sentence. p w p δ and δ both represent preset model parameters. This indicates the hidden state of the context window, excluding the central text.
[0063] Finally, the obtained α it The final long sentence representation s is obtained by weighted summation of the hidden state at this time. i (i.e., the characteristic of long sentences):
[0064] s i =∑ L h it α it
[0065] The obtained long sentence is represented as s i The next layer of the GRU is then fed into the next layer to continue mining features between paragraphs. The following calculation process is used to extract features from the entire text (i.e., the entire passage):
[0066]
[0067] In the formula, s i The vector representation of the i-th long sentence. This represents the candidate hidden state of the i-th long sentence output by the forward GRU gate circuit. G represents the candidate hidden state of the i-th long sentence output by the inverted GRU gate circuit. i This represents the hidden state of the i-th sentence after synthesizing the positive and negative GRU gate circuits.
[0068] After this calculation process, a standard attention mechanism is used again to continue mining long sentences in the text representation layer that contribute significantly to distinguishing between generative and human text. First, a single-layer perceptron is used to obtain G. i The implicit representation of H i Subsequently, by calculating H i and context vector U s The similarity is used to obtain the weight of each long sentence, and this weight is 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, and W s Let b represent the weight matrix. s H represents the preset bias value. i This represents the implicit representation after the tanh activation function. U is the transpose of this implicit representation. s Represents the context vector, α i Let represent the weight of the i-th long sentence, and D represent the final text representation vector.
[0072] Step 104: Identify the target long text based on all text features to determine whether the target long text is generated text or human text.
[0073] Specifically, for long text input data, the final-level sequence data obtained after the processing is essentially a vector formed by combining the paragraph context relationships within the long text. In this embodiment, the text features of all segments are input into a trained LSTM model for identification. The identification result determines whether the target long text is generative text or human text. The LSTM model can capture the contextual relationships within a text sequence to predict and generate text, or it can extract features within the text based on these contextual relationships to achieve text classification. With the help of the LSTM module, the system can successfully capture the contextual dependencies in long text sequences and perform the final classification based on these dependencies.
[0074] like Figure 3 The LSTM architecture diagram shown illustrates the LSTM workflow. The hidden state from the input gate and the input word pass through the forget gate, the remember gate, and finally the output gate to obtain a new hidden state. In the forget gate, the previous hidden state and the current input word are used as input, and the output is the value f of the forget gate. t :
[0075] f t =σ(W f *[h t-1 x t ]+b f )
[0076] In the formula, x t h represents the input at time t. t-1 W represents the hidden state at the previous time step. f b f f represents the weight and bias at the forget gate position, respectively. t This indicates that the value of the forget gate will be output.
[0077] Entering the LSTM's memory gate, the hidden state from the previous time step and the current input vector are used as inputs to calculate the memory gate's output i. t With temporary state
[0078] i t =σ(W i *[h t-1 x t ]+b i )
[0079]
[0080] In the formula, i t Indicates the output of the memory gate. W represents a temporary state. i b i W represents the weight and bias of the input gate position at this time, respectively.C b C h represents the weights and biases at the input gate positions of the hidden layer state at this time. t-1 Let x represent the hidden state at the previous time step. t This represents the input vector at the current moment.
[0081] Next, using the value i of the memory gate... t With the value f of the forget gate t Temporary state Compared to the previous state C t-1 As the new input, the current state value C is output. t :
[0082]
[0083] Finally, the output gate is entered. The hidden state from the previous time step, the input word at the current time step, and the state value are used as input to obtain the output gate value 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] In the formula, W o b o These represent the weights and biases of the output gate position at this point, respectively, h. t-1 Let x represent the hidden state at the previous time step. t O represents the input vector at the current time step. t This indicates the value of the output gate at this time, C. t h represents the current state value. t This represents the new hidden state value.
[0087] In this embodiment, each word in the long text is converted into a dynamic word vector. These dynamic word vectors are dynamically adjusted according to the context of the target long text, meaning that the same word may have different vector representations in different contexts. This allows for better capture of semantic differences between words. Therefore, by extracting features from each dynamic word vector, deeper semantic features can be learned, which is beneficial for subsequent long text identification operations. Furthermore, this embodiment extracts features from the long text at two levels (sentence level and paragraph level) based on the text's hierarchy, achieving feature extraction at different levels. Simultaneously, in the feature extraction operations at both levels, the weights of different words in long sentences and different long sentences in paragraphs are determined based on the contribution of different words and sentences to distinguishing between generative and human text. This makes the final extracted features more effective in distinguishing between generative and human text, thereby improving the accuracy of long text identification and accurately determining whether it is generative or human text.
[0088] In one embodiment, the implementation flow of the long text identification method of this application is as follows: Figure 4 As shown, the model structure used is as follows: Figure 5 As shown, the specific process includes:
[0089] 1. Text Input: This refers to the input of the target long text to be identified.
[0090] 2. Word vector conversion: This involves using the BERT model to convert each word in the target long text into a dynamic word vector. The BERT model includes the Masked Language Model (MLM) and the Next Sentence Attribute Prediction (NSP).
[0091] 3. Feature extraction: At the level of long sentences, a self-attention mechanism is used to obtain the long sentence representation layer, and at the level of text segments, an attention mechanism is used to obtain the text segment representation layer.
[0092] 4. Sequence data processing: This involves processing the vectors extracted from the above features using the LSTM model.
[0093] 5. Output identification result: that is, whether the target long text is generated text or human text.
[0094] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split 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 or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this application.
[0095] Another embodiment of this application relates to a long text identification device. The implementation details of the long text identification device of this embodiment are described below. The following implementation details are provided for ease of understanding and are not essential for implementing this solution. A schematic diagram of the long text identification device of this embodiment can be seen as follows: Figure 6 As shown, it includes: a long text acquisition module 601, a long sentence feature extraction module 502, a text segment 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 dynamic word vector features corresponding to each word in the target long text for each long sentence, which are used to reflect the semantic features of the words. Based on the contribution of each word to distinguishing between generative text and human text, the weight of the word vector features of each word in the long sentence is determined to obtain the long sentence features.
[0098] The text feature extraction module 603 is used to determine the weight of the long sentence features of each long sentence in the target long text based on the contribution of each long sentence in the text to distinguish between generative text and human text, so as to obtain the text features of the text.
[0099] The long text identification module 604 is used to identify the target long text based on all text features to determine whether the target long text is generated text or human text.
[0100] It is not difficult to see that this embodiment is a device embodiment corresponding to the above method embodiments, and this embodiment can be implemented in conjunction with the above method embodiments. The relevant technical details and technical effects mentioned in the above embodiments are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiments.
[0101] It is worth mentioning that all modules involved in this embodiment are logical modules. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. Furthermore, to highlight the innovative aspects of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed in this application; however, this does not mean that other units are absent in this embodiment.
[0102] Another embodiment of this application relates to a computer device, such as... Figure 7As shown, it includes: at least one processor 701; and a memory 702 communicatively connected to the at least one processor 701; wherein the memory 702 stores instructions executable by the at least one processor 701, the instructions being executed by the at least one processor 701 to enable the at least one processor 701 to perform the long text identification method in the above embodiments.
[0103] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.
[0104] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.
[0105] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the method embodiments described above.
[0106] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0107] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.
Claims
1. A method for identifying long texts, characterized in that, The method includes: The target long text to be identified is obtained, and each word contained in the target long text is converted 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 dynamic word vector features corresponding to each word in the long sentence to reflect the semantic features of the words, 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 generative text and human text, so as to obtain the long sentence features; For each segment in the target long text, the weight of the long sentence feature of each long sentence in the segment is determined according to the contribution of each long sentence in the segment to distinguish between generative text and human text, so as to obtain the segment feature of the segment. The target long text is identified based on all text features to determine whether it is generative text or human text.
2. The method for identifying long texts according to claim 1, characterized in that, For each long sentence in the target long text, the dynamic word vector features corresponding to each word in the long sentence are extracted to reflect the semantic features of the words. Based on the contribution of each word to distinguishing between generative and human text, the weight of the word vector features of each word in the long sentence is determined to obtain the long sentence features, 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 features of each word in the long sentence; Based on the self-attention mechanism, the weight of each word vector feature is determined by the magnitude of the contribution of word pairs to distinguish between generative text and human text. The weights of all word vector features in each long sentence are summed to obtain the first long sentence feature for each long sentence.
3. The method for identifying long texts according to claim 2, characterized in that, The method, based on a self-attention mechanism, determines the weight of each word's vector feature by assessing the contribution of word pairs to distinguishing between generative and human text. This includes: A sliding window of a preset length is selected for each word, and the weight of each word's word vector feature is determined based on the similarity between the word vector features of the word and the word vector features of other words within the sliding window.
4. The method for identifying long texts according to claim 3, characterized in that, For each segment in the target long text, the weight of the long sentence feature of each long sentence in the segment is determined based on the contribution of each long sentence in the segment to distinguishing between generative text and human text, in order to obtain the segment features of the segment, including: For each segment in the target long text, the first long sentence feature of each long sentence in the segment is input into the second GRU gate circuit to extract the second long sentence feature of each long sentence in the segment; Based on the attention mechanism, the weight of the second long sentence feature of each long sentence is determined by the magnitude of the contribution of long sentences to distinguish between generative text and human text. The weights of all the second longest sentence features in each passage are summed in a weighted manner to obtain the passage features of each passage.
5. The method for identifying long texts according to claim 4, characterized in that, The attention-based mechanism determines the weight of the first long sentence feature for each long sentence by assessing its contribution to distinguishing between generative and human text. This includes: For each long sentence, the weight of the second long sentence feature is determined based on the similarity between the first long sentence feature of the long sentence and the first long sentence feature of the long sentences contained in the context of the long sentence.
6. The method for identifying long texts according to claim 1, characterized in that, The identification of target long texts based on all text segment features includes: The text features of all passages are input into the trained LSTM model for identification.
7. The method for identifying long texts according to claim 1, characterized in that, The process of converting each word in the target long text into a dynamic word vector includes: The target long text is input 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 includes: The long text acquisition module 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. The long sentence feature extraction module is used to extract the dynamic word vector features corresponding to each word in each long sentence in the target long text, which are used to reflect the semantic features of the words. Based on the contribution of each word to distinguishing between generative text and human text, the weight of the word vector features of each word in the long sentence is determined to obtain the long sentence features. The text feature extraction module is used to determine the weight of the long sentence features of each long sentence in the target long text based on the contribution of each long sentence in the text to distinguish between generative text and human text, so as to obtain the text features of the text. The long text identification module is used to identify target long text based on all text segment features in order to determine whether the target long text is generated text or 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, the instructions being executed by the at least one processor to enable the at least one processor to perform 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 the processor, it implements the method for identifying long text as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Long-text structured text abstract extraction method
CN110781290A
Natural language model interpretation method and device and storage medium
CN113988049A