Corpus template generation method, device, electronic device and storage medium

By combining the predicted result sequence in the language generation model to generate corpus templates and adjusting the model parameters to improve prediction accuracy, the problem of insufficient generation efficiency and accuracy of corpus templates in the prior art is solved, and the richness and accuracy of corpus templates are achieved Improved degree and is suitable for high-demand language recognition technology.

CN114298001BActive Publication Date: 2024-11-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111449038.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-29
Publication Date
2024-11-08
Estimated Expiration
2041-11-29

AI Technical Summary

Technical Problem

The existing corpus template generation methods are inefficient and insufficiently accurate, low manual writing efficiency, and low accuracy of automatic generation based on labeled corpus, which makes it difficult to improve the richness and accuracy of corpus templates.

Method used

By entering the initial word elements into the language generation model, multiple corpus templates are generated using the combination of prediction results sequences, and the language generation model parameters are adjusted to improve the accuracy of the prediction results, increase the connection between word elements, and generate close and scientific Corpus template.

Benefits of technology

It improves the richness and accuracy of corpus templates, enhances the recall and accuracy of corpus template matching system, and is suitable for high-demand language recognition technology fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114298001B_ABST
    Figure CN114298001B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for generating a corpus template, the method comprising: inputting an initial word element into a language generation model to obtain a prediction result sequence output by the language generation model; wherein the next prediction result in the prediction result sequence is the output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one prediction word element; respectively selecting a prediction word element from each prediction result in the prediction result sequence, and combining the selected prediction word elements according to the order of precedence between each prediction result in the prediction result sequence to obtain multiple corpus templates. The technical solution of the embodiment of the present application can obtain a rich and accurate corpus template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to a method, device, electronic device and storage medium for generating a corpus template. Background Art

[0002] The development of Internet technology has led to the rapid development of speech recognition technology. Speech recognition is often used in the fields of speech recognition and information retrieval. For example, in the industrial, home appliance, communication, and automotive electronics industries, corresponding actions are taken by recognizing user voices. In audio and video software and search software, keywords are recognized based on input text.

[0003] Commonly used language recognition is actually done by establishing a template matching system. In the template matching system, there are multiple corpus templates. Then the user's query is matched with the template matching system to find the most suitable corpus template, and then the grammar of this template is used to parse the user's query. For example, a user's query is "I want to watch Infernal Affairs". In the template matching system, there is a template "I want to watch [film]", and the grammar of this template points to the video that can be played. After the user's query is entity extracted, the "Infernal Affairs" film entity will be extracted, and then the "I want to watch [film]" template can be matched for this query in the template matching system. At this time, the user's query intent is the video of "Infernal Affairs", thus completing the parsing of the user's query. Most of the current corpus template generation methods are manually written or automatically generated based on annotated corpus, but manual writing is inefficient and cannot obtain rich corpus templates. Corpus templates automatically generated based on annotated corpus have the problem of low accuracy. Summary of the invention

[0004] In order to solve the above technical problems, the embodiments of the present application provide a corpus template generation method and device, an electronic device, and a computer-readable storage medium.

[0005] According to one aspect of an embodiment of the present application, a method for generating a corpus template is provided, comprising: inputting an initial word element into a language generation model to obtain a prediction result sequence output by the language generation model; wherein the next prediction result in the prediction result sequence is an output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one predicted word element; respectively selecting a predicted word element from each prediction result in the prediction result sequence, and combining the selected predicted word elements according to the order of precedence between the prediction results in the prediction result sequence to obtain a plurality of corpus templates.

[0006] According to one aspect of an embodiment of the present application, a corpus template generating device is provided, comprising: a prediction result sequence acquisition module, configured to input an initial word element into a language generation model to obtain a prediction result sequence output by the language generation model; wherein the next prediction result in the prediction result sequence is an output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one prediction word element; and a corpus template acquisition module, configured to select prediction word elements from each prediction result in the prediction result sequence, and combine the selected prediction word elements according to the order of precedence between the prediction results in the prediction result sequence, so as to obtain multiple corpus templates.

[0007] In one embodiment, the corpus template generating device further includes:

[0008] A marked corpus template acquisition module is configured to acquire a marked corpus template composed of word elements carrying annotation information;

[0009] The language generation model acquisition module is configured to input the training word elements into the initial language generation model, and adjust the model parameters of the initial language generation model according to the prediction result sequence output by the initial language generation model, until the prediction result sequence output by the adjusted language generation model for the training word elements is within the prediction error range with the sequence of word elements in the annotated corpus template.

[0010] In one embodiment, the annotated corpus template acquisition module includes:

[0011] A tag information adding unit, configured to add tag information to each word element in the training corpus template, wherein the tag information includes noun phrase tag information and non-noun phrase tag information;

[0012] The annotated corpus template acquisition unit is configured to delete non-noun phrase annotation information and linearize the annotation information and the training corpus template to obtain the annotated corpus template, wherein the word elements of the annotated corpus template include noun phrase annotation information.

[0013] In one embodiment, the prediction result sequence acquisition module includes:

[0014] A word embedding unit, configured to obtain a word embedding representation of an input initial word element;

[0015] A prediction unit, configured to fit the word vector representation and predict the fitted word vector representation;

[0016] The prediction result sequence acquisition unit is configured to refit the predicted results to obtain the prediction results in the prediction result sequence, and the language generation model outputs the prediction result sequence composed of multiple prediction results.

[0017] In one embodiment, the prediction result sequence acquisition unit includes:

