Text splicing method, device, computer equipment and storage medium

Through the text splicing method and the trained text splicing model, the problem of poor reusability of traditional templates in different scenarios is solved, the efficient reuse and smooth generation of templates are achieved, and the cost of template management is reduced.

CN112232052BInactive Publication Date: 2024-10-18CHINA PING AN LIFE INSURANCE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202011148693.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-23
Publication Date
2024-10-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional text generation templates have poor reusability in different scenarios, resulting in high complexity and cost of template management. Frequent adaptation processing is required, such as adding or deleting pronouns, particles, prepositions, etc., which reduces the number of reuses of template components.

Method used

Using the text splicing method, by obtaining the preset template components, receiving user input, completing the setting of the template, and inputting it into the trained text splicing model for splicing, the neural network model is used to calculate the number of words and the probability of inserting words, and generate Smooth text.

Benefits of technology

It reduces the difficulty of template writing, ensures the smoothness and interventionability of generated results, and reduces the complexity and cost of template management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112232052B_ABST
    Figure CN112232052B_ABST
Patent Text Reader

Abstract

The embodiment of the present application belongs to the field of artificial intelligence and can be applied to the field of medical technology. It relates to a text splicing method, including: obtaining a preset template, the template includes multiple template components; receiving user input through multiple template components to obtain a set template component; inputting the set template component into a trained text splicing model for text splicing; and using the output of the trained text splicing model as the splicing result. In addition, the present application also relates to blockchain technology, and business data is stored in the blockchain. The present application also provides a text splicing device, a computer device, and a storage medium. To reduce the complexity and cost of template management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to a text splicing method, apparatus, computer equipment and storage medium. Background Art

[0002] Traditional text generation templates are often one-time, and templates used in one scenario are often difficult to reuse in other scenarios. In order to improve the reusability of templates and reduce management costs, template-based text generation systems often break down a large template into several template components. Here, a template component can represent a certain semantics, but it can be expressed in many different ways. However, due to the complexity of natural language expression, when writing a template component for a certain scenario and using it in a new scenario, it is often necessary to do some additional adaptation processing, such as adding / deleting pronouns, auxiliary words, prepositions, punctuation, etc. This situation is particularly obvious when the template component contains multiple expressions. Although these adaptations are not difficult, due to the frequent adaptation requirements, the reuse of the disassembled template components is reduced, which greatly increases the complexity and cost of template management. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a text splicing method, device, computer equipment and storage medium to reduce the complexity and cost of template management. In order to solve the above technical problems, the embodiments of the present application provide a text splicing method, which adopts the following technical solution:

[0004] Obtain a preset template, wherein the template includes multiple template components;

[0005] Receive user input through the multiple template components to obtain a template that has completed settings;

[0006] Inputting the set template into the trained text splicing model for text splicing;

[0007] The output of the trained text splicing model is used as the splicing result.

[0008] Furthermore, the template component includes at least one of text, slot and sub-template component, and the step of receiving user input through the multiple template components to obtain a set template specifically includes:

[0009] Acquire multiple preset template components with slots from the preset template;

[0010] The multiple preset template components are output to the user through a display device, and the user's input is received through the multiple preset template components, and the slots in the multiple preset template components are set to corresponding values ​​to obtain a template that has been completed.

[0011] Furthermore, the step of inputting the set template into the trained text splicing model specifically includes:

[0012] Obtain multiple instantiated template components in the set-completed template;

[0013] Connect the multiple instantiated template components through separators to obtain an input template;

[0014] The input template is input into the trained text concatenation model.

[0015] Furthermore, the step of using the output of the trained text splicing model as the splicing result specifically includes:

[0016] Through π plh =softmax(W plh [h′ i ; h′ i+1 ]) Calculate the probability of the number of output words of the last layer of the neural network in the trained text concatenation model, where W plh is the weight of the neuron for calculating the number of words in the trained text concatenation model, π plh To predict h i ' and h i+1 'There is a probability of the number of words between them, the h i ' is the i-th component of the neural network output;

[0017] Through π tok =softmax(W tok h′ i ) predicts the probability of each inserted word, where h′ i is the decoding of the i-th character by the encoder, W tok Calculate the weight of each inserted word probability neuron in the trained text concatenation model, π tok To predict h i ' and h i+1 'There is a probability that each word should exist;

[0018] The probability corresponding to the highest number of words and the corresponding highest probability combination of each word are selected to generate text.

