Text processing method, device, electronic device, storage medium and program product

By performing intention recognition and sample division of text sets, the problem of text neglect in rare scenes in the context of uneven distribution of the language model is solved, and a more balanced sample distribution and better intention understanding ability are achieved.

CN119782543APending Publication Date: 2025-04-08MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411863921.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

In the case of uneven distribution of training data, existing language models are prone to ignore the text of rare scenarios, making it difficult to accurately understand their intentions and give appropriate answers during the application stage.

Method used

By performing intent identification of the first text in the text set, the number of texts for each intent is determined, and the text set is divided into a first sample set and a second sample set according to a preset sample number threshold. The second sample set is filtered to reduce the number of first text with relatively common intentions, so that it is close to the preset sample number threshold, and then evenly distributes the number of texts of each intention in the first sample set.

Benefits of technology

Through this method, the distribution balance of text samples can be significantly improved, ensuring that the language model can fully learn all intentions, especially rare intentions, during the training process, thereby improving the understanding and response ability in the application stage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782543A_ABST
    Figure CN119782543A_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a text processing method, device, electronic device, storage medium and program product. The text processing method includes: performing intent recognition on a first text in a text set to obtain an intent recognition result of the first text; determining the number of texts for each intent in the text set according to the intent recognition result of the first text; dividing the text set into a first sample set and a second sample set according to the number of texts for each intent and a preset sample number threshold; the number of texts for each intent in the first sample set is less than or equal to the preset sample number threshold; screening the second sample set to obtain a target subset, and adding the target subset to the first sample set. In this way, a text sample with balanced distribution can be constructed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular to a text processing method, device, electronic device, storage medium and program product. Background Art

[0002] The language model that uses NLP and NLG technologies can respond to the text input into the model. In the actual application of the language model, there may be an uneven distribution of training data, which causes some rare scene texts to be easily ignored by the language model during the training phase. Therefore, when the language model processes the texts of these rare scenes in the application phase, it may be difficult to accurately understand their intentions, and thus, it is unable to give accurate and appropriate responses. Summary of the invention

[0003] The embodiments of the present application provide a text processing method, device, electronic device, storage medium and program product, which can construct a text sample with balanced distribution.

[0004] In a first aspect, an embodiment of the present application provides a text processing method, comprising: Performing intent recognition on a first text in the text set to obtain an intent recognition result of the first text; Determining the number of texts for each intent in the text set according to the intent recognition result of the first text; According to the number of texts of each intention and a preset sample number threshold, the text set is divided into a first sample set and a second sample set; the number of texts of each intention in the first sample set is less than or equal to the preset sample number threshold; The second sample set is screened to obtain a target subset, and the target subset is added to the first sample set.

[0005] In a second aspect, an embodiment of the present application provides a text processing device, including: A recognition unit, configured to perform intention recognition on a first text in a text set to obtain an intention recognition result of the first text; A determination unit, configured to determine the number of texts for each intent in the text set according to the intent recognition result of the first text; A division unit, configured to divide the text set into a first sample set and a second sample set according to the text quantity of each intent and a preset sample quantity threshold; the text quantity of each intent in the first sample set is less than or equal to the preset sample quantity threshold; The adding unit is used to perform screening processing on the second sample set to obtain a target subset, and add the target subset to the first sample set.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory configured to store computer-executable instructions, wherein the computer-executable instructions, when executed, cause the processor to execute the text processing method as described in the first aspect.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing computer-executable instructions, which, when executed by a processor, implement the text processing method as described in the first aspect.

[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the text processing method as described in the first aspect.

[0009] It can be seen that in an embodiment of the present application, first, intent recognition is performed on the first text in the text set to obtain the intent recognition result of the first text; then, based on the intent recognition result of the first text, the number of texts for each intent in the text set is determined; then, based on the number of texts for each intent and a preset sample number threshold, the text set is divided into a first sample set and a second sample set; the number of texts for each intent in the first sample set is less than or equal to the preset sample number threshold; finally, the second sample set is screened to obtain a target subset, and the target subset is added to the first sample set. In this way, the intention recognition results of each first text in the text set can be used to determine the text quantity of each intention. For any intention, the fewer the text quantity of the intention, the rarer the intention, and conversely, the more the text quantity of the intention, the more common the intention. By configuring the preset sample quantity threshold, the first text with relatively rare intention can be placed in the first sample set, and the first text with relatively common intention can be placed in the second sample set. The text quantity of the first text with relatively rare intention is less than or equal to the preset sample quantity threshold, and the text quantity of the first text with relatively common intention is greater than the preset sample quantity threshold. After obtaining the second sample set, the text quantity of the first text with relatively common intention can be reduced to the preset sample quantity threshold by screening the second sample set. Then, after the reduced number of first texts with relatively common intention is placed in the first sample set, the text quantity of each intention in the first sample set can be equal to or less than the preset sample quantity threshold. Therefore, when close to the same fixed value, the text quantity of each intention can be approximately regarded as the same, which is conducive to improving the balanced distribution of samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative labor. Figure 1 A schematic diagram of an implementation environment of a text processing method provided in an embodiment of the present application; Figure 2 A processing flow chart of a text processing method provided in an embodiment of the present application; Figure 3 A processing flow chart of another text processing method provided in an embodiment of the present application; Figure 4 A processing flow chart of another text processing method provided in an embodiment of the present application; Figure 5 A model training flow chart provided for an embodiment of the present application; Figure 6 A schematic diagram of a text processing device provided in an embodiment of the present application; Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0011] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0012] This specification provides a text processing method embodiment: In real conversations, users' intentions are often very diverse, but the frequency of occurrence of different intentions varies greatly. It may happen that sentences involving some intentions appear frequently, but sentences involving other intentions appear only in very rare cases. This leads to the common phenomenon of uneven distribution of training data when real conversations are used as the material for training data of language models. The language model trained with such unevenly distributed training data is likely to ignore the learning of rare intentions during the training process, and then it is difficult to accurately understand the rare intentions after being put into use.

[0013] Therefore, in order to solve the above problems, an embodiment of the present application provides a text processing method.

[0014] The text processing method provided in one or more embodiments of the present specification may be applicable to an implementation environment of the text processing method, which implementation environment at least includes a server 101 for processing a first text.

[0015] The server 101 may be a single server, or a server cluster consisting of a plurality of servers, or one or more cloud servers in a cloud computing platform, for processing the first text.

[0016] In this implementation environment, when processing the first text, the server 101 first performs intent recognition on the first text in the text collection to obtain the intent recognition result of the first text; then, based on the intent recognition result of the first text, the number of texts for each intent in the text collection is determined; then, based on the number of texts for each intent and a preset sample number threshold, the text collection is divided into a first sample collection and a second sample collection; the number of texts for each intent in the first sample collection is less than or equal to the preset sample number threshold; finally, the second sample collection is screened to obtain a target subset, and the target subset is added to the first sample collection. In this way, the intention recognition results of each first text in the text set can be used to determine the text quantity of each intention. For any intention, the fewer the text quantity of the intention, the rarer the intention, and conversely, the more the text quantity of the intention, the more common the intention. By configuring the preset sample quantity threshold, the first text with relatively rare intention can be placed in the first sample set, and the first text with relatively common intention can be placed in the second sample set. The text quantity of the first text with relatively rare intention is less than or equal to the preset sample quantity threshold, and the text quantity of the first text with relatively common intention is greater than the preset sample quantity threshold. After obtaining the second sample set, the text quantity of the first text with relatively common intention can be reduced to the preset sample quantity threshold by screening the second sample set. Then, after the reduced number of first texts with relatively common intention is placed in the first sample set, the text quantity of each intention in the first sample set can be equal to or less than the preset sample quantity threshold. Therefore, when close to the same fixed value, the text quantity of each intention can be approximately regarded as the same, which is conducive to improving the balanced distribution of samples.

[0017] Figure 2 A processing flow chart of a text processing method provided in an embodiment of the present application. Figure 2 The text processing method provided in this embodiment specifically includes steps S202 to S208: Step S202: performing intent recognition on a first text in the text set to obtain an intent recognition result of the first text.

[0018] The text collection may include a plurality of first texts.

[0019] In this specification, ordinal numbers such as "first" and "second" are used to distinguish different technical features and have no actual meaning, so they will not be elaborated below.

[0020] Each first text may be a sentence or a paragraph consisting of multiple sentences.

[0021] The first text may also be a conversation text including at least two participants.

[0022] Taking the telemarketing scenario as an example, the first text may be a conversation text obtained by performing speech-to-text processing on a call recording between an agent and a customer.

[0023] In a specific implementation, performing intent recognition on the first text in the text set to obtain the intent recognition result of the first text may be to call an intent recognition model to perform intent recognition processing on the first text to obtain the intent recognition result of the first text.

[0024] For example, the first text 1 is a sentence. The intention recognition model is called to perform intention recognition processing on the sentence to obtain the intention of the sentence, and the sentence is used as the intention recognition result of the first text 1.

[0025] Alternatively, the first text 2 is a paragraph consisting of k sentences, where k is an integer greater than 1. The intention recognition model is called to perform intention recognition processing on the k sentences in the paragraph respectively to obtain the intentions of the k sentences, and the obtained k intentions are used as the intention recognition results of the first text 2.

[0026] The intention recognition is performed on the first text in the text set to obtain the intention recognition result of the first text. Alternatively, a sub-text to be processed of the first text is determined, and the intention recognition processing is performed on the sub-text to be processed to obtain the intention recognition result, which is used as the intention recognition result of the first text.

[0027] For example, the first text 3 is a conversation text between user A and user B, specifically including: A: Subtext 1.

[0028] B: Subtext 2.

[0029] A: Subtext 3.

[0030] B: Subtext 4.

[0031] The sentences "Sub-text 1" and "Sub-text 2" of user A in the conversation text are determined as the sub-texts to be processed of the first text, and the intention recognition model is called to perform intention recognition processing on the sub-texts to be processed to obtain the intention of "Sub-text 1" and the intention of "Sub-text 2", and the two obtained intentions are used as the intention recognition results of the first text 3.

[0032] In addition, in order to optimize the quality of the first text, data cleaning processing may be performed on the text set before executing step S202.

[0033] The data cleaning process is performed on the text set, and it can be to detect whether each first text in the text set includes a stop word, and if the first text includes a stop word, delete the first text.

[0034] Stop words refer to words that are considered to appear frequently in a language but do not usually carry important meaning in text processing and information retrieval. These words usually include pronouns, prepositions, conjunctions, articles, auxiliary verbs, etc. Since they appear frequently in texts but usually do not provide much information in expressing the topic or content of the text, stop words are often filtered out in certain text analysis tasks, such as search engine indexing, text mining, and natural language processing, to improve processing efficiency and accuracy.

[0035] In the case where the first text is a conversation text, data cleaning processing can be performed on the text set, and the conversation turn of each first text in the text set can also be determined. If the conversation turn of the first text is less than or greater than a preset turn threshold, the first text is deleted.

[0036] For example, the preset turn threshold is 3. The text set includes the first text 1, the first text 2, and the first text 3. The conversation turns of the first text 1 are 2, the conversation turns of the first text 2 are 4, and the conversation turns of the first text 3 are 3. In the process of data cleaning of the text set, if the conversation turns of the first text are less than 3, the first text is deleted. After the data cleaning process is performed on the text set, the text set includes: the first text 2 and the first text 3.

[0037] Taking the example that the first text is a text originated from a call scenario, data cleaning processing is performed on the text collection, and each first text in the text collection can also be classified to obtain a classification result of the first text. The classification result is used to characterize whether the first text involves an abnormal hang-up. If it is determined that the first text involves an abnormal hang-up based on the classification result of the first text, the first text is deleted.

[0038] The two data cleaning methods listed above are optional and feasible data cleaning methods. In actual application scenarios, there may be a variety of different data cleaning methods, which may vary according to different actual application scenarios. The embodiments of this specification do not make specific limitations on this.

[0039] Step S204: determining the number of texts for each intent in the text set according to the intent recognition result of the first text.

[0040] The first text may be a sentence, a paragraph consisting of multiple sentences, or a dialogue text including one or more rounds of dialogue, and so on.

[0041] In the case where the first text is a sentence, the intent recognition result of the first text may include only one intent.

[0042] In the case where the first text is a paragraph consisting of K1 sentences, the intent recognition result of the first text may include N1 intents, where N1 is an integer greater than or equal to 1 and less than or equal to K1, and K1 is an integer greater than 1.

[0043] In the case where the first text is a dialogue text consisting of K2 rounds of dialogue, the intent recognition result of the first text may include N2 intents, where N2 is an integer greater than or equal to 1 and less than or equal to K2, and K2 is an integer greater than or equal to 1.

[0044] When the first text is a dialogue text, or the first text is a paragraph consisting of multiple sentences, considering that multiple sentences belonging to the same first text may have the same intention, which may interfere with subsequent statistical work, the intention recognition results of the first text can be deduplicated before statistical processing.

[0045] For example, the first text includes: sentence 1 of the first user, sentence 2 of the second user, sentence 3 of the first user, sentence 4 of the second user, and sentence 5 of the first user.

[0046] The sentence of the first user is used as the subtext to be processed of the first text, and the intention recognition process is performed on the subtext to be processed, specifically: Perform intent recognition on sentence 1 and obtain the intent Figure 1 ; Perform intent recognition on sentence 3 and obtain the intent Figure 2 ; Perform intent recognition on sentence 5 and obtain the intent Figure 1 .

[0047] It can be seen that the intent recognition results of the first text include: Figure 1 ,meaning Figure 2 And Figure 1 .

[0048] After deduplication processing is performed on the intention recognition result of the first text, it can be determined that the intention recognition result of the first text includes: Figure 1 Harmony Figure 2 .

[0049] Each intent recognition result of the first text may include one or more intents.

[0050] An intent may correspond to one or more first texts.

