Training of an extended writing model, text extended writing method and device, equipment and storage medium

CN122925530APending Publication Date: 2026-10-16TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510424974.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

但是,现有的扩写模型的扩写效果较差,导致扩写模型生成的扩写文本的准确率较低

Benefits of technology

[0024]本申请实施例提供的一种扩写模型的训练方法、装置、电子设备及存储介质,在本申请中,对文本样本扩写后的多个文本扩写样本构建多个文本扩写样本组合,并确定多个文本扩写样本组合各自的质量评分,而文本扩写样本组合的质量评分用于指示文本扩写样本组合中不同文本扩写样本之间的互补关系,并获取质量评分高于质量评分阈值的文本扩写样本组合,作为参考文本扩写样本组合,由此,在确定参考文本扩写样本组合时,考虑了同一个文本扩写样本组合不同文本扩写样本之间的互补关系,确定的参考文本扩写样本组合中各文本扩写样本可以相互互补,减少了参考文本扩写样本组合所包括的文本扩写样本冗余的情况,使得参考文本扩写样本组合所包括的文本扩写样本能够覆盖更多的扩写角度,避免各文本扩写样本不相互互补、各文本扩写样本冗余,导致文本扩写样本覆盖的扩写角度较少的情况发生,从而提高了基于参考文本扩写样本组合所包括的文本扩写样本训练后的扩写模型的模型效果,进而使得训练后的扩写模型所生成的扩写文本更加准确。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122925530A_ABST
    Figure CN122925530A_ABST
Patent Text Reader

Abstract

The application discloses a training method of an expansion writing model, a text expansion writing method and device, electronic equipment and a storage medium. The training method comprises the following steps: based on a plurality of text expansion writing samples obtained by expanding a text sample, a plurality of text expansion writing sample combinations are constructed; based on a plurality of related documents related to each text expansion writing sample in each text expansion writing sample combination, a quality score of each text expansion writing sample combination is determined; a text expansion writing sample combination with a quality score higher than a quality score threshold is obtained as a reference text expansion writing sample combination; and based on the text sample and the text expansion writing sample in the reference text expansion writing sample combination, the expansion writing model is trained. According to the training method, the model effect of the expansion writing model obtained by training is better, so that the expansion writing text generated by the expansion writing model is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic information technology, and more specifically, to a text expansion model training, text expansion method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the process of information retrieval, it is often necessary to expand the original text entered by the user, and then retrieve the response text based on the expanded text and the original text to improve the accuracy of the retrieved response text.

[0003] A related technology describes an expansion method that uses a trained expansion model to expand user-inputted original text to obtain expanded text. However, existing expansion models have poor expansion performance, resulting in low accuracy of the expanded text generated. Summary of the Invention

[0004] In view of this, embodiments of this application propose a text expansion model training method, apparatus, electronic device, and storage medium.

[0005] In a first aspect, embodiments of this application provide a method for training an expansion model. The method includes: constructing multiple text expansion sample combinations based on multiple text expansion samples obtained by expanding text samples; each text expansion sample combination includes at least two text expansion samples; determining the quality score of each text expansion sample combination based on multiple related documents related to each text expansion sample in each text expansion sample combination; the quality score of the text expansion sample combination is used to indicate the complementary relationship between different text expansion samples in the text expansion sample combination; obtaining text expansion sample combinations with quality scores higher than a quality score threshold as reference text expansion sample combinations; and training the expansion model based on the text samples and the text expansion samples in the reference text expansion sample combinations.

[0006] Secondly, embodiments of this application provide a text expansion method, the method comprising: obtaining target text to be expanded; expanding the target text using an expansion model to obtain expanded target text corresponding to the target text; the expansion model being trained according to the method described in the first aspect above.

[0007] Thirdly, embodiments of this application provide a training apparatus for an expansion model. The apparatus includes: a construction module, used to construct multiple text expansion sample combinations based on multiple text expansion samples obtained after expanding text samples; each text expansion sample combination includes at least two text expansion samples; a first determination module, used to determine the quality score of each text expansion sample combination based on multiple related documents related to each text expansion sample in each text expansion sample combination; the quality score of the text expansion sample combination is used to indicate the complementary relationship between different text expansion samples in the text expansion sample combination; a second determination module, used to obtain text expansion sample combinations with quality scores higher than a quality score threshold as reference text expansion sample combinations; and a training module, used to train the expansion model based on the text samples and the text expansion samples in the reference text expansion sample combinations.

[0008] Optionally, the first determining module is further configured to, for each text expansion sample combination, perform deduplication processing on multiple related documents related to each text expansion sample in the text expansion sample combination to obtain a deduplicated document set corresponding to the text expansion sample combination; and, based on the related documents in the deduplicated document set corresponding to the text expansion sample combination, perform a quality score on the text expansion sample combination to obtain a quality score for the text expansion sample combination.

[0009] Optionally, the first determining module is further configured to perform a relevance score on each relevant document based on the text sample, thereby obtaining a relevance score for each relevant document; the relevance score of the relevant document is used to indicate the degree of relevance between the relevant document and the text sample; for each text expansion sample combination, a quality score is performed on the text expansion sample combination based on the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination, thereby obtaining a quality score for the text expansion sample combination.

[0010] Optionally, the first determining module is further configured to sum the relevance scores of each relevant document in the deduplicated document set corresponding to each text expansion sample combination, and use the summation result as the quality score of the text expansion sample combination.

[0011] Optionally, the first determining module is further configured to perform a relevance score on each relevant document based on the relevance scoring requirements, the text sample, and the contextual information of the text sample, thereby obtaining a relevance score for each relevant document.

[0012] Optionally, the first determining module is further configured to construct relevance scoring prompt information for each relevant document based on the relevance scoring requirements, text samples, context information of the text samples, and relevant documents; input the relevance scoring prompt information into the large language model for relevance scoring, and obtain the relevance score output by the large language model for the relevant document.

[0013] Optionally, the second determining module is also used to determine a quality score threshold based on the quality score of a combination of multiple text expansion samples.

[0014] Optionally, the second determining module is also used to perform mean processing on the quality scores of multiple text expansion sample combinations, and obtain the mean-processed result as the quality score threshold.

[0015] Optionally, the building module is also used to expand the text sample based on the specified expansion requirements and the context information of the text sample, so as to obtain multiple text expansion samples that meet the specified expansion requirements.

[0016] Optionally, the construction module is also used to construct expansion prompt information corresponding to the text sample based on the specified expansion requirements, the text sample, and the context information of the text sample; input the expansion prompt information into the large language model text expansion processing to obtain multiple text expansion samples output by the large language model.

[0017] Optionally, the first determining module is further configured to, for each text expansion sample, determine the degree of document relevance between the text expansion sample and each preset document in the retrieval database; and select a specified number of preset documents from the retrieval database in descending order of document relevance as relevant documents related to the text expansion sample.

[0018] Optionally, the training module is also used to obtain multiple text expansion sample combinations, excluding the reference text expansion sample combination, as candidate text expansion sample combinations; construct positive sample data based on the text samples and the text expansion samples in the reference text expansion sample combination; construct negative sample data based on the text samples and the text expansion samples in the candidate text expansion sample combination; and train the expansion model based on the positive sample data and the negative sample data.

[0019] Fourthly, embodiments of this application provide a text expansion device, the device comprising: an acquisition module for acquiring target text to be expanded; and an expansion module for expanding the target text using an expansion model to obtain expanded target text corresponding to the target text; the expansion model is trained according to the method described in the first aspect above.

[0020] Optionally, the device further includes a retrieval module for retrieving response text based on the target text and the target expanded text, obtaining response text of the target text and response text of the target expanded text; and performing text merging processing on the response text of the target text and the response text of the target expanded text to obtain the target response text for the target text.

[0021] Fifthly, embodiments of this application provide an electronic device, including a processor and a memory; the memory stores computer-readable instructions, which, when executed by the processor, implement the above-described method.

[0022] Sixthly, embodiments of this application provide a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the above-described method.

[0023] In a seventh aspect, embodiments of this application provide a computer program product, including computer instructions, which, when executed by a processor, implement the method described above.