[0018] The section for obtaining the predicted word elements to be selected is configured to fit the predicted results again to obtain multiple predicted word elements to be selected;

[0019] The prediction result acquisition section is configured to calculate the probability value of each candidate prediction word element, and select the candidate prediction word element whose probability value is greater than a preset threshold as the prediction result.

[0020] In one embodiment, the corpus template generating device further includes:

[0021] A candidate corpus template library acquisition module is configured to acquire a template suffix tree of the corpus to be matched, perform entity extraction on the corpus to be matched, and obtain a candidate corpus template library from the multiple corpus templates;

[0022] The matching module is configured to match each corpus template in the candidate corpus template library according to the template suffix tree to obtain a matching corpus template of the corpus to be matched.

[0023] In one embodiment, the corpus template generating device further includes:

[0024] A dictionary tree acquisition module is configured to construct a dictionary tree according to the suffix of the corpus to be matched;

[0025] The template suffix tree acquisition module is configured to merge the single-node chains in the dictionary tree to obtain the template suffix tree.

[0026] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising one or more processors; a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the corpus template generation method as described above.

[0027] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the corpus template generation method as described above.

[0028] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the corpus template generation method provided in the above various optional embodiments.

[0029] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, which implements the steps in the template generation method described above when executed by a processor.

[0030] In the technical solution provided in the embodiments of the present application, on the one hand, different prediction result sequences are obtained through different initial word elements, so that a large number of corpus templates are obtained according to the combination of different prediction result sequences, thereby improving the richness of the corpus templates; on the other hand, the next prediction result in the prediction result sequence is obtained by taking the output signal of the previous moment in the language generation model (i.e., the previous prediction result in the prediction result sequence) as the input signal at the next moment, thereby increasing the prediction connection between each word element, making the word elements of the generated corpus template closer and more scientific, thereby improving the accuracy of the corpus template.

[0031] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0033] Figure 1 It is a schematic diagram of an implementation environment involved in this application;

[0034] Figure 2 is a flowchart of a method for generating a corpus template shown in an exemplary embodiment of the present application;

[0035] Figure 3 is a flowchart of a method for generating a corpus template shown in another exemplary embodiment of the present application;

[0036] Figure 4 is a schematic diagram of the initial language generation model training principle shown in an exemplary embodiment of the present application;

[0037] Figure 5 is an example diagram of three corpus templates shown in an exemplary embodiment of the present application;

[0038] Figure 6 yes Figure 3 A flowchart of step S310 in the illustrated embodiment in an exemplary embodiment;

[0039] Figure 7 yes Figure 3 The schematic diagram of step S310 in the illustrated embodiment;

[0040] Figure 8 yes Figure 2 A flowchart of step S210 in the illustrated embodiment in an exemplary embodiment;

[0041] Fig. 9 is a flowchart of a method for generating a corpus template shown in another exemplary embodiment of the present application;

[0042] Fig.10 is a flowchart of a method for generating a corpus template shown in another exemplary embodiment of the present application;

[0043] Fig.11 is a flowchart of a method for generating a corpus template shown in another exemplary embodiment of the present application;

[0044] Fig.12 is a schematic diagram of a dictionary tree structure shown in an exemplary embodiment of the present application;

[0045] Fig.13 is a schematic diagram of a template suffix tree structure shown in an exemplary embodiment of the present application;

[0046] Fig.14 is a schematic diagram of the structure of a corpus template generation management interface shown in an exemplary embodiment of the present application;

[0047] Fig.15 is a structural schematic diagram of a corpus template generating device shown in an exemplary embodiment of the present application;

[0048] Fig.16 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0049] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0050] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0051] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0052] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes 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. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.

[0053] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.

[0054] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0055] Machine Learning (ML) is an interdisciplinary field that involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications cover all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.

[0056] In the field of corpus template matching, the short text query is a request statement input by the user in the intelligent assistant, usually containing only one intention expectation of the user. For example: "Play Liu Moumou's Bing Yu"; "Tell me the story of Yu Gong Moving Mountains"; "I want to watch the movie Infernal Affairs", etc.

[0057] The corpus template generation method, device, electronic device, and storage medium proposed in the embodiments of this application involve artificial intelligence technology, machine learning, and corpus template matching and other technologies. These embodiments will be described in detail below.

[0058] First, for the commonly used method of manually writing corpus templates: Manually writing corpus templates is often based on the understanding of the design of skill intentions. The corpus templates obtained by this method have high quality but low richness, and the template coverage is not enough; and corpus template matching is an exact match at the character level, so the situation of having more or fewer characters will lead to matching failures; after designing the intention slots of a skill, the accuracy of manually written corpus templates is generally relatively high, but their diversity is generally not high. Especially for the intention grammars of some broadcast controls, since the query itself is relatively short, manual writing can only focus on common grammars.

[0059] For another method of automatically generating corpus templates based on annotated corpora, although the generation speed of this method is fast, the accuracy is not high. For example, there is an annotated corpus: Play <singer> Liu Moumou's <song> Wang Qing Shui. This annotated corpus can automatically generate a template like "Play [singer]'s [song]", but this is an ideal situation. In reality, due to the uneven quality of the annotated corpora and the presence of some meaningless auxiliary words and modal particles, etc., these will lead to the low quality of the automatically generated corpus templates, with many conflicts, resulting in a significant decrease in the accuracy of the entire template matching system and being inapplicable to the field of language recognition technology with high requirements.

[0060] It can be seen that in the field of corpus template generation technology, how to improve the richness and accuracy of corpus templates and balance the two is a difficult problem. The corpus template generation method disclosed in this application can effectively improve the richness and accuracy of corpus templates.