[0051] Determining the number of texts for each intent in a text collection based on the intent recognition result of the first text may be to determine the intent in the text collection based on the intent recognition result of each first text in the text collection, and then, for each intent therein, performing statistical processing on the number of first texts that include the intent in the intent recognition result to obtain the number of texts for the intent.

[0052] An intent in a text collection refers to an intent that appears at least once in the intent recognition result of each first text in the text collection.

[0053] For example, each first text in the text set is a sentence. The text set includes: first text 1, first text 2, and first text 3. Among them, the intent recognition result of the first text 1 includes: intent Figure 1 ; The intention recognition result of the first text 2 includes: Figure 2 ; The intention recognition result of the first text 3 includes: Figure 1 ; The intention recognition result of the first text 4 includes: Figure 1 .

[0054] In the above four first texts, the intent recognition result of each first text can be regarded as a set. By taking the union of the four sets, we can get the intent set: Figure 1 Harmony Figure 2 .meaning Figure 1 Each first text in the text collection appears three times in the intent recognition results. Figure 2 The intent set includes the intents in the text set if it appears once in the intent recognition result of each first text in the text set.

[0055] In the intent set, for each intent, count the number of first texts that include the intent: Including Figure 1 There are 3 first texts in total: first text 1, first text 3 and first text 4. Figure 1 The number of texts is 3.

[0056] Including Figure 2 There are 1 first text in total: first text 2. Figure 2The number of texts is 1.

[0057] For another example, the intent recognition result of the first text 1 includes: Figure 1 ,meaning Figure 2 And Figure 3 The intent recognition result of the first text 2 includes: Figure 1 Harmony Figure 2 The intent recognition result of the first text 3 includes: Figure 2 Harmony Figure 4 The intent recognition result of the first text 4 includes: Figure 5 ,etc.

[0058] In the above four first texts, the intent recognition result of each first text can be regarded as a set. The union of the four sets is obtained to obtain the intent set: Figure 1 ,meaning Figure 2 ,meaning Figure 3 ,meaning Figure 4 And Figure 5 .meaning Figure 1 Each first text in the text collection appears twice in the intent recognition results. Figure 2 Each first text in the text collection appears three times in the intent recognition results. Figure 3 Each first text in the text collection appears once in the intent recognition result. Figure 4 Each first text in the text collection appears once in the intent recognition result. Figure 5 The intent set includes the intents in the text set if it appears once in the intent recognition result of each first text in the text set.

[0059] In the intent set, for each intent, the number of first texts of the intent included in the intent recognition results is counted: meaning Figure 1 Corresponding to the first text 1 and the first text 2, it means Figure 1 The number of texts is 2; Figure 2 Corresponding to the first text 1, the first text 2 and the first text 3, it means Figure 2 The number of texts is 3; Figure 3 Corresponding to the first text 1, it means Figure 3 The number of texts is 1; Figure 4 Corresponding to the first text 3, it means Figure 4 The number of texts is 1; Figure 5 Corresponding to the first text 4, it means Figure 5 The number of texts is 1.

[0060] In a specific implementation, a first text includes multiple sub-texts, an intent recognition result of the first text includes the intent of each sub-text, and a text set includes N intents; based on the intent recognition result of the first text, the number of texts for each intent in the text set is determined, including: for the i-th intent in the text set, if there is a sub-text in the first text whose intent matches the i-th intent, then it is determined that the first text includes the i-th intent; and the number of first texts that include the i-th intent is counted to obtain the number of texts for the i-th intent, where i is a positive integer less than or equal to N.

[0061] The first text may include a plurality of subtexts.

[0062] Two adjacent subtexts in the multiple subtexts may be separated by a preset symbol.

[0063] For example, the first text 1 is: I am very interested in XXX mentioned in Activity A, but I do not meet the participation requirements of Activity A. Are there any activities similar to Activity A that are more suitable for the elderly that you can introduce to me? In the first text 1 mentioned above, the preset symbol can be "," In the first text 1: Subtext 1 is "I am very interested in XXX mentioned in Activity A", Subtext 2 is "But I do not meet the conditions for participating in Activity A", and Subtext 3 is "Is there any activity similar to Activity A that is more suitable for the elderly? Please introduce it to me." Among them, the intention of Subtext 1 is the intention Figure 1 , the intention of subtext 2 is Figure 2 , the intention of subtext 3 is Figure 3 .

[0064] In the case where the first text is generated from conversation data, the plurality of subtexts may come from one of the conversation participants in the conversation data.

[0065] For example, the first text 2 is generated by conversation data A. Conversation data A includes: Customer A: When will the product 1 I want be available? Agent B: Let me check for you. Sorry for the long time. Product 1 is expected to be officially launched on X / X. Welcome to purchase.

[0066] Customer A: Thank you. I would also like to ask if there is any purchase limit? Seat B: Each account can only purchase 1.

[0067] Customer A: OK, no further questions.

[0068] In the first text 2 generated by the above-mentioned conversation data A, subtext 1 is "When will the product 1 I want be available on the shelves?", subtext 2 is "Thank you, I would also like to ask if there is any purchase limit", and subtext 3 is "OK, no other questions."

[0069] The first text includes multiple sub-texts, the intent recognition result of the first text includes the intent of each sub-text, the text set includes N intents, and N can be an integer greater than 1.

[0070] For example, the first text includes: subtext 1, subtext 2, and subtext 3. Then the intent recognition result of the first text includes the intent of subtext 1. Figure 1 、The meaning of subtext 2 Figure 2 And the meaning of subtext 3 Figure 3 .

[0071] Before determining the number of texts for each intent based on the intent recognition result of the first text, the intents in the text set may be determined first.

[0072] In specific implementation, an intention set can be pre-configured. In the initial state, the intention set is an empty set. In the process of processing each first text in the text set, it is determined whether each intention in the intention recognition result of the first text belongs to the intention set. If so, the processing of the intention is skipped. If not, the intention is added to the intention set. After the processing of each first text in the text set is completed, the intention in the text set can be determined according to the intention set.

[0073] For example, the text set includes first text 1, first text 2, and first text 3.

[0074] The intention recognition result of the first text 1 includes: the intention of sub-text 1 Figure 1 、The meaning of subtext 2 Figure 2 And the meaning of subtext 3 Figure 3 .

[0075] The intention recognition result of the first text 2 includes: the intention of subtext 4 Figure 1 and the meaning of subtext 5 Figure 3 .

[0076] The intention recognition result of the first text 3 includes: the intention of subtext 6 Figure 2 and the meaning of subtext 7 Figure 4 .

[0077] Initially, the intention set is an empty set. Figure 1 Whether it belongs to the intention set, the judgment result indicates the intention Figure 1 If it does not belong to the intention set, Figure 1 Add to the intent collection. Similarly, add the intent Figure 2 Harmony Figure 3 Add to the intention set; in the process of processing the first text 2, determine the intention Figure 1 Whether it belongs to the intention set, the judgment result indicates the intention Figure 1 Belongs to the intent set, so skip processing intent Figure 1 Similarly, skip processing Figure 3 ; In the process of processing the first text 3, determine the meaning Figure 2 Whether it belongs to the intention set, the judgment result indicates the intention Figure 2 Belongs to the intent set, so skip processing intent Figure 2 , judgement Figure 4 Whether it belongs to the intention set, the judgment result indicates the intention Figure 4 If it does not belong to the intention set, Figure 4 Add to the intent set. In this way, the final intent set includes: Figure 1 ,meaning Figure 2 ,meaning Figure 3 And Figure 4 That is, the intent in the text set includes Figure 1 ,meaning Figure 2 ,meaning Figure 3 And Figure 4 , N=4, the text collection includes 4 intents.

[0078] In some implementations, in the process of determining the number of texts for each intent in the text collection based on the intent recognition result of the first text, the scope of “each intent” can be determined by the intents in the text collection. For example, the intents in the text collection include intents Figure 1 ,meaning Figure 2 ,meaning Figure 3 , then “every intention” means the intention Figure 1 ,meaning Figure 2 And Figure 3 Each intention in .

[0079] In other implementations, in the process of determining the number of texts for each intent in the text set according to the intent recognition result of the first text, the scope of “each intent” can also be customized. For example, a preset intent set is preconfigured, and the preset intent set includes intents Figure 1 ,meaning Figure 2 ,meaning Figure 3 ,meaning Figure 4 ,meaning Figure 5 , then “each intent in the text collection” refers to the intent Figure 1 ,meaning Figure 2 ,meaning Figure 3 ,meaning Figure 4 And Figure 5 Each intention in .

[0080] Considering that each intent is processed in the same way, the i-th intent in the text set can be taken as an example for illustrative explanation, and other intents except the i-th intent can refer to the corresponding description part.

[0081] For the i-th intention in the text set, if there is a sub-text in the first text whose intent matches the i-th intention, it is determined that the first text includes the i-th intention; the number of first texts that include the i-th intention is counted to obtain the number of texts for the i-th intention, where i is a positive integer less than or equal to N.

[0082] The existence of an intent in the first text that matches the i-th intent may be that the existence of an intent in the first text that is the same as the i-th intent.

[0083] For example, the i-th intention is Figure 2 The first text includes subtext 1 and subtext 2, and the intention recognition result of the first text includes the intention of subtext 1. Figure 1 and the meaning of subtext 2 Figure 2 , there is a subtext in the first text that has the same intention as the i-th intention, namely, subtext 2. Therefore, it can be determined that the first text includes the i-th intention.

[0084] Alternatively, there is an intent in the first text that matches the i-th intent, or there may be an intent in the first text that belongs to the same preset intent category as the i-th intent.

[0085] Each preset intent category may include one or more preset intents. In the same preset intent category, the similarity between any two preset intents is greater than a preset similarity threshold.

[0086] For example, intent category 1 includes intent A1, intent A2, and intent A3.

[0087] If the intention of subtext 1 in the first text is intention A1, and the i-th intention is intention A3, since A1 and A3 both belong to intention category 1, it can be determined that there is a subtext in the first text whose intention belongs to the same preset intention category as the i-th intention, namely subtext 1, then it is determined that the first text includes the i-th intention.

[0088] The number of first texts including the i-th intention is counted to obtain the number of texts of the i-th intention.

[0089] It should be noted that in the process of determining the number of texts for the i-th intent, if there are multiple sub-texts in the same first text that correspond to the same intent, it is necessary to first remove duplicate intents and then count the number of texts. Figure 1 , the intent is deduplicated, then the intent recognition result of the first text includes 1 intent Figure 1 , instead of 3 meanings Figure 1 .

[0090] Exemplarily, the first text may be a dialogue text, each of which includes a plurality of sentences, and each of the plurality of sentences is used as a subtext in the first text. In the intention recognition result of the first text, each subtext has a corresponding intention.

[0091] For example, the first text 1 includes: The sentence S1 of the first user has the meaning Figure 1 .

[0092] The second user's statement S2 has the meaning Figure 2 .

[0093] The first user's statement S3 has the meaning Figure 1 .

[0094] Statistics include Figure 1 The number of the first text, get the meaning Figure 1 The number of texts is 2; statistics include Figure 2 The number of the first text, get the meaning Figure 2 The number of texts is 1.

[0095] For another example, the first text 2 includes: The sentence S1 of the first user has the meaning Figure 1 .

[0096] The second user's sentence S2 does not belong to the subtext to be processed of the first text 2 and does not need to be identified by intent.

[0097] The first user's statement S3 has the meaning Figure 1 .

[0098] Statistics include Figure 1 The number of the first text, get the meaning Figure 1 The number of texts is 2.

[0099] Step S206, dividing the text set into a first sample set and a second sample set according to the text quantity of each intent and a preset sample quantity threshold; the text quantity of each intent in the first sample set is less than or equal to the preset sample quantity threshold.

[0100] The first sample set is used to place the first text corresponding to the intention that has met the sample construction expectation. The first sample set may include one or more first texts.

[0101] The first text corresponding to the intent, that is, the first text that includes the intent.

[0102] For any intention, it can be determined that the first text including the intention meets the sample construction expectations if the number of texts of the intention is less than or equal to a preset sample number threshold. It can also be determined that the first text including the intention meets the sample construction expectations if, after quality assessment processing is performed on the first text including the intention, it is determined that the number of texts with passed quality assessment results is less than or equal to a preset sample number threshold.

[0103] The quality assessment process for the first text may be to calculate an assessment score of the first text according to a preset assessment method. If the assessment score is greater than a preset score threshold, the quality assessment result is determined to be passed, otherwise it is determined to be failed.

[0104] The preset evaluation method may be an evaluation method pre-designed for one or more dimensions of the first text, for example, the one or more dimensions include but are not limited to: completeness, accuracy, consistency, relevance, readability, and the like.

[0105] Completeness refers to whether the first text contains all the necessary information and details. A complete text sample should be able to provide enough information for effective analysis.

[0106] Accuracy refers to whether the information in the first text is correct. False or misleading information will seriously affect the reliability of the analysis results.

[0107] Consistency refers to whether the information in the first text is consistent. Inconsistent information may lead to biased analysis results.

[0108] Relevance refers to whether the first text is relevant to the analysis target. Irrelevant text may introduce noise and reduce the effectiveness of the analysis.

[0109] Readability refers to whether the first text is easy to read and understand. Difficult to understand text may affect the efficiency and accuracy of analysis.

[0110] If the first text containing an intent meets the sample construction expectation, the first text containing the intent can be used as a text sample without further screening. The text sample can be used as training data for the language model.

[0111] The second sample set is used to place the first text corresponding to the intention that does not meet the sample construction expectation. The second sample set may include one or more first texts.

[0112] For any intention, it can be determined that the first text including the intention does not meet the sample construction expectations when the number of texts of the intention is greater than a preset sample number threshold. It can also be determined that the first text including the intention does not meet the sample construction expectations when, after quality assessment processing is performed on the first text including the intention, it is determined that the number of texts that pass the quality assessment result is greater than a preset sample number threshold.