[0024] This application provides a training method, apparatus, electronic device, and storage medium for an expanded text model. In this application, multiple text expanded sample combinations are constructed from multiple text expanded samples after text sample expansion, and the quality scores of each of the multiple text expanded sample combinations are determined. The quality scores of the text expanded sample combinations are used to indicate the complementary relationship between different text expanded samples in the text expanded sample combination. Text expanded sample combinations with quality scores higher than a quality score threshold are obtained as reference text expanded sample combinations. Therefore, when determining the reference text expanded sample combinations, different text expanded samples within the same text expanded sample combination are considered. The complementary relationship between the reference text expansion samples ensures that each expansion sample in the determined reference text expansion sample combination can complement the others, reducing redundancy in the text expansion samples included in the reference text expansion sample combination. This allows the text expansion samples included in the reference text expansion sample combination to cover more expansion angles, avoiding situations where the text expansion samples are not complementary or are redundant, resulting in fewer expansion angles covered by the text expansion samples. This improves the model performance of the expansion model trained based on the text expansion samples included in the reference text expansion sample combination, and consequently makes the expanded text generated by the trained expansion model more accurate. Attached Figure Description

[0025] 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.

[0026] Figure 1 A schematic diagram is shown illustrating the application scenarios applicable to the embodiments of this application;

[0027] Figure 2 A flowchart illustrating a training method for an extended model according to an embodiment of this application is shown;

[0028] Figure 3 It shows Figure 2 A flowchart of step S120 in one embodiment is shown in the corresponding example;

[0029] Figure 4 It shows Figure 2 A flowchart of step S140 in one embodiment is shown in the corresponding example;

[0030] Figure 5 A flowchart of a text expansion method according to an embodiment of this application is shown;

[0031] Figure 6 A schematic diagram illustrating the training process of an extension model according to an embodiment of this application is shown;

[0032] Figure 7 A block diagram of a training apparatus for an extended model according to one embodiment of this application is shown;

[0033] Figure 8 A block diagram of a text expansion device according to one embodiment of this application is shown;

[0034] Figure 9 A structural block diagram of an electronic device for performing a training method for an expanded model according to an embodiment of this application is shown. Detailed Implementation

[0035] 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 some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0036] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0037] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit the application. It should be noted that "multiple" as used herein refers to two or more. "And / or" describes the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.

[0038] Please refer to Figure 1 The diagram illustrates an application scenario applicable to the embodiments of this application. This application scenario includes a terminal 110, a server 120, and a database 130.

[0039] Terminal 110 can be a smartphone, tablet, e-book reader, music player, wearable device, smart home device, in-vehicle terminal, etc. Terminal 110 has a client installed, which can send the target text to be expanded. For example, the client can be an instant messaging client, content interaction client, email client, SMS client, etc.

[0040] The server 120 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0041] Database 130 can be a standalone physical storage device, a database cluster or distributed system consisting of multiple physical storage devices, or a cloud storage database providing cloud storage functionality. The database is used to store the object behavior characteristics of multiple objects to be analyzed, as well as the object behavior characteristics of multiple sample objects.

[0042] In some embodiments, server 120 obtains text samples from database 130, expands the text samples to obtain multiple expanded text samples, and constructs multiple combinations of expanded text samples based on the multiple expanded text samples. Then, server 120 determines the quality score of each expanded text sample combination based on multiple related documents related to each expanded text sample in each expanded text sample combination. Based on the quality scores of multiple expanded text sample combinations, server 120 obtains the expanded text sample combinations with quality scores higher than the quality score threshold as reference expanded text sample combinations. Finally, server 120 trains the expansion model based on the text samples and the expanded text samples in the reference expanded text sample combinations.

[0043] Correspondingly, terminal 110 can respond to the user's operation by generating and sending target text to server 120. In response to the target text, server 120 expands the target text using the trained expansion model to obtain expanded target text. Then, server 120 performs a response text retrieval based on the expanded target text and the target text to obtain the target response text, and returns the target response text to terminal 110 so that terminal 110 can display the target response text.

[0044] Of course, in some embodiments, the server 120 may directly respond to the user's operation, generate the target text, and expand the target text using the trained expansion model to obtain the expanded target text.

[0045] Alternatively, terminal 110 can obtain text samples from database 130 through server 120, and then train an expansion model based on the text samples. This allows terminal 110 to expand the target text using its own trained expansion model, enabling terminal 110 to expand the text locally. Afterward, terminal 110 can retrieve the response text based on the target expanded text and the target text to obtain the target response text.

[0046] Alternatively, after training the expansion model, the server 120 sends the trained expansion model to the terminal 110, which stores the trained expansion model so that the terminal 110 can expand the target text using its stored expansion model. After expanding the text, the terminal 110 performs a response text retrieval based on the target expanded text and the target text to obtain the target response text.

[0047] For ease of understanding, the following explanation will use electronic devices as the training method for the text expansion model and the execution subject for the text expansion method in this application.

[0048] Please see Figure 2 , Figure 2This application presents a flowchart illustrating a training method for an extended model according to an embodiment of the present application. This method is applied to an electronic device, which may be... Figure 1 The terminal 110 or server 120 in the middle, the method may include:

[0049] S110. Based on the multiple text expansion samples obtained after expanding the text samples, construct multiple text expansion sample combinations.

[0050] Each text expansion sample combination includes at least two text expansion samples.

[0051] Text samples refer to the text used as training samples for training the expansion model. Text samples can be any form of sample. For example, a text sample could be "How is xxx company?", or "Where can we go for fun on the weekend?", or "Please recommend a mobile phone?".

[0052] In this application, text in various forms can be obtained from a network platform or a given database as text samples, or text from human-computer dialogue scenarios can be extracted as text samples. Then, the text samples are expanded to obtain multiple expanded text samples.

[0053] Users can manually expand the text sample based on their actual needs to obtain multiple expanded text samples. For example, the text sample could be "How is company xxx?", and the resulting expanded text samples could be "What are the operating revenue and profit of company xxx?" and "How is the performance and competitiveness of company xxx?".

[0054] Of course, electronic devices can also expand text samples based on specified expansion requirements and contextual information of the text samples to obtain multiple text expansion samples that meet the specified expansion requirements.

[0055] The contextual information of a text sample refers to the information mentioned before the text sample when it is presented. For example, if the text sample is text presented by a person in a human-computer dialogue scenario, then the contextual information of the text sample can be the preceding dialogue generated during the human-computer dialogue before the person presents the text sample; or, if the text sample is text in a text document (such as news articles and literary works, or documents obtained by converting speech to text), then the contextual information of the text sample can be the text information in the document that precedes the text sample.

[0056] The specified expansion requirements can refer to the requirements that the text expansion samples generated by the Large Language Model (LLM) need to meet. These requirements may include the number of multiple text expansion samples, the semantic requirements that the generated text expansion samples need to meet, and the content requirements.

[0057] In other words, electronic devices can determine the context of a text sample based on its contextual information, and then expand the text sample according to specified expansion requirements based on the context, to obtain multiple expanded text samples that meet the specified expansion requirements.

[0058] This can be achieved by using a pre-set expansion model to expand text samples based on specified expansion requirements and contextual information, resulting in multiple expanded text samples that meet the specified expansion requirements. The pre-set expansion model can be a trained Long Short-Term Memory Neural Network, Recurrent Neural Network, or Transformer model, etc. The pre-set expansion model can be trained based on reference text, its contextual information, the specified expansion requirements, and the expanded reference text. The interpretation of the reference text and its contextual information is the same as described above regarding text samples and their contextual information, and will not be repeated here. The reference expanded text can be a high-quality reference expanded text manually edited by the user.

[0059] In some other embodiments, the electronic device may also construct expansion prompt information corresponding to the text sample based on the specified expansion requirements, the text sample and the context information of the text sample; input the expansion prompt information into the large language model for text expansion processing to obtain multiple text expansion samples output by the large language model.

[0060] The expansion prompt (or prompt message) is used to instruct the large language model to generate multiple text expansion samples. This can include specified expansion requirements, text samples, and contextual information about the text samples, so that the large language model can generate text expansion samples based on the text samples and their contextual information, according to the specified expansion requirements. Here, the large language model can be ChatGPT. TM Yuanbao TM deepseek TM wait.

[0061] For example, specified expansion requirements may include "the number of multiple text expansion samples is 20", "correcting possible typos in user text by combining Chinese semantics", "removing redundant expressions from user text while retaining as much semantic information as possible from the original latest text", and "expanding from multiple different angles and directions to enhance richness for subsequent retrieval", etc. Correspondingly, the constructed expansion prompt information is:

[0062] "You are a Chinese expert. Please rewrite and expand the user's current query into {20} parts, based on the user's previous dialogue information, to make it more suitable for retrieval. The requirements are as follows:"

