Text generation method and device and text detection method and device
By putting language rules on the generated text, the problem of unstable content detection method for generating generative model in the existing technology is solved, and effective detection of text generated by generating generative model is realized, ensuring the accuracy and reliability of the detection .
Patent Information
- Application Number
- CN202310743169.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2024-12-24
AI Technical Summary
The existing generative model generation content detection method depends on changes in the training method of the generative model, resulting in failure of the detection method and inability to effectively and stably detect whether the text is generated by the generative model.
By generating text in paragraphs in sequence and stamping corresponding language rules for each paragraph, so that the subsequent method can determine whether the text is generated by a generative model by detecting the language rules of each paragraph. The specific method includes when generating the first text, the first text can be used to determine whether the text is generated by a generative model. The language rules of the segment text and the second segment text are entered into a generative model, and each segment of the generated text has a specific language rule to identify the source of the text.
Effective and stable detection of the generated text of the generative model is achieved, avoiding the problem of failure of the detection method with the change of the model training method, and improving the accuracy and reliability of the detection.
Smart Images

Figure CN119179753A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence (AI) technology, and in particular to a text generation method, a text detection method and a device. Background Art
[0002] With the rise of generative models such as Chat Generative Pre-trained Transformer (ChatGPT), more and more generative model services (such as Large Language Model (LLM)) have begun to appear. However, while generative models provide convenience for people, they also bring some problems. The most typical problem is the abuse of generated content. For example, in some educational scenarios, if students abuse generative models (such as using generative models to generate academic papers, etc.), it will cause serious problems. Therefore, there is an urgent need for a method to detect whether a piece of content is generated by a generative model.
[0003] The current method used for the above-mentioned generated content detection is mainly to detect the generative pre-trained transformer (DetectGenerative Pre-trained Transformer, DetectGPT), which is based on the phenomenon that text sampled from the generative model tends to occupy the negative curvature area of the model's logarithmic probability function, and then defines a new curvature-based criterion to determine whether a specific text is generated from a given generative model.
[0004] However, the above phenomenon that this detection method relies on may change as the generative model training method changes, thus causing the above detection method to fail. Summary of the invention
[0005] The embodiments of the present application provide a text generation method, a text detection method and a device, which can effectively and stably detect whether a piece of text is generated by a generation model.
[0006] In a first aspect, the present application provides a text generation method, the method comprising: receiving first data input by a user; generating a first text based on the first data, the first data being used to describe a subject of the first text; wherein the first text contains an adjacent first paragraph of text and a second paragraph of text, the second paragraph of text being generated by inputting a language rule of the second paragraph of text and the first paragraph of text into a generative model, or inputting the first paragraph of text, the language rule of the second paragraph of text being generated by the first paragraph of text; the first paragraph of text in the first text is generated by inputting a language rule of the first paragraph of text and the first data into a generative model, or inputting the first data, the language rule of the first paragraph of text being generated based on the first data.
[0007] Each paragraph of text in the first text may be one sentence or more sentences.
[0008] Among them, the first paragraph of text is the previous paragraph of the second paragraph of text.
[0009] From the technical effect point of view, the present application generates text by paragraphs in sequence, and makes each generated text have corresponding language rules. In this way, each text in the generated first text is marked with a corresponding watermark (i.e., language rule), so that the language rules of each text can be detected later to determine whether the text input by the user is generated by a generative model (such as LLM). In this way, it is possible to effectively and stably detect whether the text is generated by a generative model.
[0010] In a feasible implementation, the types of language rules include first-category language rules and second-category language rules; wherein the first-category language rules are used to describe the length of the corresponding generated paragraph, and the second-category language rules are used to describe the character types at some or all positions on the corresponding generated paragraph, and the character types include punctuation types and parts of speech.
[0011] Among them, the above parts of speech include adverbs, prepositions, modal particles, adjectives, nouns, verbs, etc.
[0012] From a technical perspective, by adding the above-mentioned specific language rules to the text generated by the generative model, it is possible to effectively identify whether the user input text is generated by a specific generative model based on the specific language rules.
[0013] In a feasible implementation manner, the second paragraph of text is a text determined from N texts, the N texts respectively correspond to N language rules included in the language rules of the second paragraph of text, each of the N language rules is the first type of language rule or the second type of language rule, the N texts include a second text, the second text corresponds to the first language rule of the N language rules, the second text is generated by inputting the first paragraph of text and the first language rule into the generative model, N is a positive integer; the N texts include E texts, the E texts include a third text, the third text corresponds to the second language rule of the N language rules, and the language rule of the third text conforms to the second language rule, E is a positive integer less than or equal to N; each of the E texts corresponds to a quality score, and the second paragraph of text is the text with the highest quality score among the E texts; wherein the quality score of each of the texts is used to characterize the degree of grammatical correctness of each of the texts, and the degree of matching between the subject of each of the texts and the subject described by the first data.
[0014] From the technical effect point of view, each paragraph of text generated in the present application is the text with the highest quality selected from at least one text. In this way, the text quality of the generated first text can be effectively improved.
[0015] In a feasible implementation, when the quality scores of the E texts are all lower than a first threshold or each of the N texts does not conform to the corresponding language rule, the second text is generated by inputting the first text into a generative model.
[0016] From the technical effect point of view, when a paragraph of text generated based on language rules does not meet the requirements, the present application can directly generate the current paragraph of text through the previous paragraph of text without using language rules, thereby ensuring that the complete first text required by the user is obtained.
[0017] In a feasible implementation manner, the N language rules are obtained by inputting the first paragraph of text into a language rule model, and the language rule model is a deep learning model or a mathematical model.
[0018] From the technical effect point of view, the present application can generate the language rules of the text paragraphs to be generated through different models, and has good adaptability.
[0019] In a second aspect, the present application provides a text detection method, the method comprising: obtaining a third text, the third text containing a third paragraph of text, the previous paragraph of text of the third paragraph of text being a fourth paragraph of text, and the language rule of the third paragraph of text conforming to any one of the one or more language rules generated by the fourth paragraph of text; when the number of the third paragraph of text contained in the third text is greater than or equal to a second threshold, determining that the third text is generated by a generative model, and when the number is less than the second threshold, determining that the third text is not generated by the generative model.
[0020] From the perspective of technical effects, if the text is generated by the method in the first aspect (adding corresponding language rules to each paragraph of text), then when detecting whether the text is generated by a generative model, it is possible to detect whether each paragraph of text in the third text complies with the corresponding language rules, and then count the number of text paragraphs in the third text that comply with the corresponding language rules, thereby effectively determining whether the third text is generated by a generative model.
[0021] In a feasible implementation, the types of language rules include first-category language rules and second-category language rules; wherein the first-category language rules are used to describe the length of a corresponding paragraph, and the second-category language rules are used to describe the character types at some or all positions on the corresponding paragraph, and the character types include the types of punctuation marks and parts of speech.
[0022] From a technical perspective, the above-mentioned language rules added in the process of text generation by the generative model are specific and can be accurately identified during the detection process to determine whether the text to be detected is generated by a specific generative model.
[0023] In a feasible implementation manner, when the third text is input by the first user, the F segments of text contained in the third text are compressed respectively to obtain F segment summaries corresponding to the F segments of text respectively, wherein the F segment summaries include a first segment summary, and the similarity between the first segment summary and any segment summary among multiple segments in the historical query record of the first user is greater than or equal to a third threshold, where F is a positive integer; when the number of the first segment summaries contained in the F segment summaries is greater than or equal to a fourth threshold, the query times of the first user are updated; when the number is less than the fourth threshold, the F segment summary is updated to the historical query record of the first user.
[0024] From a technical effect point of view, for the detection process bound to the user, this application will determine whether the user has detected this third text before. If so, the user's query times will be updated. Therefore, when the user's query times reach a certain number, the user's use of the generative model for text generation and text detection will be restricted to prevent the abuse or improper use of the generative text.
[0025] In a third aspect, the present application provides a text generation device, comprising: a transceiver unit for receiving first data input by a user; a processing unit for generating a first text based on the first data, the first data being used to describe a subject of the first text; wherein the first text contains adjacent first and second paragraphs of text, the second paragraph of text being generated by inputting the language rules of the second paragraph of text and the first paragraph of text into a generative model, or by inputting the first paragraph of text, the language rules of the second paragraph of text being generated by the first paragraph of text; the first paragraph of text in the first text is generated by inputting the language rules of the first paragraph of text and the first data into a generative model, or by inputting the first data, the language rules of the first paragraph of text being generated based on the first data.
[0026] In a feasible implementation, the types of language rules include first-category language rules and second-category language rules; wherein the first-category language rules are used to describe the length of the corresponding generated paragraph, and the second-category language rules are used to describe the character types at some or all positions on the corresponding generated paragraph, and the character types include punctuation types and parts of speech.
[0027] In a feasible implementation manner, the second paragraph of text is a text determined from N texts, the N texts respectively correspond to N language rules included in the language rules of the second paragraph of text, each of the N language rules is the first type of language rule or the second type of language rule, the N texts include a second text, the second text corresponds to the first language rule of the N language rules, the second text is generated by inputting the first paragraph of text and the first language rule into the generative model, N is a positive integer; the N texts include E texts, the E texts include a third text, the third text corresponds to the second language rule of the N language rules, and the language rule of the third text conforms to the second language rule, E is a positive integer less than or equal to N; each of the E texts corresponds to a quality score, and the second paragraph of text is the text with the highest quality score among the E texts; wherein the quality score of each of the texts is used to characterize the degree of grammatical correctness of each of the texts, and the degree of matching between the subject of each of the texts and the subject described by the first data.
[0028] In a feasible implementation, when the quality scores of the E texts are all lower than a first threshold or each of the N texts does not conform to the corresponding language rule, the second text is generated by inputting the first text into a generative model.
[0029] In a feasible implementation manner, the N language rules are obtained by inputting the first paragraph of text into a language rule model, and the language rule model is a deep learning model or a mathematical model.
[0030] In a fourth aspect, the present application provides a text detection device, comprising: an acquisition unit, used to acquire a third text, wherein the third text contains a third paragraph of text, the previous paragraph of text of the third paragraph of text is a fourth paragraph of text, and the language rule of the third paragraph of text conforms to any one of the one or more language rules generated by the fourth paragraph of text; a processing unit, used to determine that the third text is generated by a generative model when the number of the third paragraph of text contained in the third text is greater than or equal to a second threshold, and determine that the third text is not generated by the generative model when the number is less than the second threshold.
[0031] In a feasible implementation, the types of language rules include first-category language rules and second-category language rules; wherein the first-category language rules are used to describe the length of a corresponding paragraph, and the second-category language rules are used to describe the character types at some or all positions on the corresponding paragraph, and the character types include the types of punctuation marks and parts of speech.
[0032] In a feasible implementation manner, the processing unit is also used for: when the third text is input by the first user, compressing the F paragraphs of text contained in the third text respectively to obtain F paragraph summaries corresponding to the F paragraphs of text respectively, wherein the F paragraph summaries include the first paragraph summary, and the similarity between the first paragraph summary and any paragraph summary among the multiple paragraph summaries in the historical query record of the first user is greater than or equal to a third threshold, where F is a positive integer; when the number of the first paragraph summaries contained in the F paragraph summaries is greater than or equal to a fourth threshold, updating the query times of the first user; when the number is less than the fourth threshold, updating the F paragraph summary to the historical query record of the first user.
[0033] In a fifth aspect, the present application provides a computer device, comprising at least one processor, a memory and an interface circuit, wherein the memory, the interface circuit and the at least one processor are interconnected via lines, and instructions are stored in the at least one memory; when the instructions are executed by the processor, any of the methods described in the first to second aspects above is implemented.
[0034] In the sixth aspect, an embodiment of the present application provides a chip system, which includes at least one processor, a memory and an interface circuit, wherein the memory, the interface circuit and the at least one processor are interconnected through lines, and instructions are stored in the at least one memory; when the instructions are executed by the processor, any method described in the first to second aspects above is implemented.
[0035] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed, the method described in any one of the first to second aspects above is implemented.
[0036] In an eighth aspect, an embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed, the method described in any one of the first to second aspects above is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The following is an introduction to the drawings used in the embodiments of the present application.
[0038] Figure 1A-Figure 1C Several schematic diagrams of system architectures for implementing the methods of the present application are provided in the embodiments of the present application;
[0039] Figure 2 Another schematic diagram of a system architecture provided for an embodiment of the present application;
[0040] Figure 3 A schematic diagram of distributed deployment of a generative model provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of a convolutional neural network provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of the structure of another convolutional neural network provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of a chip hardware structure provided in an embodiment of the present application;
[0044] Figure 7 A flowchart of a text generation method provided in an embodiment of the present application;
[0045] Figure 8 A process diagram of a text generation method provided in an embodiment of the present application;
[0046] Fig. 9 A flowchart of a text detection method provided in an embodiment of the present application;
[0047] Fig.10 A process diagram of a text detection method provided in an embodiment of the present application;
[0048] Fig.11 A text generation device provided in an embodiment of the present application;
[0049] Fig.12 A text detection device provided in an embodiment of the present application;
[0050] Fig.13 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0052] The terms "first", "second", "third" and "fourth" in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. Mentioning "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of this phrase at various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0053] The following are the professional terms involved in this application:
[0054] (1) Generative model: The generative model learns the joint probability density distribution, which can represent the distribution from a statistical perspective and reflect the similarity of the same type of data. It does not care where the boundaries of different classes are. Its learning convergence speed is faster than that of the discriminative model. When the sample capacity increases, the learned model can converge to the real model faster. The main generative models currently include text-image model, text-3D model, text-text model, image-text model, text-video model, text-audio model, etc. The method in this application can be implemented by a text-text model, an image-text model, etc.
[0055] See also Figure 1A-Figure 1C , Figure 1A-Figure 1C Several system architecture schematic diagrams for implementing the methods of the present application are provided in the embodiments of the present application, which can be used to execute the text generation method and text detection method in the present application.
[0056] in, Figure 1A The system shown includes a user device 110 and a data processing device 120 (server). The user device 110 includes an intelligent terminal such as a mobile phone, a personal computer, a vehicle-mounted terminal or an information processing center. The user device 110 is the initiator of natural language data processing, and as the initiator of a request such as text generation or text detection, the user usually initiates the request through the user device 110. In the implementation process of the text generation method, the user input received by the user device 110 can be voice, text, picture, video, etc. In the implementation process of the text detection method, the user input received by the user device 110 is text or voice, etc.
[0057] The data processing device 120 may be a device or server with data processing functions such as a cloud server, a network server, an application server, and a management server. The data processing device 120 receives requests such as text generation or text detection from the user device 110 through an interactive interface, and then performs language data processing in the form of machine learning, deep learning, search, reasoning, decision-making, etc. through a memory for storing data and a processor for data processing to execute the text generation method or text detection method in this application, and finally transmits the generated text or text detection result to the user device 110 through the network to notify the user. Figure 1A The memory in the description may be a general term, including local storage and a database storing historical data. The database may be located on a data processing device or on other network servers.
[0058] Figure 1B The user device 110 in the system shown directly serves as a data processing device, directly receiving input from the user and directly processing it by the hardware of the user device 110 itself. The specific process is similar to Figure 1ASimilarly, please refer to the above description, which will not be repeated here. When the generated real model is a large model (with many model parameters), the model can be lightweight and then deployed on the user device 110 to adapt to the computing power of the user device 110.
[0059] Figure 1C The system shown includes at least one local device (such as local device 301 and local device 302), execution device 210 and data storage system 250. The local device is equivalent to Figure 1A and Figure 1B In the user device 110, the execution device 210 is equivalent to the data processing device 120, and the data storage system 250 can be integrated on the execution device 210, and can also be set on the cloud or other network servers.
[0060] See also Figure 2 , Figure 2 Another system architecture diagram provided in the embodiment of the present application. Figure 2 As shown, the data acquisition device 260 is used to collect voice data, video data and text data, and store them in the database 230 , and the training device 220 trains the relevant models in this application based on the voice, video and text data maintained in the database 230 .
[0061] Among them, the models used in the implementation process of the text generation method in the present application include a generative model 201 and a language rule model 202, and the models used in the implementation process of the text detection method include a text detection model 203. Further, the generative model 201 can be a large language model LLM, and the language rule model 202 and the language rule model 202 can be a mathematical model or a neural network model.
[0062] Figure 2 In the example given, the generative model 201, the language rule model 202 and the text detection model 203 are deployed on the same execution device 210, but the above three models can also be deployed on different execution devices, that is, the text generation method and the text detection method in this application can be executed by different devices, and this application does not limit this.
[0063] Specifically, in the text generation method, the language rule model 202 is used to generate the language rules of the text to be generated (corresponding to the language rules of the second paragraph of text in the embodiment of the present application), and the generative model 201 is used to generate the text to be generated (corresponding to the second paragraph of text in the embodiment to be described later) based on the previous paragraph of text (corresponding to the first paragraph of text in the embodiment to be described later) and the language rules of the text to be generated. Finally, based on the above rules, the generated complete text (corresponding to the first text in the embodiment to be described later) is sent to the user device 240.
[0064] Specifically, in the text detection method, the text detection model 203 is used to detect whether the input text is generated by a specific generative model, and finally send the detection result to the user device 240.
[0065] Among them, the user request sent by the user device may be a text generation request and / or a text detection request, which may include one or more of voice, text, pictures, and videos (corresponding to the first data or third text in the following embodiments).
[0066] Figure 2 It is also a functional module diagram in the process of virtual human video generation, corresponding to Figure 1A-Figure 1C In the system (i.e., the actual application scenario diagram), the user device 240 may be Figure 1A-Figure 1C In the user device 110 or local device in the embodiment, the execution device 210 and the data storage system 250 can be integrated into the user device 110 or the local device when the data processing capability of the user device 110 is relatively strong. In some embodiments, the execution device 210 and the data storage system 250 can also be integrated into the user device 110 or the local device. Figure 1A The database 230, the training device 220 and the data acquisition device 260 can be integrated in Figure 1A The data processing device 120 may be located in the cloud or on other servers on the network, but this application does not limit this.
[0067] The data collection device 260 may be a terminal device or an input / output interface of a server or cloud, and is an interactive layer (interface) for obtaining query statements and returning reply statements.
[0068] In the present application, the generative model 201, the language rule model 202 and the text detection model 203 can all be deep learning models, so the training and reasoning principles of the deep learning model will be briefly introduced below.
[0069] The architecture of a deep learning model can be a deep neural network. The work of each layer in a deep neural network can be expressed mathematically as To describe: From a physical level, the work of each layer in a deep neural network can be understood as completing the transformation from input space to output space (i.e., from row space to column space of a matrix) through operations on five input spaces (a collection of input vectors). These five operations include: 1. Dimension increase / decrease; 2. Enlargement / reduction; 3. Rotation; 4. Translation; 5. "Bending". Operations 1, 2, and 3 are represented by Completed, operation 4 is completed by +b, and operation 5 is implemented by a(). The word "space" is used here because the classified object is not a single thing, but a class of things, and space refers to the set of all individuals of this class of things. Among them, W is a weight vector, and each value in the vector represents the weight value of a neuron in this layer of the neural network. The vector W determines the spatial transformation from the input space to the output space described above, that is, the weight W of each layer controls how to transform the space. The purpose of training a deep neural network is to eventually obtain the weight matrix of all layers of the trained neural network (the weight matrix formed by many layers of vectors W). Therefore, the training process of a neural network is essentially to learn how to control spatial transformation, and more specifically to learn the weight matrix.
[0070] Because we want the output of the deep neural network to be as close as possible to the value we really want to predict, we can compare the current network's predicted value with the target value we really want, and then update the weight vector of each layer of the neural network based on the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the deep neural network). For example, if the network's predicted value is high, adjust the weight vector to make it predict a lower value, and keep adjusting until the neural network can predict the target value we really want. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the deep neural network becomes a process of minimizing this loss as much as possible.
[0071] exist Figure 2 The model trained by the training device 220 can be applied to different systems or devices. The execution device 210 is configured with an I / O interface 212 to interact with external devices. The "user" can input data to the I / O interface 212 through the user device 240, that is, the user request.
[0072] The execution device 210 can call data, codes, etc. in the data storage system 250 , and can also store data, instructions, etc. in the data storage system 250 .
[0073] The computing module 211 can recognize the user request input by the user, and after recognizing the text generation request, use the generative model 201 and the language rule model 202 to process the input data (corresponding to the first data in the following embodiments), thereby generating the text required by the user (i.e., the first text in the following embodiments) and returning it to the user; or after recognizing the text detection request, use the text detection model 203 to process the input data (corresponding to the third text in the following embodiments or the speech corresponding to the third text) to obtain the corresponding detection result.
[0074] Finally, the I / O interface 212 returns the generated first text or the detection result to the user device 240 , and presents it to the user on the user device 240 .
[0075] On a deeper level, the training device 220 can train models related to specific scenarios based on different data according to different scenario requirements to provide users with better results.
[0076] exist Figure 2 In the case shown in , the user can manually specify the data input into the execution device 210, for example, by operating in the interface provided by the I / O interface 212. In another case, the user device 240 can automatically input data into the I / O interface 212 and obtain the result. If the user device 240 needs to obtain the user's authorization to automatically input data, the user can set the corresponding authority in the user device 240. The user can view the results output by the execution device 210 on the user device 240, and the specific presentation form can be a specific method such as display, sound, action, etc. The user device 240 can also be used as a data acquisition terminal to store the collected audio, video and text data into the database 230 for use in the training process.
[0077] It is worth noting that Figure 2 It is only a schematic diagram of a system architecture provided by an embodiment of the present invention. Figure 2 The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. Figure 2 In the embodiment, the data storage system 250 is an external memory relative to the execution device 210. In other cases, the data storage system 250 can also be placed in the execution device 210.
[0078] The generative model in the above-mentioned embodiment can be deployed in a centralized or distributed manner. Centralized deployment means that the generative model 201 is deployed on a network device or computing device, and distributed deployment means that the generative model is divided into multiple modules, each module is deployed on one or more network devices or computing devices.
[0079] See also Figure 3 , Figure 3The schematic diagram of distributed deployment of a generative model provided in an embodiment of the present application is a specific example of a distributed deployment method and does not constitute a limitation.
[0080] like Figure 3 As shown, the generative model is divided into multiple modules, and each module is deployed on the network devices 1-9 and the computing devices 1-3. When the user needs to use the generative model, the user calls the generative model through the interface opened on the user device.
[0081] Each network device or computing device stores addresses of other modules related to the module deployed on the device. The other related modules may be upstream modules or downstream modules of the module or other modules at the same level.
[0082] like Figure 3 As shown in the figure, the modules deployed on network devices 1-3 are modules of the same level, and the module on computing device 1 is the downstream module of the module on network device 3. The modules on network devices 4-6 are modules of the same level and are downstream modules of the modules on network devices 1-3. Conversely, the modules on network devices 1-3 are upstream modules of the modules on network devices 4-6. Upstream modules, downstream modules, and modules of the same level are relative concepts and are not discussed here. Figure 3 The relationship between each module is explained one by one.
[0083] The stored module address may be an Internet Protocol (IP) address, a Media Access Control Address (MAC) address, or the like, which can be used to locate the module.
[0084] The above network devices may be switches, routers, gateways and other devices that support communication between nodes in the network, and the computing devices may be devices with computing capabilities in the network, such as servers.
[0085] See also Figure 4 , Figure 4 A structural diagram of a convolutional neural network provided in an embodiment of the present application is used to characterize the relevant internal structure of the deep learning model in the present application.
[0086] Convolutional Neural Network (CNN) is a deep neural network with a convolutional structure and a deep learning architecture. A deep learning architecture refers to multiple levels of learning at different levels of abstraction through machine learning algorithms. As a deep learning architecture, CNN is a feed-forward artificial neural network in which each neuron responds to overlapping areas in the image input to it.
[0087] like Figure 4 As shown, the convolutional neural network (CNN) 100 may include an input layer 110 , a convolutional layer / pooling layer 120 , wherein the pooling layer is optional, and a neural network layer 130 .
[0088] Convolutional Layer:
[0089] like Figure 4 As shown, the convolution layer / pooling layer 120 may include layers 121-126 as shown in the example. In one implementation, layer 121 is a convolution layer, layer 122 is a pooling layer, layer 123 is a convolution layer, layer 124 is a pooling layer, layer 125 is a convolution layer, and layer 126 is a pooling layer; in another implementation, layers 121 and 122 are convolution layers, layer 123 is a pooling layer, layers 124 and 125 are convolution layers, and layer 126 is a pooling layer. That is, the output of a convolution layer can be used as the input of a subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
[0090] Taking the convolution layer 121 as an example, the convolution layer 121 may include a plurality of convolution operators, which are also called kernels. Their role in the present application is equivalent to a filter that extracts specific information from the input speech or semantic information. The convolution operator may essentially be a weight matrix, which is usually predefined.
[0091] The weight values in these weight matrices need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values obtained through training can extract information from the input video image, thereby helping the convolutional neural network 100 to make correct predictions.
[0092] When the convolutional neural network 100 has multiple convolutional layers, the initial convolutional layer (for example, 121) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 100 increases, the features extracted by the later convolutional layers (for example, 125) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
[0093] Pooling layer:
[0094] Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer, such as Figure 4 The layers 121-126 in the example of 120 may be a convolution layer followed by a pooling layer, or multiple convolution layers followed by one or more pooling layers. In the process of natural language data processing, the only purpose of the pooling layer is to reduce the spatial size of the data.
[0095] Neural network layer 130:
[0096] After being processed by the convolution layer / pooling layer 120, the convolution neural network 100 is not sufficient to output the required output information. As mentioned above, the convolution layer / pooling layer 120 only extracts features and reduces the parameters brought by the input data. However, in order to generate the final output information (the required class information or other related information), the convolution neural network 100 needs to use the neural network layer 130 to generate one or a group of outputs of the required number of classes. Therefore, the neural network layer 130 may include multiple hidden layers (such as Figure 4 As shown in 131, 132 to 13n) and the output layer 140, the parameters contained in the multi-layer hidden layers can be pre-trained according to relevant training data of a specific task type. For example, the task type may include speech or semantic recognition, classification or generation, etc.
[0097] After the multiple hidden layers in the neural network layer 130, that is, the last layer of the entire convolutional neural network 100 is the output layer 140, which has a loss function similar to the classification cross entropy, specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 100 (such as Figure 4 The propagation from 110 to 140 is forward propagation), and the reverse propagation (such as Figure 4 The propagation from 140 to 110 is called back propagation) and then the weight values and biases of the aforementioned layers will begin to be updated to reduce the loss of the convolutional neural network 100 and the error between the result output by the convolutional neural network 100 through the output layer and the ideal result.
[0098] It should be noted that if Figure 4 The convolutional neural network 100 shown is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models, for example, Figure 5 The multiple convolutional layers / pooling layers shown are operated in parallel, and the features extracted respectively are input to the neural network layer 130 for processing.
[0099] In this scheme, there are Figure 4 and Figure 5The deep learning model of the structure shown can be a language rule model 202, which is used to generate the language rules of the text to be generated (corresponding to the language rules of the second paragraph of the text in the embodiment of the present application). The deep learning model can also be a component of the generative model 201, which is used to generate the text to be generated (corresponding to the second paragraph of the text in the embodiment below) based on the previous paragraph of text (corresponding to the first paragraph of text in the embodiment below) and the language rules of the text to be generated.
[0100] The deep learning model may also be a text detection model 203, which is used to detect whether the input text is generated by a specific generative model.
[0101] See also Figure 6 , Figure 6 A schematic diagram of a chip hardware structure provided in an embodiment of the present application. Figure 6 As shown, the neural network processor (Neural-Networks Processing Unit, NPU) 60 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 603, and the controller 604 controls the operation circuit 603 to extract data from the memory (weight memory or input memory) and perform operations.
[0102] In some implementations, the operation circuit 603 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 603 is a two-dimensional systolic array. The operation circuit 603 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 603 is a general-purpose matrix processor.
[0103] For example, suppose there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory 602 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 601 and performs matrix operation with matrix B, and the partial result or final result of the matrix is stored in the accumulator 608accumulator.
[0104] The vector calculation unit 607 can further process the output of the operation circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector calculation unit 607 can be used for network calculations of non-convolutional / non-FC layers in a neural network, such as pooling, batch normalization, local response normalization, etc.
[0105] In some implementations, the vector calculation unit 607 can store the processed output vector to the unified memory 606. For example, the vector calculation unit 607 can apply a nonlinear function to the output of the operation circuit 603, such as a vector of accumulated values, to generate an activation value. In some implementations, the vector calculation unit 607 generates a normalized value, a merged value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 603, such as for use in a subsequent layer in a neural network.
[0106] The unified memory 606 is used to store input data and output data.
[0107] The memory unit access controller 605 (Direct Memory Access Controller, DMAC) moves the input data in the external memory to the input memory 601 and / or the unified memory 606, stores the weight data in the external memory into the weight memory 602, and stores the data in the unified memory 606 into the external memory.
[0108] The bus interface unit (BIU) 610 is used to implement the interaction between the main CPU, DMAC and instruction fetch memory 609 through the bus.
[0109] An instruction fetch buffer 609 connected to the controller 604 is used to store instructions used by the controller 604 .
[0110] The controller 604 is used to call the instructions cached in the instruction fetch memory 609 to control the working process of the computing accelerator.
[0111] Generally, the unified memory 606, the input memory 601, the weight memory 602 and the instruction fetch memory 609 are all on-chip memories, and the external memory is a memory outside the NPU, which can be a double data rate synchronous dynamic random access memory (Double Data Rate Synchronous Dynamic Random Access Memory, abbreviated as DDR SDRAM), a high bandwidth memory (High Bandwidth Memory, HBM) or other readable and writable memory.
[0112] See also Figure 7 , Figure 7 The following is a flow chart of a text generation method provided in an embodiment of the present application. Figure 7 As shown, the method includes steps S710 and S720.
[0113] Step S710: receiving first data input by a user.
[0114] The first data may include one or more of video, audio and text.
[0115] For example, the first data may be text, which is used to describe the subject of the text required by the user. For another example, the first data may be video and text, and the text is used to indicate the scene corresponding to the video. For another example, the first data may be audio and text, and the text is used to indicate the main content of the audio to be extracted.
[0116] Step S720: Generate a first text based on the first data, wherein the first data is used to describe the subject of the first text. The first text includes a first paragraph of text and a second paragraph of text adjacent to each other, wherein the second paragraph of text is generated by inputting the first paragraph of text into a generative model, or inputting the language rule of the second paragraph of text and the first paragraph of text, wherein the language rule of the second paragraph of text is generated from the first paragraph of text; the first paragraph of text in the first text is generated by inputting the first data into a generative model, or inputting the language rule of the first paragraph of text and the first data, wherein the language rule of the first paragraph of text is generated based on the first data.
[0117] The first paragraph of text and the second paragraph of text are any two adjacent paragraphs of text in the first text.
[0118] Among them, each paragraph of the above-mentioned first text may contain one or more sentences, which is not limited in this application.
[0119] The following describes the generation process of the first text:
[0120] First, the first data is input into the language rule model to generate the language rules of the first paragraph of the first text, and then the language rules of the first paragraph and the first data are input into the generative model, or only the first data is input into the generative model to generate the first paragraph. Then the first paragraph is input into the language rule model to generate the language rules of the next paragraph, and the language rules of the first paragraph and the next paragraph are input into the generative model, or only the first paragraph is input into the generative model to generate the next paragraph of the first paragraph. Each subsequent paragraph is generated in the same way as the next paragraph of the first paragraph until the last paragraph is generated to obtain the first text.
[0121] The generation process of the second paragraph of text is used to describe the generation process of the other paragraphs of text in the first text except the first paragraph of text, that is, the other paragraphs of text except the first paragraph of text are generated based on the previous paragraph of text.
[0122] Optionally, the above-mentioned language rule model may be a mathematical model or a deep learning model.
[0123] Among them, the types of language rules include two categories: first-type language rules and second-type language rules.
[0124] The first type of language rules is used to describe the length of the corresponding generated paragraph. The first type of language rules may include multiple different language rules. For example, one language rule under this category may be: the length of the corresponding generated paragraph is 50 characters. Another language rule under this category may be: the length of the corresponding generated paragraph is 25 characters.
[0125] The second type of language rules is used to describe the character types at some or all positions on the corresponding generated paragraph, and the character types include punctuation types and parts of speech. For example, a language rule under this category can be used to describe the character types at all positions of the corresponding generated paragraph, specifically: the 1st to 3rd characters on the corresponding generated paragraph are nouns, the 4th to 5th characters are verbs, the 6th to 8th characters are nouns, and the 9th character is a period. Another language rule under this category can be used to describe the character types at some positions of the corresponding generated paragraph, specifically: the 4th to 6th characters on the corresponding generated paragraph are nouns, the 7th character is a comma, the 10th to 11th characters are verbs, and the 25th character is a period.
[0126] The following describes the specific process of generating each paragraph of the first text through the generative model, taking the second paragraph of the first text (that is, any paragraph of the first text except the first paragraph) as the object for description:
[0127] The previous paragraph of the second paragraph is the first paragraph. First, the first paragraph is input into the language rule model to obtain the language rules of the second paragraph. The language rules of the second paragraph include N language rules, and each of the N language rules is the aforementioned first-category language rule or second-category language rule.
[0128] The N language rules include the first language rule. The first language rule and the first paragraph of text are input into the generative model to obtain the second text. The operation of the first language rule is performed on each of the N language rules to obtain N texts in total. The N texts correspond to the aforementioned N language rules respectively. The second paragraph of text is a text determined from the obtained N texts.
[0129] After obtaining the above N texts, E texts are determined from the N texts. Each of the E texts satisfies the following characteristics: the third text (any one of the E texts) in the E texts is used as an object for description, and the third text corresponds to the second language rule in the above N language rules, and the language rule of the third text conforms to the second language rule. That is, the language rule of the text generated by the generative model conforms to the language rule input to the generative model.
[0130] Then, the E texts are scored, each of the E texts corresponds to a quality score, and the text with the highest quality score among the E texts is determined as the second text mentioned above. The quality score of each text is used to evaluate the grammatical correctness of the text and the degree of match between the subject of the text and the subject described by the first data. For example, the evaluation rule may be: the higher the grammatical accuracy of the text, the higher the quality score; the higher the degree of match between the subject of the text and the subject described by the first data, the higher the quality score. For quantitative scoring details, scoring can be performed using a mathematical model or a deep learning model, which is not limited in this application.
[0131] If the quality scores of the above E texts are all lower than the first threshold or each of the above N texts does not conform to the corresponding language rules, then only the first paragraph of text is input into the generative model (without inputting the language rules) to generate the second paragraph of text.
[0132] Among them, the above-mentioned first threshold can be set by technical personnel in this field based on specific scenarios, and this application will not expand on it.
[0133] Among them, the number of language rules in the above-mentioned second paragraph of text is N. This number is only used to indicate that the number of language rules for each paragraph of text is one or more, and does not limit the number of language rules for each paragraph of text to N. In the first text generation process, the number of language rules for each paragraph of text can be the same or different.
[0134] This application generates each paragraph of text except the first paragraph in the first text through the above method.
[0135] For the first paragraph of the first text, the difference between it and the second paragraph is that: (1) the language rules of the first paragraph are generated by the first data, while the language rules of the second paragraph are generated by the first paragraph. (2) If the texts generated based on the first data and multiple language rules of the means text do not meet the above requirements, the first data is directly input into the generative model to generate the first paragraph. The rest of the process is the same and will not be repeated here.
[0136] Among them, the above-mentioned language rule model can be a mathematical model or a deep learning model.
[0137] Optionally, when the language rule model is a mathematical model, it can be a hash function or the like. The function establishes a mapping relationship between input text and language rules. Further, the specific implementation process can be: the input text is converted into corresponding characters or numbers through a hash function, and then based on a predefined mapping rule, the characters and numbers are mapped to a corresponding value range, and the language rule corresponding to each value in the value range is one or more language rules output by the language rule model (corresponding to the N language rules in the above embodiment).
[0138] Optionally, when the language rule model is a deep learning model, it can be trained by supervised learning, unsupervised learning, or semi-supervised learning. For example, if supervised learning is used for training, the training data can be text and the language rules (i.e., labels) corresponding to the text.
[0139] Among them, the mapping rules of the above-mentioned mathematical functions and the convergence direction of the deep learning model training process can be set based on specific scenarios, and this application does not limit them.
[0140] See also Figure 8 , Figure 8 A process diagram of a text generation method provided in an embodiment of the present application is used to describe the aforementioned generation based on language rules. Figure 7 Embodiment 1 The process of each text on the text.
[0141] like Figure 8 As shown, the first paragraph of text and the second paragraph of text are any two adjacent paragraphs of text in the first text, the second paragraph of text is the next paragraph of text of the first paragraph of text, and the second paragraph of text is generated based on the first paragraph of text and language rules.
[0142] The details are as follows: First, execute steps ① and ②: input the first paragraph of text into the language rule model to obtain N language rules (i.e., language rule 1-language rule N). Then execute steps ③ and ④: input the first paragraph of text and a language rule into the generative model each time, and the generative model calculates N times to obtain N texts (i.e., text 1-text N). Then execute step ⑤: the selector determines the second paragraph of text from the N texts. The specific selection process of the selector can be found in the above Figure 7 The relevant description in the embodiment will not be repeated here. If there is no text that meets the requirements in the N texts, the first text is directly input into the generative model to obtain the second text ( Figure 8 This step is not shown).
[0143] in, Figure 8 The specific implementation process of each step can be found in Figure 7 The corresponding description is not repeated here.
[0144] See also Fig. 9 , Fig. 9 A flowchart of a text detection method provided in an embodiment of the present application is used to detect whether a piece of text is Figure 7 The generative model in the embodiment is generated. Fig. 9 As shown, the method includes steps S910 and S920.
[0145] Step S910: obtaining a third text, wherein the third text includes a third paragraph of text, the previous paragraph of the third paragraph of text is a fourth paragraph of text, and the language rule of the third paragraph of text conforms to any one of the one or more language rules generated by the fourth paragraph of text.
[0146] The third text is the text used for detection. The third text can be input by a bound user or an unbound user.
[0147] Each paragraph of the third text may include one or more sentences.
[0148] The language rules of the third paragraph are obtained by inputting the fourth paragraph into the Figure 7 The specific process is obtained from the language rule model in the embodiment, and will not be repeated here.
[0149] The types of the above-mentioned language rules include first-type language rules and second-type language rules. The first-type language rules are used to describe the length of the corresponding paragraph, and the second-type language rules are used to describe the character types at some or all positions on the corresponding paragraph, and the character types include the types of punctuation marks and parts of speech.
[0150] For specific examples of the above language rule types, please refer to the above Figure 7 The description in the embodiments will not be repeated here.
[0151] The specific process of text detection is as follows:
[0152] The number of third paragraphs of text contained in the third text is detected. The third paragraph of text is a type of text paragraph in the third text. If a paragraph of text in the third text meets the following characteristics, then the paragraph of text is the third paragraph of text: the previous paragraph of the paragraph of text is input into the language rule model to obtain one or more language rules. If the language rule of the paragraph of text meets any one of the one or more language rules, then the paragraph of text is the above-mentioned third paragraph of text.
[0153] After finding out the number of the third text segments contained in the third text, the following step S920 is performed.
[0154] Step S920: When the number of the third paragraphs of text contained in the third text is greater than or equal to a second threshold, it is determined that the third text is generated by the generative model; when the number is less than the second threshold, it is determined that the third text is not generated by the generative model.
[0155] Specifically, when the number of the third text segment is greater than or equal to the second threshold, it is determined that the third text is Figure 7 When the number of the third text segment is less than the second threshold, it is determined that the third text segment is not generated by the aforementioned generative model. Figure 7 Generated by the generative model in the embodiment.
[0156] Among them, the above-mentioned second threshold can be set by technical personnel in this field based on specific scenarios, and this application will not expand on it.
[0157] Optionally, when the third text is input by a bound first user, the text detection method further includes: compressing the F segments of text contained in the third text respectively to obtain F segment summaries corresponding to the F segments of text respectively, wherein the F segment summaries include a first segment summary, and the similarity between the first segment summary and any segment summary in a plurality of segments in a historical query record of the first user is greater than or equal to a third threshold, where F is a positive integer; when the number of first segment summaries contained in the F segment summaries is greater than or equal to a fourth threshold, updating the query times of the first user; and when the number is less than the fourth threshold, updating the F segment summary to the historical query record of the first user.
[0158] Specifically, the F paragraphs of text contained in the third text are compressed, that is, the F paragraph summaries corresponding to the F paragraphs of text are extracted. Then, each of the F paragraph summaries is compared with multiple paragraph summaries in the historical query records of the first user. If the similarity between a paragraph of the F paragraph summaries and any paragraph of the historical query records is greater than or equal to the third threshold, then the paragraph summaries are the first paragraph summaries, that is, the first paragraph summaries are a type of summaries that meet the above conditions.
[0159] Among them, the similarity comparison of any two abstracts in the above steps can be calculated by comparing two matrices or two vectors that respectively represent the two abstracts. The specific matrix / vector similarity comparison is not expanded in this application.
[0160] The historical query record of the first user includes a summary of each text segment in each input text of the first user.
[0161] After determining the number of third paragraphs of text contained in the third text, the number is compared with the fourth threshold. If the number is greater than or equal to the fourth threshold, the query times of the first user are updated. Specifically, the query times of the first user can be increased by 1. When the query times of the first user exceeds the set value, the first user is restricted from using the generative model to generate text or detect text. When the number is less than the fourth threshold, the above-mentioned F segment summary is updated to the historical query record of the first user.
[0162] Among them, the third threshold and the fourth threshold can be set by those skilled in the art based on specific scenarios, which will not be expanded in this application.
[0163] See also Fig.10 , Fig.10 A process diagram of a text detection method provided in an embodiment of the present application is used to describe the above Fig. 9 The specific process of the text detection method.
[0164] Fig.10 The detection process is described by taking any two adjacent texts in the third text to be detected except the first text as an example. The two adjacent texts are Fig.10 The previous and next text in .
[0165] The detection process is as follows: first, execute steps ① and ②: input the previous text into the language rule model to obtain H language rules (language rule 1-language rule H), where H is a positive integer. Then execute steps ③ and ④: input the H language rules and the next text into the matcher for matching to obtain a matching result. The matching process is as follows: if the language rule of the previous text meets any one of the H language rules, the match is successful, that is, the next text belongs to the above Fig. 9 The third paragraph of text in the embodiment (a type of text paragraph); if the language rule of the previous paragraph of text does not conform to any of the H language rules, it does not match, that is, the next paragraph of text does not belong to the aforementioned Fig. 9 The third paragraph of the text in the embodiment.
[0166] Finally, the number of paragraphs in the third text is counted, and based on the relationship between the number of paragraphs and the second threshold, it is determined whether the third text is generated by the generative model.
[0167] in, Fig.10 The specific implementation process of each step can be found in Fig. 9 The relevant description in will not be repeated here.
[0168] See also Fig.11 , Fig.11 A text generation device is provided in an embodiment of the present application. Fig.11As shown, the device includes a transceiver unit 1110 and a processing unit 1120; wherein,
[0169] The transceiver unit 1110 is used to receive first data input by a user. The processing unit 1120 is used to generate a first text based on the first data, wherein the first data is used to describe the subject of the first text; wherein the first text includes a first paragraph of text and a second paragraph of text adjacent to each other, wherein the second paragraph of text is generated by inputting the language rule of the second paragraph of text and the first paragraph of text into a generative model, or inputting the first paragraph of text, wherein the language rule of the second paragraph of text is generated from the first paragraph of text; the first paragraph of text in the first text is generated by inputting the language rule of the first paragraph of text and the first data into a generative model, or inputting the first data, wherein the language rule of the first paragraph of text is generated based on the first data.
[0170] In a feasible implementation, the types of language rules include first-category language rules and second-category language rules; wherein the first-category language rules are used to describe the length of the corresponding generated paragraph, and the second-category language rules are used to describe the character types at some or all positions on the corresponding generated paragraph, and the character types include punctuation types and parts of speech.
[0171] In a feasible implementation manner, the second paragraph of text is a text determined from N texts, the N texts respectively correspond to N language rules included in the language rules of the second paragraph of text, each of the N language rules is the first type of language rule or the second type of language rule, the N texts include a second text, the second text corresponds to the first language rule of the N language rules, the second text is generated by inputting the first paragraph of text and the first language rule into the generative model, N is a positive integer; the N texts include E texts, the E texts include a third text, the third text corresponds to the second language rule of the N language rules, and the language rule of the third text conforms to the second language rule, E is a positive integer less than or equal to N; each of the E texts corresponds to a quality score, and the second paragraph of text is the text with the highest quality score among the E texts; wherein the quality score of each of the texts is used to characterize the degree of grammatical correctness of each of the texts, and the degree of matching between the subject of each of the texts and the subject described by the first data.
[0172] In a feasible implementation, when the quality scores of the E texts are all lower than a first threshold or each of the N texts does not conform to the corresponding language rule, the second text is generated by inputting the first text into a generative model.
[0173] In a feasible implementation manner, the N language rules are obtained by inputting the first paragraph of text into a language rule model, and the language rule model is a deep learning model or a mathematical model.
[0174] Specifically, the specific execution process of the above-mentioned text generation device can refer to the above-mentioned embodiment. Figure 7-Figure 8 The specific process in the embodiment will not be repeated here.
[0175] See also Fig.12 , Fig.12 A text detection device is provided in an embodiment of the present application. Fig.12 As shown, the device includes an acquisition unit 1210 and a processing unit 1220; wherein,
[0176] The acquisition unit 1210 is used to acquire a third text, wherein the third text includes a third paragraph of text, the previous paragraph of the third paragraph of text is a fourth paragraph of text, and the language rule of the third paragraph of text conforms to any one of the one or more language rules generated by the fourth paragraph of text. The processing unit 1220 is used to determine that the third text is generated by the generative model when the number of the third paragraph of text included in the third text is greater than or equal to a second threshold, and determine that the third text is not generated by the generative model when the number is less than the second threshold.
[0177] In a feasible implementation, the types of language rules include first-category language rules and second-category language rules; wherein the first-category language rules are used to describe the length of a corresponding paragraph, and the second-category language rules are used to describe the character types at some or all positions on the corresponding paragraph, and the character types include the types of punctuation marks and parts of speech.
[0178] In a feasible implementation manner, the processing unit 1220 is also used to, when the third text is input by the first user, compress the F paragraphs of text contained in the third text respectively, and obtain F paragraph summaries corresponding to the F paragraphs of text respectively, wherein the F paragraph summaries include a first paragraph summary, and the similarity between the first paragraph summary and any paragraph summary among multiple paragraph summaries in the historical query record of the first user is greater than or equal to a third threshold, where F is a positive integer; when the number of the first paragraph summaries contained in the F paragraph summaries is greater than or equal to a fourth threshold, update the query times of the first user; when the number is less than the fourth threshold, update the F paragraph summary to the historical query record of the first user.
[0179] Specifically, the specific execution process of the above-mentioned text detection device can refer to the above-mentioned embodiment. Figure 9-10 The specific process in the embodiment will not be repeated here.
[0180] See also Fig.13 , Fig.13 A schematic diagram of a computer device provided in an embodiment of the present application, as Fig.11 Chinese text generation device or Fig.12 The specific implementation of the Chinese text detection device. Fig.13 As shown, the computer device includes a processor 1301 , a memory 1302 and an interface circuit 1303 ; wherein the processor 1301 , the memory 1302 and the interface circuit 1303 are connected via a bus 1304 .
[0181] In one implementation, Fig.13 The computer device shown can be used as Fig.11 The specific implementation of the text generation device in Chinese is to execute the above-mentioned text generation method. At this time, the computer device receives the first data sent by the user device through the interface circuit 1303. The processor 1301 is used to generate a first text based on the first data, and the first data is used to describe the theme of the first text; wherein the first text contains adjacent first paragraphs of text and second paragraphs of text, and the second paragraph of text is generated by inputting the language rules of the second paragraph of text and the first paragraph of text into the generative model, or inputting the first paragraph of text, and the language rules of the second paragraph of text are generated by the first paragraph of text; the first paragraph of text in the first text is generated by inputting the language rules of the first paragraph of text and the first data into the generative model, or inputting the first data, and the language rules of the first paragraph of text are generated based on the first data. The memory 1302 is used to store the first data and the first text.
[0182] Specifically, the process of the computer device executing the text generation method can be referred to in the above embodiment. Figure 7-Figure 8 The specific process in the embodiment will not be repeated here.
[0183] In one implementation, Fig.13 The computer device shown can be used as Fig.12 The specific implementation of the text detection device in Chinese is to execute the above-mentioned text detection method. At this time, the computer device receives the third text sent by the user device through the interface circuit 1303, and the third text contains a third paragraph of text, and the previous paragraph of text of the third paragraph of text is a fourth paragraph of text, and the language rule of the third paragraph of text conforms to any one of the one or more language rules generated by the fourth paragraph of text. The processor 1301 is used to determine that the third text is generated by the generative model when the number of the third paragraph of text contained in the third text is greater than or equal to the second threshold value, and when the number is less than the second threshold value, it is determined that the third text is not generated by the generative model. The memory 1302 is used to store the third text and the number of the third paragraph of text.
[0184] Specifically, the process of the computer device executing the text detection method can be referred to in the above embodiment. Figure 9-10 The specific process in the embodiment will not be repeated here.
[0185] An embodiment of the present application provides a chip system, which includes at least one processor, a memory and an interface circuit, wherein the memory, the interface circuit and the at least one processor are interconnected via lines, and instructions are stored in the at least one memory; when the instructions are executed by the processor, part or all of the steps of any one of the above-mentioned text generation method or text detection method embodiments are implemented.
[0186] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed, some or all of the steps recorded in any one of the above-mentioned text generation method or text detection method embodiments are implemented.
[0187] An embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed by a processor, some or all of the steps recorded in any one of the above-mentioned text generation method or text detection method embodiments are implemented.
[0188] In the above embodiments, the description of each embodiment has its own emphasis. For the parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited to the described order of actions, because according to this application, some steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0189] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0190] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0191] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A text generation method, characterized in that: The method comprises: receiving first data input by a user; generating a first text based on the first data, wherein the first data is used to describe a subject of the first text; Among them, the first text contains adjacent first and second paragraphs of text, the second paragraph of text is generated by inputting the language rules of the second paragraph of text and the first paragraph of text into the generative model, or inputting the first paragraph of text, and the language rules of the second paragraph of text are generated by the first paragraph of text; the first paragraph of text in the first text is generated by inputting the language rules of the first paragraph of text and the first data into the generative model, or inputting the first data, and the language rules of the first paragraph of text are generated based on the first data.
2. The method according to claim 1, characterized in that The types of language rules include first-type language rules and second-type language rules; The first type of language rules is used to describe the length of the corresponding generated paragraph, and the second type of language rules is used to describe the character types at some or all positions on the corresponding generated paragraph, and the character types include punctuation types and parts of speech.
3. The method according to claim 2, characterized in that The second paragraph of text is a text determined from N texts, the N texts respectively correspond to N language rules included in the language rules of the second paragraph of text, each of the N language rules is the first type of language rule or the second type of language rule, the N texts include a second text, the second text corresponds to a first language rule in the N language rules, the second text is generated by inputting the first paragraph of text and the first language rule into the generative model, and N is a positive integer; The N texts include E texts, the E texts include a third text, the third text corresponds to a second language rule among the N language rules, and the language rule of the third text conforms to the second language rule, and E is a positive integer less than or equal to N; Each of the E texts corresponds to a quality score, and the second text is the text with the highest quality score among the E texts; wherein the quality score of each of the texts is used to characterize the degree of grammatical correctness of each of the texts, and the degree of match between the subject of each of the texts and the subject described by the first data.
4. The method according to claim 3, characterized in that: When the quality scores of the E texts are all lower than a first threshold or each of the N texts does not conform to the corresponding language rule, the second text is generated by inputting the first text into the generative model.
5. The method according to claim 3 or 4, characterized in that: The N language rules are obtained by inputting the first text segment into a language rule model, and the language rule model is a deep learning model or a mathematical model.
6. A text detection method, characterized in that: The method comprises: Acquire a third text, wherein the third text includes a third paragraph of text, the previous paragraph of text of the third paragraph of text is a fourth paragraph of text, and the language rule of the third paragraph of text conforms to any one of the one or more language rules generated by the fourth paragraph of text; When the number of the third paragraphs of text contained in the third text is greater than or equal to a second threshold, it is determined that the third text is generated by the generative model; when the number is less than the second threshold, it is determined that the third text is not generated by the generative model.
7. The method according to claim 6, characterized in that The types of language rules include first-type language rules and second-type language rules; The first type of language rules is used to describe the length of the corresponding paragraph, and the second type of language rules is used to describe the character types at some or all positions on the corresponding paragraph, and the character types include the types of punctuation marks and parts of speech.
8. The method according to claim 6 or 7, characterized in that: The method further comprises: When the third text is input by the first user, the F segments of text contained in the third text are compressed respectively to obtain F segment summaries corresponding to the F segments of text respectively, wherein the F segment summaries include a first segment summary, and the similarity between the first segment summary and any segment summary in the multiple segment summaries in the historical query record of the first user is greater than or equal to a third threshold, where F is a positive integer; When the number of the first segment summaries included in the F segment summaries is greater than or equal to a fourth threshold, the query times of the first user are updated; when the number is less than the fourth threshold, the F segment summaries are updated to the historical query records of the first user.
9. A text generation device, characterized in that: The device comprises: A transceiver unit, configured to receive first data input by a user; a processing unit, configured to generate a first text based on the first data, wherein the first data is used to describe a subject of the first text; Among them, the first text contains adjacent first and second paragraphs of text, the second paragraph of text is generated by inputting the language rules of the second paragraph of text and the first paragraph of text into the generative model, or inputting the first paragraph of text, and the language rules of the second paragraph of text are generated by the first paragraph of text; the first paragraph of text in the first text is generated by inputting the language rules of the first paragraph of text and the first data into the generative model, or inputting the first data, and the language rules of the first paragraph of text are generated based on the first data.
10. The device according to claim 9, characterized in that The types of language rules include first-type language rules and second-type language rules; The first type of language rules is used to describe the length of the corresponding generated paragraph, and the second type of language rules is used to describe the character types at some or all positions on the corresponding generated paragraph, and the character types include punctuation types and parts of speech.
11. The device according to claim 10, characterized in that The second paragraph of text is a text determined from N texts, the N texts respectively correspond to N language rules included in the language rules of the second paragraph of text, each of the N language rules is the first type of language rule or the second type of language rule, the N texts include a second text, the second text corresponds to a first language rule in the N language rules, the second text is generated by inputting the first paragraph of text and the first language rule into the generative model, and N is a positive integer; The N texts include E texts, the E texts include a third text, the third text corresponds to a second language rule among the N language rules, and the language rule of the third text conforms to the second language rule, and E is a positive integer less than or equal to N; Each of the E texts corresponds to a quality score, and the second text is the text with the highest quality score among the E texts; wherein the quality score of each of the texts is used to characterize the degree of grammatical correctness of each of the texts, and the degree of match between the subject of each of the texts and the subject described by the first data.
12. The device according to claim 11, characterized in that When the quality scores of the E texts are all lower than a first threshold or each of the N texts does not conform to the corresponding language rule, the second text is generated by inputting the first text into the generative model.
13. The device according to claim 11 or 12, characterized in that The N language rules are obtained by inputting the first text segment into a language rule model, and the language rule model is a deep learning model or a mathematical model.
14. A text detection device, characterized in that: The device comprises: An acquisition unit, configured to acquire a third text, wherein the third text includes a third paragraph of text, the previous paragraph of the third paragraph of text is a fourth paragraph of text, and the language rule of the third paragraph of text conforms to any one of the one or more language rules generated by the fourth paragraph of text; A processing unit is used to determine that the third text is generated by the generative model when the number of the third paragraphs of text contained in the third text is greater than or equal to a second threshold, and to determine that the third text is not generated by the generative model when the number is less than the second threshold.
15. The device according to claim 14, characterized in that The types of language rules include first-type language rules and second-type language rules; The first type of language rules is used to describe the length of the corresponding paragraph, and the second type of language rules is used to describe the character types at some or all positions on the corresponding paragraph, and the character types include the types of punctuation marks and parts of speech.
16. The device according to claim 14 or 15, characterized in that The processing unit is also used for: When the third text is input by the first user, the F segments of text contained in the third text are compressed respectively to obtain F segment summaries corresponding to the F segments of text respectively, wherein the F segment summaries include a first segment summary, and the similarity between the first segment summary and any segment summary in the multiple segment summaries in the historical query record of the first user is greater than or equal to a third threshold, where F is a positive integer; When the number of the first segment summaries included in the F segment summaries is greater than or equal to a fourth threshold, the query times of the first user are updated; when the number is less than the fourth threshold, the F segment summaries are updated to the historical query records of the first user.
17. A chip system, characterized in that: The chip system includes at least one processor, a memory and an interface circuit. The memory, the interface circuit and the at least one processor are interconnected by lines. Instructions are stored in the at least one memory. When the instructions are executed by the processor, any method described in claims 1-8 is implemented.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 8 is implemented.
19. A computer program product, characterized in that The computer program product comprises instructions, and when the instructions are executed, the method according to any one of claims 1 to 8 is implemented.