[0113] In the case where the first text including an intent does not meet the sample construction expectation, the number of texts for the intent is too large and further screening is required to reduce the number of texts.

[0114] The preset sample quantity threshold may be a custom-configured quantity threshold for determining whether the first text is assigned to the first sample set or the second sample set.

[0115] For example, if the amount of text in the intent is less than or equal to the preset sample quantity threshold S, the intent is determined to be a rare intent and the intent is assigned to the first sample set; conversely, if the amount of text in the intent is greater than the preset sample quantity threshold S, the intent is determined to be a common intent and the intent is assigned to the second sample set.

[0116] The specific value of the preset sample quantity threshold S can be configured according to the sample quantity requirement of the intent recognition model training. The sample quantity requirement of the intent recognition model training may be affected by many factors such as the structural complexity of the intent recognition model, the quality of sample data, the complexity of intent categories, and the accuracy requirements of the training objectives.

[0117] Rare intent and common intent are relative concepts.

[0118] Rare intents are those that do not appear often in a specific domain or context. These intents may be triggered less frequently due to their uniqueness or specific conditions, so identifying and processing them may be more challenging. For example, in the customer service domain, users may ask very specific or rare questions, or seek customized services for specific products, which are rare intents.

[0119] Common intent refers to intents that appear frequently in a specific domain or context. These intents are usually typical of user behavior and are easy to identify and predict. For example, in the field of customer service, users asking about product prices, checking order status, or seeking technical support are all common intents.

[0120] Specifically in one or more embodiments of the present application, the number of texts of rare intents is less than or equal to a preset sample number threshold, and the number of texts of common intents is greater than the preset sample number threshold.

[0121] According to the number of texts for each intent and a preset sample number threshold, the text set is divided into a first sample set and a second sample set. For each intent, if the number of texts for the intent is less than or equal to the preset sample number threshold, it can be determined that the intent is a rare intent, and the first text including the intent is allocated to the first sample set, so that the number of texts for each intent in the first sample set is less than or equal to the preset sample number threshold; if the number of texts for the intent is greater than the preset sample number threshold, it can be determined that the intent is a common intent, and the first text including the intent is allocated to the second sample set, so that the number of texts for each intent in the second sample set is greater than the preset sample number threshold.

[0122] According to the number of texts for each intention and a preset sample number threshold, the text collection is divided into a first sample collection and a second sample collection. Alternatively, after quality assessment is performed on each first text in the text collection and the first texts with failed quality assessment results are deleted, the number of texts for each intention is counted in the remaining first texts in the text collection. For each intention, if the number of texts for the intention is less than or equal to the preset sample number threshold, it can be determined that the intention is a rare intention, and the first texts including the intention are allocated to the first sample collection, so that the number of texts for each intention in the first sample collection is less than or equal to the preset sample number threshold. If the number of texts for the intention is greater than the preset sample number threshold, it can be determined that the intention is a common intention, and the first texts including the intention are allocated to the second sample collection, so that the number of texts for each intention in the second sample collection is greater than the preset sample number threshold.

[0123] In the case where the intent recognition result of the first text includes one intent, the intent in the first sample set is different from the intent in the second sample set.

[0124] For example, the text set includes first text 1, first text 2, and first text 3. The intent recognition result of first text 1 includes intent Figure 1 , the intent recognition result of the first text 2 includes the intent Figure 2 , the intent recognition result of the first text 3 includes the intent Figure 2 According to the number of texts of each intent and a preset sample number threshold, the text set is divided into a first sample set and a second sample set. The first sample set includes: first text 1. The second sample set includes: first text 2 and first text 3. The intent in the first sample set includes intent Figure 1 , the intent in the second sample set includes Figure 2 . The intent in the first sample set is different from the intent in the second sample set.

[0125] In the case where the intent recognition result of the first text includes one or more intents, the intents in the first sample set and the intents in the second sample set may be completely different, or may be partially the same and partially different.

[0126] For example, the text set includes first text 1, first text 2, and first text 3. The intent recognition result of first text 1 includes intent Figure 1 ,meaning Figure 2 ,meaning Figure 3 , the intent recognition result of the first text 2 includes the intent Figure 1 Harmony Figure 2 , the intent recognition result of the first text 3 includes the intent Figure 4 In this way, Figure 1 The number of texts is 2, meaning Figure 2 The number of texts is 2, meaning Figure 3 The number of texts is 1, meaning Figure 4 The number of texts is 1, and the meaning of the number of texts greater than 1 Figure 1 Harmony Figure 2 Determine the common intent and set the intent with the number of text equal to 1. Figure 3 Harmony Figure 4 The intent is determined to be rare, and then, according to the number of texts of each intent and the preset sample number threshold, the text set is divided into a first sample set and a second sample set. Figure 3 The first text 1 is divided into the first sample set, including Figure 4 The first text 3 is divided into the first sample set, and the remaining first text 2 is divided into the second sample set. That is, the first sample set includes: the first text 1, the first text 3; the second sample set includes: the first text 2.

[0127] In this way, since the first text 1 includes the meaning Figure 1 ,meaning Figure 2 ,meaning Figure 3 , the first text 3 includes the meaning Figure 4 Therefore, the intent in the first sample set includes: Figure 1 ,meaning Figure 2 ,meaning Figure 3 ,meaning Figure 4 Since the second text 1 includes Figure 1 Harmony Figure 2 Therefore, the intent in the second sample set includes: Figure 1 ,meaning Figure 2 Compared with the intentions in the second sample set, the intentions in the first sample set have some identical intentions and some different intentions.

[0128] In addition, in the case where the first text may include multiple sub-texts, in order to avoid overflow of the number of samples of common intents in the first sample set, after dividing the text set into the first sample set and the second sample set according to the number of texts for each intent and a preset sample number threshold, the sub-texts corresponding to the common intents in each first text in the first sample set may be deleted.

[0129] For example, the intents in the text collection include: Figure 1 ,meaning Figure 2 ,meaning Figure 3 .meaning Figure 1 The number of texts is 50, meaning Figure 2 The number of texts is 45, meaning Figure 3 The number of texts is 700. The preset sample number threshold is 50.

[0130] By comparing the text quantity of each intent and the preset sample quantity threshold, we can see that the intent Figure 1 Harmony Figure 2 Belongs to rare intention, meaning Figure 3 It is a common intention.

[0131] In the text set, each first text includes multiple subtexts, so a part of the first text also includes Figure 1 Harmony Figure 3 ; The other part of the first text also includes the meaning Figure 2 Harmony Figure 3 ,etc.

[0132] Assume that there is no text collection that includes both Figure 1 Harmony Figure 2 The first text of Figure 2 After the first text is assigned to the first sample set, it may cause the first sample set to Figure 3 The number of texts is greater than 0 and less than or equal to 45. For example, the first sample set is Figure 3 The number of texts is 35. Next, Figure 1 After the first text is assigned to the first sample set, it may cause the first sample set to Figure 3 The number of texts in the first sample set increases, and the specific increase value is greater than 0 and less than or equal to 50. For example, the increase value may be 20. Figure 3 The number of texts may exceed 50, for example, 35+20=55>50, which means that the number of samples of common intents overflows and does not meet the expectations of sample construction.

[0133] In order to avoid this situation, in the first sample set, for each sample that includes Figure 1 Harmony Figure 3 The first text of Figure 3 The corresponding sub-text is deleted, and only the meaning is retained. Figure 1 The corresponding subtext, and, for each Figure 2 Harmony Figure 3 The first text of Figure 3 The corresponding sub-text is deleted, and only the meaning is retained. Figure 1 The corresponding subtext.

[0134] In a specific implementation method, a text collection is divided into a first sample collection and a second sample collection according to the number of texts for each intent and a preset sample number threshold, including: based on the number of texts for each intent, selecting the text corresponding to the ith intent according to a preset rule, processing the text corresponding to the ith intent selected each time, and deleting the processed text after each processing until the text collection is empty; the processing process includes: numerically comparing the number of texts corresponding to the ith intent with the preset sample number threshold; if the number of texts for the ith intent is less than or equal to the preset sample number threshold, adding the first text including the ith intent in the text collection to the first sample collection; if the number of texts for the ith intent is greater than the preset sample number threshold, adding the first text including the ith intent in the text collection to the second sample collection.

[0135] The first sample set may be regarded as a subset of the text set, and the second sample set may be regarded as another subset of the text set.

[0136] Exemplarily, the text set may include N first texts, where N is an integer greater than 1. Before executing the step of "dividing the text set into a first sample set and a second sample set according to the number of texts of each intention and a preset sample number threshold", both the first sample set and the second sample set may be regarded as empty sets. The process of dividing the text set into the first sample set and the second sample set may be understood as: placing a portion of the first texts in the text set into the first sample set as a subset, and placing another portion of the first texts in the text set into the second sample set as a subset.

[0137] In this way, after executing the step "dividing the text set into a first sample set and a second sample set according to the number of texts of each intention and the preset sample number threshold", the first sample set includes M first texts, the second sample set includes (NM) first texts, the union of the first sample set and the second sample set is the same as the text set before executing the step "dividing the text set into a first sample set and a second sample set according to the number of texts of each intention and the preset sample number threshold", and the intersection of the first sample set and the second sample set is an empty set. The above M is an integer greater than 0.

[0138] Based on the number of texts for each intent, the text corresponding to the i-th intent is selected according to the preset rules, and the text corresponding to the i-th intent selected each time is processed. After each processing, the processed text is deleted until the text set is empty.

[0139] i can be any integer greater than 0.

[0140] The preset rule may be a preconfigured rule indicating how to divide the text set into the first sample set and the second sample set based on the amount of text for each intent.

[0141] In some implementations, based on the preset rule, the text corresponding to the ith intention can be randomly selected from the text set, and the text corresponding to the ith intention selected each time is processed. After each processing, the processed text is deleted until the text set is empty. In the process of processing the text corresponding to the ith intention, the number of texts of the ith intention is used. Specifically, the number of texts corresponding to the ith intention is numerically compared with a preset sample number threshold; if the number of texts of the ith intention is less than or equal to the preset sample number threshold, the first text including the ith intention in the text set is added to the first sample set; if the number of texts of the ith intention is greater than the preset sample number threshold, the first text including the ith intention in the text set is added to the second sample set.

[0142] For example, after the above step S204 "determine the number of texts for each intent in the text set according to the intent recognition result of the first text" is executed, the following is obtained: Figure 1 The number of texts, meaning Figure 4 The number of texts, meaning Figure 2 The amount of text and its meaning Figure 3 The amount of text.

[0143] In the process of randomly selecting the text corresponding to the i-th intent in the text collection: Choose your choice first Figure 1 The corresponding text, then select Figure 4 The corresponding text, then select Figure 2 The corresponding text, finally select Figure 3 The corresponding text.

[0144] Or, select Figure 2 The corresponding text, then select Figure 4 The corresponding text, then select Figure 1 The corresponding text, finally select Figure 3 The corresponding text.

[0145] Or, select Figure 3 The corresponding text, then select Figure 4 The corresponding text, then select Figure 1 The corresponding text, finally select Figure 2 The corresponding text, etc.

[0146] In addition, after each processing, the processed text is deleted until the text set is empty. In this way, the text corresponding to each intent in the text set will only go through the processing once, which can avoid each first text in the text set being assigned twice or even multiple times, so that each first text will only appear in one of the subsets of the text set. On this basis, the text corresponding to the i-th intent is randomly selected during each selection process, and repeated selection will not occur.

[0147] In some implementations, based on the preset rule, the text in the text collection can be divided into two parts and processed separately according to the comparison result between the text quantity of each intent and the preset sample quantity threshold.

[0148] For example, the text set includes: text corresponding to the first intention, text corresponding to the second intention, text corresponding to the third intention, and text corresponding to the fourth intention. Among them, the comparison result of the text quantity of the first intention and the preset sample quantity threshold indicates that the text quantity of the first intention is less than the preset sample quantity threshold; the comparison result of the text quantity of the second intention and the preset sample quantity threshold indicates that the text quantity of the second intention is equal to the preset sample quantity threshold; the comparison result of the text quantity of the third intention and the preset sample quantity threshold indicates that the text quantity of the third intention is greater than the preset sample quantity threshold; the comparison result of the text quantity of the fourth intention and the preset sample quantity threshold indicates that the text quantity of the fourth intention is greater than the preset sample quantity threshold.

[0149] According to the comparison result of the text quantity of each intent and the preset sample quantity threshold, the text in the text set is divided into two parts. The first part includes: the text corresponding to the first intent and the text corresponding to the second intent, and the second part includes: the text corresponding to the third intent and the text corresponding to the fourth intent.

[0150] Then, the text corresponding to the i-th intention is selected in the first part of the text, and the text corresponding to the i-th intention selected each time is processed. After each processing, the processed text is deleted until the first part of the text does not exist in the text set.

[0151] The text processing process corresponding to the first intent includes: numerically comparing the amount of text corresponding to the first intent with a preset sample quantity threshold, the numerical comparison result indicates that the amount of text for the first intent is less than or equal to the preset sample quantity threshold, and adding the first text in the text set including the first intent to the first sample set.

[0152] The text processing process corresponding to the second intent includes: numerically comparing the amount of text corresponding to the second intent with a preset sample quantity threshold, the numerical comparison result indicates that the amount of text for the second intent is less than or equal to the preset sample quantity threshold, and adding the first text in the text set including the second intent to the first sample set.

[0153] Next, the text corresponding to the i-th intention is selected in the second part of the text, and the text corresponding to the i-th intention selected each time is processed. After each processing, the processed text is deleted until the text set is empty.

[0154] The text processing process corresponding to the third intent includes: numerically comparing the amount of text corresponding to the third intent with a preset sample quantity threshold, the numerical comparison result indicates that the amount of text for the third intent is greater than the preset sample quantity threshold, and adding the first text in the text set including the third intent to the second sample set.