[0063] 1. Based on the semantic meaning of the Chinese text, correct any typos that may exist in the user's text;

[0064] 2. Remove redundant expressions from user text, but retain as much of the original, up-to-date semantic information as possible;

[0065] 3. Expand and enrich the content from multiple different angles and directions to make it suitable for subsequent retrieval.

[0066] [Preliminary Dialogue]

[0067] {context}

[0068] [Current query]

[0069] {q}”

[0070] Here, the current query refers to the text sample, and the preceding dialogue refers to the context information of the text sample. Of course, it is understood that the aforementioned expansion prompt is just an example, and the created expansion prompt can also take other forms. The expansion prompt only needs to include the specified expansion requirements, the text sample, and the context information of the text sample.

[0071] After obtaining the expansion prompts, the expansion prompts can be input into the large language model. The large language model can then expand the text samples based on the expansion prompts to obtain multiple expanded text samples.

[0072] After determining multiple text expansion samples according to the aforementioned process, a combination of text expansion samples is constructed based on the multiple text expansion samples, ensuring that each combination of text expansion samples includes at least two text expansion samples.

[0073] This can be achieved by randomly grouping multiple text expansion samples, ensuring that each group includes at least two text expansion samples. For example, if there are 100 text expansion samples, they can be evenly grouped to obtain 10 text expansion sample combinations, with each combination containing 10 text expansion samples.

[0074] Alternatively, multiple sampling can be performed, where some text expansion samples are randomly sampled from multiple text expansion samples each time to construct a text expansion sample combination. Multiple samplings are performed to obtain multiple text expansion sample combinations. In this case, the different text expansion sample combinations obtained may include the same text expansion sample.

[0075] For example, the set of multiple expanded text samples after expanding a text sample Q is Q. n : {q1,q2,……,q N}, where q i Let Q be the i-th text expansion sample, and N be the total number of text expansion samples. n :{q1,q2,……,q n} Select K queries (text expansion samples) from the given list and combine them. Such combinations are: One possibility, arbitrarily select M times. M combinations of text expansion samples were obtained. : Each text expansion sample combination Both contain K queries. In this case, Both can include text expansion samples q1 and q2.

[0076] S120. Based on multiple related documents associated with each text expansion sample in each text expansion sample combination, determine the quality score for each text expansion sample combination.

[0077] The quality score of the text expansion sample combination is used to indicate the complementary relationship between different text expansion samples in the combination. The stronger the complementary relationship between different text expansion samples in the combination, the more complementary the different text expansion samples in the combination can achieve a complementary effect, and the higher the quality score of the corresponding text expansion sample combination. Conversely, the weaker the complementary relationship between different text expansion samples in the combination, the less complementary the different text expansion samples in the combination can achieve a complementary effect, and the lower the quality score of the corresponding text expansion sample combination.

[0078] Generally, the less repetitive information and semantic similarity between different text expansion samples, the stronger the complementary relationship between them. Conversely, the more repetitive information or semantic similarity, the weaker the complementary relationship. For example, the text expansion samples "What are the operating revenue and profit of company xxx?" and "What are the revenue and profit of company xxx?" have a lot of repetitive information and semantic similarity (operating revenue is equivalent to revenue, and profit is equivalent to profit), resulting in a weak complementary relationship between them. On the other hand, the text expansion samples "What are the operating revenue and profit of company xxx?" and "What are the performance and competitiveness of company xxx?" have less repetitive information and semantic similarity (operating revenue is not equivalent to performance, and profit is not equivalent to competitiveness), resulting in a strong complementary relationship between them.

[0079] In this application, for each text sample, multiple related documents can be indexed. Then, for the text expansion samples in the same text expansion sample combination, the document similarity between the related documents corresponding to different text expansion samples can be compared, and the quality score corresponding to the text expansion sample combination can be determined based on the document similarity between the related documents corresponding to different text expansion samples.

[0080] In this application, for each text expansion sample, the degree of document relevance between the text expansion sample and each preset document in the retrieval database is determined; a specified number of preset documents are selected from the retrieval database according to the degree of document relevance from high to low as the relevant documents related to the text expansion sample.

[0081] The retrieval database refers to the data used to store documents. The retrieval database can store multiple preset documents. The document relevance here can be the similarity between the text expansion sample and the preset documents (the similarity can be determined using Boolean models, vector space models, probabilistic models, and language models, etc.).

[0082] After determining the relevance of the documents, a specified number of pre-defined documents can be selected from the search database in descending order of relevance as relevant documents for the text expansion sample. The specified number can be set based on requirements; for example, 10 documents.

[0083] At this point, for any text expansion sample q i In other words, the relevant documents retrieved can be denoted as {d} i1 ,d i2 ,……,d im} where m is the number of relevant documents for the text expansion sample. In this case, for a combination of text expansion samples including n text expansion samples, the number of relevant documents is m*n, denoted as D. n :{{d 11 ,d 12 ,……,d 1m},{d 21 ,d 22 ,……,d 2m},……,{d n1 ,d n2 ,……,d nm}}.

[0084] Specifically, for text expansion samples in the same text expansion sample combination, the document similarity between related documents corresponding to different text expansion samples can be compared (document similarity can be determined using Boolean model, vector space model, probability model and language model, etc.). Then, the document similarity between related documents corresponding to different text expansion samples is summed, averaged and multiplied. Based on the obtained calculation results, the quality score corresponding to the text expansion sample combination is determined. Here, the reciprocal or negative value of the calculation result can be used to obtain the quality score. A larger result indicates greater similarity between related documents corresponding to different text expansion samples, higher correlation between these documents, and thus greater similarity between different text expansion samples associated with different related documents. Consequently, the different text expansion samples associated with different related documents are less complementary, and the quality score should be lower. Conversely, a smaller result indicates less similarity between related documents corresponding to different text expansion samples, lower correlation between these documents, and thus lower similarity between different text expansion samples associated with different related documents. Consequently, the different text expansion samples associated with different related documents are more complementary, and the quality score should be higher. Therefore, taking the reciprocal or a complex number of the calculation result achieves a negative correlation between the calculation result and the quality score.

[0085] For text expansion samples a1 and a2 in the same text expansion sample combination a, the related documents a11 and a12 corresponding to a1, and the related documents a21 and a22 corresponding to a1, the document similarity between a11 and a21 and a22 is determined, and the document similarity between a11 and a21 and a22 is determined, so as to obtain four similarity scores. Then, the four similarity scores are summed, averaged, and multiplied. The reciprocal of the result is used as the quality score of the text expansion sample combination a.

[0086] In some implementations, for any given combination of text expansion samples, the document similarity between related documents corresponding to different text expansion samples in that combination can be compared. Then, operations such as summing, averaging, and multiplying the document similarities between related documents corresponding to different text expansion samples are performed to obtain the similarity calculation result. Based on the relevance scores of the related documents corresponding to the text expansion samples in that combination, the relevance calculation result is determined. Based on the similarity calculation result and the relevance calculation result, the quality score of the text expansion sample combination is determined. Here, the relevance score of the related documents is used to indicate the degree of relevance between the related documents and the text samples.

[0087] For any given combination of text expansion samples, the higher the relevance between the relevant document and the text sample, the better the relevant document answers the text sample, and the higher the relevance score. Conversely, the lower the relevance between the relevant document and the text sample, the less the relevant document answers the text sample, and the lower the relevance score.

[0088] In this application, the relevance score of each relevant document can be obtained by scoring each relevant document based on the relevance scoring requirements, text samples, and contextual information of the text samples.

[0089] Relevance scoring requirements are the criteria that documents must meet when scoring their relevance. These requirements can include different preset relevance scores and their respective scoring standards. Therefore, electronic devices can determine the context of a text sample based on its contextual information, and then score the relevant documents according to the relevance scoring requirements based on that context, thus obtaining a relevance score for each document.

[0090] Optionally, a relevance score can be obtained by using a scoring model to score the relevance of each relevant document based on the relevance scoring requirements, text samples, and contextual information of the text samples. The scoring model can be a trained Long Short-Term Memory Neural Network, Recurrent Neural Network, or Transformer model, etc. The scoring model can be trained based on the text sample to be scored, the contextual information of the text sample to be scored, the relevance scoring requirements, the sample document, and the sample label of the sample document. The interpretation of the text sample to be scored and the contextual information of the text sample is the same as described above and will not be repeated here. The sample document can be any document, and the sample label of the sample document refers to the relevance score between the sample document and the text sample to be scored.

