Model processing method and device, electronic equipment and storage medium
By splitting the text as the center sentence and environmental sentence and adjusting the weight distribution, the problem of low accuracy of content recognition generated by artificial intelligence is solved, and the recognition classification performance and context relevance of text content are improved.
Patent Information
- Application Number
- CN202411779227.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-01-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the process of identifying and classification of content generated by artificial intelligence, the accuracy of text recognition is low, and it is impossible to effectively identify the characteristics of AI-generated text.
By splitting the training text into multiple central sentences and adjusting the weight distribution between the central sentence and the environment sentence according to the first and second coefficients, dispersing the weights to improve the context relevance of the text, thereby improving the model's content of the text Identify classification performance.
It improves the accuracy and performance of text content recognition classification, enhances the model's ability to recognize text context relevance, and avoids the defect of independently processing each sentence.
Smart Images

Figure CN119271818A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a model processing method, device, electronic equipment and storage medium. Background Art
[0002] With the rapid development of artificial intelligence, more and more articles and other content are generated by artificial intelligence models to replace manual writing. In the process of identifying and classifying content generated by artificial intelligence (AI), it is often necessary to input the text sentence by sentence into the recognition model to identify whether the text is generated by AI, but the recognition accuracy is not high. Summary of the invention
[0003] The embodiments of the present application provide a model processing method, device, electronic device and storage medium to solve the technical problem of low text recognition accuracy.
[0004] According to one aspect of an embodiment of the present application, a model processing method is provided, comprising: splitting a training text into a plurality of central sentences, and determining an environment sentence associated with each central sentence; adjusting the weight distribution between each central sentence and the associated environment sentence based on a first coefficient, a second coefficient, and a distance between the central sentence and the associated environment sentence in the training text; the first coefficient characterizes the degree of dispersion of the first weight of the central sentence to the second weight of the environment sentence associated with the central sentence; the second coefficient is related to the number of environment sentences associated with the central sentence; inputting the training text into a predetermined model based on the first weight and the second weight corresponding to each central sentence to train the predetermined model; the predetermined model is used to recognize a target text.
[0005] Further, the method adjusts the weight distribution between each central sentence and the related environmental sentences based on the first coefficient, the second coefficient, and the distance between the central sentence and the related environmental sentences in the training text, including: determining a weight dispersion coefficient based on the first coefficient and the second coefficient; determining the product of the distance between the central sentence and the related environmental sentences in the training text and the weight dispersion coefficient; determining the second weight of the environmental sentences related to the central sentence based on the product; and determining the first weight of the central sentence based on the second weights of all environmental sentences related to the central sentence.
[0006] Further, determining the second weight of the environmental sentence related to the central sentence based on the product includes: determining the second weight of the environmental sentence related to the central sentence based on the product and a predetermined value; the predetermined value is the reciprocal of the first coefficient plus 1.
[0007] Furthermore, before adjusting the weight distribution between each of the central sentences and the related environmental sentences based on the first coefficient, the second coefficient, and the distance between the environmental sentences and the related central sentences in the training text, the method also includes: adding a predetermined number of empty strings at the beginning and end of the training text respectively; determining the position of each of the central sentences and the environmental sentences related to the central sentences in the training text after adding the empty strings; and determining the distance between the central sentence and the related environmental sentences in the training text based on the position of each of the central sentences and the environmental sentences related to the central sentences.
[0008] Further, the predetermined number is equal to the second coefficient minus 1.
[0009] Further, the method also includes: determining the first coefficient and / or the second coefficient based on the text length of the training text; obtaining the learning rate of the previous training of the predetermined model; inputting the training text into the predetermined model based on the first weight and the second weight corresponding to each of the central sentences to train the predetermined model, including: inputting the training text into the predetermined model based on the first weight and the second weight corresponding to each of the central sentences and the learning rate to train the predetermined model.
[0010] Furthermore, before splitting the training text into multiple central sentences and determining the environment sentences related to each central sentence, the method also includes: obtaining training text in a first training set and a second training set; the first training set includes multiple first-category texts and multiple second-category texts; the second training set includes multiple text groups, each of the text groups includes a question text, a first-category text corresponding to the question text, and a second-category text corresponding to the question text.
[0011] According to another aspect of an embodiment of the present application, a model processing device is also provided, including: a splitting module, used to split a training text into multiple central sentences and determine the environmental sentences related to each central sentence; an adjustment module, used to adjust the weight distribution between each central sentence and the related environmental sentences based on a first coefficient, a second coefficient, and the distance between the central sentence and the related environmental sentences in the training text; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the environmental sentences related to the central sentence; the second coefficient is related to the number of environmental sentences related to the central sentence; a training module, used to input the training text into a predetermined model based on the first weight and the second weight corresponding to each central sentence to train the predetermined model; the predetermined model is used to identify the target text.
[0012] Furthermore, the adjustment module is specifically used to: determine a weight dispersion coefficient based on a first coefficient and a second coefficient; determine the product of a distance between the central sentence and related environmental sentences in the training text and the weight dispersion coefficient; determine a second weight of the environmental sentences related to the central sentence based on the product; and determine a first weight of the central sentence based on the second weights of all environmental sentences related to the central sentence.
[0013] Furthermore, the adjustment module is specifically used to: determine the second weight of the environment sentence related to the central sentence based on the product and a predetermined value; the predetermined value is the reciprocal of the first coefficient plus 1.
[0014] Furthermore, the adjustment module is also used to: add a predetermined number of empty strings at the beginning and end of the training text respectively; determine the position of each central sentence and the surrounding sentences related to the central sentence in the training text after adding the empty strings; and determine the distance between the central sentence and the related surrounding sentences in the training text based on the position of each central sentence and the surrounding sentences related to the central sentence.
[0015] Further, the predetermined number is equal to the second coefficient minus 1.
[0016] Furthermore, the training module is specifically used to: determine the first coefficient and / or the second coefficient based on the text length of the training text; obtain the learning rate of the previous training of the predetermined model; based on the first weight and the second weight corresponding to each of the central sentences and the learning rate, input the training text into the predetermined model to train the predetermined model.
[0017] Furthermore, the splitting module is also used to: obtain training texts from the first training set and the second training set; the first training set includes multiple first-category texts and multiple second-category texts; the second training set includes multiple text groups, each of the text groups includes a question text, a first-category text corresponding to the question text, and a second-category text corresponding to the question text.
[0018] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the steps in the above method are executed when the program is run.
[0019] According to another aspect of an embodiment of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the program stored in the memory.
[0020] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps in the above method.
[0021] The embodiment of the present application proposes a model processing method, device, electronic device and storage medium, the method splits a training text into multiple central sentences, and determines the environmental sentences related to each central sentence; based on the first coefficient, the second coefficient, and the distance between the central sentence and the relevant environmental sentences in the training text, adjusts the weight distribution between each central sentence and the relevant environmental sentences; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the environmental sentences related to the central sentence; the second coefficient is related to the number of environmental sentences related to the central sentence; based on the first weight and the second weight corresponding to each central sentence, the training text is input into a predetermined model to train the predetermined model; the predetermined model is used to recognize the target text. In this way, the weight of each sentence is adjusted before the text is input into the model, and the weight of a sentence is dispersed to the environmental sentences related to it according to the number of environmental sentences and the required dispersion degree, which can improve the relevance of each sentence with other sentences in the text, avoid independent processing for each sentence, thereby improving the text context relevance in model processing, and then improving the performance of the model in text content recognition and classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 is a flow chart of a model processing method according to an embodiment of the present application; Figure 2 is a flow chart of a model processing method according to an embodiment of the present application; Figure 3 is a schematic diagram of a central sentence and an environmental sentence according to an embodiment of the present application; Figure 4 is a weight distribution diagram according to an embodiment of the present application; Figure 5 is a weight distribution diagram according to an embodiment of the present application; Figure 6 is a structural diagram of a model processing device according to an embodiment of the present application; Figure 7 It is a structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] In this embodiment, a model processing method is provided. Figure 1 is a flow chart of a model processing method according to an embodiment of the present application, such as Figure 1 As shown, the process includes the following steps: S10: Split the training text into multiple central sentences and determine the environment sentences related to each central sentence; S20: Based on the first coefficient, the second coefficient, and the distance between the central sentence and the relevant surrounding sentences in the training text, adjust the weight distribution between each central sentence and the relevant surrounding sentences; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the surrounding sentences related to the central sentence; the second coefficient is related to the number of surrounding sentences related to the central sentence; S30: Inputting the training text into a predetermined model based on the first weight and the second weight corresponding to each central sentence to train the predetermined model; the predetermined model is used to recognize the target text.
[0026] In this embodiment, the predetermined model can be used to identify the target text, for example, to determine the category of the target text according to the content of the target text, and the predetermined model can be a large language model (LLM). Here, the category of the target text can refer to whether the target text is generated by AI. The training text can be an article, a conversation, or other forms of text, and can contain one or more paragraphs.
[0027] In one embodiment, splitting the training text into multiple central sentences may refer to splitting the training text into multiple central sentences based on a predetermined sentence segmentation strategy. Here, splitting into multiple central sentences may refer to all sentences in the training text being central sentences. For example, multiple central sentences constitute the training text.
[0028] In one embodiment, determining the environmental sentences related to each central sentence may refer to determining all environmental sentences related to each central sentence. Environmental sentences related to a central sentence may be other central sentences in the training text. Environmental sentences related to a central sentence may refer to other central sentences that have a predetermined association relationship with the content of the central sentence. A central sentence may correspond to one or more related environmental sentences.
[0029] Exemplarily, the training text contains a, b, c, d, and e. When the central sentence is a, the related environment sentences may be b and c. When the central sentence is b, the related environment sentences may be c and d, and so on.
[0030] In the related technology, the text is input into the model sentence by sentence, the weight of each sentence is 1, and it is processed independently. The coherence and contextual relevance of the text content are poor, and the characteristics of AI-generated text in text continuity cannot be effectively identified, resulting in low recognition and classification accuracy.
[0031] In one embodiment, adjusting the weight distribution between each central sentence and the related environment sentences in step S20 may refer to adjusting the weight distribution between each group of central sentences and all the related environment sentences of the central sentence, wherein the weight of the central sentence is the first weight, and the weight of the environment sentence is the second weight.
[0032] In one embodiment, the first coefficient and the second coefficient can be fixed values, or can be values adjusted according to the content of the training text. The first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the surrounding sentences related to the central sentence. For example, the larger the first coefficient, the lower the first weight of the central sentence, and the higher the sum of the second weights of all the surrounding sentences related to the central sentence.
[0033] In one embodiment, the second coefficient is related to the number of surrounding sentences related to the central sentence. For example, the larger the second coefficient is, the larger the average number of surrounding sentences related to the central sentence in the training text is.
[0034] In one embodiment, the sum of the first weight of a central sentence and the second weights of all the surrounding sentences related to the central sentence is equal to 1.
[0035] In one embodiment, in step S30, inputting the training text into a predetermined model based on the first weight and the second weight corresponding to each of the central sentences may include: inputting multiple central sentences of the training text into the predetermined model in sequence based on the first weight and the second weight corresponding to each of the central sentences.
[0036] In one embodiment, inputting the training text into a predetermined model based on the first weight and the second weight corresponding to each of the central sentences may include: inputting the training text into the predetermined model in sequence according to the central sentences, each time inputting a central sentence, the first weight of the central sentence, and the second weights of all the environment sentences corresponding to the central sentence into the predetermined model.
[0037] In one embodiment, inputting the training text into a predetermined model based on the first weight and the second weight corresponding to each of the central sentences may include: inputting the training text into the predetermined model in sequence according to the central sentences, each time inputting a central sentence, the first weight of the central sentence, all the surrounding sentences corresponding to the central sentence, and the second weights of all the surrounding sentences corresponding to the central sentence into the predetermined model.
[0038] In this way, the weight of each sentence is adjusted before the text is input into the model. The weight of a sentence is dispersed to the related environmental sentences according to the number of environmental sentences and the required degree of dispersion. This can improve the relevance of each sentence with other sentences in the text and avoid independent processing of each sentence, thereby improving the relevance of text context in model processing, and further improving the model's performance in text content recognition and classification.
[0039] In this embodiment, a model processing method is provided. Figure 2 is a flow chart of a model processing method according to an embodiment of the present application, such as Figure 2 As shown, in step S20, adjusting the weight distribution between each of the central sentence and the related environment sentence based on the first coefficient, the second coefficient, and the distance between the central sentence and the related environment sentence in the training text may include: S21: determining a weight dispersion coefficient based on the first coefficient and the second coefficient; S22: Determine the product of the distance between the central sentence and the relevant environment sentences in the training text and the weight dispersion coefficient; S23: determining a second weight of the surrounding sentence related to the central sentence based on the product; S24: Determine the first weight of the central sentence based on the second weights of all surrounding sentences related to the central sentence.
[0040] In one embodiment, the weight dispersion coefficient may be positively correlated with the degree of dispersion of the first weight to the second weight. The larger the weight dispersion coefficient, the higher the degree of dispersion of the first weight of the central sentence to the second weight of the related environment sentence. The larger the second weight, the lower the first weight.
[0041] In one embodiment, the second coefficient Indicates the maximum distance between all surrounding sentences corresponding to the central sentence and the central sentence in the training text, for example Figure 3 As shown, the central sentence All corresponding environmental sentences , ,but and The distance between them is 1, and The maximum distance is 2.
[0042] In one embodiment, the weight dispersion coefficient can also be expressed as a weight leakage coefficient, such as a weight leakage slope. The first coefficient is , the second coefficient is , the weight dispersion coefficient can be .
[0043] In one embodiment, the distance between the central sentence and the related environment sentence in the training text can be determined according to the position of the central sentence in the training text and the position of the environment sentence in the training text. For example, it can refer to the distance between the position of the central sentence in the training text and the position of a related environment sentence in the training text. Exemplarily, if the central sentence is the first sentence and the environment sentence is the second sentence, the distance between the central sentence and the environment sentence in the training text is 1.
[0044] In one embodiment, j represents the position difference between the central sentence and the related environment sentences in the training text, and the distance between the central sentence and the related environment sentences in the training text is expressed as the absolute value of j , An integer greater than 0.
[0045] In one embodiment, the first weight of the central sentence is determined based on the second weights of all surrounding sentences related to the central sentence, which may mean that the first weight of the central sentence is equal to 1 minus the sum of the second weights of all surrounding sentences related to the central sentence.
[0046] In one embodiment, determining the second weight of the environmental sentence related to the central sentence based on the product includes: determining the second weight of the environmental sentence related to the central sentence based on the product and a predetermined value; the predetermined value is the reciprocal of the first coefficient plus 1.
[0047] Compared with directly letting the recognition text corpus enter the model's input layer sentence by sentence, we choose to Sentences (called the Central sentence), let Central sentence Write weight Leaking part of it into the environment sentence Among them, the leakage level depends on the leakage component , which determines the ratio of the total weight of the ambient sentence to the weight of the central sentence. The larger the value, the greater the leakage; the leakage distance depends on the leakage component , which determines the amount of ambient sentences, that is, how many sentences are considered relevant to the central sentence.
[0048] For example, let the training text be of length n Split the sentence into , where the length is n, which means that the training text is split into n sentences, i.e., n central sentences, then we can get: (1) (2) (3) in, is a sentence in the training text, Represents the i-th central sentence The jth related environmental sentence, is the weight function, and each environment sentence has a weight , From the ambient sentence to the corresponding central sentence Obviously, there is (4) Combining (2)(3)(4), we can determine the second weight of an environment sentence: It can be expressed as:
[0049] in, Indicates greater than 0 and less than An integer.
[0050] In this way, the weight dispersion coefficient can more intuitively and accurately represent the degree of weight dispersion to the surrounding sentences. By multiplying the distance between each surrounding sentence and the central sentence by the dispersion coefficient, the relevance and continuity of the sentence position in the text can be further combined to determine the second weight. The first weight and second weight obtained can improve the model's ability to recognize the relevance of text context when each central sentence is input.
[0051] Since once a piece of text is entered, a single sentence The sum of the weights input in each input process is the The total weight of . Define the initial input weight function =1 , then the total weight :
[0052] In principle, However, practice has found that Partial , the total weight will be less than 1, which can be called weight loss. The loss weight is This is because in the sequence Partial When calculating the total weight, if Figure 4 As shown, is the sum of the weights of the i-th central sentence and its surrounding sentences, i , is the weight loss value. right The undefined part of Some are not counted Inside.
[0053] Therefore, in some embodiments, before step S20, the method may further include: Adding a predetermined number of empty strings at the beginning and end of the training text respectively; The position of each of the central sentences and the surrounding sentences related to the central sentences in the training text after the empty string is added is determined.
[0054] In one embodiment, after determining the position of each of the central sentences and the surrounding sentences related to the central sentences in the training text after adding the empty string, before step S20, the method may also include: determining the distance between the central sentence and the related surrounding sentences in the training text based on the position of each of the central sentences and the surrounding sentences related to the central sentences.
[0055] In one embodiment, adjusting the weight distribution between each of the central sentences and the related environment sentences may include: adjusting the weight distribution between each of the central sentences and the related environment sentences in the training text. For example, it includes: adjusting the weight distribution between each of the central sentences and the related environment sentences in the training text after adding the empty string.
[0056] In one embodiment, the predetermined number is equal to the second coefficient minus 1, that is, adding An empty string.
[0057] So, like Figure 5 As shown, in order to cope with the impact of weight loss, Make corrections and expand its domain to both sides. Added the beginning and end of empty strings to form a new set As the original , and when calculating the weight distribution, empty strings are used to occupy some sentences that may have lost weight, thereby correcting the impact of weight loss.
[0058] Since in the actual training process, the model recognizes that the length n is lower than When the input is short text, the input imbalance caused by the short length will seriously affect the classification effect of the model.
[0059] Therefore, in some embodiments, before step S20, the method may further include: Determine the first coefficient and / or the second coefficient based on the text length of the training text; Obtaining the learning rate of the last training of the predetermined model; Step S30 may include: Based on the first weight and the second weight corresponding to each of the central sentences and the learning rate, the training text is input into a predetermined model to train the predetermined model.
[0060] In one embodiment, the text length of the training text may refer to the number of sentences included in the training text, such as the number of central sentences included.
[0061] In one embodiment, based on the first weight and the second weight corresponding to each of the central sentences and the learning rate, the training text is input into a predetermined model to train the predetermined model, which may include: determining the target learning rate corresponding to the current training based on the learning rate and a predetermined learning rate inheritance strategy; based on the first weight and the second weight corresponding to each of the central sentences and the target learning rate, the training text is input into a predetermined model to train the predetermined model.
[0062] In this way, when training the model, the weight distribution is performed by adjusting different first and second coefficients based on the text length, which can flexibly deal with texts of different lengths and reduce the situation where short texts cause input imbalance and lead to poor model classification results. In addition, based on learning rate inheritance, it can avoid the learning rate of the model returning to the initial value after each training epoch, resulting in low training efficiency.
[0063] In some embodiments, before step S10, the method may further include: Training texts are obtained from a first training set and a second training set; the first training set includes a plurality of first-category texts and a plurality of second-category texts; the second training set includes a plurality of text groups, each of which includes a question text, a first-category text corresponding to the question text, and a second-category text corresponding to the question text.
[0064] In one embodiment, the first type of text may be text written by humans, and the second type of text may be text generated by AI.
[0065] In one embodiment, a data set CA (CNN-AI Writer set) is constructed, i.e., a first training set, and a data set HC3 is called, i.e., a second training set.
[0066] In one embodiment, the first training set consists of news articles, which are randomly mixed with positive samples and negative samples. The negative samples, i.e., the first type of text, can be a public data set provided on a web page, for example, containing more than 4,000 news articles written by humans; the positive samples, i.e., the second type of text, come from calling the official interface of OpenAI and are directly generated by the GPT-3.5-turbo
[0613] model.
[0067] In one embodiment, before S10, obtaining training texts in the first training set and the second training set may include: splitting the first category of text and the second category of text to obtain a plurality of first target sentences corresponding to the first category of text and a plurality of second target sentences corresponding to the second category of text; and selecting a first number of first target sentences and second target sentences according to a predetermined ratio to integrate into the first training set.
[0068] In one embodiment, after the above steps, before S10, the method may further include: selecting a second number of other target sentences different from those in the first training set to be integrated into a first test set; the first test set is used to test the performance of a predetermined model.
[0069] For example, for processing data sets, the Natural Language Toolkit (nltk) library can be used to split samples into sentences, delete special punctuation marks, hyperlinks and other characters that may cause model bias, and mark the types of samples. Then, the first 100,000 items in each data set, totaling 200,000 items, are taken and divided into training sets and validation sets in an 8:2 ratio, and recorded as the first training set CA1. Then, 7,000 items of data that are not in CA1 are taken as the first test set, recorded as CA2.
[0070] In one embodiment, the second training set may be the HC3 dataset, which is the dataset published in a paper by Guo et al. The HC3 corpus is a text corpus pair containing human answers and AI answers to a given question.
[0071] In one embodiment, a second test set can also be determined based on the second training set, and the second test set is used to test the performance of the predetermined model. The second test set can include multiple text sets, each of which includes a question text, a first-category text corresponding to the question text, a second-category text with the highest similarity to the first-category text, and a second-category text with the lowest similarity to the first-category text.
[0072] For example, the second test set can be determined based on the HC3_K dataset corresponding to the second training set HC3 dataset. Here, the HC3_K dataset can be processed using tools such as all-MiniLM-L6-v2 to assemble the texts that are closest to and have the largest gap with human answers into a new dataset, and the final size of the new dataset is about 10% of the original dataset. This benchmark dataset can be used as a standardized reference for evaluating the ability of different technologies to detect AI-generated content.
[0073] In this way, the overfitting of the model to a single text corpus form can be reduced, and possible data leakage in a single corpus form can be suppressed. Tests based on the above test set can also provide more accurate feedback on the true performance of the model.
[0074] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0075] In this embodiment, a model processing device is also provided to implement the above-mentioned embodiments and preferred implementation modes, which have been described and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0076] Figure 6 is a structural block diagram of a model processing device according to an embodiment of the present application, such as Figure 6 As shown, the device includes: a splitting module 100, used to split the training text into multiple central sentences and determine the environmental sentences related to each central sentence; an adjustment module 200, used to adjust the weight distribution between each central sentence and the related environmental sentences based on a first coefficient, a second coefficient, and the distance between the central sentence and the related environmental sentences in the training text; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the environmental sentences related to the central sentence; the second coefficient is related to the number of environmental sentences related to the central sentence; a training module 300, used to input the training text into a predetermined model based on the first weight and the second weight corresponding to each central sentence to train the predetermined model; the predetermined model is used to recognize the target text.
[0077] Further, the adjustment module 200 is specifically used to: determine a weight dispersion coefficient based on a first coefficient and a second coefficient; determine the product of a distance between the central sentence and related environmental sentences in the training text and the weight dispersion coefficient; determine a second weight of the environmental sentences related to the central sentence based on the product; and determine a first weight of the central sentence based on the second weights of all environmental sentences related to the central sentence.
[0078] Furthermore, the adjustment module 200 is specifically used to: determine the second weight of the environment sentence related to the central sentence based on the product and a predetermined value; the predetermined value is the reciprocal of the first coefficient plus 1.
[0079] Furthermore, the adjustment module 200 is also used to: add a predetermined number of empty strings at the beginning and end of the training text respectively; determine the position of each central sentence and the surrounding sentences related to the central sentence in the training text after adding the empty strings; and determine the distance between the central sentence and the related surrounding sentences in the training text based on the position of each central sentence and the surrounding sentences related to the central sentence.
[0080] Further, the predetermined number is equal to the second coefficient minus 1.
[0081] Furthermore, the training module 300 is specifically used to: determine the first coefficient and / or the second coefficient based on the text length of the training text; obtain the learning rate of the previous training of the predetermined model; based on the first weight and the second weight corresponding to each of the central sentences and the learning rate, input the training text into the predetermined model to train the predetermined model.
[0082] Furthermore, the splitting module 100 is also used to: obtain training texts from the first training set and the second training set; the first training set includes multiple first-category texts and multiple second-category texts; the second training set includes multiple text groups, each of which includes a question text, a first-category text corresponding to the question text, and a second-category text corresponding to the question text.
[0083] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0084] An embodiment of the present application also provides an electronic device, which may be a robot or used in a robot. Figure 7 is a structural diagram of an electronic device according to an embodiment of the present application, such as Figure 7 As shown, it includes a processor 41, a communication interface 42, a memory 43 and a communication bus 44, wherein the processor 41, the communication interface 42 and the memory 43 communicate with each other through the communication bus 44, and the memory 43 is used to store computer programs; the processor 41 is used to implement the following steps when executing the program stored in the memory 43: split the training text into multiple central sentences, and determine the environmental sentences related to each central sentence; based on the first coefficient, the second coefficient, and the distance between the central sentence and the related environmental sentences in the training text, adjust the weight distribution between each central sentence and the related environmental sentences; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the environmental sentences related to the central sentence; the second coefficient is related to the number of environmental sentences related to the central sentence; based on the first weight and the second weight corresponding to each central sentence, the training text is input into a predetermined model to train the predetermined model; the predetermined model is used to recognize the target text.
[0085] Further, the method adjusts the weight distribution between each central sentence and the related environmental sentences based on the first coefficient, the second coefficient, and the distance between the central sentence and the related environmental sentences in the training text, including: determining a weight dispersion coefficient based on the first coefficient and the second coefficient; determining the product of the distance between the central sentence and the related environmental sentences in the training text and the weight dispersion coefficient; determining the second weight of the environmental sentences related to the central sentence based on the product; and determining the first weight of the central sentence based on the second weights of all environmental sentences related to the central sentence.
[0086] Further, determining the second weight of the environmental sentence related to the central sentence based on the product includes: determining the second weight of the environmental sentence related to the central sentence based on the product and a predetermined value; the predetermined value is the reciprocal of the first coefficient plus 1.
[0087] Furthermore, before adjusting the weight distribution between each of the central sentences and the related environmental sentences based on the first coefficient, the second coefficient, and the distance between the environmental sentences and the related central sentences in the training text, the method also includes: adding a predetermined number of empty strings at the beginning and end of the training text respectively; determining the position of each of the central sentences and the environmental sentences related to the central sentences in the training text after adding the empty strings; and determining the distance between the central sentence and the related environmental sentences in the training text based on the position of each of the central sentences and the environmental sentences related to the central sentences.
[0088] Further, the predetermined number is equal to the second coefficient minus 1.
[0089] Further, the method also includes: determining the first coefficient and / or the second coefficient based on the text length of the training text; obtaining the learning rate of the previous training of the predetermined model; inputting the training text into the predetermined model based on the first weight and the second weight corresponding to each of the central sentences to train the predetermined model, including: inputting the training text into the predetermined model based on the first weight and the second weight corresponding to each of the central sentences and the learning rate to train the predetermined model.
[0090] Furthermore, before splitting the training text into multiple central sentences and determining the environment sentences related to each central sentence, the method also includes: obtaining training text in a first training set and a second training set; the first training set includes multiple first-category texts and multiple second-category texts; the second training set includes multiple text groups, each of the text groups includes a question text, a first-category text corresponding to the question text, and a second-category text corresponding to the question text.
[0091] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0092] The communication interface is used for communication between the above terminal and other devices.
[0093] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0094] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0095] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the model processing method described in any one of the above embodiments.
[0096] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the model processing method described in any one of the above embodiments.
[0097] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0098] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
[0099] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A model processing method, characterized in that: include: Split the training text into multiple central sentences and determine the surrounding sentences related to each central sentence; Based on the first coefficient, the second coefficient, and the distance between the central sentence and the relevant surrounding sentences in the training text, adjusting the weight distribution between each central sentence and the relevant surrounding sentences; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the surrounding sentences related to the central sentence; the second coefficient is related to the number of surrounding sentences related to the central sentence; The training text is input into a predetermined model based on the first weight and the second weight corresponding to each of the central sentences to train the predetermined model; the predetermined model is used to recognize the target text.
2. The method according to claim 1, characterized in that The step of adjusting the weight distribution between each of the central sentence and the related environment sentence based on the first coefficient, the second coefficient, and the distance between the central sentence and the related environment sentence in the training text comprises: determining a weight dispersion coefficient based on the first coefficient and the second coefficient; Determine the product of the distance between the central sentence and the relevant environment sentences in the training text and the weight dispersion coefficient; Determine a second weight of the surrounding sentence related to the central sentence based on the product; The first weight of the central sentence is determined based on the second weights of all surrounding sentences related to the central sentence.
3. The method according to claim 2, characterized in that The determining, based on the product, a second weight of the environment sentence related to the central sentence comprises: The second weight of the environment sentence related to the central sentence is determined based on the product and a predetermined value; the predetermined value is the reciprocal of the first coefficient plus 1.
4. The method according to claim 1, characterized in that: Before adjusting the weight distribution between each of the central sentences and the related central sentences based on the first coefficient, the second coefficient, and the distance between the central sentences and the related central sentences in the training text, the method further includes: Adding a predetermined number of empty strings at the beginning and end of the training text respectively; Determine the position of each of the central sentences and the surrounding sentences related to the central sentences in the training text after adding the empty string; Based on the positions of each of the central sentences and the surrounding sentences related to the central sentences, the distance between the central sentences and the related surrounding sentences in the training text is determined.
5. The method according to claim 4, characterized in that The predetermined number is equal to the second coefficient minus one.
6. The method according to claim 1, characterized in that The method further comprises: Determine the first coefficient and / or the second coefficient based on the text length of the training text; Obtaining the learning rate of the last training of the predetermined model; The step of inputting the training text into a predetermined model based on the first weight and the second weight corresponding to each of the central sentences to train the predetermined model includes: Based on the first weight and the second weight corresponding to each of the central sentences and the learning rate, the training text is input into a predetermined model to train the predetermined model.
7. The method according to claim 1, characterized in that Before splitting the training text into a plurality of central sentences and determining the surrounding sentences related to each central sentence, the method further includes: Training texts are obtained from a first training set and a second training set; the first training set includes a plurality of first-category texts and a plurality of second-category texts; the second training set includes a plurality of text groups, each of which includes a question text, a first-category text corresponding to the question text, and a second-category text corresponding to the question text.
8. A model processing device, characterized in that: include: A splitting module is used to split the training text into multiple central sentences and determine the surrounding sentences related to each central sentence; An adjustment module, for adjusting the weight distribution between each of the central sentences and the related environmental sentences based on a first coefficient, a second coefficient, and a distance between the central sentence and the related environmental sentences in the training text; the first coefficient represents the degree of dispersion of the first weight of the central sentence to the second weight of the environmental sentences related to the central sentence; the second coefficient is related to the number of environmental sentences related to the central sentence; The training module is used to input the training text into a predetermined model based on the first weight and the second weight corresponding to each of the central sentences to train the predetermined model; the predetermined model is used to recognize the target text.
9. An electronic device, characterized in that: The electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the model processing method according to any one of claims 1 to 7 when executed by the processor.
10. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, implements the steps of the model processing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method, medium and system for identifying AI generation text contained in test paper
CN117113977A
Text detection method combined with academic text structure
CN117521639A
Abstract source detection method based on text similarity and deep learning
CN117807492A
AI generated news identification method based on ensemble learning
CN119046817A
KR20240057666A