[0155] The text processing process corresponding to the 4th intent includes: numerically comparing the amount of text corresponding to the 4th intent with the preset sample quantity threshold, the numerical comparison result indicates that the amount of text of the 4th intent is greater than the preset sample quantity threshold, and adding the first text in the text set including the 4th intent to the second sample set.

[0156] Alternatively, you may first select the text corresponding to the i-th intention in the second part of the text and perform subsequent operations, and then select the text corresponding to the i-th intention in the first part of the text and perform subsequent operations.

[0157] Exemplarily, a specific preset rule for selecting the text corresponding to the i-th intention may be: Based on the number of texts of each intention, the intention with a text amount greater than a preset sample number threshold is taken as the first intention to be processed, and the intention with a text amount less than or equal to the preset sample number threshold is taken as the second intention to be processed. One is randomly selected from the first intention to be processed, namely the i-th intention, and then the text corresponding to the i-th intention is selected from the text set. After each processing of the text corresponding to the selected i-th intention, the processed text is deleted from the text set until the text set does not contain the first text including the first intention to be processed. Then, one is randomly selected from the second intention to be processed, namely the i-th intention, and then the text corresponding to the i-th intention is selected from the text set. After each processing of the text corresponding to the selected i-th intention, the processed text is deleted from the text set until the text set is empty.

[0158] For example, the preset sample quantity threshold is S'. The text set includes: text corresponding to the first intention, text corresponding to the second intention, text corresponding to the third intention, and text corresponding to the fourth intention.

[0159] Among them, the number of texts for the first intention is S1, the number of texts for the second intention is S2, the number of texts for the third intention is S3, and the number of texts for the fourth intention is S4. S1>S', S2 <S’,S3=S’,S4>S’。

[0160] It can be seen that in the text set, the first intention to be processed includes: the first intention and the fourth intention; the second intention to be processed includes: the second intention and the third intention.

[0161] Randomly select one of the first intents to be processed: the fourth intent, and then select the text corresponding to the fourth intent from the text set. After processing the text corresponding to the fourth intent, delete the processed text from the text set. After deletion, the text set includes: the text corresponding to the first intent, the text corresponding to the second intent, and the text corresponding to the third intent.

[0162] Randomly select one of the first intents to be processed: the first intent, and then select the text corresponding to the first intent from the text set. After processing the text corresponding to the first intent, delete the processed text from the text set. After deletion, the text set includes: the text corresponding to the second intent and the text corresponding to the third intent. That is, the text set does not contain the first text that includes the first intent to be processed.

[0163] Randomly select one of the second intents to be processed: the second intent, and then select the text corresponding to the second intent from the text set. After processing the text corresponding to the second intent, delete the processed text from the text set. After deletion, the text set includes: the text corresponding to the third intent.

[0164] Randomly select one of the second intentions to be processed: the third intention, and then select the text corresponding to the third intention from the text set. After processing the text corresponding to the third intention, delete the processed text from the text set. After deletion, the text set is empty.

[0165] Exemplarily, a specific preset rule referred to in selecting the text corresponding to the i-th intention may also be: Based on the number of texts for each intent, the intent with a text amount greater than a preset sample number threshold is taken as the first intent to be processed, and the intent with a text amount less than or equal to the preset sample number threshold is taken as the second intent to be processed. According to the pre-configured intent priority order, one is selected from the first intent to be processed, namely the i-th intent, and then the text corresponding to the i-th intent is selected from the text set. After each processing of the text corresponding to the selected i-th intent, the processed text is deleted from the text set until the text set does not contain the first text including the first intent to be processed. Then, according to the intent priority order, one is selected from the second intent to be processed, namely the i-th intent, and then the text corresponding to the i-th intent is selected from the text set. After each processing of the text corresponding to the selected i-th intent, the processed text is deleted from the text set until the text set is empty.

[0166] For example, the preset sample quantity threshold is S'. The text set includes: text corresponding to the first intention, text corresponding to the second intention, text corresponding to the third intention, and text corresponding to the fourth intention.

[0167] Among them, the number of texts for the first intention is S1, the number of texts for the second intention is S2, the number of texts for the third intention is S3, and the number of texts for the fourth intention is S4. S1>S', S2 <S’,S3=S’,S4>S’。

[0168] It can be seen that in the text set, the first intention to be processed includes: the first intention and the fourth intention; the second intention to be processed includes: the second intention and the third intention.

[0169] The pre-configured intents are prioritized from high to low as follows: 1st intent, 4th intent, 3rd intent, 2nd intent, and so on.

[0170] According to the pre-configured intent priority order, one is selected from the first intent to be processed: the first intent, and then the text corresponding to the first intent is selected from the text set. After the text corresponding to the first intent is processed, the processed text is deleted from the text set. After the deletion, the text set includes: the text corresponding to the fourth intent, the text corresponding to the second intent, and the text corresponding to the third intent.

[0171] According to the pre-configured intent priority order, one is selected from the first intent to be processed: the fourth intent, and then the text corresponding to the fourth intent is selected from the text set. After the text corresponding to the fourth intent is processed, the processed text is deleted from the text set. After the deletion, the text set includes: the text corresponding to the second intent and the text corresponding to the third intent. That is, the text set does not include the first text of the first intent to be processed.

[0172] According to the pre-configured intent priority order, one is selected from the second intent to be processed: the third intent, and then the text corresponding to the third intent is selected from the text set. After the text corresponding to the third intent is processed, the processed text is deleted from the text set. After the deletion, the text set includes: the text corresponding to the second intent.

[0173] According to the pre-configured intent priority order, one is selected from the second intent to be processed: the second intent, and then the text corresponding to the second intent is selected from the text set. After the text corresponding to the second intent is processed, the processed text is deleted from the text set. After the deletion, the text set is empty.

[0174] In some implementations, based on the preset rules, each intent can also be sorted according to the amount of text in each intent to obtain an intent sorting result, and the text corresponding to the i-th intent is selected according to the intent sorting result. The text corresponding to the i-th intent selected each time is processed, and after each processing, the processed text is deleted until the text set is empty.

[0175] In some implementations, the reason for sorting first and then determining which texts to select for processing based on the intent sorting result is that the first text may include multiple sub-texts, and each sub-text in the same first text may have different intents, so a first text may include multiple intents at the same time. Sorting can avoid the following problems: Regarding an intent with a very large number of texts, after performing the above-mentioned processing operation, the K first texts including the intent are deleted from the text set, K is an integer greater than or equal to 1, and the text set no longer includes the K first texts, but in fact these K first texts are not exclusive to the intent with a very large number of texts, and may also involve other rare intents. Therefore, when other rare intents are processed later, the number of first texts may be too small and may not be enough. Therefore, by sorting, rare intents are processed in the front and common intents are processed in the back, so as to ensure that the number of texts for rare intents is sufficient as much as possible, which is conducive to making the number of texts for each intent in the constructed first sample set equal or approximately equal.

[0176] Each intent is sorted according to the number of texts in each intent to obtain an intent sorting result. This can be done by sorting each intent in ascending order of the number of texts to obtain an intent sorting result. In the intent sorting result, the smaller the number of texts, the higher the ranking, and the larger the number of texts, the lower the ranking. According to the intent sorting result, the text corresponding to the i-th intent is selected, and the text corresponding to the i-th intent selected each time is processed. After each processing, the processed text is deleted until the text set is empty. The specific process is as follows: Select the text corresponding to the first intent in the intent sorting result, process the selected text, and delete the text corresponding to the first intent after processing; select the text corresponding to the second intent in the intent sorting result, process the selected text, and delete the text corresponding to the second intent after processing; ...: select the text corresponding to the Nth intent in the intent sorting result, process the selected text, and delete the text corresponding to the Nth intent after processing, so that the text set is empty. N represents the number of intents in the text set, and N is an integer greater than 1.

[0177] Among them, the text processing process corresponding to the selected i-th intention includes: numerically comparing the number of texts corresponding to the i-th intention with a preset sample number threshold; if the number of texts for the i-th intention is less than or equal to the preset sample number threshold, adding the first text in the text set including the i-th intention to the first sample set; if the number of texts for the i-th intention is greater than the preset sample number threshold, adding the first text in the text set including the i-th intention to the second sample set.

[0178] In the case where the first text includes multiple subtexts, considering that the number of texts of other intents may change after deleting the first text including one of the intents in the text set, the number of texts of each intent in each remaining first text in the text set can be re-counted after each deletion operation. That is, after processing the text corresponding to the i-th intent, the processed text is deleted from the text set, and the intent sorting result is updated when the intent sorting result includes at least two intents, and the next selection is performed according to the updated intent sorting result.

[0179] For example: Assume that the intents in the text collection include: Figure 1 ,meaning Figure 2 ,meaning Figure 3 The intent ranking results include: Figure 1 ,meaning Figure 3 ,meaning Figure 2 , among which, Figure 1 The amount of text is less than expected Figure 3 The number of texts, meaning Figure 3 The amount of text is less than expected Figure 2 That is, the intents in the intent sorting results are arranged in ascending order according to the amount of text.

[0180] Sort the results based on intent and select Figure 1 Corresponding text, process the selected text, and delete the meaning in the text collection after processing Figure 1 The corresponding text is used to update the intent sorting results. The updated intent sorting results include: Figure 2 ,meaning Figure 3, among which, Figure 2 The amount of text is less than expected Figure 3 The amount of text.

[0181] Sort the results based on intent and select Figure 2 Corresponding text, process the selected text, and delete the meaning after processing Figure 2 The corresponding text.

[0182] Sort the results based on intent and select Figure 3 Corresponding text, process the selected text, and delete the meaning after processing Figure 3 The corresponding text makes the text collection empty.

[0183] The preset rules listed above are merely exemplary. In actual applications, the preset rules can be configured in combination with the amount of text for each intent and the requirements of the specific scenario.

[0184] Step S208: Screen the second sample set to obtain a target subset, and add the target subset to the first sample set.

[0185] In the case where the sentence intent result of the first text includes one intent, the intent in the first sample set is different from the intent in the second sample set, and the first sample set has no effect on the screening of the second sample set.

[0186] In the case where the sentence intent result of the first text includes one or more intents, the intents in the first sample set and the intents in the second sample set may be partially the same and partially different.

[0187] In some implementations, considering that the number of first texts including common intents in the text set before executing step S202 is relatively large, in order to avoid the situation where the number of first texts including common intents in the first sample set is greater than the preset sample quantity threshold after executing step S208, resulting in uneven sample distribution, common intents whose text quantity is greater than the preset sample quantity threshold can be determined before step S208 is executed, and in the first sample set, redundant sub-texts are determined and deleted in each first text according to the common intents, and then, during the execution of step S208, the preset sample quantity threshold can be used to assist in the screening of the second sample set.

[0188] For example, the intents in the text collection include: Figure 1 ,meaning Figure 2 ,meaning Figure 3 .meaning Figure 1 The number of texts is 50, meaning Figure 2 The number of texts is 45, meaning Figure 3 The number of texts is 700. The preset sample number threshold is 50.

[0189] By comparing the text quantity of each intent and the preset sample quantity threshold, we can see that the intent Figure 1 Harmony Figure 2 Belongs to rare intention, meaning Figure 3 It is a common intention.

[0190] In the text set, each first text includes multiple subtexts, so a part of the first text also includes Figure 1 Harmony Figure 3 ; The other part of the first text also includes the meaning Figure 2 Harmony Figure 3 ,etc.

[0191] Assume that there is no text collection that includes both Figure 1 Harmony Figure 2 The first text of Figure 2 After the first text is assigned to the first sample set, it may cause the first sample set to Figure 3 The number of texts is greater than 0 and less than or equal to 45. For example, the first sample set is Figure 3 The number of texts is 35. Next, Figure 1 After the first text is assigned to the first sample set, it may cause the first sample set to Figure 3 The number of texts in the first sample set increases, and the specific increase value is greater than 0 and less than or equal to 50. For example, the increase value may be 20. Figure 3 The number of texts may exceed 50, for example, 35+20=55>50, which means that the number of samples of common intents overflows and does not meet the expectations of sample construction.

[0192] In order to avoid this situation, the first sample set may include Figure 3 The first text, in each including Figure 3 In the first text, the meaning Figure 3 The corresponding subtext is regarded as a redundant subtext and the redundant subtext is deleted.

[0193] In this way, by determining redundant sub-texts and deleting them, common intents can be excluded from the first sample set. Then, by executing step S208, a portion of the first texts including common intents can be screened from the second sample set and added to the first sample set. This can accurately control the number of texts with common intents in the first sample set, and avoid uneven sample distribution caused by too many texts with common intents.

[0194] For example, after redundant subtexts are determined and deleted from each first text in the first sample set, 50 subtexts including the intended subtexts are selected from the second sample set. Figure 3The first text is put into the first sample set. In this way, in the first sample set, Figure 1 The number of texts is 50, meaning Figure 2 The number of texts is 45, meaning Figure 3 The number of texts is 50, meaning Figure 1 ,meaning Figure 2 And Figure 3 The number of texts is less than or equal to 50, and the values ​​are very close, so the first sample set can be approximately regarded as a balanced sample distribution.

[0195] In other implementations, before executing step S208, common intents whose text quantity is greater than a preset sample quantity threshold can be determined, the text quantity of each common intent can be determined in the first sample set, and the screening quantity of each common intent can be determined based on the text quantity of each common intent and the preset sample quantity threshold. Then, during the execution of step S208, the screening quantity can be used to assist in the screening of the second sample set.

[0196] For any common intent, the screening quantity of the common intent refers to the quantity of first texts including the common intent that need to be screened from the second sample set in the process of screening the second sample set to obtain the target subset.

[0197] For example, the intents in the text collection include: Figure 1 ,meaning Figure 2 ,meaning Figure 3 .meaning Figure 1 The number of texts is 50, meaning Figure 2 The number of texts is 45, meaning Figure 3 The number of texts is 700. The preset sample number threshold is 50.