[0019] Furthermore, before the step of inputting the set template component into the trained text splicing model, the step further includes:

[0020] Get multiple training data and corresponding training labels;

[0021] Inputting the plurality of training data and the corresponding training labels into an initial text concatenation model;

[0022] The initial text splicing model is trained through a loss function to obtain a trained text splicing model.

[0023] Furthermore, after the step of training the initial text splicing model through the loss function to obtain the trained text splicing model, the step further includes:

[0024] Get multiple test data and corresponding test labels;

[0025] Inputting the plurality of training data into the trained text concatenation model;

[0026] Obtaining multiple output results corresponding to the multiple training data under the trained text concatenation model;

[0027] Calculate the accuracy rate through the corresponding multiple output results and the corresponding test labels;

[0028] If the accuracy rate is lower than a threshold, the learning rate of the initial text splicing model is adjusted, and the initial text splicing model is retrained.

[0029] Furthermore, after the step of obtaining the preset template, the following steps are further included:

[0030] The preset template is stored in the blockchain.

[0031] In order to solve the above technical problems, the embodiment of the present application further provides a text splicing device, which adopts the following technical solution:

[0032] The acquisition module is used to acquire a preset template, wherein the template includes multiple template components;

[0033] The receiving module is used to receive user input through the multiple template components to obtain a template component that has completed settings;

[0034] The input module is used to input the set template component into the trained text splicing model;

[0035] The splicing module is used to use the output of the trained text splicing model as the splicing result.

[0036] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0037] A computer device comprises at least one connected processor, memory, and input-output unit, wherein the memory is used to store computer-readable instructions, and the processor is used to call the computer-readable instructions in the memory to execute the steps of the above-mentioned text splicing method.

[0038] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0039] A computer-readable storage medium stores computer-readable instructions, which implement the steps of the above-mentioned text splicing method when executed by a processor.

[0040] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0041] This application uses template components and text splicing models, so that template compilers do not need to pay attention to the grammatical details to ensure the fluency of sentences, but only need to pay attention to the grammar of the core components (template components), which reduces the difficulty of template writing. Since the input of the result generated by the template splicing method is the template, the model ensures the fluency of the generated result, making the text generation result highly intervened, and the generated result can be easily intervened by adjusting the input template. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0043] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0044] Figure 2-1 A flowchart of an embodiment of a text splicing method according to the present application;

[0045] Figure 2-2 A schematic diagram of template splicing according to the text splicing method of the present application;

[0046] Figure 2-3 A schematic diagram of a text splicing model according to the text splicing method of the present application;

[0047] Figure 3 is a structural schematic diagram of an embodiment of a text splicing device according to the present application;

[0048] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0050] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in 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 may be combined with other embodiments.

[0051] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0052] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0053] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0054] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0055] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0056] It should be noted that the text splicing method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the text splicing device is generally arranged in the server / terminal device.

[0057] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0058] Continue to refer Figure 2-1 , shows a flow chart of an embodiment of a text splicing method according to the present application. The text splicing method comprises the following steps:

[0059] Step 201, obtaining a preset template, wherein the template includes multiple template components.

[0060] In this embodiment, the text splicing method is executed on the electronic device (eg Figure 1 The server / terminal device shown in the figure can receive the user request for calibration through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0061] In this embodiment, a text generation template T is composed of several template components TU, that is, T = [TU_1][TU_2]…[TU_k]. A template component TU contains several expressions E with the same semantics. A expression E can contain a paragraph of text, a single slot s, and at least one item in a single sub-template component stu. That is, a template component is composed of several expressions E, and the simplest expression E is composed of only one template component. This template component can be a paragraph of text|a slot, where slot s corresponds to the input variable of text generation and needs to be replaced with the value of the corresponding variable when generating text; the content type of the sub-template component stu is the same as the above-mentioned text template component TU. For example, the template: "[SLOT:Insured]|[TEMP:GetDisease]|, obtain [SLOT:Claim_Insurance Liability][SLOT:Claim_Payment Amount]" is composed of 3 template components, and each template component is separated by |. Among them, [TEMP:GetDisease] is a template component. The [TEMP:GetDisease] template component contains two expressions E1 and E2, where E1 is "diagnosed as | [SLOT: claim_disease]", and E2 is "unfortunately diagnosed as | [SLOT: claim_disease]". When instantiated, [TEMP:GetDisease] is instantiated as E1 or E2, specifically indicating that each unit separated by a vertical line | is a statement E. In [SLOT: insured], slot is slot s, "insured" is the input variable for the corresponding text generation, and "obtained" is text.

