Text summary generation method and its device, equipment, medium, and product

By using a locality-sensitive hash function to bucket text characters and a pre-trained self-attention encoding model, the method addresses the inefficiencies of existing models, reducing computational complexity and training time for text summarization.

CN114328898BActive Publication Date: 2024-12-06GUANGZHOU HUADUO NETWORK TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111626683.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2024-12-06
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

Existing text summarization models, such as BERT and GPT, face high computational complexity and long training times due to attention calculations proportional to the square of the text length, making them inefficient for processing long texts.

Method used

Implement a text summary generation method using a locality-sensitive hash function to map text characters into data buckets based on proximity, followed by a pre-trained self-attention encoding model to reduce attention calculation complexity and training time.

Benefits of technology

The method significantly reduces attention calculation complexity from O(L^2) to O(L log L), decreasing computing power and training time required for text summarization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114328898B_ABST
    Figure CN114328898B_ABST
Patent Text Reader

Abstract

The present application discloses a text summary generation method, apparatus, computer equipment and storage medium, including: obtaining a text file to be processed; mapping the text file to a preset data bucket according to a preset local sensitive hash function; inputting the text file and the text characters in the multiple data buckets into a preset summary generation model, wherein the summary generation model is a self-attention encoding model pre-trained to a convergence state for extracting document summaries; generating a text summary of the text file according to the output result of the summary generation model. The time complexity of the attention calculation is reduced from being proportional to the square of the input text length to L log L, wherein L refers to the length of the text in the bucket. It can be seen that this embodiment can greatly reduce the complexity of attention calculation in the existing attention model, thereby reducing the computing power and training time required for the model to extract summaries.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of text processing, and in particular to a text summary generation method, apparatus, product, computer equipment, and storage medium. Background Art

[0002] With the advent of the big data era and the enhancement of hardware computing power, deep learning technology has made significant progress. In the field of text summary generation, this important task has been widely used in e-commerce. With the continuous expansion of user scale, store, and product scale, such as buyer product reviews and seller product long text introductions, if all of them are manually screened and edited, it will cost a lot of manpower costs. It is very necessary to use text summarization technology to process long texts and extract key information.

[0003] The inventor of this application found in the research that the summary extraction method in the prior art is: pre-trained models based on Transformer, such as BERT, GPT and other models, extract the summary of the text. However, in practice, since the model calculation amount is mainly concentrated in the attention calculation and feedforward layer, its calculation complexity and video memory usage are proportional to the square of the text length. When facing long text data, the existing model requires a lot of computing power and the training time is too long. Summary of the invention

[0004] The embodiments of the present application provide a method, apparatus, product, computer equipment and storage medium for generating a text summary by classifying text files by similarity, thereby reducing model computing power and training time.

[0005] In order to solve the above technical problems, a technical solution adopted by the embodiment created by the present application is: to provide a text summary generation method, comprising:

[0006] Get the text file to be processed;

[0007] Mapping the text file into a preset data bucket according to a preset local sensitive hash function;

[0008] Inputting the text file and all text characters in the plurality of data buckets into a preset summary generation model, wherein the summary generation model is a self-attention encoding model pre-trained to a convergence state for extracting document summaries;

[0009] A text summary of the text file is generated according to the output result of the summary generation model.

[0010] Optionally, obtaining the text file to be processed includes:

[0011] Get the upload instruction of product pictures;

[0012] The text file corresponding to the product image is collected according to the upload instruction.

[0013] Optionally, mapping the text file to a preset data bucket according to a preset local sensitive hash function includes:

[0014] Calculating a hash value of each text character in the text file according to the locality-sensitive hash function, wherein the locality-sensitive hash function constrains the hash value of each text character by a proximity distance between the text characters;

[0015] The text characters whose corresponding hash value differences among the text characters are less than or equal to a preset hash threshold are stored in the same data bucket.

[0016] Optionally, the summary generation model includes an attention layer and a feedforward neural network layer; and inputting the text file and all text characters in the plurality of data buckets into a preset summary generation model includes:

[0017] Inputting all text characters in the plurality of data buckets into the attention layer to generate attention features;

[0018] Combining the attention feature and the text file to generate first input data, and inputting the first input data into the feedforward neural network layer to generate first feature data;

[0019] The first feature data and all text characters in the plurality of data buckets are combined to generate second input data, and the second input data is used as input data for the next processing step.

[0020] Optionally, the summary generation model includes an encoder and a decoder; and the training method of the summary generation model includes:

[0021] Get training samples;

[0022] Inputting the training sample into the initial model of the summary generation model, and encoding the training sample by the encoder to generate encoded data;

[0023] Inputting the encoded data into the decoder to decode the encoded data to generate decoded data;

[0024] Calculating a loss value between the training sample and the decoded data according to a loss function preset in the initial model;

[0025] When the loss value is greater than a preset loss threshold, the weight value of the encoder is corrected by a back propagation function preset in the initial model.

[0026] Optionally, after correcting the weight value of the encoder by using the back propagation function preset in the initial model, the method further comprises:

[0027] Counting the number of training times of the initial model to generate training values;

[0028] The training value is compared with a preset training threshold, and when the training value is equal to the training threshold, it is confirmed that the initial model is trained to a convergence state and becomes the summary generation model.