[0061] First see Figure 1 , Figure 1 1 is a schematic diagram of an implementation environment involved in the present application. The implementation environment includes a terminal 100 and a server 200, and the terminal 100 and the server 200 communicate with each other via a wired or wireless network.

[0062] It should be understood that Figure 1 The number of the terminal devices 100 and the server 200 in the embodiment is only for illustration. Any number of the terminal devices 100 and the server 200 may be provided according to actual needs.

[0063] In some embodiments of the present application, the corpus template generation method can be executed by the server 200, and accordingly, the corpus template generation device is configured in the server 200. The terminal 100 is used to receive the initial word element and send the initial word element to the server 200. The server 200 inputs the initial word element into the language generation model, obtains the prediction result sequence output by the language generation model, and obtains multiple corpus templates according to the prediction result sequence, and then the server 200 also sends the multiple corpus templates to the terminal 100, and the multiple corpus templates can be visually displayed through the display module of the terminal 100.

[0064] Exemplarily, the initial word element is an arbitrary word element, which can be manually set or randomly generated in machine operation, such as a word element automatically generated by a language generation model, and the initial word element marks the beginning of the operation of the language generation model; after receiving the initial word element, the terminal 100 sends the initial word element to the server 200, and the server 200 inputs the initial word element into the language generation model to obtain a prediction result sequence output by the language generation model, wherein the next prediction result in the prediction result sequence is the output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one prediction word element, and then the server 200 selects prediction word elements from each prediction result in the prediction result sequence, and combines the selected prediction word elements according to the order of precedence between the prediction results in the prediction result sequence to obtain multiple corpus templates.

[0065] Among them, the terminal 100 includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, car terminals, etc., such as smart phones, tablets, laptops, computers, and any other electronic devices that can realize image visualization, which are not limited here. The server end 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, wherein multiple servers can form a blockchain, and the server is a node on the blockchain. The server end 200 can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network, content distribution network) and big data and artificial intelligence platforms, which are not limited here.

[0066] Figure 2 FIG. 1 is a flowchart of a method for generating a corpus template according to an exemplary embodiment. Figure 2 As shown, in an exemplary embodiment, the method may include steps S210 to S230, which are described in detail as follows:

[0067] Step S210: inputting the initial word element into the language generation model to obtain a prediction result sequence output by the language generation model.

[0068] In this embodiment, the language generation model is obtained by training the language model with multiple annotated corpus templates. The language model learns the probability that a sentence is a normal expression, which is defined as: for a language sequence w1, w2, w3..., wn, the language model calculates the probability of the sequence, that is, P(w1, w2, w3..., wn). From the perspective of machine learning, the language model is a modeling of the probability distribution of sentences, so as to determine whether a language sequence is a normal sentence, for example, P(i am right)>P(i right am). Traditional machine learning uses N-Gram (N-gram model) technology to calculate this probability value in a statistical way.

[0069] A word element is a token, that is, a sentence is segmented and each word obtained can be called a token. The initial word element can be manually set or randomly generated by machine operation, such as a word element automatically generated by a language generation model. The initial word element marks the beginning of the language generation model.

[0070] In this embodiment, after the initial word element is input into the language generation model, the language generation model will output a prediction result, and the prediction result includes at least one predicted word element. Specifically, the language generation model will predict the next word element of the initial word element, that is, the language generation model will output at least one predicted word element, and each predicted word element corresponds to a probability value representing the possibility of being the next word element of the initial word element. In some cases, in order to improve the accuracy of the output result, the language generation model may not output all the predicted word elements at once as a prediction result in the prediction result sequence, but the predicted word element with a probability greater than a certain prediction threshold among all the predicted word elements output at once is used as a prediction result in the prediction result sequence. Of course, it is also possible to select a suitable predicted word element from all the predicted word elements output at once as a prediction result in the prediction result sequence by beam-search, or to improve the richness of the output, all the predicted word elements output at once are used as a prediction result in the prediction result sequence. No specific restrictions are made here.

[0071] After the language generation model outputs a prediction result according to the input initial word element, the predicted word element in the prediction result is automatically input into the language generation model, and at least one predicted word element is obtained through the language generation model. Similarly, according to the above method, some predicted word elements are selected from the multiple predicted word elements output this time as another prediction result, and then the above steps are repeated, and the predicted word elements in the previous prediction result are respectively used as the input of the next language generation model to obtain the next prediction result. This is repeated, and finally the language generation model will output multiple prediction results until the language generation model automatically gives an end word element, marking the end of the current cycle, and no longer inputs signals to the language generation model; then the multiple prediction results obtained are arranged and combined in the output order to obtain a prediction result sequence.

[0072] Of course, as mentioned above, a prediction result includes at least one predicted word element. When the predicted word element in the prediction result is used as the input signal of the language generation model, it is still performed separately. When a certain predicted word element in the prediction result is used as input, some predicted word elements will be output. When another predicted word element in the prediction result is used as input, other predicted word elements will be output. In this way, all the predicted word elements in the prediction result are used as inputs respectively, corresponding to multiple predicted word elements, and some of these predicted word elements are selected as the next prediction result. It should be noted that for all the predicted word elements of the prediction result, some predicted word elements obtained by using a certain predicted word element as input will form a connection with a certain predicted word element as input, so that the subsequent language generation model can combine multiple related predicted word elements into a complete corpus template when generating grammatical expressions.