[0062] Step 202: receiving user input through the multiple template components to obtain a template that has completed settings.

[0063] In this embodiment, a feasible expression E is randomly selected for each template component TU in the template, and the feasible expression means that the slot contained therein can be instantiated by the value of the input variable. For example, the slot SLOT can take the value "insured person" or "claim_disease".

[0064] Step 203: input the set template into the trained text splicing model to perform text splicing.

[0065] In this embodiment, the input of the text splicing model is two or more template components to be spliced, and the text splicing model obtains the final smooth text by adding characters outside the template components. That is, the order of the template components to be spliced ​​before and after the input of the text splicing model remains unchanged, and after passing through the text splicing model, connecting characters are added to obtain a smooth text.

[0066] Step 204: Using the output of the trained text splicing model as the splicing result.

[0067] In this embodiment, the present application uses template components and text splicing models so that template editors do not need to pay attention to the grammatical details to ensure the fluency of sentences, but only need to pay attention to the grammar of the core components (template components), thereby reducing the difficulty of template writing. Since the input of the result generated by the template splicing method is the template, the model ensures the fluency of the generated result, making the text generation result highly intervened, and the generated result can be easily intervened by adjusting the input template.

[0068] In some optional implementations, the template component includes at least one of text, slot, and sub-template components, and the step of receiving user input through the multiple template components to obtain a set template specifically includes:

[0069] Acquire multiple preset template components with slots from the preset template;

[0070] The multiple preset template components are output to the user through a display device, and the user's input is received through the multiple preset template components, and the slots in the multiple preset template components are set to corresponding values ​​to obtain a template that has been completed.

[0071] In the above implementation mode, if Figure 2-2 As shown, first, through the splicing of slots and texts, they are merged into two template components "[SLOT: Policyholder] is [SLOT: Insured] | [STU: Insured Product]". Through instantiation, the above template becomes "Mr. Li is his son | [STU: Insured Product]", where the second template component [STU: Insured Product] is a sub-template component, which becomes "Insured Children's Ping An Fu" after text merging and instantiation. After the sub-template is expanded, the template component consists of two new instantiated template components: "Mr. Li is his son | Insured Children's Ping An Fu". The automatic splicing of templates is completed in the above way.

[0072] In some optional implementations, the step of inputting the set template into the trained text splicing model specifically includes:

[0073] Obtain multiple instantiated template components in the set-completed template;

[0074] Connect the multiple instantiated template components through separators to obtain an input template;

[0075] The input template is input into the trained text concatenation model.

[0076] In the above implementation, the template that completes the setting consists of multiple instantiated template components, such as Figure 2-3As shown in the figure, for the form of multi-template component splicing, the input data format is ([x1][SEP][x2][SEP]…[SEP][xn],[x1][c12][x2][c23]…[c(n-1)(n)][xn]). [x1][SEP][x2][SEP]…[SEP][xn] is the model input, and [x1][c12][x2][c23]…[c(n-1)(n)][xn] is the model output. Among them, [xi] is a text segment, that is, an instantiated component, [SEP] is a special separator between text segments, used to separate components, and [cij] is the connecting phrase between text segments [xi] and [xj]. For example, the two instantiated template components "Mr. Li" and "heart bypass surgery" are input into the text splicing model. The text splicing model distinguishes them by the [SEP] separator. [x_1] is "Mr. Li" and [x_2] is "heart bypass surgery". The input data is "Mr. Li" [SEP] "heart bypass surgery". The text splicing model outputs a reasonable [c12] which can be "done". The output text is "Mr. Li" "done" "heart bypass surgery". At this time, [x_1] is "Mr. Li", [c12] is "done", and [x_2] is "heart bypass surgery". The accuracy of text splicing is improved.

[0077] The text concatenation model can use any sequence neural network model, or a text editing model based on operations such as addition, deletion, and modification. Figure 2-3 As shown, when training the model, the same training strategy as the text editing-based model can be adopted.

[0078] In some optional implementations, the step of using the output of the trained text splicing model as the splicing result specifically includes:

[0079] Through π plh =softmax(W plh [h′ i ; h′ i+1 ]) Calculate the probability of the number of output words of the last layer of the neural network in the trained text concatenation model, where W plh is the weight of the neuron for calculating the number of words in the trained text concatenation model, π plh To predict h i ' and h i+1 'There is a probability of the number of words between them, the h i ' is the i-th component of the neural network output;