[0029] Optionally, after generating the text summary of the text file according to the output result of the summary generation model, the method further comprises:

[0030] Collect the product code of the product image;

[0031] The product image and the text summary are stored in association with each other according to the product code, so that the user can view the text summary through a preset calling instruction with the product image.

[0032] In order to solve the above technical problems, the embodiment of the present application further provides a text summary generation device, including:

[0033] An acquisition module is used to acquire the text file to be processed;

[0034] A partitioning module, used for mapping the text file into a preset data bucket according to a preset local sensitive hash function;

[0035] A processing module, used for inputting the text file and all text characters in the plurality of data buckets into a preset summary generation model, wherein the summary generation model is a self-attention encoding model pre-trained to a convergence state for extracting document summaries;

[0036] An execution module is used to generate a text summary of the text file according to the output result of the summary generation model.

[0037] Optionally, the text summary generating device further includes:

[0038] The first acquisition submodule is used to obtain the upload instruction of the product image;

[0039] The first collection submodule is used to collect the text file corresponding to the product image according to the upload instruction.

[0040] Optionally, the text summary generating device further includes:

[0041] A first calculation submodule is used to calculate the hash value of each text character in the text file according to the locality sensitive hash function, wherein the locality sensitive hash function constrains the hash value of each text character by the proximity distance between the text characters;

[0042] The first storage submodule is used to store the text characters whose corresponding hash value differences are less than or equal to a preset hash threshold in the same data bucket.

[0043] Optionally, the summary generation model includes an attention layer and a feedforward neural network layer; the text summary generation device also includes:

[0044] A first input submodule, used for inputting all text characters in the plurality of data buckets into the attention layer to generate attention features;

[0045] A first processing submodule, configured to combine the attention feature and the text file to generate first input data, and input the first input data into the feedforward neural network layer to generate first feature data;

[0046] The first execution submodule is used to merge the first feature data and all text characters in the multiple data buckets to generate second input data, and use the second input data as input data for the next processing link.

[0047] Optionally, the summary generation model includes an encoder and a decoder; and the text summary generation device further includes:

[0048] The second acquisition submodule is used to acquire training samples;

[0049] A second input submodule, used for inputting the training sample into the initial model of the summary generation model, and the encoder performs encoding processing on the training sample to generate encoded data;

[0050] A third input submodule, used for inputting the encoded data into the decoder to decode the encoded data and generate decoded data;

[0051] A second processing submodule, used for calculating the loss value between the training sample and the decoded data according to the loss function preset in the initial model;

[0052] The second execution submodule is used to correct the weight value of the encoder through the back propagation function preset in the initial model when the loss value is greater than a preset loss threshold.

[0053] Optionally, the text summary generating device further includes:

[0054] A first statistical submodule, used for generating training values ​​by counting the number of training times of the initial model;

[0055] The third execution submodule is used to compare the training value with a preset training threshold, and when the training value is equal to the training threshold, confirm that the initial model is trained to a convergence state and becomes the summary generation model.

[0056] Optionally, the text summary generating device further includes:

[0057] The second collection submodule is used to collect the commodity code of the commodity image;

[0058] The second storage submodule is used to store the product image and the text summary in association with each other according to the product code, so as to allow the user to view the text summary through a preset calling instruction with the product image.

[0059] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the above-mentioned text summary generation method.

[0060] In order to solve the above technical problems, an embodiment of the present application further provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the above-mentioned text summary generation method.

[0061] A computer program product provided for another purpose of the present application includes a computer program / instruction, which, when executed by a processor, implements the steps of the text summary generation method described in any embodiment of the present application.

[0062] The beneficial effects of the embodiments of the present application are: preprocessing the text file through the local sensitive hash function, dividing the text characters with close distance in the text file into the same data bucket, and performing attention processing in the summary generation model, the text characters in different data buckets are respectively calculated for attention, and there is no need to pay attention to the attention calculation between the text characters across the data buckets, so that the time complexity of the attention calculation is reduced from proportional to the square of the input text length to L logL, where L refers to the length of the text in the bucket. It can be seen that this embodiment can greatly reduce the complexity of attention calculation in the existing attention model, thereby reducing the computing power and training time required for the model to extract summaries. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0064] Figure 1 A basic flow chart of a text summary generation method according to a specific embodiment of the present application;

[0065] Figure 2 A schematic diagram of a connection structure of an attention layer and a feedforward neural network layer of a specific embodiment of the present application;

[0066] Figure 3 A schematic diagram of the process of collecting text files for a specific embodiment of the present application;

[0067] Figure 4 A schematic diagram of a process of allocating data buckets according to a specific embodiment of the present application;

[0068] Figure 5 A schematic diagram of a flow chart of a local operation of a summary generation model according to a specific embodiment of the present application;

[0069] Figure 6 A training flow chart of a summary generation model according to a specific embodiment of the present application;

[0070] Figure 7 A schematic diagram of a process for confirming and generating a summary generation model according to an embodiment of the present application;

[0071] Figure 8 A storage flow chart of a text summary of an embodiment of the present application;

[0072] Fig. 9 This is a basic structural diagram of a text summary generation device according to an embodiment of the present application;

[0073] Fig.10 This is a basic structural block diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0074] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.