[0091] In some other embodiments, for each relevant document, the electronic device can also construct relevant document relevance score prompts based on relevance scoring requirements, text samples, contextual information of text samples, and relevant documents; input the relevant document relevance score prompts into a large language model for relevance scoring, and obtain the relevance score output by the large language model for the relevant document.

[0092] Relevance scoring prompts are used to guide the large language model in scoring relevance. These prompts can include relevance scoring requirements, text samples, contextual information about the text samples, and related documents. This allows the large language model to score the relevance of related documents based on the text samples and their context, according to the relevance scoring requirements, thus obtaining a relevance score for each document. Here, the large language model can be ChatGPT. TM Yuanbao TM deepseek TM wait.

[0093] For example, relevance scoring criteria could include "0 points: document is completely irrelevant and cannot answer the user's text," "1 point: document is partially relevant and can partially answer the user's text," and "2 points: document is completely relevant and can completely answer the user's text." Correspondingly, the constructed relevance scoring prompt would be:

[0094] "You are a Chinese expert. Based on the user's [previous dialogue] information, please determine whether the retrieved document [document] can answer the user's text [current query], and give it a score of 0-2. The meaning of the score is as follows:"

[0095] 0 points: The document is completely irrelevant and cannot answer the user's text.

[0096] 1 point: The document is partially relevant and answers the user's question partially.

[0097] 2 points: The document is completely relevant and fully answers the user's text question.

[0098]

document

[0099] {d}

[0100] [Preliminary Dialogue]

[0101] {context}

[0102] [Current query]

[0103] {q}”

[0104] In this context, "document" refers to any relevant document.

[0105] Thus, for each combination of text expansion samples, the relevance scores of the relevant documents corresponding to the text expansion samples in that combination are determined, so as to indicate the degree of relevance between the relevant documents and the text samples through the relevance scores.

[0106] In this embodiment, for any text expansion sample in a text expansion sample combination, the average relevance scores of the related documents associated with that text expansion sample can be calculated as the mean relevance score of that text expansion sample. Then, the mean relevance scores of all text expansion samples in the same text expansion sample combination are summed, multiplied, or averaged to obtain the relevance calculation result of the text expansion sample combination. Finally, the similarity calculation result and the relevance calculation result of the text expansion sample combination are summed to obtain the quality score of the text expansion sample combination.

[0107] S130. Obtain a combination of text expansion samples with a quality score higher than the quality score threshold, and use it as a reference combination of text expansion samples.

[0108] As mentioned earlier, the quality score is used to indicate the complementarity between different text expansion samples in a text expansion sample combination. Therefore, the more complementary the different text expansion samples in a determined text expansion sample combination, the better the text expansion sample combination. A higher quality score means that the different text expansion samples in the text expansion sample combination are more complementary. Therefore, in this application, text expansion sample combinations with quality scores higher than the quality score threshold can be obtained as reference text expansion sample combinations. In this way, text expansion sample combinations with strong complementarity between different text expansion samples can be selected. The quality score threshold can be, for example, 0.5 or 0.6.

[0109] In some embodiments, a quality score threshold can also be determined based on the quality scores of multiple text expansion sample combinations. That is, the quality score threshold is determined based on the quality scores of multiple text expansion sample combinations. For example, the quality scores of multiple text expansion sample combinations can be averaged to obtain the averaged result as the quality score threshold. Alternatively, the median and mode of the quality scores of multiple text expansion sample combinations can be obtained as the quality score threshold.

[0110] Because the quality scores of multiple text expansion sample combinations may differ in different scenarios (for example, in some scenarios, the quality scores of multiple text expansion sample combinations are all very high, while in others, the quality scores of multiple text expansion sample combinations are all very low), it is difficult to accurately distinguish the better-quality text expansion sample combinations by using a constant quality score threshold. Therefore, in this application, a quality score threshold is determined based on the quality scores of multiple text expansion sample combinations, thereby correlating the quality score threshold with the quality scores of each text expansion sample combination, so that the quality score threshold can be more accurate.

[0111] S140. The text expansion model is trained based on the text expansion samples in the combination of text samples and reference text expansion samples.

[0112] After selecting a high-quality reference text expansion sample combination from multiple text expansion sample combinations, the expansion model can be trained based on the original text samples and the text expansion samples from the reference text expansion sample combination to obtain an expansion model with high expansion capabilities. The expansion model can be a large language model with a small amount of data; for example, the expansion model can be a large language model with a size of 7 bytes.

[0113] In this embodiment, text samples can be input into the expansion model for expansion. The expansion model outputs multiple predicted expanded text samples. Then, based on the differences between the multiple predicted expanded text samples and the text expansion samples in the combination of reference expanded text samples, a loss value is determined (e.g., using a cross-entropy loss function or a mean squared error loss function). The expansion model is then adjusted according to the determined loss value until the training termination condition is met, resulting in the trained expansion model. The training termination condition can be that the loss value is less than a loss threshold (e.g., 0.01 or 0.1) or the number of iterations reaches the maximum number of iterations (e.g., 100,000 iterations).

[0114] In some implementations, based on the first expansion requirement, the text sample, and the context information of the text sample, a first expansion prompt information corresponding to the text sample is constructed. Then, the first expansion prompt information corresponding to the text sample is input into the expansion model, and the expansion model generates multiple predicted expanded text samples based on the expansion prompt information.

[0115] The first expansion requirement can refer to the requirements that the expanded text generated by the expansion model during the training phase (in this embodiment, it refers to the predicted expanded text sample generated by the expansion model) needs to meet. It can include the number of expanded texts, the semantic requirements that the expanded texts need to meet, and the content requirements, etc.

[0116] The first expansion prompt (i.e., the Prompt) is used to prompt the expansion model to generate multiple predicted expanded text samples. It may include the first expansion requirement, the text sample, and the context information of the text sample, so that the expansion model can generate text expanded samples according to the first expansion requirement based on the text sample and the context information of the text sample.

[0117] For example, specified expansion requirements may include "the number of expanded texts is 3", "correcting possible typos in the user text by combining Chinese semantics", "removing redundant expressions from the user text while retaining as much semantic information as possible from the original latest text", and "expanding from multiple different angles and directions to enhance richness for subsequent retrieval use", etc. Correspondingly, the training process data of the expansion model is shown in Table 1, as follows:

[0118] Table 1

[0119]

[0120] Wherein, id refers to the data identifier of the training data constructed based on different sample texts, preceding dialogue refers to the context information of the text sample, current query refers to the text sample, q11, a12 and q13 refer to the three predicted expanded text samples generated by the expansion model based on the first expansion prompt information constructed based on {context1} and {query1}, and q21, a22 and q23 refer to the three predicted expanded text samples generated by the expansion model based on the first expansion prompt information constructed based on {context2} and {query2}.

[0121] Of course, it is understandable that the aforementioned first expansion prompt is merely an example, and the created first expansion prompt can also take other forms. The first expansion prompt can include the first expansion requirement, the text sample, and the context information of the text sample.

[0122] It is important to note that in order to improve the expansion effect of the expansion model, the number of expanded texts in the first expansion requirement during the training phase can be multiple different values. In other words, the number of expanded texts output by the expansion model during the training phase can be varied. Different numbers of expanded texts can be generated from the trained expansion model, so that the trained expansion model can achieve the optimal expansion effect for different numbers of expansion tasks.

[0123] For example, the expansion model can be used for the RAG (Retrieval-Augmented Generation) task. RAG refers to retrieving relevant information from an external knowledge base before the large language model responds to the text, and then using the retrieved information to generate the response text. Specifically, the expansion model can expand the original text to obtain expanded text, then retrieve relevant information related to both the original text and the expanded text from the external knowledge base, and finally, the large language model generates the response text based on the relevant information of both the original text and the expanded text, thus obtaining the response text for the original text.

[0124] In this embodiment, multiple text expansion sample combinations are constructed from multiple expanded text samples, and the quality scores of each of the multiple text expansion sample combinations are determined. The quality scores of the text expansion sample combinations are used to indicate the complementary relationship between different text expansion samples in the text expansion sample combination. Text expansion sample combinations with quality scores higher than the quality score threshold are selected as reference text expansion sample combinations. Thus, when determining the reference text expansion sample combinations, the complementary relationship between different text expansion samples in the same text expansion sample combination is considered. The text expansion samples in the determined reference text expansion sample combinations can complement each other, reducing the redundancy of the text expansion samples included in the reference text expansion sample combinations. This allows the text expansion samples included in the reference text expansion sample combinations to cover more expansion angles, avoiding the situation where the text expansion samples are not complementary or are redundant, resulting in fewer expansion angles covered by the text expansion samples. This improves the model performance of the expansion model trained based on the text expansion samples included in the reference text expansion sample combinations, thereby making the expanded text generated by the trained expansion model more accurate.