[0080] Through π tok =softmax(W tok h′ i)Predict the probability of each inserted word, where h′ i is the decoding of the i-th character at the encoding end, and W tok is the weight of the neuron that calculates the probability of each inserted word in the trained text splicing model, and π tok is the probability that there should be each word predicted between h i ' and h i+1 ';

[0081] Select the probability corresponding to the highest number of said words and the corresponding combination of the highest probability of each said word to generate text.

[0082] In the above embodiments, the model is not limited. The text splicing model is as Figure 2-3 shown. The input data and the training data are in the same format. Where h′ i corresponds to hi in the accompanying drawings. Assume that k characters need to be inserted between the i-th and the i + 1-th characters predicted in this step. Then insert k [PLH] special symbols in the encoded text part. Then assume that the i-th [PLH] is predicted to be replaced by the word "will". Then replace the i-th [PLH] with "will", and continue to repeat the loop of placeholder prediction and character prediction. Finally, combine to generate text. Through the above method, the number of words and words between text splicing can be accurately obtained, and the text can be accurately spliced continuously.

[0083] In some alternative implementation manners, before the step of inputting the completed template component into the trained text splicing model, it further includes:

[0084] Obtain a plurality of training data and corresponding training labels;

[0085] Input the plurality of training data and the corresponding training labels into the initial text splicing model;

[0086] Train the initial text splicing model through a loss function to obtain a trained text splicing model.

[0087] In the above embodiments, the final loss function is where P * and T *is the target placeholder and the target character. During the model training process, the training method that minimizes the loss function value will be adopted, and the loss function is the above loss function. If a sequential neural network model is selected, the loss function can generally be cross entropy. Here, the supervised form is more flexible and can handle a variety of language phenomena, but because it requires manual construction, the amount of data is limited; the self-supervised method can cover a limited number of language phenomena, but it can construct a large amount of training data. In actual training, the two types of training data can be combined at the same time. The specific combination method can be quite diverse. For example, the loss function values ​​of the two parts of the data can be weighted averaged. Assuming that the loss function value on the supervised data is L sprv , the loss function value on the self-supervised data is L self , then the final loss is aL sprv +(1-a)L self , where a is a pre-specified parameter. You can also first train on supervised data and then add self-supervised data for training. In this way, you can combine supervised data and self-supervised data for training.

[0088] In some optional implementations, after the step of training the initial text splicing model through the loss function to obtain the trained text splicing model, the step further includes:

[0089] Get multiple test data and corresponding test labels;

[0090] Inputting the plurality of training data into the trained text concatenation model;

[0091] Obtaining multiple output results corresponding to the multiple training data under the trained text concatenation model;

[0092] Calculate the accuracy rate through the corresponding multiple output results and the corresponding test labels;

[0093] If the accuracy rate is lower than a threshold, the learning rate of the initial text splicing model is adjusted, and the initial text splicing model is retrained.

[0094] In the above implementation, for the supervised form, a batch of data in the above form can be annotated according to the generation scenario as the test data of the model; for the self-supervised form, we can first perform part-of-speech tagging on the corpus (for example, using tools such as Stanford NLP [9]), and then count some high-frequency prepositions, pronouns, verbs, etc. in the corpus (the complete list of parts of speech is: adp, aux, cconj, part, punct, sconj, verb, adj, adv, det, intj, pron), and remove these words from the original text. The retained words can be considered as template components, and the removed words are the words that need to be filled in the template splicing model. For example, for a sentence in the corpus "Ten years after the insurance, Mr. Zhao was unfortunately diagnosed with severe visual impairment, and the insurance company paid 200,000 yuan", the following four text fragments can be constructed by removing words: "[Ten years after the insurance][Mr. Zhao][Severe visual impairment][Insurance company paid 200,000 yuan]". Therefore, by using the above text fragments as the input of the model and the original sentences as the output of the model, we automatically construct a test dataset for text concatenation. The above method can be used to evaluate the model.

[0095] In some optional implementations, after the step of obtaining a preset template, the step further includes:

[0096] The preset template is stored in the blockchain.

[0097] It should be emphasized that in order to further ensure the privacy and security of the preset template, the preset template can also be stored in a node of a blockchain.

[0098] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0099] It can be applied in the field of medical technology / digital medicine. Through this application, medical text templates such as medical records, ward rounds logs, and hospitalization summaries can be spliced ​​and generated to improve the work efficiency of doctors.