[0075] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0076] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.

[0077] It will be understood by those skilled in the art that the term "terminal" as used herein includes both devices with wireless signal receivers, which are devices with only wireless signal receivers without transmission capability, and devices with receiving and transmitting hardware, which are devices with receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. Such devices may include: cellular or other communication devices, which have a single-line display or a multi-line display or a cellular or other communication device without a multi-line display; PCS (Personal Communications Service), which may combine voice, data processing, fax and / or data communication capabilities; PDA (Personal Digital Assistant), which may include a radio frequency receiver, a pager, Internet / intranet access, a web browser, a notepad, a calendar and / or a GPS (Global Positioning System) receiver; conventional laptop and / or palmtop computers or other devices, which have and / or include a conventional laptop and / or palmtop computer or other device with a radio frequency receiver. The "terminal" used here can be portable, transportable, installed in a vehicle (air, sea and / or land), or suitable and / or configured to operate locally, and / or in a distributed form, at any other location on the earth and / or in space. The "terminal" used here can also be a communication terminal, an Internet terminal, a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device) and / or a mobile phone with music / video playback function, or a smart TV, a set-top box and other devices.

[0078] The hardware referred to by the names such as "server", "client", and "service node" in this application is essentially an electronic device with capabilities equivalent to those of a personal computer. It is a hardware device that has the necessary components revealed by the von Neumann principle, such as a central processing unit (including an arithmetic unit and a controller), a memory, an input device, and an output device. The computer program is stored in its memory, and the central processing unit calls the program stored in the external memory into the internal memory for execution, executes the instructions in the program, and interacts with the input and output devices to complete specific functions.

[0079] It should be pointed out that the concept of "server" referred to in this application can also be extended to the case of server clusters. According to the network deployment principle understood by those skilled in the art, the servers should be logically divided. In physical space, these servers can be independent of each other but can be called through interfaces, or integrated into a physical computer or a set of computer clusters. Those skilled in the art should understand this flexibility, and should not use it to restrict the implementation of the network deployment method of this application.

[0080] Unless expressly specified, one or more technical features of the present application can be deployed on a server for implementation and accessed by a client through a remote call to obtain an online service interface provided by the server, or can be directly deployed and run on a client for access.

[0081] The neural network models referenced or may be referenced in this application, unless expressly specified, can be deployed on a remote server and remotely called on the client, or can be deployed and directly called on a client with sufficient device capabilities. In some embodiments, when it runs on the client, its corresponding intelligence can be obtained through transfer learning to reduce the requirements for the client's hardware operating resources and avoid excessive occupation of the client's hardware operating resources.

[0082] Unless explicitly specified, the various data involved in this application can be stored remotely on a server or on a local terminal device, as long as it is suitable for being called by the technical solution of this application.

[0083] Those skilled in the art should be aware that, although the various methods of the present application are described based on the same concept and thus present commonality to each other, unless otherwise specified, these methods can be independently executed. Similarly, for each embodiment disclosed in the present application, they are all proposed based on the same inventive concept, therefore, concepts with the same expression, and concepts that are appropriately changed for convenience despite different expressions, should be understood as equivalent.

[0084] Unless the mutually exclusive relationship between the embodiments to be disclosed in this application is explicitly stated, the relevant technical features involved in each embodiment can be cross-combined to flexibly construct a new embodiment, as long as such combination does not deviate from the creative spirit of this application and can meet the needs of the prior art or solve certain deficiencies in the prior art. Those skilled in the art should be aware of this flexibility.

[0085] See also Figure 1 , Figure 1 Schematic diagram of the basic flow of the text summary generation method of this embodiment. Figure 1 As shown, a text summary generation method includes:

[0086] S1100, obtaining a text file to be processed;

[0087] In this embodiment, when the server receives an upload request from a user to upload a product picture, the server sends a text collection module to the user terminal according to the upload request. The text collection module is displayed on the user terminal in the form of a pop-up window for collecting text files corresponding to the product picture.

[0088] The text content recorded in the text file is a detailed introduction to the user's pictures. However, the text file content in this embodiment corresponds to the uploaded file is not limited to product pictures, but can also be: audio and video data or pictures of scenic spots, buildings and other types.

[0089] The method for collecting text files on the server is not limited to this. In some embodiments, after the user terminal sends a request to upload product images to the server, the server sends a collection page for collecting product images and corresponding text files to the user terminal. The user terminal uploads the product images and text files at the corresponding positions on the collection page.

[0090] In some embodiments, in order to avoid the inconsistency between the product image uploaded by the user terminal and the content of the text file, after the product image and the text file are collected, the product image is subjected to image recognition to identify the product name represented by the product image. Then, the text file is input into a preset neural network model, which is a network model pre-trained to a convergence state and used to extract entity names from documents. According to the product name, the synonyms corresponding to the product name are queried in the preset extended database of similar products, and the synonyms and product names are matched with the entity name together. When the entity name matches any one of the synonyms and the product name, it is confirmed that the content of the product image and the text file matches.

[0091] S1200, mapping the text file to a preset data bucket according to a preset local sensitive hash function;

[0092] After the text file is collected, it is necessary to preprocess the text file according to the preset local sensitive hash function, map the text characters with similar hash values ​​in the text file into a data bucket, and classify the content of the text file.