[0198] By comparing the text quantity of each intent and the preset sample quantity threshold, we can see that the intent Figure 1 Harmony Figure 2 Belongs to rare intention, meaning Figure 3 It is a common intention.

[0199] In the text set, each first text includes multiple subtexts, so a part of the first text also includes Figure 1 Harmony Figure 3 ; The other part of the first text also includes the meaning Figure 2 Harmony Figure 3 ,etc.

[0200] Assume that there is no text collection that includes both Figure 1 Harmony Figure 2 The first text of Figure 2 After the first text is assigned to the first sample set, it may cause the first sample set to Figure 3 The number of texts is greater than 0 and less than or equal to 45. For example, the first sample set is Figure 3 The number of texts is 10. Next, Figure 1 After the first text is assigned to the first sample set, it may cause the first sample set to Figure 3 The number of texts in the first sample set increases, and the specific increase value is greater than 0 and less than or equal to 50. For example, the increase value may be 20. Figure 3 The number of texts with common intents may be less than 50, for example, 10+20=30<50, that is, the number of samples of common intents is less than the preset sample number threshold. Figure 3 The number of texts is 30 and the preset sample number threshold is 50 to determine the meaning Figure 3 The screening number is 50-30-20.

[0201] Furthermore, during the execution of step S208, the screening quantity 20 can be used to assist in the screening of the second sample set. Figure 3 The screening number 20 means that in the process of screening the second sample set to obtain the target subset, 20 samples including the desired subset need to be screened from the second sample set. Figure 3 The first text.

[0202] Next, the 20 samples obtained from the second sample set are Figure 3 After the first text is put into the first sample set, in the first sample set, Figure 1 The number of texts is 50, meaning Figure 2 The number of texts is 45, meaning Figure 3 The number of texts is 50, meaning Figure 1 ,meaning Figure 2 And Figure 3 The number of texts is less than or equal to 50, and the values ​​are very close, so the first sample set can be approximately regarded as a balanced sample distribution.

[0203] The second sample set may include one or more first texts.

[0204] Before screening the second sample set to obtain the target subset, in order to clarify the scope of intent, the intent in the second sample set can be determined based on the intent recognition result of the first text in the second sample set. For details, please refer to the corresponding instructions for determining the intent in the text set mentioned above.

[0205] The following briefly explains the definition of intent in the first sample set with examples: The first sample set may include multiple first texts, and if the intent recognition result of at least one of the first texts includes intent Figure 1 , then you can Figure 1Determined as the intent in the first sample set.

[0206] Based on the same concept, the definition of intent in the second sample set is similar and will not be repeated here.

[0207] For the convenience of distinction, the intent in the first sample set can be determined as the first intent, and the intent in the second sample set can be determined as the second intent. That is, the intent in the first sample set includes one or more first intents, and the intent in the second sample set includes one or more second intents. The first intent and the second intent may be the same or different.

[0208] The second sample set is screened to obtain the target subset, which may be, for each second intent, sampling the first text including the second intent to obtain the sampled text of the second intent, and adding the sampled text of the intent to the target subset. The number of the sampled text of the second intent is equal to a preset sample number threshold.

[0209] The target subset is a subset of the second sample set and can be used to place sample texts that have met the intended purpose of sample construction after screening.

[0210] The target subset may include sample text of one or more second intents.

[0211] In some implementations, the second sample set is screened to obtain a target subset, which can be accomplished by sampling the first text including the second intent in the second sample set according to a preset sample quantity threshold to obtain a sample text of the second intent, and then adding the sample text of the second intent to the target subset.

[0212] In a specific implementation, for each second intent, the number of texts of the second intent is determined in the second sample set, and a sampling parameter corresponding to the second intent is determined based on a preset sample number threshold and the number of texts of the second intent. The first text in the second sample set including the second intent is sampled according to the sampling parameters to obtain the sampled text of the second intent, so that the number of the sampled text of the second intent is equal to the preset sample number threshold, and the sampled text of the second intent is migrated from the second sample set to the target subset.

[0213] For example, the sampling parameter may be a sampling rate, which refers to the frequency of selecting samples from the text, and may be based on the number of characters, words, or other text units. The sampling rate determines the density of the sampling, a higher sampling rate means more samples are selected, and a lower sampling rate reduces the number of samples.

[0214] For example, the preset sample quantity threshold is K, where K is an integer greater than 1. The second intention includes: Figure 1 ,meaning Figure 2 ,meaning Figure 3 In the second sample set, Figure 1 The number of texts is k1, meaning Figure 2 The number of texts is k2, meaning Figure 3 The number of texts is k3. Determine the meaning based on k1 and K Figure 1 The sampling parameters of the second sample set are selected according to the sampling parameters. Figure 1 The first texts are sampled to obtain K first texts, and the K first texts are used as the meaning Figure 1 The sampled text. Determine the meaning based on k2 and K Figure 2 The sampling parameters of the second sample set are selected according to the sampling parameters. Figure 2 The first texts are sampled to obtain K first texts, and the K first texts are used as the meaning Figure 2 The sampled text. Determine the meaning based on k3 and K Figure 1 The sampling parameters of the second sample set are selected according to the sampling parameters. Figure 3 The first texts are sampled to obtain K first texts, and the K first texts are used as the meaning Figure 3 Sample text of .

[0215] In other implementations, the second sample set is screened to obtain a target subset, which may be by sampling the first text including the second intent in the second sample set according to preset sampling parameters to obtain the sampled text of the second intent. If the number of sampled texts of the second intent is less than or equal to a preset sample number threshold, the sampled text of the second intent is migrated from the second sample set to the target subset; if the number of sampled texts of the second intent is greater than the preset sample number threshold, the sampled text of the second intent is migrated from the second sample set to the candidate subset, so as to further reduce the number of texts of the second intent through other screening methods later.

[0216] For example, the second sample set includes N first texts, where N is an integer greater than or equal to 1, and each of the N first texts has a unique corresponding second intent. Figure 1 The number of texts is K1, and for K1 texts including Figure 1 The first text is sampled and processed to obtain K1' meanings Figure 1 The sampled text, K1 and K1' are both integers greater than or equal to 1, and K1' is less than K1. Assuming that K1' is less than or equal to the preset sample quantity threshold, the K1' meaning Figure 1 The sampled texts are migrated to the target subset. Figure 2 The number of texts is K2, and for K2 texts including Figure 2The first text is sampled and processed to obtain K2' meanings Figure 2 The sampled text, K2 and K2' are both integers greater than or equal to 1, and K2' is less than K2. Assuming that K2' is less than or equal to the preset sample quantity threshold, the K2' meaning Figure 2 The sampled texts are migrated to the target subset. Figure 3 The number of texts is K3, including Figure 3 The first text is sampled and processed to obtain K3' meanings Figure 3 K3 and K3' are both integers greater than or equal to 1, and K3' is less than K3. Assuming that K3' is greater than the preset sample quantity threshold, the K3' meaning Figure 3 The sampled text is migrated to the candidate subset so that other screening methods can be used to further reduce the meaning. Figure 3 The amount of text.