[0125] In some embodiments, such as Figure 3 As shown, S120 may include:

[0126] S210. For each text expansion sample combination, perform deduplication on multiple related documents related to each text expansion sample in the text expansion sample combination to obtain the deduplicated document set corresponding to the text expansion sample combination.

[0127] As mentioned earlier, since text expansion samples are based on text samples, different text expansion samples have a certain degree of similarity. Therefore, the related documents identified for different text expansion samples may contain duplicate documents. That is, for each text expansion sample combination, there are duplicate documents among the multiple related documents of each text expansion sample in the combination. For example, in text expansion sample combination a, text expansion samples a1, a2, and a3, the related documents corresponding to a1 are a11 and a12, a21 and a22, and the related documents corresponding to a3 are a12 and a22. In this case, the six related documents corresponding to the three text expansion samples a1, a2, and a3 in text expansion sample combination a contain duplicate documents a12 and a22.

[0128] Therefore, it is necessary to perform deduplication on multiple related documents of each text expansion sample in the same text expansion sample combination to obtain the deduplicated result, which serves as the deduplicated document set corresponding to the text expansion sample combination. Deduplication means keeping only one duplicate document and deleting the others. For example, in the previous example, the related documents corresponding to text expansion samples a1, a2, and a3 are {a11, a12}, {a21, a22}, and {a12, a22}, respectively. In this case, a12 and a22 are duplicated once, so deleting the duplicate a12 and a22 will yield the deduplicated document set {a11, a12, a21, a22} corresponding to text expansion sample combination a.

[0129] In this way, by iterating through each text expansion sample combination, a set of deduplicated documents for each text expansion sample combination is obtained. For each text expansion sample combination, the quality score of the text expansion sample combination is determined based on the relevant documents in the set of deduplicated documents corresponding to that text expansion sample combination. As a result, there is no need to process duplicate data, which improves data processing efficiency and enables the quality score to be obtained quickly.

[0130] S220. Based on the relevant documents in the deduplicated document set corresponding to the text expansion sample combination, perform a quality score on the text expansion sample combination to obtain the quality score of the text expansion sample combination.

[0131] Once the set of deduplicated documents corresponding to the text expansion sample combination is obtained, the quality score of the text expansion sample combination can be determined based on the document similarity between related documents in the set of deduplicated documents corresponding to the text expansion sample combination.

[0132] For example, the document similarity between each pair of related documents in the deduplicated document set corresponding to the text expansion sample combination is determined, and the summation, product and average of the document similarities between each pair of related documents in the deduplicated document set corresponding to the text expansion sample combination are calculated to obtain the calculation results, and the quality score of the text expansion sample combination is determined based on the calculation results.

[0133] Here, the reciprocal or negative value of the calculation result can be used to obtain the quality score. A larger result indicates greater similarity between related documents corresponding to different text expansion samples, higher correlation between these documents, and thus greater similarity between different text expansion samples associated with different related documents. Consequently, the different text expansion samples associated with different related documents are less complementary, and the quality score should be lower. Conversely, a smaller result indicates less similarity between related documents corresponding to different text expansion samples, lower correlation between these documents, and thus lower similarity between different text expansion samples associated with different related documents. Consequently, the different text expansion samples associated with different related documents are more complementary, and the quality score should be higher. Therefore, taking the reciprocal or a complex number of the calculation result achieves a negative correlation between the calculation result and the quality score.

[0134] In some implementations, a relevance score can be obtained by scoring each relevant document based on the text sample; the relevance score of the relevant document is used to indicate the degree of relevance between the relevant document and the text sample; for each text expansion sample combination, a quality score is obtained by scoring the text expansion sample combination based on the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination.

[0135] In this embodiment, the process of determining the relevance score of relevant documents is described in the aforementioned embodiment S120, and will not be repeated here. For each combination of text expansion samples, the relevance score of each relevant document in the deduplicated document set corresponding to that combination of text expansion samples is determined, so as to indicate the degree of relevance between the relevant documents and the text samples through the relevance score.

[0136] In some implementations, for each text expansion sample combination, the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination can be summed, and the summed result can be used as the quality score of the text expansion sample combination.

[0137] For different combinations of text expansion samples, if they include the same number of text expansion samples, a higher quality score for the text expansion sample combination means a higher relevance score for the relevant documents corresponding to the text expansion samples in the text expansion sample combination, a higher degree of association between the relevant documents and the text samples, and thus a higher quality of the text expansion samples associated with the relevant documents. Therefore, when the quality score is obtained by summing the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination, the determined quality score can accurately indicate the quality of the text expansion samples in the text expansion sample combination.

[0138] Meanwhile, for different combinations of text expansion samples, if the relevance scores of the related documents associated with the text expansion samples are similar, and if the number of related documents corresponding to the text expansion sample combination is smaller, it means that the number of duplicate related documents associated with different text expansion samples in the text expansion sample combination is larger (the larger the number of duplicates, the smaller the number of duplicates after deduplication), and the higher the similarity between different text expansion samples in the text expansion sample combination (because the more duplicate related documents, the more the same related documents are shared by multiple text expansion samples, so the more similar the text content expressed by different text expansion samples is, and the higher the similarity between different text expansion samples), the weaker the complementary relationship between different text expansion samples in the text expansion sample combination, and thus the lower the quality score obtained. Conversely, the more relevant documents a text expansion sample combination corresponds to, the fewer duplicate documents there are (fewer duplicates mean more duplicates), and the lower the similarity between different text expansion samples in the combination (because fewer duplicate documents mean fewer documents shared by multiple text expansion samples, resulting in less similarity between different text expansion samples). This also strengthens the complementary relationship between different text expansion samples in the combination, leading to a higher quality score. Therefore, when calculating the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination to obtain the quality score, the determined quality score accurately indicates the complementary relationship between different text expansion samples in the combination.

[0139] In summary, by summing the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination, a quality score for the text expansion sample combination is obtained. This quality score not only evaluates the quality of the text expansion samples in the text expansion sample combination, but also evaluates the complementary relationship between different text expansion samples in the text expansion sample combination.

[0140] It is worth noting that, in order for the quality score to accurately indicate the complementary relationship between different text expansion samples in a text expansion sample combination, the relevance scores of duplicate related documents cannot be repeatedly accumulated. Therefore, the aforementioned deduplication process is required for the related documents corresponding to each text expansion sample in the text expansion sample combination. This is because, for any text expansion sample combination, if there are duplicate related documents corresponding to each text expansion sample in the combination, it means that multiple text expansion samples in the combination share the same related document. Text expansion samples sharing the same related document have high similarity, and the complementary relationship between them is weak. If the relevance scores of duplicate related documents are repeatedly accumulated, the quality score of the text expansion sample combination will be high. In this case, the quality score cannot accurately indicate the weak complementary relationship between the text expansion samples. However, by not repeatedly accumulating the relevance scores of duplicate related documents, when multiple text expansion samples in a combination share related documents, the quality score of the determined text expansion sample combination is lower, which can indicate the weak complementary relationship between the text expansion samples.

[0141] In this embodiment, multiple related documents associated with each text expansion sample in the text expansion sample combination are deduplicated to obtain a deduplicated document set corresponding to the text expansion sample combination. Then, based on the relevance scores of each related document in the deduplicated document set corresponding to the text expansion sample combination, the quality score of the text expansion sample combination is determined. The determined quality score not only evaluates the quality of the text expansion samples in the text expansion sample combination, but also evaluates the complementary relationship between different text expansion samples in the text expansion sample combination. This makes the quality score more accurately indicate the quality of the text expansion sample combination, thereby improving the quality of the determined reference text expansion sample combination and enhancing the expansion effect of the expansion model trained based on the reference text expansion sample combination. This makes the expanded text after expansion by the expansion model more accurate.

[0142] In yet another embodiment, such as Figure 4 As shown, S140 includes:

[0143] S310. Obtain the text expansion sample combination other than the reference text expansion sample combination from multiple text expansion sample combinations as candidate text expansion sample combinations.