[0093] Locality-sensitive hash function means that after two adjacent data points in the original data space are transformed by the same mapping or projection, the probability that the two data points are still adjacent in the new data space is high, while the probability that non-adjacent data points are mapped to the same bucket is low. In other words, if we perform some hash mapping on the original data, we hope that the two originally adjacent data can be hashed into the same bucket and have the same data bucket number. After hash mapping all the data in the original data set, we get a hash table, and these original data sets are scattered into the buckets of the hash table. That is, if two characters are adjacent in a text file, then the hash values ​​of the two characters calculated by the locality-sensitive hash function are also the same or similar, and the preset hash threshold maps the text characters whose hash value difference between the two characters is less than or equal to the hash threshold into a data bucket. In this way, the text file can be divided into multiple data buckets, and the position of the text characters in each data bucket in the text file is closer to the distance between the text characters in other data buckets. In fact, the classification of text files is completed by adjacent distances. Since the positional relationship between texts has a great influence on the correlation between texts, in the subsequent model feature processing, we only need to pay attention to the attention calculation between text characters in the same data bucket, and there is no need to pay attention to the attention calculation between text characters across data buckets. This greatly reduces the complexity of the attention calculation of text files and reduces the computing power required for attention calculation.

[0094] S1300, inputting the text file and all text characters in the plurality of data buckets into a preset summary generation model, wherein the summary generation model is a self-attention encoding model that is pre-trained to a convergence state and is used to extract document summaries;

[0095] After the text file is divided into multiple data buckets, the text file and the text in each data bucket are used as input to the preset summary generation model.

[0096] In this implementation, the summary generation model is a semi-supervised training model that needs to be trained in advance. The initial model of the summary generation model is trained through training samples. The summary generation model trained to a convergent state can extract text summaries from text files.

[0097] The summary generation model is specifically: Transformer model. The Transformer model is a model based on the encoder (encoding)-decoder (decoding) structure. The Transformer model includes an encoding component and a decoding component. The encoding component part is composed of multiple cascaded encoders (encoders). The decoding component part is also composed of the same number (corresponding to the encoder) of decoders (decoders). Generally, the Transformer model includes 6 cascaded encoders and 6 cascaded decoders. However, the number of encoders and decoders included in the Transformer model is not limited to this. Depending on the specific application scenario, in some embodiments, the number of encoders and decoders can be (not limited to): 1, 2, 3, 4, 5, 7 or more.

[0098] The encoder and decoder of the Transformer model both include: an attention layer and a feedforward neural network layer. The attention layer is located before the feedforward neural network layer, that is, in the encoder and decoder, the attention layer and the feedforward neural network layer are connected in a standard residual manner. This connection structure requires the storage of a large number of calculation results during forward propagation in order to calculate the gradient during back propagation, that is, it is necessary to record the input data of the attention layer, the output data of the attention layer, the combined data of the input data and output data of the attention layer, and the output data of the feedforward neural network layer.

[0099] In some implementations, in order to avoid the drawback of storing a large amount of computational results during forward propagation and occupying memory, the structures of the attention layer and the feedforward neural network layer in the Transformer model are adjusted. Figure 2 , Figure 2 FIG. 1 is a schematic diagram of a connection structure of the attention layer and the feedforward neural network layer of this embodiment. Figure 2 As shown, the attention layer and feedforward neural network layer adopt the reversible residual structure in the RevNets network. When the structure shown in the figure is the first-level encoder, X1 represents the text file, X2 represents the text characters of multiple data buckets, Attention represents the attention layer, Y1 represents the input data of the feedforward neural network layer, Y2 represents the output data of the encoder or decoder, and FFN represents the feedforward neural network layer. Among them, Y2 will be used as the input data of the next encoder or decoder. After the next encoder or decoder classifies Y2 into data buckets, it will use Y2 and the characters classified by the data buckets as input and perform the same Figure 2After adopting this structure, only the output Y1 and Y2 need to be stored. During back propagation, X1 and X2 can be derived through the formula without storage. The formula is as follows: X2 = Y2 - FFN(Y1); X1 = Y1 - Attention(X2), where FFN(Y1) represents the output data of the feedforward neural network layer, and Attention(X2) represents the output data of the attention layer. Since both data can be calculated through Y1 and X2, there is no need to store them. X1 and X2 can also be deduced without storage, which will greatly reduce memory usage.

[0100] The summary generation model in this embodiment is not limited to the Transformer model. Depending on the specific application scenario, in some embodiments, the summary generation model can also be a neural network model with an encoding-decoding structure such as GPT or BERT.

[0101] S1400: Generate a text summary of the text file according to an output result of the summary generation model.

[0102] The text file and the text characters in multiple data buckets are input into a preset summary generation model to obtain a text summary output by the summary generation model.

[0103] In some embodiments, after the summary generation model outputs a text summary, the text summary needs to be stored, and the storage method is: read the product code of the product picture uploaded by the user terminal, wherein the product code is a unique identity code assigned by the server when the user terminal uploads the product picture. After the product code is read, a storage folder is generated according to the product code, and the product picture and the text summary are associated and stored in the storage folder. In actual applications, after the user uploads the product picture, when other users access the web page where the user's picture is located, when the cursor or click instruction acts on the product picture, the trigger instruction of the text summary is triggered, and the server calls the text summary in the storage folder and sends it to the corresponding user terminal for display of the text summary. In this storage method, the user can modify the text summary on the server at any time, and there is no need to update the storage location of the text summary after the modification, which improves the modification efficiency of the text summary.