[0217] For another example, the second sample set includes N first texts, where N is an integer greater than or equal to 1, and each of the N first texts has one or more second intentions. Figure 1 The number of texts is K1, and for K1 texts including Figure 1 The first text is sampled and processed to obtain K1' meanings Figure 1 The sampled text, K1 and K1' are both integers greater than or equal to 1, and K1' is less than K1. Figure 1 After the sampled text is obtained, assuming that K1' is less than or equal to the preset sample quantity threshold, the K1' meaning Figure 1 The sampled texts are transferred to the target subset, and the remaining (K1-K1') include Figure 1 The first text of the (N-K1') first texts is still retained in the second sample set for subsequent screening of other intents. Figure 2 The number of texts is K2, and for K2 texts including Figure 2 The first text is sampled and processed to obtain K2' meanings Figure 2 The sampled text, K2 and K2' are both integers greater than or equal to 1, and K2' is less than K2. Figure 2 After the sampled text is obtained, assuming that K2' is less than or equal to the preset sample quantity threshold, the K2' meaning Figure 2 The sampled texts are transferred to the target subset, and the remaining (K2-K2') include Figure 2 The first text of the second sample set is still retained in order to be used to filter other intents later. Then, among the (N-K1'-K2') first texts, the intent Figure 3 The number of texts is K3, including Figure 3The first text is sampled and processed to obtain K3' meanings Figure 3 The sampled text, K3 and K3' are both integers greater than or equal to 1, and K3' is less than K3. Figure 3 After the sampled text is obtained, assuming that K3' is greater than the preset sample quantity threshold, the K3' meaning Figure 3 The sampled text is migrated to the candidate subset so that other screening methods can be used to further reduce the meaning. Figure 3 The remaining (K3-K3') include Figure 3 The first text is still retained in the second sample set so as to be used for subsequent screening of other intents, and so on.

[0218] In addition, in order to ensure that a sufficient number of sampled texts can be screened for each second intent, sorting can be performed first and then sampling.

[0219] According to the number of texts of each second intent in the second sample set, each second intent is sorted to obtain an intent sorting result; according to the intent sorting result, the first text corresponding to each second intent is sampled in turn to obtain the sampled text of the second intent; for each second intent, if the number of sampled texts of the second intent is less than or equal to a preset sample number threshold, the sampled text including the second intent in the second sample set is migrated to the target subset; if the number of sampled texts of the second intent is greater than the preset sample number threshold, the sampled text including the second intent in the second sample set is migrated to the candidate subset, so as to further reduce the number of texts of the second intent through other screening methods later.

[0220] By giving priority to processing intents with less text, it is more beneficial that after migrating a portion of the first text in the second sample set to the target subset, the remaining portion of the first text in the second sample set is sufficient to be used to screen out sample texts whose number of other intents is equal to the preset sample quantity threshold when processing other intents subsequently.

[0221] For example, the second sample set includes 150 first texts in total, among which Figure 1 The number of texts is 100, meaning Figure 2 The number of texts to be processed is 50. The preset sample number threshold is 30. Figure 1 , will mean Figure 1 The 30 sample texts are added to the target subset, which may result in a part of the text containing both Figure 1 Also includes intention Figure 2 The first texts of the second sample set are removed, and then, among the remaining 120 first texts in the second sample set, the meaning Figure 2The first text of the intent may only have 25 left. Considering that performing a filtering operation can only reduce the number of texts in the intent, but cannot increase the number of texts in the intent, Figure 2 At most, Figure 2 The 25 sample texts are added to the target subset.

[0222] Although in the process of constructing the first sample set, the user's expectation for the number of texts for each intent is less than or equal to the preset sample number threshold, the "less than" here is a concession made considering that there may be individual rare intents that do have too few texts. In order to balance the distribution of the first text in the first sample set obtained after executing the text processing method provided by one or more embodiments of the present application, in the most ideal state, after executing the text processing method provided by this embodiment, the number of texts for each intent in the first sample set is equal to the preset sample number threshold. In the first sample set, the closer the number of texts of different intents is, the more balanced the distribution of the constructed text samples is, and the better the training effect of the subsequent input of the text samples into the model training. Therefore, in the process of executing the text processing method, no special requirements are made for rare intents, but the number of texts for common intents should be equal to the preset sample number threshold as much as possible.

[0223] In addition, in order to avoid the situation where the number of samples of rare intents is too small, after executing step S208, it is also possible to determine whether there is an intent in the first sample set whose text quantity is less than or equal to a preset abnormal quantity threshold. If so, a notification message is generated, which carries the intent identifier of "the intent whose text quantity is less than or equal to the preset abnormal quantity threshold" to prompt the user to update the first sample set according to the intent.

[0224] By sorting the intents, it is possible to avoid as much as possible the situation where the number of texts for each intent in the second sample set is insufficient, which is conducive to building a first sample set with balanced distribution.

[0225] In addition, after step S202 is executed, data statistical processing may be performed on the text set to obtain statistical results of one or more preset statistical parameters of the text set.

[0226] Taking the first text in the telemarketing scenario as the conversation text between the agent and the customer as an example, the preset statistical parameters include but are not limited to: conversation rounds, average length of conversation sentences, customer closing remarks, agent closing remarks, etc.

[0227] The statistical results of the preset statistical parameters can be used as a screening basis in the process of screening the second sample set to obtain the target subset.

[0228] For example, the statistics of the conversation rounds of the text set indicate that the average conversation rounds of the first text in the text set are M rounds. The second sample set is screened according to the statistics of the conversation rounds, and the first text with more than M rounds of conversation rounds is migrated to the target subset, and the first text with less than or equal to M rounds of conversation rounds is retained in the second sample set. M is an integer greater than 1.

[0229] After the target subset is added to the first sample set, the first sample set is constructed and can be used as training data for the language model. The second sample set no longer includes any first text in the target subset, and the number of texts for each intent in the first sample set is less than or equal to a preset sample number threshold.

[0230] In addition, after adding the target subset to the first sample set, the quality assessment process can also be performed on each first text in the first sample set. If the quality assessment result of the first text is passed, the first text is retained in the first sample set. If the quality assessment result of the first text is not passed, the first text is deleted. Considering that deleting a part of the first text with a quality assessment result not passed after the quality assessment may cause a large difference between the number of texts of a part of the intentions in the first sample set and the preset sample number threshold, which is not conducive to the balanced distribution of text samples, it can be determined whether it is necessary to screen a part of the text samples from the second sample set or other new text sets and put them into the first sample set according to the number of texts of each intention in the first text and the preset sample number threshold.

[0231] After the target subset is added to the first sample set, the number of texts of each intent in the first sample set is less than or equal to a preset sample number threshold, which is conducive to constructing a text sample with a balanced distribution.

[0232] In a specific implementation, the second sample set is screened to obtain a target subset, including: determining the intent in the second sample set as the second intent, clustering the first text including the second intent to obtain a clustering result of the second intent; and based on the clustering result of the second intent, selecting a preset number of first texts from the first text including the second intent and adding them to the target subset.

[0233] Clustering is a technique in data analysis and machine learning. Its purpose is to group a set of data objects into multiple classes or clusters, so that objects in the same cluster have high similarity, while objects in different clusters have high dissimilarity. Clustering is an unsupervised learning method because it does not require pre-labeled data.

[0234] The main goals of cluster analysis include: (1) Discover the intrinsic structure of data: Clustering can reveal hidden patterns and relationships in the data.

[0235] (2) Data simplification: Grouping a large number of data points into a smaller number of clusters helps to simplify data representation and analysis.

[0236] (3) Anomaly Detection: Clustering can help identify abnormal points or outliers in the data.

[0237] (4) Classification and labeling: In some cases, clustering results can be used to assign category labels to data points.

[0238] Simply put, clustering can be understood as grouping multiple texts with similar semantics into the same group.

[0239] Clustering results refer to the data grouping obtained after processing data through clustering algorithms. Specifically, clustering results divide a set of data objects into several clusters, each of which consists of a group of similar data objects. These clusters represent the inherent structure and pattern in the data.

[0240] The intent in the second sample set is determined as the second intent.

[0241] For example, the second sample set includes first text 1, first text 2, and first text 3.

[0242] The intent recognition results of the first text 1 include: Figure 1 Harmony Figure 2 The intent recognition result of the first text 2 includes: Figure 2 Harmony Figure 3 The intent recognition result of the first text 3 includes the intent Figure 4 .

[0243] According to the intention recognition results of each first text, it can be determined that the intentions in the second sample set include: Figure 1 ,meaning Figure 2 ,meaning Figure 3 And Figure 4 That is, the second intention includes Figure 1 ,meaning Figure 2 ,meaning Figure 3 And Figure 4 .

[0244] The second sample set may include multiple first texts. The intent recognition result of each first text in the second sample set may include one or more intents.

[0245] The first text including the second intent is clustered to obtain a clustering result of the second intent.

[0246] For example, the second sample set contains Figure 1 The 100 first texts, as well as, also exist including Figure 2 The 150 first texts.

[0247] Targeted Figure 1 , including Figure 1 The 100 first texts are clustered and the meaning is obtained. Figure 1 The clustering results, as well as Figure 2 , including Figure 2 The 150 first texts are clustered and the meaning is obtained. Figure 2 The clustering results.

[0248] According to the clustering result of the intent, the first texts including the intent may be divided into a plurality of groups, and the semantic similarity of each first text in each group is greater than a preset similarity threshold.

[0249] According to the clustering result of the second intent, a preset number of first texts are selected from the first texts including the second intent and added to the target subset.

[0250] After obtaining multiple groups, one or more first texts may be randomly selected in each group, and the selected first texts may be added to the target subset, thereby making the semantics of the first texts with the same intention in the target subset more diverse.

[0251] The preset number may be one or more than one, and may be determined by a preset sample number threshold.

[0252] For example, the preset sample quantity threshold is 30, and the preset quantity is 30.

[0253] Alternatively, if you want to perform another round of screening through other screening methods, you can also set the preset number to a value greater than the preset number of sample thresholds.

[0254] For example, the preset sample quantity threshold is 30 and the preset quantity is 50.

[0255] In practical applications, multiple text samples with the same intent may have similar semantics or large differences.

[0256] For example, the inquiry intent is: Text 1: When will activity A end? Text 2: What materials do I need to process business B offline? Text 3: When will activity D end? If the second sample set is screened by random sampling to obtain the target subset, multiple sentences with similar semantics may be put into the target subset, resulting in poor sample diversity for the semantics. However, for the sake of model training effect, when constructing samples, users often expect the texts with the same intent to be as diverse as possible.

[0257] Therefore, by clustering the first texts that include intent, the first texts with similar semantics can be grouped together, and the first texts with different semantics can be grouped into different groups. Then, each of the multiple groups selects a portion of the first texts to add to the target subset, and the target subset is added to the first sample set, which is conducive to making the semantics of the same intent in the constructed first sample set more diversified.

[0258] In a specific implementation method, the clustering results of the second intention include a first number of clusters; based on the clustering results of the second intention, a preset number of first texts are selected from the first text including the second intention and added to the target subset, including: in the first number of clusters, the center position of each cluster is determined; for each cluster, according to the center position of the cluster and the preset radius, the target text belonging to the cluster in the clustering results of the second intention is determined; a second number of target texts are selected and added to the target subset; the second number is determined by the first number and the preset number.

[0259] In cluster analysis, a cluster refers to a set of data objects that are similar to each other under a certain similarity measure, but different from data objects in other clusters. In other words, a cluster is the result of a clustering algorithm grouping a data set. Each cluster represents a subset of the data. Objects within a cluster have high similarity, while objects between clusters have high dissimilarity.

[0260] The clustering result of the second intention includes a first number of clusters, and each cluster can be regarded as a set consisting of one or more first texts.

[0261] The first number may be determined by clustering. The center position of each cluster may be determined by clustering.

[0262] For each cluster, the target text belonging to the cluster in the clustering result of the second intention is determined according to the center position and the preset radius of the cluster. It can be that the circular area corresponding to the cluster can be determined according to the center position and the preset radius of the cluster, and the circular area includes one or more points, each point represents a first text, and the first text represented by each point in the circular area is used as the target text belonging to the cluster.

[0263] The second number may be a ratio of a preset number to the first number, or the second number may be a ratio of the preset number to the first number plus / minus a specified value.

[0264] For example, the preset number is 200, and in the first sample set expected to be obtained by executing the text processing method provided in the embodiment of the present application, the number of samples for each intent is 200. Assume that the clustering result of the second intent includes 10 (i.e., the first number) clusters, and the semantics of each target text in each cluster are relatively similar. In these 10 clusters, each cluster selects 20 (i.e., the second number) target texts to be added to the target subset. In this way, a total of 10x20=200 (i.e., the preset number) target texts are selected and added to the target subset.

[0265] Taking the example that the second number is the ratio of the preset number to the first number, for each cluster, a second number of target texts are selected from the target texts belonging to the cluster, and if the intended clustering result includes the first number of clusters, a total of the preset number of target texts are selected.

[0266] For example, Figure 1 The clustering result includes 10 clusters, each cluster has a center position and a preset radius R. According to the center position and R, a circle can be determined. There are multiple points in the circle, and each point represents a first text, that is, the target text belonging to the cluster.

[0267] The preset number is 30, and there are 10 clusters. Then selecting 3 target texts in each circle will make up 30 target texts, that is, the second number is 3.

[0268] In addition, according to the clustering result of the second intention, a preset number of first texts are selected from the first text including the intention and added to the target subset. It is also possible to determine the circular area corresponding to the cluster according to the center position of the cluster and the preset radius, the circular area includes one or more points, each point represents a first text, randomly select a point in the circular area, and randomly select K points from the points outside the circular area but belonging to the cluster, and add the first texts represented by the selected points to the target subset. K is an integer greater than 1, and K can be determined by the first number and the preset number.

[0269] For example, Figure 2 The clustering result includes 10 clusters, each cluster has a center position and a preset radius R. According to the center position and R, a circle can be determined, and there are multiple points inside the circle. There are multiple points outside the circle belonging to the cluster, and each point represents a first text.

[0270] The preset number is 30, and there are 10 clusters. For each cluster, select one in the circular area and 2 outside the circular area, and you can collect 30 first texts and add them to the target subset.

[0271] In the case where the intent recognition result of the first text includes one or more intents, the first intent in the first sample set may include the second intent in the second sample set.

[0272] For example, the first intention includes: Figure 1 ,meaning Figure 2 ,meaning Figure 3 ,meaning Figure 4 And Figure 5 The second intention includes Figure 1 Harmony Figure 2 .

[0273] In the above case, in order to balance the sampling, the number of texts of each first intent in the first sample set can be statistically processed first, and each first intent can be sorted according to the number of texts of each first intent. Then, using the sorting results of each first intent, the screening can be started from the second intent with less text, and the second intent that has met the standard will no longer be sampled. The second intent has met the standard means that the number of texts of the first intent that matches the second intent in the first sample set is less than or equal to the preset sample number threshold, or there is no first text including the second intent in the second sample set.

[0274] For each second intention that does not meet the standard, first group them according to the cluster, round the cluster distance, and then group them according to the distance between each first text and the center position of the cluster to determine whether the distance is less than or equal to a preset distance threshold.

[0275] When the distance is less than or equal to the preset distance threshold, it means that the data semantic difference between the first text and the cluster cluster is small enough, and one first text can be screened for each distance grouping and added to the target subset; when the distance is greater than the preset distance threshold, it means that the data semantic difference between the first text and the cluster cluster is large, and multiple first texts can be screened for each distance grouping and added to the target subset.

[0276] Through intent clustering, we can select the most informative part of the first text from the first text corresponding to common intents with a relatively large number of texts, so that the semantics of the screened first text can be as diverse as possible. This is more conducive to achieving the same generalization ability while reducing the amount of training data, and can greatly reduce the fine-tuning cost and increase the iteration speed.

[0277] In a specific implementation method, the second sample set is screened to obtain a target subset, including: for each keyword in a preset keyword set, determining the first text including the keyword in the second sample set, and using the first text including the keyword as the first text sample of the keyword; counting the number of first text samples of each keyword in the second sample set to obtain a target sample number for each keyword; if the target sample number is less than or equal to a preset sample number threshold, adding the first text sample of the keyword to the target subset.

[0278] The use of the keyword set is based on the consideration that, during the execution of step S202, if the intent recognition model is used, only a part of the intent may be recognized, and some personalized intents in specific fields may be difficult to distinguish. In this case, each keyword in the keyword set can be used to screen in the second sample set.

[0279] The preset keyword set may include one or more keywords, each of which represents an intention.

[0280] For each keyword in the preset keyword set, it can be determined whether each first text in the second sample set includes the keyword. If the first text includes the keyword, the first text is used as the first text sample of the keyword.

[0281] The number of first text samples of each keyword in the second sample set is counted to obtain a target sample number for each keyword; if the target sample number is less than or equal to a preset sample number threshold, the first text sample of the keyword is added to a target subset; if the target sample number is greater than the preset sample number threshold, the first text sample of the keyword is added to a candidate subset, pending subsequent screening through other screening methods to reduce the sample number of the keyword.

[0282] In addition, the number of first text samples of each keyword in the first sample set can also be counted to obtain the number of samples for each keyword; the keywords can be sorted according to the number of samples of each keyword to obtain keyword sorting results; and according to the keyword sorting results, the target sample number of each keyword and the preset sample number threshold can be numerically compared in turn.

[0283] The reason why we need to sort first and then compare the target sample quantity of each intent with the preset sample quantity threshold in turn according to the keyword sorting results is that the first text may include one or more keywords, so a first text may be used as the first text sample of multiple keywords at the same time. Sorting can avoid the following problems: for a keyword with a relatively large number of target samples, after performing the numerical comparison process, the K first text samples of the keyword are migrated from the second sample set to the target subset, K is an integer greater than or equal to 1, and then after the migration, the second sample set no longer includes the K first text samples, but in fact, these K first text samples do not only include the keyword, but may also involve other rarer keywords. Then, when the rarer keyword is processed later, the number of first text samples may be too small and may not be enough. Therefore, by sorting, the rarer keywords are processed in the front and the relatively common keywords are processed in the back, so as to ensure that the number of texts of rare keywords is sufficient.

[0284] In addition, the keyword may include a first keyword and a second keyword, and the first keyword is processed before the second keyword.

[0285] In the case where the target sample number of the second keyword in the second sample set is less than or equal to the preset sample number threshold, the candidate subset corresponding to the previously processed first keyword can be obtained to determine the sample number of the second keyword included in the candidate subset corresponding to the first keyword. For the sake of distinction, it can be referred to as the candidate sample number of the second keyword. If the sum of the target sample number and the candidate sample number of the second keyword is less than or equal to the preset sample number threshold, the first text sample of the second keyword in the second sample set and the first text sample of the second keyword in the candidate subset corresponding to the first keyword are added to the target subset; if the sum of the target sample number and the candidate sample number of the second keyword is greater than the preset sample number threshold, the first text sample of the second keyword in the second sample set and the first text sample of the second keyword in the candidate subset corresponding to the first keyword are added to a candidate subset, to be subsequently screened by other screening methods to reduce the sample number of the keyword.

[0286] In a specific implementation, the second sample set is screened to obtain a target subset, including: determining the intent in the second sample set as the second intent, statistically processing the preset features of the first text including the second intent, and obtaining distribution information of the preset features; based on the distribution information of the preset features, sampling the first text including the second intent to obtain a second text sample of the second intent, and adding the second text sample to the target subset.

[0287] Distribution Information refers to information about the frequency or probability of occurrence of each data point in a data set in statistics and data analysis. It describes the distribution of data in different values ​​or intervals, helping us understand the central tendency, dispersion and shape characteristics of the data.

[0288] Specifically in one or more embodiments of the present application, the distribution information may reflect the distribution of each first text including the second intent in the preset features.

[0289] In the case where the first text is a dialogue text, the preset feature may be a dialogue turn, and the distribution information of the preset feature, for example, Figure 1 Among the 100 first texts, 30 first texts have 3 dialogue turns, 40 first texts have 4 dialogue turns, 20 first texts have 5 dialogue turns, and 10 first texts have 6 dialogue turns. The distribution information of the dialogue turns can be expressed by 0:0:30:40:20:10=0:0:3:4:2:1, wherein the first "0" represents the proportion information of the first text with a dialogue turn of 1; the second "0" represents the proportion information of the first text with a dialogue turn of 2; "3" represents the proportion information of the first text with a dialogue turn of 3; "4" represents the proportion information of the first text with a dialogue turn of 4; "2" represents the proportion information of the first text with a dialogue turn of 5; and "1" represents the proportion information of the first text with a dialogue turn of 6.

[0290] The preset feature may also be a target preset interval corresponding to the text length of the first text in a plurality of preset length intervals.

[0291] For example, in the Figure 2 Among the 100 first texts, the text lengths of 50 first texts are within the first preset interval, and the text lengths of the other 50 first texts are within the second preset interval, then the distribution information of the text lengths can be represented by 50:50=1:1, wherein the first "1" represents the proportion information of the first texts whose text lengths are within the first preset interval, and the second "1" represents the proportion information of the first texts whose text lengths are within the second preset interval.

[0292] The two preset features listed above are merely exemplary. The preset feature may be any feature extracted from the first text, and the user may customize the configuration.

[0293] The ratio information of the preset feature may be a ratio of a plurality of candidate feature values ​​of the preset feature. The second text sample of the second intent may be composed of second text samples corresponding to each candidate feature value.

[0294] According to the distribution information of the preset feature, the first text including the second intent is sampled and processed to obtain the second text sample of the second intent. The method may be to determine the sampling quantity corresponding to each candidate feature value according to the distribution information and a preset sample quantity threshold, and for each candidate feature value, determine the first text corresponding to the candidate feature value in the first text including the second intent, and then perform sampling processing on the first text corresponding to the candidate feature value according to the sampling quantity corresponding to the candidate feature value to obtain the second text sample corresponding to the candidate feature value.

[0295] For example, the first text is a dialogue text, and different dialogue texts may include 2 rounds of dialogue, 3 rounds of dialogue, ..., N rounds of dialogue, where N is an integer greater than 1.

[0296] In the second sample set, Figure 1 , including Figure 1 The first text has 100.

[0297] Among these 100 first texts, the number of dialogue rounds is statistically processed, and it can be found that: 2 rounds: 3 rounds: 4 rounds = 2:3:5, that is, among the 100 first texts, 20 first texts include 2 rounds of dialogue, 30 first texts include 3 rounds of dialogue, and 50 first texts include 5 rounds of dialogue.

[0298] The preset sample quantity threshold is 10, which means that the user only wants 10 Figure 1 In this case, 2 samples can be randomly sampled from 20 text samples including 2 rounds of dialogue, 3 samples can be randomly sampled from 30 text samples including 3 rounds of dialogue, and 5 samples can be randomly sampled from 50 text samples including 4 rounds of dialogue. This is conducive to the distribution of the second text samples obtained by sampling and the second sample set being consistent in the preset feature of the number of dialogue rounds.

[0299] In such Figure 2In the illustrated embodiment, first, intent recognition is performed on the first text in the text collection to obtain an intent recognition result of the first text; then, based on the intent recognition result of the first text, the number of texts for each intent in the text collection is determined; then, based on the number of texts for each intent and a preset sample number threshold, the text collection is divided into a first sample collection and a second sample collection; the number of texts for each intent in the first sample collection is less than or equal to the preset sample number threshold; finally, the second sample collection is screened to obtain a target subset, and the target subset is added to the first sample collection. In this way, the intention recognition results of each first text in the text set can be used to determine the text quantity of each intention. For any intention, the fewer the text quantity of the intention, the rarer the intention, and conversely, the more the text quantity of the intention, the more common the intention. By configuring the preset sample quantity threshold, the first text with relatively rare intention can be placed in the first sample set, and the first text with relatively common intention can be placed in the second sample set. The text quantity of the first text with relatively rare intention is less than or equal to the preset sample quantity threshold, and the text quantity of the first text with relatively common intention is greater than the preset sample quantity threshold. After obtaining the second sample set, the text quantity of the first text with relatively common intention can be reduced to the preset sample quantity threshold by screening the second sample set. Then, after the reduced number of first texts with relatively common intention is placed in the first sample set, the text quantity of each intention in the first sample set can be equal to or less than the preset sample quantity threshold. Therefore, when close to the same fixed value, the text quantity of each intention can be approximately regarded as the same, which is conducive to improving the balanced distribution of samples.

[0300] The following takes the application of a text processing method provided by this embodiment in a telemarketing scenario as an example. Figure 3 The text processing method provided in this embodiment is further explained. Figure 3 A processing flow chart of another text processing method provided in an embodiment of the present application.

[0301] like Figure 3 As shown, step S302, data cleaning.

[0302] Perform data cleaning on the candidate sample set of telemarketing data.

[0303] The candidate sample set of telemarketing data may refer to the text set in the aforementioned method embodiment.

[0304] In the telemarketing scenario, the telemarketing data candidate sample set includes multiple first texts, each of which is a conversation data.

[0305] Step S304: data statistics.

[0306] Step S306, intent recognition.

[0307] For this step, reference may be made to the corresponding description of step S202 in the aforementioned method embodiment.

[0308] Step S308, screening data based on intent recognition.

[0309] Step S310, screening data according to keywords.

[0310] Step S312, clustering different intent data sets.

[0311] Step S314: screening data according to the clustering results.

[0312] In some implementations, after step S308 is executed, step S310, step S312, and step S314 may be executed in sequence to obtain a valid sample set; or, after step S308 is executed, step S310 may be skipped, and step S312 and step S314 may be executed in sequence to obtain a valid sample set; or, after step S308 is executed, step S310 may be executed, and step S312 and step S314 may be skipped to obtain a valid sample set.

[0313] The valid sample set refers to a set of constructed text samples, and can refer to the first sample set obtained after executing step S208 in the aforementioned method embodiment.

[0314] In other implementations, after step S314 is executed, if the number of texts for each intent in the obtained valid sample set does not meet the expectation of sample construction, the process can return to step S306 and subsequent steps to iterate the valid sample set until the number of texts for each intent in the valid sample set meets the expectation of sample construction.

[0315] Whether the amount of text for each intent meets the expectation of sample construction can be determined by a preset sample amount threshold and the amount of text for each intent.

[0316] In addition, by modifying the preset sample quantity threshold, the total amount of data screening can be conveniently adjusted during the construction of the text sample.

[0317] Since the technical concept is the same, the description in this embodiment is relatively simple, and the relevant parts may refer to the corresponding description of the method embodiment provided above.

[0318] Figure 4 A processing flow chart of another text processing method provided in an embodiment of the present application.

[0319] like Figure 4 As shown, step S402, data cleaning.

[0320] Step S404: data statistics.

[0321] Step S406: client-side single sentence intent recognition.

[0322] In telemarketing scenarios, agents usually use fixed lines of speech in conversations. Recognizing the intent of the agents' sentences is not very helpful in building a balanced text sample. Therefore, the agent's sentences are ignored, and only the customer's sentences are used for intent recognition.

[0323] For this step, reference may be made to the corresponding description of step S202 in the aforementioned method embodiment.

[0324] Step S408, counting the data volume of each intent in the sample set and arranging them in ascending order.

[0325] For this step, reference may be made to the corresponding description of step S204 in the aforementioned method embodiment.

[0326] Step S410, traverse each intent.

[0327] Step S412: the data volume is less than or equal to a threshold.

[0328] The threshold in this step is the preset sample quantity threshold mentioned above. The data volume refers to the number of texts for each intent.

[0329] If the data volume is less than or equal to the threshold, execute step S414; if the data volume is greater than the threshold, execute step S416.

[0330] Step S414: adding the subset to the first sample set.

[0331] Step S416: adding the subset to the second sample set.

[0332] For steps S410 to S416 , reference may be made to the corresponding description of step S206 in the aforementioned method embodiment.

[0333] Step S418: Count the data volume of each keyword in the first sample set and sort them in ascending order.

[0334] Step S420, traverse each keyword.

[0335] Step S422: Filter samples in the second sample set that contain the current keyword.

[0336] Step S424, filtering data volume ≤ threshold value.

[0337] The amount of data to be screened may refer to the target sample quantity of the intended keywords in the aforementioned method embodiment.

[0338] If the amount of filtered data is less than or equal to the threshold, step S426 is executed; if the amount of filtered data is greater than the threshold, step S432 is executed.

[0339] Step S426: the remaining data volume ≤ the threshold value - the screening data volume.

[0340] This step may refer to the corresponding description part of "if the sum of the target sample quantity and the candidate sample quantity of the second keyword is less than or equal to the preset sample quantity threshold" in the aforementioned method embodiment.

[0341] If the remaining data volume is less than or equal to the threshold value minus the screening data volume, step S414 is executed; if the remaining data volume is greater than the threshold value minus the screening data volume, step S428 is executed.

[0342] Step S428, counting the proportions of different dialogue rounds and determining the amount of data filtered in different rounds.

[0343] Step S430: random screening is performed in combination with statistical indicators.

[0344] Step S432: adding the subset to the second sample set.

[0345] It should be emphasized here that adding a subset to the second sample set means that after screening in sequence, the number of samples of the intended keyword is still greater than the threshold. Therefore, the text sample of the intended keyword needs to be added to the candidate subset to be further screened through other screening methods in subsequent steps.

[0346] Step S434, counting the data volume of each intent in the second sample set and sorting them in ascending order.

[0347] Step S436, traverse all intents.

[0348] Step S438, filtering samples in the second sample set that contain the current intention.

[0349] Step S440: concatenate the client-side sentences to the current intent candidate sample.

[0350] Step S442, sentence content cleaning.

[0351] Step S444, clustering.

[0352] Step S446, clustering results of the current intent candidate sample set.

[0353] Step S448, counting the amount of data currently intended to be in the first sample set.

[0354] Step S450, filtering data volume ≤ threshold value.

[0355] If the amount of filtered data is less than or equal to the threshold, step S452 is executed.

[0356] Step S452: grouping according to clusters.

[0357] Step S454, grouping according to distance.

[0358] Step S456, distance ≤ threshold.

[0359] If the distance is less than or equal to the threshold, execute step S458; if the distance is greater than the threshold, execute step S460.

[0360] Step S458, screening multiple samples for each group in combination with statistical indicators.

[0361] Step S460, screening a sample for each group in combination with the statistical index.

[0362] Step S462: Generate a valid sample candidate set.

[0363] Step S464, random sampling.

[0364] Since the technical concept is the same, the description in this embodiment is relatively simple, and the relevant parts may refer to the corresponding description of the method embodiment provided above.

[0365] Figure 5 A model training flowchart provided for an embodiment of the present application shows a model training method, in which the training data used in the model training method is a first sample set generated by executing the text processing method provided by the aforementioned method embodiment.

[0366] like Figure 5 As shown, step S502 is sampling of valid sample sets based on intent clustering.

[0367] This step may refer to the corresponding description part of the complete implementation flow of the text processing method provided in the aforementioned method embodiment.

[0368] The first text can be a dialogue text. Taking the telemarketing scenario as an example, Figure 5 In , a dialogue text is represented by sample 1, sample 2, ..., sample N. N is an integer greater than 1.

[0369] Set the amount of data that needs to be sampled for each intent, that is, configure the preset sample quantity threshold. Call the valid sample set sampling module based on intent clustering to downsample the data and obtain the initial valid training sample set.

[0370] The effective sample set sampling module based on intent clustering can be used to execute the text processing method provided by the aforementioned method embodiment.

[0371] The initial valid training sample set may refer to the first sample set obtained after executing step S208 in the aforementioned method embodiment.

[0372] Step S504, calling the general large model to perform sample scoring and re-segmentation.

[0373] Step S506: re-label samples with lower scores.

[0374] In the telemarketing scenario, the dialogue text is converted from speech. The ASR (Automatic Speech Recognition) translation process will cause many typos, punctuation errors, punctuation errors, etc. If the initial valid training sample set generated after step S502 is directly used to fine-tune the large language model, the large language model will also have the same problems. If all training sets are manually checked, the workload is relatively large. In order to reduce the manual workload, the general large model can be called by the few-shot prompt method to score each dialogue text. The dialogue text with a low score is manually re-annotated, for example, typos, incorrect punctuation and punctuation are corrected, etc. The sentences on the agent side can also be called by the general large model for re-segmentation, which can further eliminate the dialogues with incorrect punctuation in the middle and correct the sentences with incorrect punctuation.

[0375] LLMs (Large Language Models) refer to complex artificial intelligence systems that are trained using large amounts of data and computing resources and can understand and generate human language. These models are usually based on deep learning techniques, especially the Transformer architecture, which can capture the nuances of language, including grammar, semantics, contextual relationships, and some common sense knowledge.

[0376] General Large Models refer to large artificial intelligence models designed to handle a variety of tasks and fields.

[0377] The few-shot prompt method is a technique used in the field of NLP, especially in large pre-trained language models. This method aims to guide the model to perform a specific task by providing a small number of examples (i.e., "few-shot" examples) without the need for extensive task-specific training.

[0378] After step S506 is executed, the manually modified training data may be used as the final fine-tuning data set.

[0379] Step S508, fine-tuning the large language model for a specific domain through a supervised fine-tuning method.

[0380] The sampled fine-tuning dataset is used to fine-tune the language model in the field of telemarketing, that is, the language model used by the conversational robot. The supervised fine-tuning method is used to fully fine-tune the model parameters. After the model is fine-tuned, it can be used for human-computer dialogue.

[0381] The quality of the training data set directly determines the final effect of the model. Most of the early work of the NLP task is also mainly concentrated in the data preprocessing part. It is very important to screen effective data sets and effectively improve the efficiency of data processing. The model training method provided in this embodiment uses a method combining intent, keywords and clustering to perform effective data sampling, and calls a general large model to score the sampled data, providing prior information for manual re-labeling, thereby improving the efficiency of the entire data processing.

[0382] First, the effective sample set sampling module based on intent clustering downsamples the data to obtain the initial effective training sample set. It not only retains the diversity and complexity of the original data set, but also can further control the range of the candidate data set according to various statistical information, limit the data set to the required range from multiple dimensions, and reduce the sampling of redundant data from different clustering distances, so that the training data has better generalization performance.

[0383] Secondly, we call the general large model and use the few-shot prompt method to score the selected training set. We use the score threshold to filter out low-scoring data, which indicates that the quality of the text conversation data is not high and there are some typos, incorrect punctuation and other problems. This can effectively reduce labor costs.

[0384] Finally, by manually relabeling the data with lower scores to ensure the overall quality of the training data and fine-tuning the model with high-quality data, a high-quality model can be obtained.

[0385] The model training method provided in this embodiment transforms the analysis of a large number of data sets into the analysis of a small sample data set while maintaining the diversity and complexity of the original data. This not only improves the iteration efficiency of the model, but also reduces the training cost and labor cost, making the quality of the training data more controllable and the fine-tuned model more effective.

[0386] Since the technical concept is the same, the description in this embodiment is relatively simple, and the relevant parts may refer to the corresponding description of the method embodiment provided above.

[0387] An embodiment of a text processing device provided in this specification is as follows: In the above-mentioned embodiment, a text processing method is provided. Based on the same technical concept, the embodiment of the present application also provides a text processing device, which is described below in conjunction with the accompanying drawings.

[0388] Figure 6 Schematic diagram of a text processing device provided in an embodiment of the present application. This embodiment provides a text processing device 600, including: The recognition unit 602 is used to perform intention recognition on a first text in the text set to obtain an intention recognition result of the first text; A determination unit 604, configured to determine the number of texts for each intent in the text set according to the intent recognition result of the first text; A division unit 606 is used to divide the text set into a first sample set and a second sample set according to the text quantity of each intent and a preset sample quantity threshold; the text quantity of each intent in the first sample set is less than or equal to the preset sample quantity threshold; The adding unit 608 is configured to perform screening processing on the second sample set to obtain a target subset, and add the target subset to the first sample set.

[0389] Optionally, the first text includes multiple subtexts, the intent recognition result of the first text includes the intent of each subtext, and the text set includes N intents; when the determination unit 604 determines the number of texts for each intent in the text set according to the intent recognition result of the first text, the determination unit 604 performs the following steps: For the i-th intention in the text set, if there is a subtext in the first text whose intention matches the i-th intention, determining that the first text includes the i-th intention; The number of first texts including the i-th intention is counted to obtain the number of texts of the i-th intention, where i is a positive integer less than or equal to N.

[0390] Optionally, when the dividing unit 606 divides the text set into the first sample set and the second sample set according to the text quantity of each intention and a preset sample quantity threshold, it performs the following steps: Based on the number of texts for each intent, select the text corresponding to the i-th intent according to the preset rules, process the text corresponding to the i-th intent selected each time, and delete the processed text after each processing until the text set is empty; The processing process includes: Compare the number of texts corresponding to the i-th intention with the preset sample number threshold; If the number of texts of the i-th intention is less than or equal to the preset sample number threshold, then the first text including the i-th intention in the text set is added to the first sample set; If the number of texts of the i-th intention is greater than a preset sample number threshold, the first text including the i-th intention in the text set is added to the second sample set.

[0391] Optionally, when the adding unit 608 performs screening processing on the second sample set to obtain a target subset, the adding unit 608 performs the following steps: Determining the intent in the second sample set as the second intent, performing clustering processing on the first text including the second intent, and obtaining a clustering result of the second intent; According to the clustering result of the second intent, a preset number of first texts are selected from the first texts including the second intent and added to the target subset.

[0392] Optionally, the clustering result of the second intent includes a first number of clusters; when the adding unit 608 selects a preset number of first texts from the first text including the second intent and adds them to the target subset according to the clustering result of the second intent, the adding unit 608 performs the following steps: Among the first number of clusters, determining the center position of each cluster; For each cluster, determining, according to the center position and a preset radius of the cluster, a target text belonging to the cluster in the clustering result of the second intention; A second number of the target texts is selected and added to the target subset; the second number is determined by the first number and the preset number.

[0393] Optionally, when the adding unit 608 performs screening processing on the second sample set to obtain a target subset, the adding unit 608 performs the following steps: For each keyword in the preset keyword set, determining a first text including the keyword in the second sample set, and using the first text including the keyword as a first text sample of the keyword; Counting the number of first text samples of each keyword in the second sample set to obtain a target number of samples of each keyword; If the target sample quantity is less than or equal to the preset sample quantity threshold, the first text sample of the keyword is added to the target subset.

[0394] Optionally, when the adding unit 608 performs screening processing on the second sample set to obtain a target subset, the adding unit 608 performs the following steps: Determining the intent in the second sample set as the second intent, and performing statistical processing on the preset features of the first text including the second intent to obtain distribution information of the preset features; According to the distribution information of the preset features, the first text including the second intent is sampled to obtain a second text sample of the second intent, and the second text sample is added to the target subset.

[0395] In an embodiment of the present application, a text processing device includes: an identification unit, which is used to perform intent recognition on a first text in a text set to obtain an intent recognition result of the first text; a determination unit, which is used to determine the number of texts for each intent in the text set based on the intent recognition result of the first text; a division unit, which is used to divide the text set into a first sample set and a second sample set based on the number of texts for each intent and a preset sample number threshold; the number of texts for each intent in the first sample set is less than or equal to the preset sample number threshold; and an adding unit, which is used to screen the second sample set to obtain a target subset, and add the target subset to the first sample set. In this way, the intention recognition results of each first text in the text set can be used to determine the text quantity of each intention. For any intention, the fewer the text quantity of the intention, the rarer the intention, and conversely, the more the text quantity of the intention, the more common the intention. By configuring the preset sample quantity threshold, the first text with relatively rare intention can be placed in the first sample set, and the first text with relatively common intention can be placed in the second sample set. The text quantity of the first text with relatively rare intention is less than or equal to the preset sample quantity threshold, and the text quantity of the first text with relatively common intention is greater than the preset sample quantity threshold. After obtaining the second sample set, the text quantity of the first text with relatively common intention can be reduced to the preset sample quantity threshold by screening the second sample set. Then, after the reduced number of first texts with relatively common intention is placed in the first sample set, the text quantity of each intention in the first sample set can be equal to or less than the preset sample quantity threshold. Therefore, when close to the same fixed value, the text quantity of each intention can be approximately regarded as the same, which is conducive to improving the balanced distribution of samples.

[0396] Corresponding to the above-described text processing method, based on the same technical concept, an embodiment of the present application further provides an electronic device, which is used to execute the above-provided text processing method. Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0397] like Figure 7As shown, the electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 701 and memory 702, and the memory 702 may store one or more storage applications or data. Among them, the memory 702 may be a temporary storage or a permanent storage. The application stored in the memory 702 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 701 may be configured to communicate with the memory 702 to execute a series of computer executable instructions in the memory 702 on the electronic device. The electronic device may also include one or more power supplies 703, one or more wired or wireless network interfaces 704, one or more input / output interfaces 705, one or more keyboards 706, etc.

[0398] In a specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs configured to be executed by one or more processors include the following computer executable instructions: Performing intent recognition on a first text in the text set to obtain an intent recognition result of the first text; Determining the number of texts for each intent in the text set according to the intent recognition result of the first text; According to the number of texts of each intention and a preset sample number threshold, the text set is divided into a first sample set and a second sample set; the number of texts of each intention in the first sample set is less than or equal to the preset sample number threshold; The second sample set is screened to obtain a target subset, and the target subset is added to the first sample set.

[0399] The computer-readable storage medium provided in this embodiment is used to store computer-executable instructions. When the computer-executable instructions are executed by a processor, the following process is implemented: Performing intent recognition on a first text in the text set to obtain an intent recognition result of the first text; Determining the number of texts for each intent in the text set according to the intent recognition result of the first text; According to the number of texts of each intention and a preset sample number threshold, the text set is divided into a first sample set and a second sample set; the number of texts of each intention in the first sample set is less than or equal to the preset sample number threshold; The second sample set is screened to obtain a target subset, and the target subset is added to the first sample set.

[0400] It should be noted that the embodiment of the computer-readable storage medium in this specification and the embodiment of the text processing method in this specification are based on the same inventive concept, so the specific implementation of this embodiment can refer to the implementation of the corresponding method mentioned above, and the repeated parts will not be repeated.

[0401] Another embodiment of the present disclosure further provides a computer program product, the computer program product comprising a computer program, and when the computer program is executed by a processor, the following process is implemented: Performing intent recognition on a first text in the text set to obtain an intent recognition result of the first text; Determining the number of texts for each intent in the text set according to the intent recognition result of the first text; According to the number of texts of each intention and a preset sample number threshold, the text set is divided into a first sample set and a second sample set; the number of texts of each intention in the first sample set is less than or equal to the preset sample number threshold; The second sample set is screened to obtain a target subset, and the target subset is added to the first sample set.

[0402] The computer program product in the embodiment of the present disclosure can implement each process of the above-mentioned text processing method embodiment and achieve the same effect and function, which will not be repeated here.

[0403] In an embodiment of the present application, first, intent recognition is performed on the first text in the text collection to obtain the intent recognition result of the first text; then, based on the intent recognition result of the first text in the text collection, the number of texts for each intent in the text collection is determined; then, based on the number of texts for each intent and a preset sample number threshold, the text collection is divided into a first sample set and a second sample set; the number of texts for each intent in the first sample set is less than or equal to the preset sample number threshold; finally, the second sample set is screened to obtain a target subset, and the target subset is added to the first sample set. In this way, the intention recognition results of each first text in the text set can be used to determine the text quantity of each intention. For any intention, the fewer the text quantity of the intention, the rarer the intention, and conversely, the more the text quantity of the intention, the more common the intention. By configuring the preset sample quantity threshold, the first text with relatively rare intention can be placed in the first sample set, and the first text with relatively common intention can be placed in the second sample set. The text quantity of the first text with relatively rare intention is less than or equal to the preset sample quantity threshold, and the text quantity of the first text with relatively common intention is greater than the preset sample quantity threshold. After obtaining the second sample set, the text quantity of the first text with relatively common intention can be reduced to the preset sample quantity threshold by screening the second sample set. Then, after the reduced number of first texts with relatively common intention is placed in the first sample set, the text quantity of each intention in the first sample set can be equal to or less than the preset sample quantity threshold. Therefore, when close to the same fixed value, the text quantity of each intention can be approximately regarded as the same, which is conducive to improving the balanced distribution of samples.

[0404] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0405] It should be understood by those skilled in the art that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0406] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable electronic device to produce a machine, so that the instructions executed by the processor of the computer or other programmable electronic device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0407] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable electronic device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0408] These computer program instructions may also be loaded onto a computer or other programmable electronic device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0409] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0410] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0411] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0412] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0413] Embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0414] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0415] The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.