[0073] The following example explains this step. For example, an initial word element A is input into a language generation model, and the language generation model outputs multiple predicted word elements B1, B2, B3, B4... Then, some predicted word elements such as B1 and B2 are selected as the first prediction result b according to the probability value of each predicted word element or according to beam-search and other methods as mentioned above, and then the predicted word elements in the prediction result b are used as the input of the language generation model. For example, B1 is used as the input of the language generation model, and the language generation model predicts the next word element of B1 and outputs C11, C12, C13... Similarly, some predicted word elements C11 are selected from C11, C12, C13...; B2 is used as the input of the language generation model. type of input, output C21, C22, C23..., and also select the predicted word element C22 from it; then C11 and C22 are used as the second prediction result c, and links are established between the predicted word elements in the prediction result c and the predicted word elements in the prediction result b. For example, for C22, B2 is obtained as the input of the language generation model, then C22 is linked to B2, and at the same time, C11 is linked to B1; then the predicted word element in the prediction result c is used as the input of the language generation model, and the above operation is performed in the same way to obtain the third prediction result d, and this is repeated until the language generation model automatically ends the word element, and the multiple prediction results output by the language generation model are combined into a prediction result sequence in the output order, such as bcd, etc.

[0074] Step S230: Select predicted word elements from each prediction result in the prediction result sequence respectively, and combine the selected predicted word elements according to the order of the prediction results in the prediction result sequence to obtain a plurality of corpus templates.

[0075] A corpus template is a template that can match all queries that conform to a similar template in a template matching system (such as "I want to watch Infernal Affairs", "I want to watch Journey to the West", etc.). For example, a template like "I want to watch [film]", where "film" represents "entity & slot" (entity & slot: in a task-based dialogue system, it is used to express important information in the user input query; for example, in a query like "Play Bing Yu by Liu XX", the query itself represents the user's intention expectation to listen to a song (music.play), and at the same time, entities such as "[sys.music.singer = Liu XX, sys.music.song = Bing Yu]" are designed to represent the important information in this query. Semantic understanding identifies the structured information of "intention + entity slot", which facilitates subsequent services to respond to the user's query). Any value in the dictionary set or the film entity extracted by the entity model. Using corpus template matching to identify queries in the semantic parsing system is also a very important part. Compared with model parsing, corpus template parsing has the characteristics of relatively accurate recognition and lower recall rate. Corpus templates are a very effective means for solving queries in high-frequency scenarios.

[0076] In this embodiment, select the predicted word elements with links from the predicted results in the obtained predicted result sequence, and form a corpus template according to their order in the predicted result sequence. For example, select the predicted word element B1 in the predicted result b, select the predicted word element C11 that has a link with B1 in the predicted result c, and select the predicted word element D11 that has a link with C11 in the predicted result d... Then combine these predicted word elements with links in order to obtain a corpus template composed of B1C11D11... By selecting different predicted word elements, corpus templates formed by multiple predicted word elements linked to them can be obtained. Thus, multiple corpus templates can be obtained, and these corpus templates can be used to match the user's demand conditions subsequently.

[0077] In this embodiment, for different initial word elements, different predicted result sequences are obtained. According to different predicted result sequences, a large number of corpus templates can be combined to improve the richness of the corpus templates, thereby improving the recall rate of the corpus template matching system and matching more suitable corpus templates for the customer's demand conditions. On the other hand, by using the output of the previous moment in the language generation model as the input of the next moment, the prediction connection between each word element is increased, making the word elements in the generated corpus template more closely and scientifically related, and improving the accuracy of the corpus template.

[0078] Figure 3FIG. 1 is a flow chart of a method for generating a corpus template according to another exemplary embodiment. Figure 3 As shown, in an exemplary embodiment, the method can be implemented in Figure 2 Before step S210, the method may include steps S310 to S330, which are described in detail as follows:

[0079] Step S310: Obtain a tagged corpus template consisting of word elements carrying tag information.

[0080] In this embodiment, the annotated corpus template is a corpus obtained by adding annotation information to a corpus template and linearizing it. For example, for an existing corpus template XYZ, after adding annotation information to XYZ and linearizing it, a annotated corpus template mXnYjZ is obtained, wherein m, n, and j are annotation information. The annotation information can be added for each word element in the corpus template according to its property. For example, if X is a name, name annotation information m is added to it.

[0081] Step S330: Input the training word elements into the initial language generation model, and adjust the model parameters of the initial language generation model according to the prediction result sequence output by the initial language generation model, until the prediction result sequence output by the adjusted language generation model for the training word elements and the sequence of word elements in the annotated corpus template are within the prediction error range.

[0082] In this embodiment, the specific training process can be referred to Figure 4 , the initial language generation model can be a language model, such as Figure 4 The model consists of an Embedding (word vector layer), a Dropout layer (to enhance the generalization effect of the model itself), an LSTM (long short-term memory artificial neural network), a Dropout layer, and a linear+softmax (linear+activation function) layer. First, the training word elements are output to the initial language generation model, which is reflected in Figure 4 The [BOS] pointed to by Sentence (judgment) is a training word element similar to the initial word element. It can be manually set or automatically and randomly generated by the initial language generation model in training.

[0083] The training word elements enter the initial language generation model to obtain a prediction result sequence, and the model parameters of the initial language generation model are adjusted according to the probability of the word prediction elements in the prediction result sequence until the prediction result sequence and the sequence of word elements in the annotated corpus template are within the prediction error range.