[0104] The above implementation uses a local sensitive hash function to preprocess the text file, and divides the text characters with similar distances in the text file into different data buckets. When performing attention processing in the summary generation model, the text characters in different data buckets are respectively calculated for attention, and there is no need to pay attention to the attention calculation between the text characters across the data buckets, so that the time complexity of the attention calculation is reduced from proportional to the square of the input text length to L log L, where L refers to the length of the text in the bucket. It can be seen that this implementation can greatly reduce the complexity of attention calculation in the existing attention model, thereby reducing the computing power and training time required for the model to extract summaries.

[0105] In some implementations, the acquisition of the text file is initiated after the user uploads the product image. Figure 3 , Figure 3 This is a schematic diagram of the process of collecting text files in this embodiment.

[0106] like Figure 3 As shown, S1100 includes:

[0107] S1110, obtaining an upload instruction for a product image;

[0108] In this embodiment, when the server receives an upload request from a user to upload a product picture, the server sends a text collection module to the user terminal according to the upload request. The text collection module is displayed on the user terminal in the form of a pop-up window for collecting text files corresponding to the product pictures. The text content recorded in the text file is a detailed introduction to the user's picture.

[0109] S1120. Collect the text file corresponding to the product image according to the upload instruction.

[0110] In order to avoid the inconsistency between the product images uploaded by the user terminal and the content of the text file, after the product images and text files are collected, image recognition is performed on the product images to identify the product names represented by the product images. Then, the text file is input into a preset neural network model, which is a network model that is pre-trained to a convergence state and is used to extract entity names from documents. According to the product name, the synonyms corresponding to the product name are queried in the preset extended database of similar products, and the synonyms and product names are matched with the entity name together. When the entity name matches any of the synonyms and product names, it is confirmed that the content of the product image and the text file matches.

[0111] In some implementations, the division between data buckets is determined based on the difference in hash values ​​between text characters. Figure 4 , Figure 4 A schematic diagram of the process of allocating data buckets in this embodiment.

[0112] like Figure 4 As shown, S1200 includes:

[0113] S1210, calculating a hash value of each text character in the text file according to the locality-sensitive hash function, wherein the locality-sensitive hash function constrains the hash value of each text character by a proximity distance between the text characters;

[0114] After the text file is collected, it is necessary to preprocess the text file according to the preset local sensitive hash function, map the text characters with similar hash values ​​in the text file into a data bucket, and classify the content of the text file.

[0115] A locality-sensitive hash function means that after two adjacent data points in the original data space are transformed by the same mapping or projection, the probability that the two data points are still adjacent in the new data space is high, while the probability that non-adjacent data points are mapped to the same bucket is low. In other words, if we perform some hash mapping on the original data, we hope that the two originally adjacent data can be hashed into the same bucket and have the same data bucket number. After hash mapping all the data in the original data set, we get a hash table, and these original data sets are scattered into the buckets of the hash table. From this, it can be seen that the locality-sensitive hash function can constrain the difference in hash values ​​between adjacent characters in a text file to approach 0, so as to achieve the purpose of constraining the hash value of each text character according to the proximity distance between the text characters.

[0116] S1220. Store the text characters whose corresponding hash value differences are less than or equal to a preset hash threshold in the same data bucket.

[0117] If two characters are adjacent in a text file, the hash values ​​of the two characters calculated by the local sensitive hash function are also the same or similar. The preset hash threshold maps the text characters whose hash value difference between the two characters is less than or equal to the hash threshold into a data bucket. In this way, the text file can be divided into multiple data buckets, and the position of the text characters in each data bucket in the text file is closer than the distance between the text characters in other data buckets. In fact, the classification of text files by adjacent distance is completed. Since the positional relationship between texts has a high influence on the correlation between texts, therefore, in the subsequent model feature processing, it is only necessary to pay attention to the attention calculation between text characters in the same data bucket, and there is no need to pay attention to the attention calculation between text characters across data buckets, which greatly reduces the complexity of the attention calculation of text files and reduces the computing power required for attention calculation.

[0118] In some embodiments, the summary generation model includes an attention layer and a feedforward neural network layer. The structure of the attention layer and the feedforward neural network layer can prevent the summary generation model from storing too much intermediate data during the previous propagation process. Figure 5 , Figure 5 The figure is a flowchart of local operation of the summary generation model of this embodiment.

[0119] like Figure 5 As shown, S1300 includes:

[0120] S1311, inputting all text characters in the plurality of data buckets into the attention layer to generate attention features;

[0121] The summary generation model is specifically a Transformer model. The Transformer model includes 6 cascaded encoders and 6 cascaded decoders. However, the number of encoders and decoders included in the Transformer model is not limited thereto. Depending on the specific application scenario, in some implementations, the number of encoders and decoders can be (not limited to): 1, 2, 3, 4, 5, 7 or more.