Claims

1. A text processing method, characterized in that: include: Performing intent recognition on a first text in the text set to obtain an intent recognition result of the first text; Determining the number of texts for each intent in the text set according to the intent recognition result of the first text; According to the number of texts of each intention and a preset sample number threshold, the text set is divided into a first sample set and a second sample set; the number of texts of each intention in the first sample set is less than or equal to the preset sample number threshold; The second sample set is screened to obtain a target subset, and the target subset is added to the first sample set.

2. The method according to claim 1, characterized in that The first text includes a plurality of subtexts, the intent recognition result of the first text includes the intent of each subtext, and the text set includes N intents; and determining the number of texts for each intent in the text set according to the intent recognition result of the first text includes: For the i-th intention in the text set, if there is a subtext in the first text whose intention matches the i-th intention, determining that the first text includes the i-th intention; The number of first texts including the i-th intention is counted to obtain the number of texts of the i-th intention, where i is a positive integer less than or equal to N.

3. The method according to claim 2, characterized in that The step of dividing the text set into a first sample set and a second sample set according to the text quantity of each intention and a preset sample quantity threshold comprises: Based on the number of texts for each intent, select the text corresponding to the i-th intent according to a preset rule, process the text corresponding to the i-th intent selected each time, and delete the processed text after each processing until the text set is empty; The processing process includes: Compare the number of texts corresponding to the i-th intention with the preset sample number threshold; If the number of texts of the i-th intention is less than or equal to the preset sample number threshold, then adding the first text including the i-th intention in the text set to the first sample set; If the number of texts of the i-th intention is greater than the preset sample number threshold, the first text in the text set including the i-th intention is added to the second sample set.