[0144] As mentioned above, multiple text expansion sample combinations are obtained, and reference text expansion sample combinations are determined according to the aforementioned process S110-S130. Then, the text expansion sample combinations other than the reference multiple text expansion sample combinations can be used as candidate text expansion sample combinations.

[0145] S320. Construct positive sample data based on the text samples and the text expansion samples in the combination of text samples and reference text expansion samples; construct negative sample data based on the text samples and the text expansion samples in the combination of text samples and candidate text expansion samples.

[0146] Since the reference text expansion sample combination is a high-quality combination, and the text expansion samples it includes are also relatively good expansions, the text sample and the text expansion samples in the reference text expansion sample combination can be directly used as positive sample data. On the other hand, the candidate text expansion sample combination is a low-quality combination, and the text expansion samples it includes are also relatively poor expansions. Therefore, the text sample and the text expansion samples in the candidate text expansion sample combination can be directly used as negative sample data. Thus, positive sample data indicates relatively good expansions, and negative sample data indicates relatively poor expansions. In this way, for the same text sample, one positive sample data and one negative sample data are obtained, forming a positive-negative sample pair, thereby achieving the purpose of constructing positive-negative sample pairs for the text sample.

[0147] For example, the reference text expansion sample combination b1 corresponding to text sample b includes three text expansion samples: b11, b12, and b13, and the candidate text expansion sample combination b2 corresponding to text sample b includes three text expansion samples: b21, b22, and b23. In this case, text samples b, b11, b12, and b13 can be obtained as positive sample data corresponding to text sample b, and text samples b, b21, b22, and b23 can be obtained as negative sample data corresponding to text sample b.

[0148] S330. The expansion model is trained based on positive and negative sample data.

[0149] After obtaining the corresponding positive and negative sample data for each text sample, the expansion model can be trained based on the corresponding positive and negative sample data.

[0150] The process can involve inputting text samples into an expansion model for expansion, with the expansion model outputting multiple predicted expanded text samples. Then, based on the differences between the multiple predicted expanded text samples and the text expanded samples in the positive sample data, a positive sample loss value is determined (e.g., using a cross-entropy loss function or a mean squared error loss function). Similarly, based on the differences between the multiple predicted expanded text samples and the text expanded samples in the negative sample data, a negative sample loss value is determined (e.g., using a cross-entropy loss function or a mean squared error loss function). Finally, based on the positive and negative sample loss values, a model loss value is determined. The expansion model is then adjusted according to the determined model loss value.

[0151] When training the expansion model, the optimization objective is to minimize the differences between multiple predicted expanded text samples and the text expanded samples in the positive sample data, and to maximize the differences between multiple predicted expanded text samples and the text expanded samples in the negative sample data. Therefore, the model loss can be determined with this optimization objective as a reference. For example, the model loss can be calculated by summing the reciprocal of the negative sample loss value (or by taking a negative value, etc., to achieve a negative correlation between the negative sample loss value and the model loss value) and the positive sample loss value. Thus, the smaller the model loss, the smaller the positive sample loss value and the larger the negative sample loss value. This means that the differences between multiple predicted expanded text samples and the text expanded samples in the positive sample data are smaller, and the differences between multiple predicted expanded text samples and the text expanded samples in the negative sample data are larger. Therefore, by minimizing the model loss when training the expansion model, the aforementioned optimization objective can be achieved.

[0152] In this embodiment, positive and negative sample data are constructed for the text samples. Through comparative learning of positive and negative sample data, the expansion model can learn good expansion features from good expansions and bad expansion features from bad expansions. This enables the trained expansion model to more accurately distinguish between good and bad expansions, resulting in more accurate and higher-quality expanded text generated by the trained expansion model.

[0153] Please see Figure 5 , Figure 5 This application illustrates a flowchart of a text expansion method according to an embodiment of the present application. The method is applied to an electronic device, which may be... Figure 1 The terminal 110 or server 120 in the middle, the method may include:

[0154] S410. Obtain the target text to be expanded.

[0155] The target text to be expanded can be any form of text. For example, the target text to be expanded can be any text proposed by a person in a human-computer dialogue scenario, or any text in a text document.

[0156] S420. Expand the target text using the expansion model to obtain the expanded target text corresponding to the target text.

[0157] The expansion model is trained according to any of the methods in the aforementioned embodiments, which will not be repeated here.

[0158] First, the contextual information of the target text can be obtained. Then, based on the second expansion requirement, the target text, and the contextual information of the target text, the second expansion prompt information corresponding to the target text is constructed. Then, the second expansion prompt information corresponding to the target text is input into the expansion model, and the expansion model generates multiple predicted expansion texts based on the second expansion prompt information, which serve as the expansion target text.

[0159] The second expansion requirement refers to the requirements that the expanded text generated by the expansion model during the inference phase (in this embodiment, it refers to the expanded target text generated by the expansion model) must meet. This can include the number of expanded texts, the semantic requirements the expanded texts must meet, and content requirements. It is easy to understand that both the second and first expansion requirements are specific to the expansion model; therefore, the second and first expansion requirements can be the same or similar. For example, the only difference between the second and first expansion requirements is the number of expanded texts generated by the expansion model. The semantic and content requirements that the expanded texts must meet are consistent between the second and first expansion requirements.

[0160] Similarly, the second expansion prompt information is used to prompt the expansion model to generate multiple expansion target texts. It may include the second expansion requirements, the target text, and the context information of the target text, so that the expansion model can generate the expansion target text according to the second expansion requirements based on the target text and the context information of the target text.

[0161] After obtaining the second expansion prompt, the second expansion prompt is input into the expansion model. The expansion model generates multiple predicted expansion texts based on the second expansion prompt. These multiple predicted expansion texts can all be used as expansion target texts, or one can be randomly selected as the expansion target text. In this way, the expansion of the target text is realized.

[0162] In some implementations, after S420, the method further includes: retrieving response text based on the target text and the target expanded text to obtain response text of the target text and response text of the target expanded text; and performing text merging processing on the response text of the target text and the response text of the target expanded text to obtain the target response text for the target text.

[0163] The purpose of text expansion is to obtain more text, and then use more text to index the response text, thereby obtaining a more accurate and content-rich response text based on the response text of multiple texts. Therefore, after obtaining the expansion target text, response texts can be retrieved based on the expansion target text and the target text respectively, to obtain the expansion target text and the response text of the target text. Then, the expansion target text and the corresponding response text of the target text are merged to obtain the target response text, so that the target response text is rich and accurate.

[0164] For example, in a human-computer dialogue scenario, a user inputs the target text "How is company xxx?". Based on this target text, the expansion model expands it to include "What are the revenue and profit of company xxx?" and "How is the performance and competitiveness of company xxx?". Then, response texts can be generated based on these three texts, resulting in three response texts. These three response texts are then merged into one response text to obtain the target response text. At this point, the target response text is relatively complete, not only including the response text for "How is company xxx?", but also involving information such as company xxx's performance, competitiveness, revenue, and profit. The content of the target response text is rich and accurate.

[0165] Specifically, in the field of information retrieval, if the information retrieved from the database is relevant to the target text, the retrieval score is determined to be 1; if the retrieved information is irrelevant to the target text, the retrieval score is determined to be 0. Then, the effectiveness of different methods is measured based on ndcg@5 (normalized depreciated cumulative gain) and recall@5 (recall rate). The data obtained is shown in Table 2, where 5 represents the top 5 most similar entries selected from the database. Table 2 is as follows:

[0166] Table 2

[0167]

[0168]

[0169] Here, "original" refers to directly retrieving information using the target text. "Rewrite" refers to expanding the original target text into an expanded target text, and then using the expanded target text for retrieval. "Expansion" refers to expanding the original target text into three expanded target texts, and then using the three expanded target texts and the original target text for retrieval.

[0170] As shown in Table 2, when rewriting and expanding using the method described in this application, both ndcg@5 (normalized loss cumulative gain) and recall@5 (recall rate) are relatively high. This means that when the expanded target text based on the expansion model of this application is retrieved, the retrieved information is highly relevant to the original target text, the expanded target text is highly relevant to the target text, the expansion effect of the expansion model is good, and the expanded target text is more accurate.

[0171] In this embodiment, the expansion model is trained based on each text expansion sample in the reference text expansion sample combination. The text expansion samples in the reference text expansion sample combination can complement each other, reducing the redundancy of the text expansion samples included in the reference text expansion sample combination. This allows the text expansion samples included in the reference text expansion sample combination to cover more expansion angles, avoiding the situation where the text expansion samples are not complementary or are redundant, resulting in fewer expansion angles covered by the text expansion samples. This improves the model performance of the expansion model trained based on the text expansion samples included in the reference text expansion sample combination, and makes the expanded target text generated by the trained expansion model based on the target text more accurate.