[0122] Figure 2 As shown, the attention layer and feedforward neural network layer adopt the reversible residual structure in the RevNets network. When the structure shown in the figure is the first-level encoder, X1 represents the text file, X2 represents the text characters of multiple data buckets, Attention represents the attention layer, Y1 represents the input data of the feedforward neural network layer, Y2 represents the output data of the encoder or decoder, and FFN represents the feedforward neural network layer. Among them, Y2 will be used as the input data of the next encoder or decoder. After the next encoder or decoder classifies Y2 into data buckets, it will use Y2 and the characters classified by the data buckets as input and perform the same Figure 2 After adopting this structure, only the output Y1 and Y2 need to be stored. During back propagation, X1 and X2 can be derived through the formula without storage. The formula is as follows: X2 = Y2 - FFN(Y1); X1 = Y1 -Attention(X2), where FFN(Y1) represents the output data of the feedforward neural network layer, and Attention(X2) represents the output data of the attention layer. Since both data can be calculated through Y1 and X2, there is no need to store them. X1 and X2 can also be deduced without storage, which will greatly reduce memory usage.

[0123] The text characters in multiple data buckets are input into the attention layer to generate attention features. The attention layer performs attention calculations in units of data buckets.

[0124] S1312, merging the attention feature and the text file to generate first input data, and inputting the first input data into the feedforward neural network layer to generate first feature data;

[0125] The attention feature and the text file are combined to generate the first input data, wherein the first input data refers to Figure 2 Then, the first input data is input into the feed-forward neural network layer for feature extraction to generate first feature data, wherein the first feature data is FFN (Y1).

[0126] S1313: Combine the first feature data and all text characters in the plurality of data buckets to generate second input data, and use the second input data as input data for the next processing step.

[0127] The first feature data and the text characters in multiple data buckets are feature concatenated to generate second input data, which will be used as input data for the next encoder or decoder.

[0128] The summary generation model in this embodiment is an improved model of the Transformer model. The specific improvement method is as follows: Figure 2 The summary generation model is a semi-supervised model and needs to be pre-trained to convergence. Figure 6 , Figure 6 This is a training flowchart of the summary generation model in this embodiment.

[0129] like Figure 6 As shown, including:

[0130] S2100, obtaining training samples;

[0131] In this embodiment, a training sample set is provided, and the training sample set includes a plurality of training samples, and each training sample is a training document. When training the summary generation model, a training sample is randomly selected from the training sample set as the training document for the current round of training.

[0132] S2200, inputting the training sample into the initial model of the summary generation model, and encoding the training sample by the encoder to generate encoded data;

[0133] The summary generation model is a Transformer model. Before training the Transformer model into a summary generation model, it is necessary to initialize the parameters of the Transformer model to generate an initial model.

[0134] After the training samples are input into the initial model, they are first encoded by a multi-stage encoder, and the training samples are low-dimensionally mapped. The result of the low-dimensional mapping is to generate encoded data.

[0135] S2300, inputting the encoded data into the decoder to decode the encoded data to generate decoded data;

[0136] After the multi-level encoder maps the sample data into a low-dimensional space to generate encoded data, the encoded data is transmitted to the multi-level decoder for high-dimensional data restoration. The result of high-dimensional data restoration is decoded data. Decoded data is actually restored data with the same dimension as the training sample generated by restoring the encoded data.

[0137] S2400, calculating the loss value between the training sample and the decoded data according to the loss function preset in the initial model;

[0138] The loss function preset in the initial model is used to calculate the loss value between the decoded data and the training sample. The loss value can be one or more composite distances among the Euclidean distance, Mahalanobis distance, and Manhattan distance between the decoded data and the training sample.

[0139] S2500. When the loss value is greater than a preset loss threshold, the weight value of the encoder is corrected by a back propagation function preset in the initial model.

[0140] When the loss value obtained by the calculation is equal to the preset loss threshold, if the loss value is greater than the loss threshold, the gradient value of the initial model needs to be calculated according to the preset back propagation function in the initial model, and then the weight value of the encoder in the initial model is corrected according to the gradient value. When the loss value is less than or equal to the loss threshold, it is confirmed that this round of training is over.

[0141] The above training process is the training process of a single training sample in the initial model. When there are multiple models, the above training process is performed on the multiple models in turn. Therefore, the above training is performed in a cycle.

[0142] In this implementation, the initial model of the summary generation model calculates the loss value and the return gradient of the model according to the training samples and the decoded data, without the need to label the training samples, thereby improving the efficiency of model training.

[0143] In some implementations, when there are multiple training samples in the training set, it is necessary to determine whether the model has converged based on the number of training times. Figure 7 , Figure 7 The figure is a flowchart of confirming and generating a summary generation model in this embodiment.

[0144] like Figure 7 As shown, S2500 and later include:

[0145] S2600, generating training values ​​by counting the number of training times of the initial model;

[0146] When the initial model is trained, the number of trainings of the initial model is counted, and a complete training process of S2100-S2500 is recorded as one training. The training value is obtained by accumulating statistics for each training.

[0147] S2700: Compare the training value with a preset training threshold, and when the training value is equal to the training threshold, confirm that the initial model is trained to a convergence state and becomes the summary generation model.