[0084] In this embodiment, the prediction result sequence obtained based on the training word element also includes multiple prediction results, but each prediction result only contains one predicted word element, which is the one with the largest probability value among the multiple predicted word elements obtained by the initial language generation model. Specifically, the initial language generation model is used to predict the next word element for the training word element, and the next word element is converted into a word vector (token) by embedding. Embedding), and then output multiple predicted words and the corresponding probabilities of multiple predicted word elements through the Dropout layer, LSTM, Dropout layer, linear+softmax layer, adjust the initial language generation model, so that the predicted word element with the largest probability value among the predicted word elements obtained by taking the training word elements as input is the same as the first word element in the annotated corpus template; then input the predicted word element with the largest probability (i.e. the first word element in the annotated corpus template) into the adjusted initial language generation model, and also obtain multiple predicted word elements, and adjust the parameters of the initial language generation model here, so that the predicted word element with the largest probability value among the predicted word elements output this time is the same as the second word element in the annotated corpus template, and then input the predicted word element with the largest probability into the adjusted initial language generation model again, repeat the above steps, adjust the initial language generation model multiple times, so that the predicted word elements in the prediction result sequence outputted in the adjusted language generation model are the same as the sequence of predicted word elements in the annotated corpus template within the error allowable range, that is, the model converges at this moment and can be used for subsequent corpus template generation.

[0085] As reference Figure 4 In the embodiment, the initial language generation model is trained according to a labeled corpus template "B-PER Jose E-PER valetin...", after the training word element [BOS] enters the initial language prediction model, multiple predicted word elements are output, and the first word element of the labeled corpus template is B-PER, then the parameters of the initial language generation model are modulated so that the probability of the predicted word element (Predictions) "B-PER" output by the adjusted initial language generation model is maximized, and then "B-PER" is input into the adjusted initial language generation model, and the parameters of the initial language generation model are modulated again so that the probability of its output "Jose" is maximized, and then "Jose" is input into the adjusted initial language generation model... The parameters of the initial language generation model are repeatedly adjusted until the model generates receiving word elements, and then the adjusted initial language generation model is trained again according to the next labeled corpus template until the model converges.

[0086] Furthermore, the word vector representation of word elements can be performed through AIlab (open source Chinese word vector), or through common Word2vec, glove, etc. (all open source word vector tools), without specific restrictions here. In addition, in the LSTM layer, since the model is mainly used for prediction of word elements, the hidden state (hidden state) output of each LSTM Cell can be used here. It should be noted that the language generation model in this embodiment is obtained by training the language model with multiple annotated corpus templates, so a large number of corpus templates obtained by the language generation model also have annotation information.

[0087] Of course, in order to increase the types of corpus templates, unlabeled corpus templates and knowledge base annotations can also be introduced. Figure 5 This is an example of three types of corpus templates, which can be used for the initial training of the language generation model. In the figure, the first one is the labeled corpus template [labeled], the second one is the unlabeled corpus template [unlabeled], and the third one is the knowledge base labeled corpus template [KB]. [EOS] is the end word element.

[0088] In this embodiment, the initial language generation model is trained with the annotated corpus templates and the parameters of the initial language generation model are adjusted to obtain a language generation model that can be used to generate a large number of corpus templates, so that as long as the initial word elements are input into the language generation model, a large number of corpus templates with annotated information can be generated, thereby improving the richness of the corpus templates. On the other hand, the use of LSTM and the use of dropout before and after in this embodiment can effectively enhance the generalization effect of the model itself, improve the learning ability of the model, and generate richer predicted word elements.

[0089] Figure 6 yes Figure 3 The flowchart of step S310 in the embodiment shown is in an exemplary embodiment. Figure 6 As shown, in an exemplary embodiment, the process of obtaining a marked corpus template composed of word elements carrying markup information in step S310 may include steps S610 to S630, which are described in detail as follows:

[0090] Step S610: adding annotation information to each word element in the training corpus template.

[0091] The principle diagram of obtaining the annotated corpus template in this embodiment can be referred to Figure 7Specifically, first obtain a large number of existing corpus templates, and then add annotation information to each word element of the corpus template. Raw labeling or joint segmentation and labeling can be used to add annotation information to the word elements. Figure 7 In the corpus template, annotation information is added by using the BIO annotation method in the original annotation. The annotation information includes noun phrase annotation information and non-noun phrase annotation information. The non-noun phrase annotation information is marked as "O". Figure 7 The corpus template in is "Jose Valentine has...in London". The annotation information added to it is that "Jose" is the beginning of the name phrase and is a person's name, so its annotation information is B-PER, which means the beginning of the person's name noun phrase. "Valentine" is the end of the person's name noun phrase, and its annotation information is E-PER. All the word elements in "has a...in" are non-noun phrases, so they are all marked as O. "London" is a single address noun phrase, so it is marked as S-LOC. At this point, annotation information has been added to each word element in the corpus template.

[0092] Step S630: Delete the non-noun phrase annotation information, and linearize the annotation information and the training corpus template to obtain the annotated corpus template.

[0093] In this embodiment, since non-noun phrases are usually not important information in the corpus, the non-noun phrase annotation information is deleted here, the noun phrase annotation information is retained, and then the noun phrase annotation information and the corpus template are linearized, so as to obtain the following: Figure 7 The labeled corpus template shown in “B-PER Jose E-PER Valentine has…in S-LOCLondon” can be used to train the initial language generation model by adding corpus information to a large number of corpus templates.