[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0101] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0102] Further references Figure 3 , as a response to the above Figure 2-1 The present application provides an embodiment of a text splicing device, and the device embodiment is similar to Figure 2-1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0103] like Figure 3 As shown, the text splicing device 300 described in this embodiment includes: an acquisition module 301, a picture receiving module 302, an input module 303 and a splicing module 304. Among them:

[0104] An acquisition module, used to acquire a preset template, wherein the template includes a plurality of template components;

[0105] A receiving module, used for receiving user input through the multiple template components to obtain a set template;

[0106] An input module, used for inputting the set template into a trained text splicing model for text splicing;

[0107] The splicing module is used to use the output of the trained text splicing model as a splicing result.

[0108] This application uses template components and text splicing models, so that template compilers do not need to pay attention to the grammatical details to ensure the fluency of sentences, but only need to pay attention to the grammar of the core components (template components), which reduces the difficulty of template writing. Since the input of the result generated by the template splicing method is the template, the model ensures the fluency of the generated result, making the text generation result highly intervened, and the generated result can be easily intervened by adjusting the input template to reduce the complexity and cost of template management.

[0109] Furthermore, the receiving module includes a component acquisition submodule and a component value acquisition submodule.

[0110] The component acquisition submodule is used to acquire a plurality of preset template components with slots from the preset template;

[0111] The component value acquisition submodule is used to output the plurality of preset template components to the user through the display device, receive the user's input through the plurality of preset template components, and set the slots in the plurality of preset template components to corresponding values ​​to obtain the template components that have been set.

[0112] Furthermore, the input module includes a segmentation submodule, a sorting submodule and a component input submodule.

[0113] The segmentation submodule is used to obtain multiple instantiated template components in the set template;

[0114] The sorting submodule is used to connect the multiple instantiated template components through separators to obtain an input template;

[0115] The component input submodule is used to input the input template into the trained text splicing model.

[0116] Furthermore, the splicing module includes a word quantity calculation submodule, a word probability calculation submodule and a selection submodule, which are used to:

[0117] The word count submodule is calculated through π plh =softmax(W plh [h′ i ; h′ i+1 ]) Calculate the probability of the number of output words of the last layer of the neural network in the trained text concatenation model, where W plh is the weight of the neuron for calculating the number of words in the trained text concatenation model, π plh To predict h i ' and h i+1 'There is a probability of the number of words between them, the h i ' is the i-th component of the neural network output;

[0118] The word probability calculation submodule is used to calculate the word probability through π tok =softmax(W tok h′ i ) predicts the probability of each inserted word, where h′ i is the decoding of the i-th character by the encoder, W tok Calculate the weight of each inserted word probability neuron in the trained text concatenation model, π tok To predict h i ' and h i+1 'There is a probability that each word should exist;

[0119] The selection submodule is used to select the combination corresponding to the highest probability of the number of words and the highest probability of each word to generate text.

[0120] Furthermore, the text splicing device also includes a training data acquisition submodule, a training data input submodule and a training submodule.

[0121] The training data acquisition submodule is used to obtain multiple training data and corresponding training labels;

[0122] The training data input submodule is used to input the plurality of training data and the corresponding training labels into the initial text splicing model;

[0123] The training submodule is used to train the initial text splicing model through a loss function to obtain a trained text splicing model.

[0124] Furthermore, the text splicing device also includes a test data acquisition submodule, a test data input submodule, an output result acquisition submodule, an accuracy calculation submodule and a retraining submodule.

[0125] The test data acquisition submodule is used to obtain multiple test data and corresponding test labels;

[0126] The test data input submodule is used to input the plurality of training data into the trained text splicing model;

[0127] The output result acquisition submodule is used to obtain multiple output results corresponding to the multiple training data under the trained text splicing model;

[0128] The accuracy calculation submodule is used to calculate the accuracy through the corresponding multiple output results and the corresponding test labels;

[0129] The retraining submodule is used to adjust the learning rate of the initial text splicing model and retrain the initial text splicing model if the accuracy rate is lower than a threshold.

[0130] Furthermore, the text splicing device also includes a blockchain sub-module.

[0131] The blockchain submodule is used to store the preset template in the blockchain.

[0132] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0133] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0134] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0135] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the text splicing method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.

[0136] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the text splicing method. In addition to the steps of executing the above-mentioned text splicing method, the specific implementation method will not be repeated.

[0137] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.

[0138] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the text splicing method as described above.