[0148] During training, the training threshold is obtained according to the accuracy required for training or historical training data, and the training value is compared with the training threshold. When the training value is equal to the training threshold, it means that the number of initial model trainings has reached the design requirements, and the initial model has been trained to a convergence state and has become a summary generation model.

[0149] In some implementations, when a text summary is generated, the summary text needs to be stored. Figure 8 , Figure 8 The figure is a storage flow chart of the text summary of this embodiment.

[0150] like Figure 8 As shown, S1400 and later include:

[0151] S1410, collecting the product code of the product image;

[0152] The product code of the product image uploaded by the user terminal is read, wherein the product code is a unique identity code assigned by the server when the user terminal uploads the product image.

[0153] S1420: The product image and the text summary are stored in association with each other according to the product code, so as to allow the user to view the text summary through a preset calling instruction with the product image.

[0154] After the product code is read, a storage folder is generated according to the product code, and the product image and text summary are associated and stored in the storage folder. In actual applications, after the user uploads the product image, when other users access the web page where the user's image is located, when they use the cursor or click command on the product image, the trigger instruction of the text summary is triggered, and the server calls the text summary in the storage folder and sends it to the corresponding user terminal for display of the text summary. In this storage method, the user can modify the text summary on the server side at any time, and there is no need to update the storage location of the text summary after the modification, which improves the modification efficiency of the text summary.

[0155] In order to solve the above technical problems, the present application embodiment also provides a text summary generation device. Fig. 9 , Fig. 9 Schematic diagram of the basic structure of the text summary generation device of this embodiment.

[0156] like Fig. 9 As shown, a text summary generation device includes: an acquisition module 1100, a division module 1200, a processing module 1300 and an execution module 1400. The acquisition module 1100 is used to acquire a text file to be processed; the division module 1200 is used to map the text file to a preset data bucket according to a preset local sensitive hash function; the processing module 1300 is used to input the text file and all text characters in a plurality of the data buckets into a preset summary generation model, wherein the summary generation model is a self-attention encoding model pre-trained to a convergence state for extracting document summaries; the execution module 1400 is used to generate a text summary of the text file according to the output result of the summary generation model.

[0157] The text summary generation device preprocesses the text file through a local sensitive hash function, and divides the text characters with close distances in the text file into the same data bucket. When performing attention processing in the summary generation model, the text characters in different data buckets are respectively calculated for attention, and there is no need to pay attention to the attention calculation between the text characters across the data buckets, so that the time complexity of the attention calculation is reduced from proportional to the square of the input text length to L log L, where L refers to the length of the text in the bucket. It can be seen that this embodiment can greatly reduce the complexity of attention calculation in the existing attention model, thereby reducing the computing power and training time required for the model to extract summaries.

[0158] In some embodiments, the text summary generation device further includes: a first acquisition submodule and a first collection submodule. The first acquisition submodule is used to obtain an upload instruction for a product image; and the first collection submodule is used to collect a text file corresponding to the product image according to the upload instruction.

[0159] In some embodiments, the text summary generation device further includes: a first calculation submodule and a first storage submodule. The first calculation submodule is used to calculate the hash value of each text character in the text file according to the local sensitive hash function, wherein the local sensitive hash function constrains the hash value of each text character by the proximity distance between the text characters; and the first storage submodule is used to store the text characters whose corresponding hash value differences are less than or equal to a preset hash threshold in the same data bucket.

[0160] In some embodiments, the summary generation model includes an attention layer and a feedforward neural network layer; the text summary generation device also includes: a first input submodule, a first processing submodule and a first execution submodule. The first input submodule is used to input all text characters in the multiple data buckets into the attention layer to generate attention features; the first processing submodule is used to merge the attention features and the text file to generate first input data, and input the first input data to the feedforward neural network layer to generate first feature data; the first execution submodule is used to merge the first feature data and all text characters in the multiple data buckets to generate second input data, and use the second input data as input data for the next processing link.

[0161] In some embodiments, the summary generation model includes an encoder and a decoder; the text summary generation device also includes: a second acquisition submodule, a second input submodule, a third input submodule, a second processing submodule, and a second execution submodule. Among them, the second acquisition submodule is used to acquire training samples; the second input submodule is used to input the training samples into the initial model of the summary generation model, and the encoder encodes the training samples to generate encoded data; the third input submodule is used to input the encoded data into the decoder to decode the encoded data to generate decoded data; the second processing submodule is used to calculate the loss value between the training sample and the decoded data according to the loss function preset in the initial model; the second execution submodule is used to correct the weight value of the encoder through the back propagation function preset in the initial model when the loss value is greater than the preset loss threshold.

[0162] In some embodiments, the text summary generation device further includes: a first statistical submodule and a third execution submodule. The first statistical submodule is used to generate a training value by counting the number of training times of the initial model; the third execution submodule is used to compare the training value with a preset training threshold, and when the training value is equal to the training threshold, it is confirmed that the initial model has been trained to a convergence state and becomes the summary generation model.

[0163] In some embodiments, the text summary generating device further includes: a second collection submodule and a second storage submodule. The second collection submodule is used to collect the product code of the product image; the second storage submodule is used to associate and store the product image and the text summary according to the product code, so that the user can view the text summary through the preset call instruction with the product image.