[0094] In this embodiment, annotated corpus templates are obtained by adding annotation information to existing corpus templates, and the initial language generation model is trained through these annotated corpus templates. The annotation information is also included during the training, so that the trained language generation model can generate corpus templates with annotation information during prediction, which is convenient for subsequent matching of corpus templates according to query conditions, and can more quickly understand the semantics of the corpus templates.

[0095] Figure 8 yes Figure 2 The flowchart of step S210 in the embodiment shown is in an exemplary embodiment. Figure 8As shown, in an exemplary embodiment, step S210 inputs the initial word element into the language generation model, and the process of obtaining the prediction result sequence output by the language generation model may include steps S810 to S850, which are described in detail as follows:

[0096] Step S810: Obtain the word vector representation of the input initial word element.

[0097] In this embodiment, reference Figure 4 After obtaining the initial word element, the language generation model obtains the vector representation of the initial word element through tools such as AIlab, Word2vec or glove.

[0098] Step S830: Fit the word vector representation and predict the fitted word vector representation.

[0099] In this embodiment, the word vector representation is fitted through the Dropout layer, and then the fitted word vector representation is input into the LSTM, and prediction is performed through the hidden state of each LSTM Cell.

[0100] Step S850: the predicted results are fitted again to obtain the predicted results in the prediction result sequence, and the language generation model outputs the prediction result sequence composed of multiple prediction results.

[0101] In this embodiment, the predicted result is fitted again through the Dropout layer, and the fitted result enters the linear+softmax layer for linearization and other processing, and outputs multiple predicted word elements and the probability value corresponding to each predicted word element. Figure 2 The method in the embodiment selects appropriate predicted word elements from the output multiple predicted word elements to form a prediction result, such as setting the output multiple predicted word elements as candidate predicted word elements, and then comparing the probability values ​​of the candidate predicted word elements, and selecting the candidate predicted word elements whose probability values ​​are greater than a preset threshold as the prediction result; and then using the prediction result as the input of the speech generation model to obtain a prediction result sequence in a cycle.

[0102] In this embodiment, by fitting the word elements multiple times, the randomness in the generated corpus template is increased, the final generalization effect is increased, and more predicted word elements can be achieved to achieve the effect of obtaining a richer corpus template.

[0103] Fig. 9 FIG. 1 is a flow chart of a method for generating a corpus template according to another exemplary embodiment. Fig. 9 As shown, in an exemplary embodiment, the method may include steps S910 to S930, which are described in detail as follows:

[0104] Step S910: Obtain the template suffix tree of the corpus to be matched, perform entity extraction on the corpus to be matched, and obtain a candidate corpus template library from multiple corpus templates.

[0105] In this embodiment, after obtaining a large number of corpus templates, these corpus templates can be used for matching the query condition (the corpus to be matched). For example, when obtaining a corpus to be matched, a template suffix tree can be created according to the corpus to be matched; as shown in Fig.10 the corpus template matching process diagram in, if the corpus to be matched is "play a movie", then construct the suffix tree shown on the right in Fig.10 according to "play a movie", and then perform entity extraction on the corpus to be matched, that is, match the word elements in the corpus to be matched with corpus templates with similar features in a large number of corpus templates. After entity extraction, obtain Fig.10 the candidate corpus template library composed of multiple corpus templates shown on the left in

[0106] In the matching of common query conditions, the data of corpus templates is huge. Especially when using the corpus template generation method proposed in this embodiment, a huge amount of corpus templates will be obtained. If the query condition is matched in a large number of corpus templates one by one, it will take a long time and the running cost is also high. In this embodiment, the template suffix tree is used. It is considered that if the query condition can be matched, the corpus template must be the prefix of a certain suffix of the query condition. Therefore, it can greatly reduce the matching time of the query condition in the corpus matching system and improve the matching efficiency.

[0107] Step S930: Match each corpus template in the candidate corpus template library according to the template suffix tree to obtain the matching corpus template of the corpus to be matched.

[0108] In this embodiment, when matching the candidate corpus template library in the suffix tree, the specific process is to parse each word in the template suffix tree. For example, when matching "play" in the candidate corpus template library, the corpus template "play [singer]'s song" is obtained. When matching "movie" in the candidate corpus template library, the corpus template "movie [movie]" is matched. When matching "put" in the candidate corpus template library, the two corpus templates "play [actor]'s [movie]" and "play [singer]'s [song]" are obtained, and then the hit corpus template results are returned.

[0109] In this embodiment, the target corpus template can be quickly matched from a large number of corpus templates through the template suffix tree.

[0110] Fig.11 is a flowchart of a corpus template generation method shown according to another exemplary embodiment. As shown in Fig.11As shown, in an exemplary embodiment, the method may include steps S1110 to S1130, which are described in detail as follows:

[0111] Step S1110: construct a dictionary tree according to the suffix of the corpus to be matched.

[0112] In this embodiment, all suffixes of the to-be-matched corpus are obtained. For example, for a to-be-matched corpus "song", its suffixes are: song, ong, ng, g, and then a dictionary tree is constructed according to these suffixes.

[0113] Specifically, the starting node is divided into 4 single chains, and each single chain has a node at the end. Each chain corresponds to the first word of a suffix. If there is only one word, the branch is completed, and then chains are divided from other nodes to correspond to the next word of the suffix. This is constructed until each branch in the dictionary tree is connected to correspond to a suffix, and the result is as follows: Fig.12 The dictionary tree shown.

[0114] Step S1130: Merge the single-node chains in the dictionary tree to obtain a template suffix tree.