[0172] To explain the scheme of this application more clearly, the training process of the extended model of this application will be explained below with an example.

[0173] In this example, sample text is determined from the dialogue information generated by the human-computer dialogue, and the preceding dialogue before the sample text is obtained as the context information of the sample text.

[0174] like Figure 6 As shown, firstly, based on the sample text, the context information of the sample text, and the specified expansion requirements, expansion prompts are determined, and the large language model performs preliminary expansion based on the expansion prompts to obtain n text expansion samples: q1, q2, ..., qn.

[0175] Subsequently, relevant documents related to each text expansion sample in each combination of text expansion samples are retrieved from the retrieval database, and the relevance score of each relevant document is determined by a large language model (the large language model determines the relevance score of relevant documents based on the relevance score prompt information of relevant documents, where the relevance score requirements, text samples, context information of text samples, and relevant documents are used to determine the relevance score prompt information of relevant documents), so as to indicate the degree of relevance between relevant documents and text samples through the relevance score of relevant documents.

[0176] For example, Figure 6In the above, the relevance score determined for document d11 related to q1 is 2, the relevance score determined for document d12 related to q1 is 0, the relevance score determined for document d13 related to q1 is 1, the relevance score determined for document d21 related to q2 is 1, the relevance score determined for document d22 related to q2 is 2, the relevance score determined for document d23 related to q2 is 1, ..., the relevance score determined for document dn1 related to qn is 0, the relevance score determined for document dn2 related to qn is 2, and the relevance score determined for document dn3 related to qn is 1.

[0177] Subsequently, multiple random samplings are performed based on n text expansion samples. Each random sampling of multiple text expansion samples constructs a text expansion sample combination. Then, the relevant documents corresponding to each text expansion sample in each text expansion sample combination are deduplicated to obtain a set of deduplicated documents for each text expansion sample combination. Each text expansion sample combination is then evaluated to determine its quality score: the relevance scores of each relevant document in the corresponding set of deduplicated documents are summed to obtain the quality score for each text expansion sample combination.

[0178] For example Figure 6 In the given text, the related document d11 of q1 is the same as the related document d22 of q2, and the related document d13 of q1 is the same as the related document d21 of q2. Therefore, if q1 and q2 are combined into a single text expansion sample, the quality score of this sample is 2+0+1+1 = 4. Similarly, the related document d21 of q2 is the same as the related document dn3 of qn. Therefore, if q2 and qn are combined into a single text expansion sample, the quality score of this sample is 1+2+1+0+2 = 6.

[0179] After obtaining the quality scores corresponding to each text expansion sample combination, a reference text expansion sample combination can be determined from multiple text expansion sample combinations. Then, the text expansion samples and text samples in the reference text expansion sample combination are used to construct training data, and the expansion model is trained using the training data.

[0180] Of course, after training the expansion model, it can also be used in human-computer dialogue scenarios to expand the text based on a certain text proposed by the user in the human-computer dialogue scenario and the dialogue content before that text (that is, the context information of the text), to obtain multiple expanded texts. Then, based on the multiple expanded texts and the relevant information retrieved from each text, the large language model generates the response text based on the multiple expanded texts and the relevant information retrieved from each text, and displays the generated response text to the user in the human-computer dialogue scenario.

[0181] This example introduces combinatorial optimization to achieve the best overall effect when multiple expanded texts are combined. These optimal text combinations are then used as training data for the expansion model, enabling it to generate multiple high-quality expanded texts in a single step when given new text input. Simultaneously, a large language model is used to determine whether retrieved relevant documents can answer the user's text, serving as the basis for evaluating the effectiveness of the expanded text. This ensures that the determined relevance score more accurately indicates the degree of relevance between the relevant documents and the text input, resulting in a more accurate quality score for the text expansion sample combinations. Consequently, the reference text expansion sample combinations selected based on the quality score are of higher quality, leading to better model performance and more accurate expanded texts generated by the model.

[0182] Please see Figure 7 , Figure 7 This diagram illustrates a block diagram of a training apparatus for an expanded model according to an embodiment of this application. The training apparatus 800 for the expanded model includes:

[0183] Module 810 is used to construct multiple text expansion sample combinations based on multiple text expansion samples obtained after expanding the text samples; each text expansion sample combination includes at least two text expansion samples.

[0184] The first determining module 820 is used to determine the quality score of each text expansion sample combination based on multiple related documents related to each text expansion sample in each text expansion sample combination; the quality score of the text expansion sample combination is used to indicate the complementary relationship between different text expansion samples in the text expansion sample combination.

[0185] The second determining module 830 is used to obtain a combination of text expansion samples with a quality score higher than the quality score threshold, as a reference combination of text expansion samples.

[0186] Training module 840 is used to train the expansion model based on text expansion samples from a combination of text samples and reference text expansion samples.

[0187] Optionally, the first determining module 820 is further configured to, for each text expansion sample combination, perform deduplication processing on multiple related documents related to each text expansion sample in the text expansion sample combination to obtain a deduplicated document set corresponding to the text expansion sample combination; and, based on the related documents in the deduplicated document set corresponding to the text expansion sample combination, perform a quality score on the text expansion sample combination to obtain a quality score for the text expansion sample combination.

[0188] Optionally, the first determining module 820 is further configured to perform a relevance score on each relevant document based on the text sample, thereby obtaining a relevance score for each relevant document; the relevance score of the relevant document is used to indicate the degree of relevance between the relevant document and the text sample; for each text expansion sample combination, a quality score is performed on the text expansion sample combination based on the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination, thereby obtaining a quality score for the text expansion sample combination.

[0189] Optionally, the first determining module 820 is further configured to sum the relevance scores of each relevant document in the deduplicated document set corresponding to each text expansion sample combination, and use the summation result as the quality score of the text expansion sample combination.

[0190] Optionally, the first determining module 820 is further configured to perform a relevance score on each relevant document based on the relevance scoring requirements, the text sample, and the context information of the text sample, to obtain a relevance score for each relevant document.

[0191] Optionally, the first determining module 820 is further configured to construct relevance score prompt information for each relevant document based on the relevance score requirements, text samples, context information of the text samples, and relevant documents; input the relevance score prompt information into the large language model for relevance scoring, and obtain the relevance score output by the large language model for the relevant document.

[0192] Optionally, the second determining module 830 is also used to determine a quality score threshold based on the quality score of a combination of multiple text expansion samples.

[0193] Optionally, the second determining module 830 is further configured to perform mean processing on the quality scores of multiple text expansion sample combinations, and obtain the mean-processed result as the quality score threshold.

[0194] Optionally, the construction module 810 is also used to expand the text sample based on the specified expansion requirements and the context information of the text sample, so as to obtain multiple text expansion samples that meet the specified expansion requirements.

[0195] Optionally, the construction module 810 is also used to construct expansion prompt information corresponding to the text sample based on the specified expansion requirements, the text sample and the context information of the text sample; input the expansion prompt information into the large language model text expansion processing to obtain multiple text expansion samples output by the large language model.

[0196] Optionally, the first determining module 820 is further configured to, for each text expansion sample, determine the degree of document relevance between the text expansion sample and each preset document in the retrieval database; and select a specified number of preset documents from the retrieval database in descending order of document relevance as relevant documents related to the text expansion sample.

[0197] Optionally, the training module 840 is further configured to obtain multiple text expansion sample combinations, excluding the reference text expansion sample combination, as candidate text expansion sample combinations; construct positive sample data based on the text samples and the text expansion samples in the reference text expansion sample combination; construct negative sample data based on the text samples and the text expansion samples in the candidate text expansion sample combination; and train the expansion model based on the positive sample data and the negative sample data.

[0198] Please see Figure 8 , Figure 8 This illustration shows a block diagram of a text expansion device according to an embodiment of this application. The text expansion device 900 includes:

[0199] Module 910 is used to acquire the target text to be expanded.

[0200] The expansion module 920 is used to expand the target text using the expansion model to obtain the expanded target text corresponding to the target text; the expansion model is trained according to the method in the aforementioned embodiment.

[0201] Optionally, the device further includes a retrieval module for retrieving response text based on the target text and the target expanded text, obtaining response text of the target text and response text of the target expanded text; and performing text merging processing on the response text of the target text and the response text of the target expanded text to obtain the target response text for the target text.