4. The method according to claim 1, characterized in that: The screening process of the second sample set to obtain a target subset includes: Determining the intent in the second sample set as the second intent, performing clustering processing on the first text including the second intent, and obtaining a clustering result of the second intent; According to the clustering result of the second intent, a preset number of first texts are selected from the first texts including the second intent and added to the target subset.

5. The method according to claim 4, characterized in that The clustering result of the second intent includes a first number of clusters; and selecting a preset number of first texts from the first text including the second intent and adding them to the target subset according to the clustering result of the second intent includes: Among the first number of clusters, determining the center position of each cluster; For each cluster, determining, according to the center position and a preset radius of the cluster, a target text belonging to the cluster in the clustering result of the second intention; A second number of the target texts is selected and added to the target subset; the second number is determined by the first number and the preset number.

6. The method according to claim 1, characterized in that The screening process of the second sample set to obtain a target subset includes: For each keyword in the preset keyword set, determining a first text including the keyword in the second sample set, and using the first text including the keyword as a first text sample of the keyword; Counting the number of first text samples of each keyword in the second sample set to obtain a target number of samples of each keyword; If the target sample quantity is less than or equal to the preset sample quantity threshold, the first text sample of the keyword is added to the target subset.

7. The method according to claim 1, characterized in that The screening process of the second sample set to obtain a target subset includes: Determining the intent in the second sample set as the second intent, and performing statistical processing on the preset features of the first text including the second intent to obtain distribution information of the preset features; According to the distribution information of the preset features, the first text including the second intent is sampled to obtain a second text sample of the second intent, and the second text sample is added to the target subset.

8. An electronic device, characterized in that: include: processor; And, a memory configured to store computer executable instructions, which, when executed, cause the processor to perform the text processing method according to any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store computer-executable instructions, and the computer-executable instructions, when executed by a processor, implement the text processing method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the text processing method according to any one of claims 1 to 7.