[0164] In order to solve the above technical problems, the embodiment of the present application also provides a computer device. Fig.10This is a basic structural block diagram of the computer device in this embodiment.

[0165] like Fig.10 As shown, a schematic diagram of the internal structure of a computer device. The computer device includes a processor, a non-volatile storage medium, a memory, and a network interface connected via a system bus. Among them, the non-volatile storage medium of the computer device stores an operating system, a database, and computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor can implement a text summary generation method. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute a text summary generation method. The network interface of the computer device is used to connect and communicate with a terminal. Those skilled in the art can understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0166] In this embodiment, the processor is used to execute Fig. 9 The specific functions of the acquisition module 1100, the division module 120, the processing module 130 and the execution module 140 are stored in the memory, and the program code and various data required to execute the above modules are stored. The network interface is used to transmit data between the user terminal or the server. The memory in this embodiment stores the program code and data required to execute all sub-modules in the text summary generation device, and the server can call the program code and data of the server to execute the functions of all sub-modules.

[0167] The computer device preprocesses the text file through a local sensitive hash function, and divides the text characters with close distances in the text file into the same data bucket. When performing attention processing in the summary generation model, the text characters in different data buckets are respectively calculated for attention, and there is no need to pay attention to the attention calculation between the text characters across the data buckets, so that the time complexity of the attention calculation is reduced from proportional to the square of the input text length to L log L, where L refers to the length of the text in the bucket. It can be seen that this implementation can greatly reduce the complexity of attention calculation in the existing attention model, thereby reducing the computing power and training time required for the model to extract summaries.

[0168] The present application also provides a computer storage medium, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the text summary generation method in any of the above embodiments.

[0169] The present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the text summary generation method described in any embodiment of the present application.

[0170] 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 a computer program, and the computer program 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).

[0171] Those skilled in the art will appreciate that the various operations, methods, steps, measures, and schemes in the processes discussed in this application may be alternated, altered, combined, or deleted. Further, other steps, measures, and schemes in the various operations, methods, and processes discussed in this application may also be alternated, altered, rearranged, decomposed, combined, or deleted. Further, the steps, measures, and schemes in the prior art that are similar to those disclosed in this application may also be alternated, altered, rearranged, decomposed, combined, or deleted.

[0172] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A text summary generation method, It is characterized in that include: Get the text file to be processed; Mapping the text file to a preset data bucket according to a preset local sensitive hash function, including: calculating a hash value of each text character in the text file according to the local sensitive hash function, wherein the local sensitive hash function constrains the hash value of each text character by the proximity distance between the text characters; storing the text characters whose corresponding hash value differences are less than or equal to a preset hash threshold in the same data bucket; Inputting the text file and all text characters in the plurality of data buckets into a preset summary generation model, wherein the summary generation model is a self-attention encoding model pre-trained to a convergence state for extracting document summaries; A text summary of the text file is generated according to the output result of the summary generation model.

2. The text summary generation method according to claim 1, It is characterized in that The obtaining of the text file to be processed comprises: Get the upload instruction of product pictures; The text file corresponding to the product image is collected according to the upload instruction.

3. The text summary generation method according to claim 1, It is characterized in that The summary generation model includes an attention layer and a feedforward neural network layer; The step of inputting the text file and all text characters in the plurality of data buckets into a preset summary generation model comprises: Inputting the text characters in the plurality of data buckets into the attention layer to generate attention features; Combining the attention feature and the text file to generate first input data, and inputting the first input data into the feedforward neural network layer to generate first feature data; The first feature data and all text characters in the plurality of data buckets are combined to generate second input data, and the second input data is used as input data for the next processing step.

4. The text summary generation method according to claim 3, It is characterized in that The summary generation model includes an encoder and a decoder, each of which includes the attention layer and the feedforward neural network layer; The training method of the summary generation model includes: Get training samples; Inputting the training sample into the initial model of the summary generation model, and encoding the training sample by the encoder to generate encoded data; Inputting the encoded data into the decoder to decode the encoded data to generate decoded data; Calculating a loss value between the training sample and the decoded data according to a loss function preset in the initial model; When the loss value is greater than a preset loss threshold, the weight value of the encoder is corrected by a back propagation function preset in the initial model.

5. The text summary generation method according to claim 4, It is characterized in that After correcting the weight value of the encoder by the back propagation function preset in the initial model, the method further comprises: Counting the number of training times of the initial model to generate training values; The training value is compared with a preset training threshold, and when the training value is equal to the training threshold, it is confirmed that the initial model is trained to a convergence state and becomes the summary generation model.

6. The text summary generation method according to claim 2, It is characterized in that After generating the text summary of the text file according to the output result of the summary generation model, the method includes: Collect the product code of the product image; The product image and the text summary are stored in association with each other according to the product code, so that the user can view the text summary through a preset calling instruction with the product image.

7. A computer device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes the steps of the text summary generation method according to any one of claims 1 to 6.

8. A computer storage medium, It is characterized in that When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the text summary generation method according to any one of claims 1 to 6.

9. A computer program product comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Cross-media retrieval method based on local sensitive hash algorithm and neural network

    CN106649715A

  • Text abstract automatic generation method based on self-attention network

    CN110209801A

  • Classification-based method and apparatus for string selectivity estimation

    US20080010267A1