[0202] It should be noted that the device embodiments in this application correspond to the aforementioned method embodiments. The specific principles in the device embodiments can be found in the content of the aforementioned method embodiments, and will not be repeated here.

[0203] Figure 9 A structural block diagram of an electronic device for performing a training method for an expanded model according to embodiments of this application is shown. The electronic device may be... Figure 1 The terminal (110) or server (120), etc., should be noted. Figure 9 The computer system 1200 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0204] like Figure 9As shown, the computer system 1200 includes a Central Processing Unit (CPU) 1201, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on programs stored in Read-Only Memory (ROM) 1202 or programs loaded from storage portion 1208 into Random Access Memory (RAM) 1203. The RAM 1203 also stores various programs and data required for system operation. The CPU 1201, ROM 1202, and RAM 1203 are interconnected via a bus 1204. An Input / Output (I / O) interface 1205 is also connected to the bus 1204.

[0205] The following components are connected to I / O interface 1205: an input section 1206 including a keyboard, mouse, etc.; an output section 1207 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to I / O interface 1205 as needed. Removable media 1211, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1210 as needed so that computer programs read from them can be installed into storage section 1208 as needed.

[0206] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1209, and / or installed from removable medium 1211. When the computer program is executed by central processing unit (CPU) 1201, it performs various functions defined in the system of this application.

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

[0208] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0209] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0210] In another aspect, this application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable storage medium carries computer-readable instructions that, when executed by a processor, implement the methods in any of the above embodiments.

[0211] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including 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 of any of the above embodiments.

[0212] In the embodiments of this application, the terms "module" or "unit" refer to a part of a computer program with a predetermined function, which works together with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (e.g., processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that functions as a whole.

[0213] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0214] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause an electronic device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the methods according to the embodiments of this application.

[0215] Other embodiments of this application will readily conceive of by those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. It should be understood that this application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

[0216] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A training method for an extended model, characterized in that, The method includes: Based on multiple text expansion samples obtained by expanding the text samples, multiple text expansion sample combinations are constructed; each text expansion sample combination includes at least two of the text expansion samples; Based on multiple related documents associated with each text expansion sample in each text expansion sample combination, a quality score is determined for each text expansion sample combination; the quality score of the text expansion sample combination is used to indicate the complementary relationship between different text expansion samples in the text expansion sample combination; Obtain text expansion sample combinations with quality scores higher than the quality score threshold as reference text expansion sample combinations; The expansion model is trained based on the text expansion samples in the combination of the text samples and the reference text expansion samples.

2. The method according to claim 1, characterized in that, The process of determining a quality score for each text expansion sample combination based on multiple related documents associated with each text expansion sample in each combination includes: For each of the text expansion sample combinations, multiple related documents related to each text expansion sample in the text expansion sample combination are deduplicated to obtain the deduplicated document set corresponding to the text expansion sample combination. Based on the relevant documents in the deduplicated document set corresponding to the text expansion sample combination, a quality score is performed on the text expansion sample combination to obtain the quality score of the text expansion sample combination.

3. The method according to claim 2, characterized in that, The quality score of the text expansion sample combination is obtained by performing a quality score on the relevant documents in the deduplicated document set corresponding to the text expansion sample combination, including: Each relevant document is scored based on the text sample to obtain a relevance score for each relevant document; the relevance score of the relevant document is used to indicate the degree of relevance between the relevant document and the text sample. For each text expansion sample combination, a quality score is obtained by evaluating the text expansion sample combination based on the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination.

4. The method according to claim 3, characterized in that, For each text expansion sample combination, a quality score is calculated based on the relevance scores of relevant documents in the deduplicated document set corresponding to the text expansion sample combination, resulting in a quality score for the text expansion sample combination, including: For each text expansion sample combination, the relevance scores of each relevant document in the deduplicated document set corresponding to the text expansion sample combination are summed, and the summation result is used as the quality score of the text expansion sample combination.

5. The method according to claim 3 or 4, characterized in that, The process of scoring the relevance of each relevant document based on the text sample to obtain a relevance score for each relevant document includes: Based on the relevance scoring requirements, the text sample, and the context information of the text sample, a relevance score is obtained for each relevant document.

6. The method according to claim 5, characterized in that, The process of scoring each relevant document based on the relevance scoring requirements, the text sample, and the context information of the text sample to obtain a relevance score for each relevant document includes: For each relevant document, a relevant score prompt is constructed based on the relevantness scoring requirements, the text sample, the context information of the text sample, and the relevant document. The relevance score prompt information is input into the large language model to perform relevance scoring, and the relevance score output by the large language model for the relevant document is obtained.

7. The method according to claim 1, characterized in that, Before obtaining a combination of text expansion samples with a quality score higher than the quality score threshold as a reference combination of text expansion samples, the method further includes: The quality score threshold is determined based on the quality score of the combination of the multiple text expansion samples.

8. The method according to claim 7, characterized in that, The process of determining the quality score threshold based on the quality score of the combination of the multiple text expansion samples includes: The quality scores of the multiple text expansion sample combinations are averaged, and the averaged result is used as the quality score threshold.

9. The method according to claim 1, characterized in that, Before constructing a combination of multiple text expansion samples based on multiple text expansion samples obtained after expanding the text samples, the method further includes: Based on the specified expansion requirements and the context information of the text sample, the text sample is expanded to obtain the plurality of text expansion samples that meet the specified expansion requirements.

10. The method according to claim 9, characterized in that, The process of expanding the text sample based on specified expansion requirements and context information of the text sample to obtain multiple expanded text samples that meet the specified expansion requirements includes: Based on the specified expansion requirements, the text sample, and the context information of the text sample, expand prompt information corresponding to the text sample is constructed; The expanded prompt information is input into a large language model for text expansion processing to obtain the multiple text expansion samples output by the large language model.

11. The method according to claim 1, characterized in that, Before determining the quality score of each text expansion sample combination based on multiple related documents associated with each text expansion sample in each text expansion sample combination, the method further includes: For each of the text expansion samples, determine the degree of document relevance between the text expansion sample and each preset document in the retrieval database; A specified number of predefined documents are selected from the retrieval database according to their relevance from high to low, and these documents are used as the relevant documents related to the text expansion sample.

12. The method according to claim 1, characterized in that, The process of training the expansion model based on the text expansion samples in the combination of the text samples and the reference text expansion samples includes: Obtain the text expansion sample combinations other than the reference text expansion sample combination from the plurality of text expansion sample combinations as candidate text expansion sample combinations; Based on the text samples and the text expansion samples in the combination of the reference text expansion samples, positive sample data is constructed. Based on the text samples and the text expansion samples in the candidate text expansion sample combination, negative sample data is constructed. The expansion model is trained based on the positive sample data and the negative sample data.

13. A text expansion method, characterized in that, The method includes: Obtain the target text to be expanded; The target text is expanded by an expansion model to obtain the expanded target text corresponding to the target text; the expansion model is trained according to any one of claims 1-12.

14. The method according to claim 13, characterized in that, After expanding the target text using the expansion model to obtain the expanded target text, the method further includes: Based on the target text and the target expanded text, the response text is retrieved to obtain the response text of the target text and the response text of the target expanded text; The response text to the target text and the response text to the target expanded text are merged to obtain the target response text for the target text.

15. A training device for an expanded model, characterized in that, The device includes: A construction module is used to construct multiple text expansion sample combinations based on multiple text expansion samples obtained after expanding text samples; each text expansion sample combination includes at least two of the text expansion samples; The first determining module is used to determine the quality score of each text expansion sample combination based on multiple related documents associated with each text expansion sample in each text expansion sample combination; the quality score of the text expansion sample combination is used to indicate the complementary relationship between different text expansion samples in the text expansion sample combination. The second determining module is used to obtain text expansion sample combinations with quality scores higher than the quality score threshold, as reference text expansion sample combinations. The training module is used to train the expansion model based on the text expansion samples in the combination of the text samples and the reference text expansion samples.

16. A text expansion device, characterized in that, The device includes: The acquisition module is used to acquire the target text to be expanded. An expansion module is used to expand the target text using an expansion model to obtain the expanded target text corresponding to the target text; the expansion model is trained according to any one of claims 1-12.

17. An electronic device, characterized in that, include: processor; A memory storing computer-readable instructions that, when executed by the processor, implement the method as described in any one of claims 1-14.

18. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that, when executed by a processor, implement the method as described in any one of claims 1-14.