[0115] In this embodiment, after obtaining the dictionary tree, there may be a single-node branch, that is, there is no fork on this branch, such as Fig.12 The song suffix branch of the template suffix tree in , that is, the chain composed of multiple single chains does not have a fork, then such single-node chains can be merged into one chain, and finally the following is obtained Fig.13 The template suffix tree shown.

[0116] In this embodiment, the template suffix tree is constructed in the above manner to improve the speed of subsequent query condition matching.

[0117] In this embodiment, the effect of the above-mentioned corpus template generation method is verified. The manually written corpus template and the corpus template obtained by this method are matched respectively by query conditions in three fields: smart TV control, music, and broadcasting, and the matching results shown in Table 1 are obtained, where P is the precision rate and R is the recall rate:

[0118]

[0119] Table 1

[0120] According to Table 1, the precision rate of matching through these two corpus templates is high, and the recall rate is relatively low. The precision rate of the corpus template generated by this method is lower than that of the manually written template, but the recall rate is greatly improved, so that the final F1 effect will bring nearly 10 points of improvement. It can be seen that the corpus template generation method proposed in this method can obtain rich and accurate corpus templates, which can overcome the shortcomings of the traditional manually written corpus template grammar that is not rich enough. The obtained corpus template can bring rich corpus templates. The obtained corpus template is also used in the corpus template matching system. On the basis of ensuring the accuracy, a more complete matching result is obtained, which can improve the overall performance and use effect of the corpus template matching system.

[0121] Figure 2 The corpus template generation method proposed in -13 can be used in the field of artificial intelligence language recognition technology, such as in-vehicle language recognition equipment, household intelligent robots and other devices. A large number of corpus templates are generated by using the corpus template generation method on these devices. When receiving the user's voice query, the target corpus template is matched in the corpus template according to the voice query to parse the user's language query; it can also be used in the search engine. A large number of corpus templates are generated by using the corpus template generation method on the back end of the search engine. When receiving the user's text query conditions, they are matched in a large number of corpus templates to obtain the intention of the user's query conditions.

[0122] Fig.14 This is an exemplary corpus template generation management interface. In this embodiment, the initial language generation model can be trained through annotated corpus templates in different fields to obtain a trained language generation model. Finally, a large number of corpus templates in related fields are obtained through the trained language generation model, that is, the corpus template of the skill is obtained according to the skill intent and the demand definition; Fig.14 In the process, if it is necessary to obtain music-related corpus templates, the initial language generation model can be trained with the existing music-related annotated corpus templates with annotation information added, and then a large number of music-related corpus templates can be generated through the trained language generation model. Subsequently, these corpus templates can be used in the template matching system to parse the music-related query conditions proposed by the user through the template matching system.

[0123] Fig.15 FIG. 1 is a schematic diagram showing a structure of a corpus template generating device according to an exemplary embodiment. Fig.15 As shown, in an exemplary embodiment, the corpus template generating device includes:

[0124] The prediction result sequence acquisition module 1510 is configured to input the initial word element into the language generation model to obtain the prediction result sequence output by the language generation model; wherein the next prediction result in the prediction result sequence is the output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one predicted word element;

[0125] The corpus template acquisition module 1530 is configured to select prediction word elements from each prediction result in the prediction result sequence, and combine the selected prediction word elements according to the order between the prediction results in the prediction result sequence to obtain multiple corpus templates.

[0126] In this embodiment, a large number of corpus templates can be obtained through the above-mentioned corpus template generation device, thereby improving the richness of the corpus templates.

[0127] In one embodiment, the corpus template generating device further includes:

[0128] A marked corpus template acquisition module is configured to acquire a marked corpus template composed of word elements carrying annotation information;

[0129] The language generation model acquisition module is configured to input the training word elements into the initial language generation model, and adjust the model parameters of the initial language generation model according to the prediction result sequence output by the initial language generation model, until the prediction result sequence output by the adjusted language generation model for the training word elements and the sequence of word elements in the annotated corpus template are within the prediction error range.

[0130] In one embodiment, the annotated corpus template acquisition module includes:

[0131] A tag information adding unit, configured to add tag information to each word element in the training corpus template, the tag information including noun phrase tag information and non-noun phrase tag information;

[0132] The annotated corpus template acquisition unit is configured to delete non-noun phrase annotations and linearize the annotation information and the training corpus template to obtain the annotated corpus template, and the word elements of the annotated corpus template include noun phrase annotation information.

[0133] In one embodiment, the prediction result sequence acquisition module 1510 includes:

[0134] A word embedding unit, configured to obtain a word embedding representation of an input initial word element;

[0135] A prediction unit, configured to fit the word vector representation and predict the fitted word vector representation;

[0136] The prediction result sequence acquisition unit is configured to fit the predicted results again to obtain the prediction results in the prediction result sequence, and the language generation model outputs the prediction result sequence composed of multiple prediction results.

[0137] In one embodiment, the prediction result sequence acquisition unit includes:

[0138] The section for obtaining the predicted word elements to be selected is configured to fit the predicted results again to obtain multiple predicted word elements to be selected;

[0139] The prediction result acquisition section is configured to calculate the probability value of each candidate prediction word element, and select the candidate prediction word element whose probability value is greater than a preset threshold as the prediction result.

[0140] In one embodiment, the corpus template generating device further includes:

[0141] A candidate corpus template library acquisition module is configured to acquire a template suffix tree of a to-be-matched corpus, perform entity extraction on the to-be-matched corpus, and obtain a candidate corpus template library from multiple corpus templates;

[0142] The matching module is configured to match each corpus template in the candidate corpus template library according to the template suffix tree to obtain a matching corpus template of the corpus to be matched.