[0139] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0140] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A text splicing method, characterized in that: The steps include: Obtain a preset template, wherein the template includes multiple template components; Receive user input through the multiple template components to obtain a template that has completed settings; Inputting the set template into the trained text splicing model to perform text splicing; Using the output of the trained text splicing model as the splicing result; The step of using the output of the trained text splicing model as the splicing result specifically includes: Through π plh =softmax(W plh [h′ i ; h′ i+1 ]) Calculate the probability of the number of output words of the last layer of the neural network in the trained text concatenation model, where W plh is the weight of the neuron for calculating the number of words in the trained text concatenation model, π plh To predict h i ' and h i+1 'There is a probability of the number of words between them, the h i ' is the i-th component of the neural network output; Through π tok =softmax(W tok h′ i ) predicts the probability of each inserted word, where h′ i is the decoding of the i-th character by the encoder, W tok Calculate the weight of each inserted word probability neuron in the trained text concatenation model, π tok To predict h i ' and h i+1 'There is a probability that each word should exist; The probability corresponding to the highest number of words and the corresponding highest probability combination of each word are selected to generate text.

2. The text splicing method according to claim 1, characterized in that: The template component includes at least one of text, slot and sub-template component, and the step of receiving user input through the multiple template components to obtain a set template specifically includes: Acquire multiple preset template components with slots from the preset template; The multiple preset template components are output to the user through a display device, and the user's input is received through the multiple preset template components, and the slots in the multiple preset template components are set to corresponding values ​​to obtain a template that has been completed.

3. The text splicing method according to claim 2, characterized in that: The step of inputting the set template into the trained text splicing model specifically includes: Obtain multiple instantiated template components in the set completed template; Connect the multiple instantiated template components through separators to obtain an input template; The input template is input into the trained text concatenation model.

4. The text splicing method according to any one of claims 1 to 3, characterized in that: Before the step of inputting the set template component into the trained text splicing model, the following steps are also included: Get multiple training data and corresponding training labels; Inputting the plurality of training data and the corresponding training labels into an initial text concatenation model; The initial text splicing model is trained through a loss function to obtain a trained text splicing model.

5. The text splicing method according to claim 4, characterized in that: After the step of training the initial text splicing model by the loss function to obtain the trained text splicing model, the following step is further included: Get multiple test data and corresponding test labels; Inputting the plurality of training data into the trained text concatenation model; Obtaining multiple output results corresponding to the multiple training data under the trained text concatenation model; Calculate the accuracy rate through the corresponding multiple output results and the corresponding test labels; If the accuracy rate is lower than a threshold, the learning rate of the initial text splicing model is adjusted, and the initial text splicing model is retrained.

6. The text splicing method according to claim 5, characterized in that: After the step of obtaining the preset template, the method further includes: The preset template is stored in the blockchain.

7. A text splicing device, characterized in that: include: An acquisition module, used to acquire a preset template, wherein the template includes a plurality of template components; A receiving module, used for receiving user input through the multiple template components to obtain a set template component; An input module, used for inputting the set template component into a trained text splicing model for text splicing; A splicing module, used for taking the output of the trained text splicing model as a splicing result; The splicing module includes a word quantity calculation submodule, a word probability calculation submodule and a selection submodule, which are used to: The word count submodule is calculated through π plh =softmax(W plh [h′ i ; h′ i+1 ]) Calculate the probability of the number of output words of the last layer of the neural network in the trained text concatenation model, where W plh is the weight of the neuron for calculating the number of words in the trained text concatenation model, π plh To predict h i ' and h i+1 'There is a probability of the number of words between them, the h i ' is the i-th component of the neural network output; The word probability calculation submodule is used to calculate the word probability through π tok =softmax(W tok h′ i ) predicts the probability of each inserted word, where h′ i is the decoding of the i-th character by the encoder, W tok Calculate the weight of each inserted word probability neuron in the trained text concatenation model, π tok To predict h i ' and h i+1 'There is a probability that each word should exist; The selection submodule is used to select the combination corresponding to the highest probability of the number of words and the highest probability of each word to generate text.

8. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the text splicing method according to any one of claims 1 to 6 when executing the computer-readable instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the text splicing method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method, apparatus, storage medium and terminal device for generating short text

    CN108959256A

  • Copy generation method and device, storage medium, and electronic device

    CN109522531A

  • Introduction text generation method and device

    CN110750975A

  • Text generation method and device, electronic equipment and storage medium

    CN111325002A

  • OOS sentence generating method and apparatus

    US20190088250A1