A text expansion method and device, electronic equipment and storage medium
By acquiring the differences in key text coverage between candidate articles and abstracts, a text expansion model is trained, which solves the problem of ignoring the key points of the target text in existing technologies and achieves accurate expansion around the key content.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAOHONGSHU TECH CO LTD
- Filing Date
- 2023-07-19
- Publication Date
- 2026-07-14
AI Technical Summary
Existing text expansion models tend to overlook key content in long texts, resulting in expansion effects that do not meet user needs or even distort the original meaning.
By acquiring candidate articles and their abstracts, we can identify key text coverage differences, select target articles and abstracts to form long and short text sample pairs, and train a text expansion model to expand around key content.
It achieves accurate expansion of the key content of the target text, ensuring that the long text covers all key content, avoiding distortion of the original meaning, and improving the expansion effect.
Smart Images

Figure CN117725296B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text processing technology, specifically to a text expansion method, apparatus, electronic device, and storage medium. Background Technology
[0002] In related technologies, text expansion can be achieved by using a model to expand target text into a longer text. However, in this text expansion scheme, when the model fills in the details of the long text, the content of the target text may not be the key content of the long text. In other words, the text expansion scheme may not be expanding on the key points of the target text, which may distort the original meaning of the target text and result in the expansion effect not meeting the user's needs. Summary of the Invention
[0003] This application provides a text expansion method, apparatus, electronic device, and storage medium that can expand text around the key points of the target text.
[0004] In a first aspect, embodiments of this application provide a text expansion method, including:
[0005] Retrieve candidate articles and multiple candidate key texts corresponding to the candidate articles;
[0006] Obtain candidate article summaries from the candidate articles;
[0007] Based on the candidate articles, the candidate article summaries, and the candidate key texts, determine the differences in key text coverage of the candidate articles and candidate article summaries to the candidate key texts;
[0008] Based on the key text coverage differences, target articles and their corresponding target article summaries are selected from the candidate articles and candidate article summaries to obtain long and short article sample pairs.
[0009] The text expansion model to be trained is trained based on the long and short text samples to obtain the trained text expansion model.
[0010] The target text is expanded using the trained text expansion model to obtain the expanded long text.
[0011] Secondly, embodiments of this application also provide a text expansion device, comprising:
[0012] The article acquisition unit is used to acquire candidate articles and multiple candidate key texts corresponding to the candidate articles;
[0013] Abstract acquisition unit, used to acquire candidate article abstracts of the candidate articles;
[0014] The coverage difference determination unit is used to determine the key text coverage difference of the candidate article and the candidate article summary to the candidate key text based on the candidate article, the candidate article summary and the candidate key text;
[0015] The sample generation unit is used to select a target article and its corresponding target article summary from the candidate articles and candidate article summaries based on the key text coverage differences to obtain long and short article sample pairs.
[0016] The model training unit is used to train the text expansion model to be trained based on the long and short text samples to obtain the trained text expansion model.
[0017] The text expansion unit is used to expand the target text using the trained text expansion model to obtain the expanded long text of the target text.
[0018] Thirdly, embodiments of this application also provide an electronic device, including a memory storing multiple instructions; the processor loads instructions from the memory to execute the steps of any of the text expansion methods provided in embodiments of this application.
[0019] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute the steps of any of the text expansion methods provided in embodiments of this application.
[0020] Fifthly, embodiments of this application also provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps in any of the text expansion methods provided in embodiments of this application.
[0021] The scheme adopted in the application embodiment can obtain candidate articles and multiple candidate key texts corresponding to the candidate articles; obtain candidate article summaries of the candidate articles; determine the key text coverage differences of the candidate articles and candidate article summaries on each candidate key text based on the candidate articles, candidate article summaries, and candidate key texts; select target articles and target article summaries corresponding to the target articles from the candidate articles and candidate article summaries according to the key text coverage differences to obtain long and short text sample pairs; train the text expansion model to be trained according to the long and short text sample pairs to obtain the trained text expansion model; expand the target text through the trained text expansion model to obtain the long text after expansion of the target text. In this application embodiment, by measuring the text coverage differences of the candidate articles and candidate article summaries on each candidate key text of the candidate articles, it is possible to easily, quickly, and accurately find candidate article summaries with high overlap with the key content of the candidate articles, thereby obtaining high-quality long and short text sample pairs to train the text expansion model. The high content overlap of the long and short text sample pairs can ensure that the text expansion model fully learns how to expand around the key points of the short articles during training, thereby obtaining a long text expanded around the original meaning of the short articles. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic flowchart of an embodiment of the text expansion method provided in this application.
[0024] Figure 2 This is a schematic flowchart of an embodiment of the method for obtaining key text coverage differences in candidate article summaries provided in this application.
[0025] Figure 3 This is a schematic diagram of the structure of the text expansion device provided in the embodiments of this application;
[0026] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. At the same time, in the description of the embodiments of this application, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0028] It should be noted that all information (including but not limited to user search history and user interaction information), data (including but not limited to data used for analysis, stored data, and displayed data), and signals involved in this application have been authorized by the user or by all parties in full, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the search logs involved in this application (including historical articles and historical search text) were obtained with full authorization.
[0029] This application provides a text expansion method, apparatus, electronic device, and computer-readable storage medium.
[0030] Specifically, this embodiment will be described from the perspective of a text expansion device, which can be integrated into an electronic device. That is, the text expansion method of this embodiment can be executed by an electronic device. Optionally, the electronic device can be a terminal device with data processing capabilities. The terminal device can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, game console, or personal computer (PC), etc. Optionally, the electronic device can also be a server. The server can be an independent server, or a server network or server cluster composed of servers, including but not limited to computers, network hosts, single network servers, multiple network server sets, or cloud servers composed of multiple servers. The cloud server consists of a large number of computers or network servers based on cloud computing.
[0031] The text expansion method provided in this application can be applied to a text expansion system. This text expansion system may include a terminal and a server. The terminal can be a device that includes both receiving and transmitting hardware, i.e., a device with receiving and transmitting hardware capable of performing bidirectional communication over a bidirectional communication link. The terminal and the server can communicate bidirectionally via a network.
[0032] The terminal can receive target text input by the user and send the target text to the server. The server can use the text expansion method of this application embodiment to expand the target text to obtain a long text, and then send the long text to the terminal so that the terminal can display it to the user.
[0033] The following detailed description, in conjunction with the accompanying drawings, illustrates that the executing entity in this embodiment is an electronic device capable of invoking a deduplication algorithm. It should be noted that the order of description in the following embodiments is not intended to limit the preferred order of the embodiments. Although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown in the accompanying drawings.
[0034] Please refer to Figure 1 The specific process of this text expansion method can be summarized in steps 101 to 106, where:
[0035] 101. Retrieve candidate articles and their corresponding multiple key candidate texts;
[0036] The text expansion method of this embodiment can be applied to any scenario where target text is expanded into long text through electronic devices, such as AIGC (AI Generated Content) scenarios.
[0037] When expanding a target text into a longer text, it is often necessary to expand the content of the target text in detail. If the key content of the target text is ignored during the expansion, two problems may occur: 1. The longer text does not cover all the key content of the target text; 2. The longer text does not expand the key content of the target text in detail, or even creates key content that is not in the target text, thus distorting the original meaning of the target text.
[0038] In this embodiment, an improved text expansion model is trained, which can expand upon the key content of the target text. The accuracy of this text expansion model comes from the precise generation scheme for long and short text sample pairs in this embodiment.
[0039] In one example, the candidate article can be from the same content platform or from multiple different content platforms. The article can include text and other modal multimedia content, such as audio, video, and images. This embodiment does not limit this.
[0040] In this embodiment, "multiple candidate key texts" can refer to two or more. Candidate key texts can be words, phrases, etc., and this embodiment does not limit this. A candidate key text can include at least one word, at least one phrase, or a combination of words and phrases, and this embodiment does not limit this either.
[0041] In one optional example, candidate articles and candidate key texts can be pre-configured using an existing sample database. Alternatively, candidate articles can be selected, and candidate key texts can be annotated using a model or manually.
[0042] In another alternative example, considering that users generally use key words, sentences, or unique phrases in an article when searching, the search text entered by the user is naturally the key words of the article, which is a kind of prior knowledge. Therefore, this embodiment can use this prior knowledge to obtain candidate text and candidate key text, reducing the cost of candidate key text annotation.
[0043] Therefore, in a specific implementation, step 101 may include:
[0044] Retrieve historical articles from the search logs and select candidate articles from them;
[0045] Identify multiple key candidate texts for candidate articles from the historical search texts of the candidate articles.
[0046] Optionally, search logs can be the logs of the platform's search engine, and the type of platform includes, but is not limited to, content platforms, search platforms, etc.
[0047] Optionally, when selecting candidate articles from historical articles, a batch of articles with high content quality can be selected. In an optional example, the content quality of the articles can be determined manually, that is, articles with high content quality can be selected from historical articles as candidate articles manually.
[0048] In another example, the quality of an article's content can be judged by its interaction with users. For example, candidate articles can be selected from historical articles based on interaction-related metrics such as page views, search counts, likes, comments, the sentiment of comments, and the length of comments.
[0049] For example, the steps of selecting candidate articles from historical articles may specifically include:
[0050] Obtain the time distribution of historical search counts and user interaction information for historical articles based on search logs;
[0051] Calculate the search importance parameter of historical articles based on the time distribution of historical search volume;
[0052] Calculate the importance parameter of user interaction for historical articles based on user interaction information;
[0053] Candidate articles are selected from historical articles based on the search importance parameter and the user interaction importance parameter.
[0054] The time distribution of historical search counts can be used to indicate the number of searches in multiple segments of a historical time period. The duration of the historical time period can be set as needed, such as the past 30 days or the past 15 days. The duration of each segment can also be set as needed, such as 1 day, etc.
[0055] Each time segment is assigned a weight parameter. Based on the weight parameter and search frequency of each segment, the search importance parameter of each segment can be obtained. The search importance parameters of each segment are then fused to obtain the search importance parameter of the historical articles. The fusion methods include, but are not limited to, summation, taking the maximum value, and averaging.
[0056] Optional user interactions with historical articles include, but are not limited to: browsing, liking, commenting, sharing, clicking links in the article, purchasing products linked in the article, etc.
[0057] Each interactive behavior has a different weight parameter. The deeper the interaction, the larger the weight parameter. In other words, the more complex the interactive operation on the article, the deeper the interaction. For example, browsing can be set to have the lowest level of interaction, while purchasing products linked in the article can have the highest level of interaction.
[0058] Optionally, calculating the user interaction importance parameters of historical articles based on user interaction information may include: obtaining the number and weight parameters of interaction behaviors of various interaction types in historical articles; calculating the interaction importance parameters under each interaction type based on the number and weight parameters of interaction behaviors of each interaction type; and fusing the interaction importance parameters of each type to obtain the interaction importance parameters of candidate articles.
[0059] Optionally, there are several ways to select candidate articles from historical articles based on the search importance parameter and user interaction importance parameter of historical articles. For example, historical articles with a search importance parameter higher than a preset search importance parameter threshold and / or a user interaction importance parameter higher than a preset user interaction importance parameter threshold can be selected as candidate articles.
[0060] Alternatively, the search importance parameters of historical articles and the user interaction importance parameters can be merged to obtain merged parameters, and candidate articles can be selected from historical articles based on the merged parameters.
[0061] It is understandable that when a user searches for historical articles, they may enter multiple words or phrases simultaneously. In this embodiment, the multiple words entered by the user in a single search can be considered as a single historical search text, and candidate key texts can be directly selected from this historical search text. Alternatively, in one example, the historical search text can be split, and candidate key texts can be determined from the split results. Or, in another example, the historical search text can be aggregated to obtain candidate key texts. During aggregation, multiple historical search texts can be merged, or partially merged, to obtain candidate key texts. Of course, the above methods for obtaining historical search texts can be combined arbitrarily as needed, and this embodiment does not impose any restrictions on this.
[0062] 102. Obtain candidate article abstracts;
[0063] In this embodiment, the candidate article abstracts can be pre-extracted and stored in the database, or they can be extracted in real time; this embodiment does not limit this.
[0064] In one example, to find the most suitable summary possible, for a candidate article, at least two candidate article summaries can be obtained using at least two different text summarization methods. Subsequent steps then select data with high overlap with the key content of the candidate articles to train the text expansion model.
[0065] 103. Based on candidate articles, candidate article abstracts, and candidate key texts, determine the differences in key text coverage of candidate articles and candidate article abstracts over candidate key texts;
[0066] Optionally, in one example, key text coverage difference can be used to characterize the difference in key content between the candidate article and the candidate key text. The higher the key text coverage difference, the greater the difference in key content between the candidate article summary and the candidate article; the lower the key text coverage difference, the smaller the difference in key content between the candidate article summary and the candidate article.
[0067] In an optional example, the step of determining the difference in key text coverage between the candidate article and the candidate article summary and the candidate key text, based on the candidate article, the candidate article summary, and the candidate key text, may include:
[0068] Obtain the first relevance score between candidate articles and candidate key texts;
[0069] Obtain the second relevance score between the candidate article abstract and the selected candidate key text;
[0070] Based on the difference between the first and second relevance scores of the candidate key texts, the difference in key text coverage between the candidate articles and the candidate article abstracts is determined.
[0071] Optionally, the first relevance score and the second relevance score can be obtained by scoring using a relevance model. The relevance score can be calculated in real time or read from the search log (in this example, the platform's code can calculate the relevance score based on the search text and articles at the time of the search and store it in the search log). This embodiment does not limit this.
[0072] For example, obtaining the first relevance score between candidate articles and candidate key texts can involve inputting the candidate articles and candidate key texts into a relevance assessment model to obtain the first relevance score. Multiple relevance assessment models can be used, and the average of the parameters is taken as the first relevance score. The method for obtaining the second relevance score is similar and will not be elaborated here.
[0073] Optionally, after determining the first relevance score, this embodiment can also filter the candidate key texts to be processed in the subsequent process to avoid the first relevance scores of the candidate key texts being concentrated, which would affect the training effect.
[0074] For example, before determining the difference in key text coverage of candidate articles and candidate article abstracts to candidate key texts based on the difference between the first and second relevance scores of candidate key texts, it may also include:
[0075] The selection is based on the first relevance score among multiple candidate key texts, such that the first relevance score of the selected candidate key text satisfies the condition of uniform distribution within the range of relevance score values.
[0076] Correspondingly, in this example, the difference in key text coverage between candidate articles and candidate article summaries is determined based on the difference between the first and second relevance scores of the selected candidate key texts.
[0077] The range of the correlation score can be set according to actual needs, for example, set to a range of 0-1.
[0078] Optionally, in this embodiment, when selecting candidate key texts, multiple sub-ranges of the relevance score range can be determined; in each sub-range, at least one candidate key text whose first relevance score falls within the sub-range is selected.
[0079] Optionally, the uniform distribution condition may include: the number of candidate key texts selected in each sub-range can be approximately the same. For example, the difference in the number of candidate key texts selected in different sub-ranges does not exceed a preset threshold. The value of this threshold is determined based on the minimum number of candidate key texts in the sub-range and a preset proportion value, such as 20% of the minimum number value (the preset proportion value can also be other values, which are not limited in this embodiment), etc. For example, the sub-range with the highest relevance score can have more candidate key texts.
[0080] It is understandable that there may be situations where the first relevance score of no candidate key text falls into a certain subrange. In such cases, it is permissible for the candidate key text selected from that subrange to be empty.
[0081] It is conceivable that each candidate key text corresponds to a difference between the first relevance score and the second relevance score. Therefore, the difference in key text coverage between the candidate article and the candidate article abstract and the candidate key text needs to be obtained by combining this difference corresponding to each candidate key text.
[0082] Optionally, the step "determine the key text coverage difference of candidate articles and candidate article summaries to candidate key texts based on the difference between the first relevance score and the second relevance score of candidate key texts" may include: calculating the score difference between the first relevance score and the second relevance score of each candidate key text under the candidate article summary to obtain multiple candidate key text coverage differences under the candidate article summary; and determining the key text coverage difference corresponding to the candidate article summary based on the multiple candidate key text coverage differences.
[0083] Optionally, there are multiple ways to determine the key text coverage differences corresponding to the candidate article abstracts. For example, the average value of the key text coverage differences of the candidates can be used to obtain the key text coverage differences corresponding to the candidate article abstracts. Alternatively, the maximum value of the key text coverage differences of the candidates can be used to obtain the key text coverage differences corresponding to the candidate article abstracts. Or, the maximum and minimum values of the key text coverage differences of the candidates can be removed, and then the average value can be used to obtain the key text coverage differences corresponding to the candidate article abstracts. This embodiment does not limit this.
[0084] The scheme of this embodiment can be divided into sample data collection, model training and text expansion stages. The sample data collection stage includes steps 101-104 of this embodiment. The data collection stage includes: the acquisition stage of candidate articles and the candidate key text coverage differences of their candidate article summaries (including steps 101-103), and the sample generation stage (step 104).
[0085] For ease of understanding, this embodiment combines Figure 2An example is provided to illustrate the method for obtaining the key text coverage differences in candidate article abstracts:
[0086] Assuming this application can obtain the search logs of a search engine (with prior user authorization), in one example, the search engine can be equipped with a relevance evaluation model. This model can calculate a relevance score between the query terms and articles in the database during a search. The calculated relevance score can be stored in the search engine's search logs. Therefore, this embodiment can obtain this relevance score from the logs. In one example, this embodiment can use the search engine's relevance evaluation model to evaluate the relevance score rel(q, d) of the query term q (candidate key text) and document d (candidate article) in real time, representing the strength of their relevance. In this example, the difference in key text coverage between the candidate article summaries is represented by the score y. See [link to relevant documentation]. Figure 2 This can be obtained through the following steps:
[0087] Step 201: For document d, rewrite document d into a summary s (candidate text summary) using the text summarization method.
[0088] The abstract is scored using the following method: the larger the score y is, the more information is lost in the abstract, and the worse the quality of the abstract.
[0089] Step 202: Using the search engine's search logs, for each document d, obtain multiple query terms q1, q2, q3...qm.
[0090] Step 203: Calculate the first relevance score rel(qi, d) for document d and m query terms q1, q2, q3, ..., qm, where i indicates that the query term is the i-th query term.
[0091] Step 204: Select k query terms from m query terms. The k query terms should cover all relevance score ranges, that is, the first relevance scores of the k query terms should be evenly distributed rather than concentrated in a very small interval.
[0092] Step 205: Calculate the second relevance score rel(qj,s) between the k query terms and each summary s of document d, where i indicates that the query term is the j-th query term;
[0093] Step 206: Calculate the difference in relevance scores (diff) for each query term. i =|rel(qi,d)-rel(qi,s)|, taking the maximum value among the k diff scores as the key text coverage difference of the summary s.
[0094] The larger y is, the worse the summary is, and the less it covers the key content of document d.
[0095] In another example, one could first identify the target texts that are commonly covered by the candidate articles and their abstracts, and then determine the differences in coverage of the key texts based on the target texts and the candidate key texts.
[0096] For example, step 103 may specifically include:
[0097] Identify the target texts that are commonly covered in the candidate articles and their abstracts;
[0098] Calculate the third relevance score between each target text and the candidate key text, and determine the difference in key text coverage between the candidate article and the candidate article abstract and the candidate key text based on the third relevance score.
[0099] The acquisition of the third relevance score can refer to the acquisition method of the first relevance score, and will not be repeated here. The target text that is jointly covered can come from either the candidate article or the candidate article abstract. In this example, the other candidate article or candidate article abstract contains text corresponding to (or similar to) the target text. The similarity between the corresponding texts of the jointly covered target text in the candidate article and the candidate article abstract is not lower than a preset similarity threshold. The similarity threshold can be set according to actual needs, such as a value of 0.9.
[0100] Optionally, for each candidate article abstract, the key text coverage difference corresponding to that candidate article abstract can be determined based on the third relevance scores corresponding to multiple candidate key texts under that candidate article abstract. For example, the minimum value, average, or average of multiple third relevance scores of the candidate article abstract can be taken as the key text coverage difference of the candidate article abstract. It is understandable that the smaller the third relevance score, the greater the key text coverage difference.
[0101] 104. Based on the differences in coverage of key texts, select the target article and its corresponding target article summary from the candidate articles and candidate article summaries to obtain long and short article sample pairs;
[0102] Optionally, a candidate article can have multiple candidate article summaries. The smaller the difference in key text coverage between the target article and the target article summary, the better. The smaller the difference in key text coverage, the less loss there is in the article summary.
[0103] In this application, the methods for selecting the target article and the target article abstract may include:
[0104] The candidate articles and the candidate article abstracts corresponding to the candidate articles are identified, and the differences in key text coverage among the multiple candidate article abstracts of the candidate articles meet the preset key coverage conditions. These are the target articles and the target article abstracts, respectively. Based on the target articles and the target article abstracts, long and short text sample pairs are generated.
[0105] In one example, the preset key coverage condition may include that the key text coverage difference is not lower than the minimum key text coverage difference threshold. Under this condition, at least one candidate article summary may be selected from multiple candidate article summaries as the target article summary to form multiple long and short article sample pairs with the candidate articles. For example, for multiple candidate article summaries of each candidate article, the candidate article summary with a key text coverage difference less than the minimum key text coverage difference threshold is selected as the target article summary.
[0106] In one example, the preset key coverage condition may include: the difference in key text coverage is minimized, and the candidate article summary selected is the best performing among multiple candidate article summaries, with the least loss of key information about the candidate article.
[0107] Optionally, the step "determine the candidate articles and the candidate article abstracts whose key text coverage differences among multiple candidate article abstracts satisfy the preset key coverage conditions, namely the target article and the target article abstract" may include:
[0108] The candidate articles and the candidate article abstracts with the smallest differences in key text coverage among multiple candidate article abstracts are identified as the target article and the target article abstract, respectively.
[0109] For example, taking the above scheme of obtaining k query terms for document d based on search engine logs as an example, given each document d, this embodiment can generate multiple summaries s1, ..., sn using various document summarization methods. The methods in steps 201-206 above score each summary s separately, obtaining n key text coverage difference scores y1, ..., yn.
[0110] If yi is the smallest among the n scores, it means that the summary si has the least information loss, and it is used as the summary of document d. In this way, a document-summary pair {(d,s)} is obtained, which is the long and short document sample pair in this embodiment.
[0111] 105. Train the text expansion model to be trained based on long and short text samples to obtain the trained text expansion model.
[0112] Optionally, the type of text expansion model in this embodiment is not limited. It can be any feasible NPL (Nature Language Processing) model, such as CNN (convolutional neural networks) model, RNN (recurrent neural networks) model, LSTM (long-short term memory networks) model, GRU (gated recurrent unit, an improved version of LSTM) model, GPT (Generative Pre-trained Transformer) model, etc.
[0113] GPT is a text generation model that generates new text from a given text input. This application trains the GPT model using short and long text samples, where each sample is a document-summary tuple (d, s). Using the summary s as input, the GPT model is required to output text that fits the document d'. Based on d' and d in the tuple, the parameters of the GPT model are adjusted, thus training a GPT model capable of expanding short texts into long texts d.
[0114] Optionally, in one example, the text expansion model to be trained may include a multi-layer connected decoder. The training process of the text expansion model includes: inputting the target article summary from the long and short text sample pairs into the text expansion model to be trained; decoding the target article summary multiple times through the multi-layer decoder module of the text expansion model to obtain the expanded text output by the text expansion model; calculating the text expansion loss of the text expansion model based on the expanded text and the target article in the long and short text sample pairs; and adjusting the parameters of the text expansion model based on the text expansion loss to obtain the trained text expansion model.
[0115] In this embodiment, the number of layers in the decoder module of the GPT model is unlimited and can be set as needed, such as 12 layers, 24 layers, 36 layers, 48 layers, etc.
[0116] Optionally, the text expansion loss of the text expansion model can be calculated based on the target article in the long and short text sample pairs after expansion. This can include: extracting the first text feature from the expanded text, extracting the second text feature from the target article, calculating the fourth relevance score of the first text feature and the second text feature, and determining the text expansion loss based on the fourth relevance score.
[0117] Optionally, the fourth relevance score can be calculated using Euclidean distance, cosine distance, etc. Optionally, the first and second text features reside in the same text vector space.
[0118] In another example, a fourth relevance score can be evaluated on the target article in the long and short text sample pairs using a relevance assessment model, and the text expansion loss can be determined based on this fourth relevance score.
[0119] Understandably, the smaller the fourth relevance score, the smaller the text expansion loss.
[0120] 106. The target text is expanded using the trained text expansion model to obtain the expanded long text.
[0121] Optionally, the target text is the text to be expanded. This target text can be input via text, voice, or image (or video). Voice, images, or videos can be converted into text before being expanded as described in this application. Therefore, this embodiment can convert multimedia content in different modalities, such as target text, audio, images, or videos, into long text.
[0122] For example, the terminal can receive target text input by the user, or receive audio input by the user and convert the audio into text as the target text; or receive an image input by the user, understand the image through an AI model, and obtain target text describing the image; or receive a video input by the user, extract audio and image from the video, convert the audio into first text, convert the image into second text, and obtain the target text based on the first text and the second text.
[0123] In one example, when the trained text expansion model expands the target text, it can decode the target article summary multiple times through the multi-layer decoder module of the text expansion model to obtain the expanded text output by the text expansion model.
[0124] The method in this embodiment allows a short text to be used as input, and the trained GPT model to output an expanded long text. It also improves the coverage of key content from the short text by the long text, without arbitrarily adding new key points. This embodiment improves the sample data collection method, eliminating the need for manual data annotation. It automatically acquires massive amounts of data using search engines, thereby selecting a large number of long and short text sample pairs with good training performance. These large number of long and short text sample pairs are then used to train a GPT model with excellent expansion performance to achieve article expansion.
[0125] This embodiment also provides a text expansion device, which can be integrated into an electronic device, such as a computer device. The computer device can be a terminal, server, or other device. This embodiment does not limit this.
[0126] For example, such as Figure 3 As shown, the text expansion device may include:
[0127] Article acquisition unit 301 is used to acquire candidate articles and multiple candidate key texts corresponding to the candidate articles;
[0128] Abstract acquisition unit 302 is used to acquire candidate article abstracts;
[0129] The coverage difference determination unit 303 is used to determine the key text coverage difference of the candidate article and the candidate article abstract to the candidate key text based on the candidate article, the candidate article abstract and the candidate key text;
[0130] The sample generation unit 304 is used to select the target article and the target article summary corresponding to the target article from the candidate articles and candidate article summaries based on the differences in key text coverage to obtain long and short text sample pairs.
[0131] The model training unit 305 is used to train the text expansion model to be trained based on long and short text samples to obtain the trained text expansion model.
[0132] The text expansion unit 306 is used to expand the target text using the trained text expansion model to obtain the expanded long text.
[0133] Optionally, in the apparatus of this application embodiment, the coverage difference determination unit is used to obtain a first relevance score between the candidate article and the candidate key text; obtain a second relevance score between the candidate article summary and the candidate key text; and determine the key text coverage difference of the candidate article and the candidate article summary to the candidate key text based on the difference between the first relevance score and the second relevance score of the candidate key text.
[0134] Optionally, in the apparatus of this application embodiment, the coverage difference determination unit is further configured to, before determining the key text coverage difference of the candidate article and candidate article summary on the candidate key text based on the first relevance score, select from multiple candidate key texts based on the first relevance score, such that the first relevance score corresponding to the selected candidate key text satisfies the uniform distribution condition within the value range of the relevance score; and determine the key text coverage difference of the candidate article and candidate article summary on the candidate key text based on the difference between the first relevance score and the second relevance score of the selected candidate key text.
[0135] In one example, the method by which the coverage difference determination unit selects from multiple candidate key texts based on a first relevance score includes: determining multiple sub-ranges of the relevance score's value range; and in each sub-range, selecting at least one candidate key text whose first relevance score falls within that sub-range.
[0136] Optionally, in the apparatus of this application embodiment, the coverage difference determination unit is used to calculate the score difference between the first relevance score and the second relevance score of each candidate key text under the candidate article summary, to obtain the coverage difference of multiple candidate key texts under the candidate article summary; and to determine the key text coverage difference corresponding to the candidate article summary based on the coverage difference of multiple candidate key texts.
[0137] Optionally, a candidate article may have multiple candidate article summaries; a sample generation unit is used to determine the candidate article and the candidate article summaries corresponding to the candidate article whose key text coverage differences meet the preset key coverage conditions, namely the target article and the target article summary; and to generate long and short text sample pairs based on the target article and the target article summary.
[0138] Optionally, the article retrieval unit is used to retrieve historical articles found in the search log, select candidate articles from the historical articles, and determine multiple candidate key texts of the candidate articles from the historical search texts of the candidate articles.
[0139] Optionally, the article acquisition unit is used to obtain the time distribution of historical search counts and user interaction information of historical articles based on search logs; calculate the search importance parameter of historical articles based on the time distribution of historical search counts; calculate the user interaction importance parameter of historical articles based on user interaction information; and select candidate articles from historical articles based on the search importance parameter and user interaction importance parameter of historical articles.
[0140] Optionally, a model training unit is used to input the target article summary from the long and short text sample pairs into the text expansion model to be trained; decode the target article summary multiple times through the multi-layer decoder module of the text expansion model to obtain the expanded text output by the text expansion model; calculate the text expansion loss of the text expansion model based on the expanded text and the target article in the long and short text sample pairs; adjust the parameters of the text expansion model based on the text expansion loss to obtain the trained text expansion model.
[0141] Optionally, a text expansion unit is used to decode the target article summary multiple times through the multi-layer decoder module of the text expansion model to obtain the expanded text output by the text expansion model.
[0142] Using the apparatus of this embodiment, by measuring the text coverage difference between the candidate article and the candidate article summary on each candidate key text of the candidate article, it is possible to easily, quickly and accurately find the candidate article summary with a high degree of overlap with the key content of the candidate article, thereby obtaining high-quality long and short text sample pairs to train the text expansion model. The high content overlap of the long and short text sample pairs can ensure that the text expansion model fully learns how to expand around the key points of the short article during training, thereby obtaining a long article expanded around the original meaning of the short article.
[0143] Furthermore, the candidate articles and multiple candidate key texts for the candidate articles are selected from articles found in the past and the search text when searching for articles. Therefore, the search text is highly likely to be the key text of the candidate articles, without the need for manual annotation of the key text of the articles.
[0144] Furthermore, each candidate article can have multiple candidate article summaries. For each candidate article summary, the coverage difference of the candidate key text is calculated under each candidate key text. The coverage rate of the candidate article summary to the key content of the candidate article can be measured by the coverage difference of the candidate key texts under each candidate article summary. Then, the candidate article summary with the highest coverage rate is selected from the candidate article summaries to form long and short text sample pairs with the candidate article. Thus, without manual annotation, accurate long and short text sample pairs can be automatically obtained based on the search logs of the search engine, which not only reduces the cost of sample acquisition, but also improves the training effect of long and short text samples on the text expansion model.
[0145] Accordingly, this application also provides an electronic device, which can be a terminal, such as a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other terminal device. Alternatively, the electronic device can be a server.
[0146] like Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 400 includes a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 and the memory 402 are electrically connected. Those skilled in the art will understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0147] The processor 401 is the control center of the electronic device 400. It connects various parts of the electronic device 400 through various interfaces and lines. By running or loading software programs and / or units stored in the memory 402, and calling data stored in the memory 402, it executes various functions of the electronic device 400 and processes data. The processor 401 may be a CPU, GPU, network processor (NP), etc., and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0148] In this embodiment, the processor 401 in the electronic device 400 loads the instructions corresponding to the processes of one or more applications into the memory 402 according to the following steps, and the processor 401 runs the applications stored in the memory 402 to realize various functions, such as:
[0149] Retrieve candidate articles and their corresponding multiple key candidate texts;
[0150] Get the candidate article abstracts;
[0151] Based on candidate articles, candidate article abstracts, and candidate key texts, determine the differences in key text coverage of candidate articles and candidate article abstracts over candidate key texts;
[0152] Based on the differences in key text coverage, target articles and their corresponding target article summaries are selected from candidate articles and candidate article summaries to obtain long and short article sample pairs.
[0153] The text expansion model to be trained is trained based on long and short text samples to obtain the trained text expansion model.
[0154] The target text is expanded by a trained text expansion model to obtain a longer expanded text.
[0155] Furthermore, the various functions implemented by running the application stored in memory 402 can also be found in the description of the foregoing embodiments, and will not be repeated here.
[0156] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0157] Optional, such as Figure 4 As shown, the electronic device 400 also includes: a touch display screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch display screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0158] The touch display screen 403 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 403 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 401. It can also receive and execute commands from the processor 401. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 401 to determine the type of touch event. Subsequently, the processor 401 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 403 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 403 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 403 can also be used as part of the input unit 406 to achieve input functions.
[0159] The radio frequency circuit 404 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other electronic devices, and to transmit and receive signals with network devices or other electronic devices.
[0160] Audio circuit 405 can be used to provide an audio interface between a user and an electronic device via a speaker and a microphone. Audio circuit 405 can convert received audio data into electrical signals and transmit them to the speaker, where the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuit 405, converted back into audio data, and then processed by processor 401 before being transmitted via radio frequency circuit 404 to, for example, another electronic device, or output to memory 402 for further processing. Audio circuit 405 may also include an earphone jack to provide communication between peripheral headphones and electronic devices.
[0161] The input unit 406 can be used to receive input numbers, characters, or user characteristic information (such as fingerprints, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
[0162] Power supply 407 is used to supply power to various components of electronic device 400. Optionally, power supply 407 can be logically connected to processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 407 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0163] although Figure 4 As not shown in the diagram, the electronic device 400 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.
[0164] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0165] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0166] Therefore, embodiments of this application provide a computer-readable storage medium storing multiple computer programs that can be loaded by a processor to execute any of the text expansion methods provided in this application. For example, the computer program can execute the steps of the following text expansion method:
[0167] Retrieve candidate articles and their corresponding multiple key candidate texts;
[0168] Get the candidate article abstracts;
[0169] Based on candidate articles, candidate article abstracts, and candidate key texts, determine the differences in key text coverage of candidate articles and candidate article abstracts over candidate key texts;
[0170] Based on the differences in key text coverage, target articles and their corresponding target article summaries are selected from candidate articles and candidate article summaries to obtain long and short article sample pairs.
[0171] The text expansion model to be trained is trained based on long and short text samples to obtain the trained text expansion model.
[0172] The target text is expanded by a trained text expansion model to obtain a longer expanded text.
[0173] Furthermore, the detailed steps of the above method can be found in the description of the foregoing embodiments, and will not be repeated here.
[0174] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0175] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0176] Since the computer program stored in the computer-readable storage medium can execute any of the text expansion methods provided in the embodiments of this application, the beneficial effects that any of the text expansion methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0177] According to one aspect of this application, a computer program product or computer program is also provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the methods provided in the various optional implementations of the above embodiments.
[0178] In the above embodiments of the text expansion device, computer-readable storage medium, electronic device, and computer program product, the descriptions of each embodiment have different focuses. Parts not described in detail in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes and beneficial effects of the text expansion device, computer-readable storage medium, computer program product, electronic device, and their corresponding units described above can be referred to the description of the text expansion method in the above embodiments, and will not be repeated here.
[0179] The foregoing has provided a detailed description of a text expansion method, apparatus, electronic device, computer-readable storage medium, and computer program product provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A text expansion method, characterized in that, include: Retrieve candidate articles and multiple candidate key texts corresponding to the candidate articles; Obtain candidate article summaries from the candidate articles; Based on the candidate articles, the candidate article summaries, and the candidate key texts, determine the differences in key text coverage of the candidate articles and candidate article summaries to the candidate key texts; Based on the key text coverage differences, target articles and their corresponding target article summaries are selected from the candidate articles and candidate article summaries to obtain long and short article sample pairs. The text expansion model to be trained is trained based on the long and short text samples to obtain the trained text expansion model. The target text is expanded using the trained text expansion model to obtain the expanded long text.
2. The text expansion method according to claim 1, characterized in that, The step of determining the key text coverage difference of the candidate article and candidate article summary over the candidate key text based on the candidate article, the candidate article summary, and the candidate key text includes: Obtain the first relevance score between the candidate articles and the candidate key texts; Obtain the second relevance score between the candidate article abstract and the candidate key text; Based on the difference between the first relevance score and the second relevance score of the candidate key text, the difference in key text coverage between the candidate article and the candidate article summary and the candidate key text is determined.
3. The text expansion method according to claim 2, characterized in that, Before determining the difference in key text coverage of the candidate article and candidate article summary to the candidate key text based on the difference between the first relevance score and the second relevance score of the candidate key text, the method further includes: Based on the first relevance score, the selected candidate key texts are selected such that the first relevance score corresponding to the selected candidate key texts satisfies the condition of uniform distribution within the range of relevance score values. The determination of the key text coverage difference between the candidate article and the candidate article summary for the candidate key text based on the difference between the first relevance score and the second relevance score of the candidate key text includes: Based on the difference between the first relevance score and the second relevance score of the selected candidate key texts, the difference in key text coverage of the candidate articles and candidate article summaries to the candidate key texts is determined.
4. The text expansion method according to claim 2, characterized in that, The determination of the key text coverage difference between the candidate article and the candidate article summary for the candidate key text based on the difference between the first relevance score and the second relevance score of the candidate key text includes: Calculate the difference between the first relevance score and the second relevance score of each candidate key text under the candidate article summary to obtain the coverage difference of multiple candidate key texts under the candidate article summary; Based on the differences in coverage of the multiple candidate key texts, the differences in coverage of key texts corresponding to the candidate article abstracts are determined.
5. The text expansion method according to any one of claims 1-4, characterized in that, A candidate article can have multiple candidate article abstracts; The step of selecting a target article and its corresponding target article summary from the candidate articles and candidate article summaries based on the key text coverage differences to obtain long-short article sample pairs includes: The candidate articles and the candidate article summaries corresponding to the candidate articles whose key text coverage differences satisfy the preset key coverage conditions are identified as the target articles and target article summaries, respectively. Based on the target article and its abstract, generate long and short article sample pairs.
6. The text expansion method according to any one of claims 1-4, characterized in that, The process of obtaining candidate articles and multiple candidate key texts corresponding to the candidate articles includes: Retrieve historical articles from the search logs, and select candidate articles from these historical articles; Multiple candidate key texts of the candidate articles are identified from the historical search texts of the candidate articles.
7. The text expansion method according to any one of claims 1-4, characterized in that, The step of training the text expansion model to be trained based on the long and short text samples to obtain the trained text expansion model includes: Input the target article summary from the long and short article sample pairs into the text expansion model to be trained; The target article summary is decoded multiple times by the multi-layer decoder module of the text expansion model to obtain the expanded text output by the text expansion model; The text expansion loss of the text expansion model is calculated based on the target article in the pair of long and short text samples after expansion. The parameters of the text expansion model are adjusted based on the text expansion loss to obtain the trained text expansion model.
8. A text expansion device, characterized in that, include: The article acquisition unit is used to acquire candidate articles and multiple candidate key texts corresponding to the candidate articles; Abstract acquisition unit, used to acquire candidate article abstracts of the candidate articles; The coverage difference determination unit is used to determine the key text coverage difference of the candidate article and the candidate article summary to the candidate key text based on the candidate article, the candidate article summary and the candidate key text; The sample generation unit is used to select a target article and its corresponding target article summary from the candidate articles and candidate article summaries based on the key text coverage differences to obtain long and short article sample pairs. The model training unit is used to train the text expansion model to be trained based on the long and short text samples to obtain the trained text expansion model. The text expansion unit is used to expand the target text using the trained text expansion model to obtain the expanded long text of the target text.
9. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform the steps of the text expansion method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the text expansion method according to any one of claims 1 to 7.
11. A computer program product, characterized in that, It includes a computer program or instructions that, when executed by a processor, implement the steps of the text expansion method according to any one of claims 1 to 7.