[0143] In one embodiment, the corpus template generating device further includes:

[0144] A dictionary tree acquisition module is configured to construct a dictionary tree according to the suffix of the corpus to be matched;

[0145] The template suffix tree acquisition module is configured to merge the single node chains in the dictionary tree to obtain the template suffix tree.

[0146] It should be noted that the corpus template generation device provided in the above embodiment and the corpus template generation method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.

[0147] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by one or more processors, the electronic device implements the corpus template generation method provided in the above-mentioned embodiments.

[0148] Fig.16 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.

[0149] It should be noted that Fig.16 The computer system 1600 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0150] like Fig.16 As shown, the computer system 1600 includes a central processing unit (CPU) 1601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1602 or the program loaded from the storage part 1608 to the random access memory (RAM) 1603, such as executing the method in the above embodiment. In RAM 1603, various programs and data required for system operation are also stored. CPU 1601, ROM 1602 and RAM 1603 are connected to each other through bus 1604. Input / output (I / O) interface 1605 is also connected to bus 1604.

[0151] The following components are connected to the I / O interface 1605: an input section 1606 including a keyboard, a mouse, etc.; an output section 1607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1608 including a hard disk, etc.; and a communication section 1609 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1609 performs communication processing via a network such as the Internet. A drive 1610 is also connected to the I / O interface 1605 as needed. A removable medium 1611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1610 as needed so that a computer program read therefrom is installed into the storage section 1608 as needed.

[0152] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1609, and / or installed from a removable medium 1611. When the computer program is executed by a central processing unit (CPU) 1601, various functions defined in the system of the present application are executed.

[0153] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0154] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0155] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0156] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the corpus template generation method as described above is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0157] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the corpus template generation method provided in each of the above embodiments.

[0158] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

Claims

1. A method for generating a corpus template, characterized in that: include: Inputting the initial word element into the language generation model to obtain a prediction result sequence output by the language generation model; wherein the next prediction result in the prediction result sequence is the output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one predicted word element; Prediction word elements are selected from each prediction result in the prediction result sequence, and the selected prediction word elements are combined according to the order between the prediction results in the prediction result sequence to obtain multiple corpus templates.

2. The method according to claim 1, characterized in that Before inputting the initial word element into the language generation model to obtain the prediction result sequence output by the language generation model, the method further includes: Obtaining a labeled corpus template consisting of word elements carrying labeling information; The training word elements are input into an initial language generation model, and the model parameters of the initial language generation model are adjusted according to the prediction result sequence output by the initial language generation model, until the prediction result sequence output by the adjusted language generation model for the training word elements and the sequence of word elements in the annotated corpus template are within a prediction error range.

3. The method according to claim 2, characterized in that The step of obtaining a labeled corpus template composed of word elements carrying labeling information includes: Adding annotation information to each word element in the training corpus template, wherein the annotation information includes noun phrase annotation information and non-noun phrase annotation information; The non-noun phrase annotation information is deleted, and the annotation information and the training corpus template are linearized to obtain the annotated corpus template, wherein the word elements of the annotated corpus template include the noun phrase annotation information.

4. The method according to claim 1, characterized in that: The step of inputting the initial word element into the language generation model to obtain a prediction result sequence output by the language generation model comprises: Get the word vector representation of the input initial word element; Fitting the word vector representation, and predicting the fitted word vector representation; The predicted results are fitted again to obtain the predicted results in the predicted result sequence, and the language generation model outputs the predicted result sequence formed by combining multiple predicted results.

5. The method according to claim 4, characterized in that The predicted results are fitted again to obtain the predicted results in the predicted result sequence, including: The predicted results are fitted again to obtain multiple candidate predicted word elements; The probability value of each candidate prediction word element is calculated, and the candidate prediction word element whose probability value is greater than a preset threshold is selected as the prediction result.

6. The method according to any one of claims 1 to 5, characterized in that: After respectively selecting predicted word elements from each prediction result in the prediction result sequence, and combining the selected predicted word elements according to the order between the prediction results in the prediction result sequence to obtain a plurality of corpus templates, the method further includes: Acquire a template suffix tree of the to-be-matched corpus, perform entity extraction on the to-be-matched corpus, and obtain a candidate corpus template library from the multiple corpus templates; Each corpus template in the candidate corpus template library is matched according to the template suffix tree to obtain a matching corpus template of the corpus to be matched.

7. The method according to claim 6, characterized in that Before obtaining the template suffix tree of the to-be-matched corpus, performing entity extraction on the to-be-matched corpus, and obtaining a candidate corpus template library from the multiple corpus templates, the method further includes: Construct a dictionary tree according to the suffix of the corpus to be matched; The single-node chains in the dictionary tree are merged to obtain the template suffix tree.

8. A corpus template generating device, characterized in that: include: A prediction result sequence acquisition module is configured to input an initial word element into a language generation model to obtain a prediction result sequence output by the language generation model; wherein the next prediction result in the prediction result sequence is an output result obtained by the language generation model using the previous prediction result in the prediction result sequence as an input signal, and each prediction result in the prediction result sequence includes at least one predicted word element; The corpus template acquisition module is configured to select predicted word elements from each prediction result in the prediction result sequence, and combine the selected predicted word elements according to the order between the prediction results in the prediction result sequence to obtain multiple corpus templates.

9. An electronic device, characterized in that: include: one or more processors; A storage device, used for storing one or more computer programs, when the one or more computer programs are executed by the one or more processors, enables the electronic device to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.