Training sample selection method and device, electronic equipment and storage medium

By filtering out interference information from live text and using a hierarchical clustering strategy to select sentences from the anchor's corpus as training samples, the problem of interference information affecting model training in existing technologies is solved, thereby improving the training effect and imitation ability of the role-playing model.

CN120409489APending Publication Date: 2025-08-01GUANGZHOU HUYA INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510478138.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing technologies using TF-IDF to select live broadcast audio-to-text samples suffer from interference that affects model training, making it difficult to accurately capture the broadcaster's language style and resulting in poor role-playing model imitation ability.

Method used

By filtering out interference information in the live broadcast text, the semantic and stylistic features of sentences are determined, a broadcaster corpus is established, and a hierarchical clustering strategy is used to select target sentences as training samples for the role-playing model.

Benefits of technology

The improved text content quality enhanced the training effect and imitation ability of the role-playing model, enabling the model to more accurately imitate the broadcaster's language style.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409489A_ABST
    Figure CN120409489A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and provides a training sample selection method and device, electronic equipment and a storage medium. The method comprises the following steps: firstly, converting live broadcast voice of an anchor into a live broadcast text, and filtering interference information in the live broadcast text to obtain a target text; then determining semantic features and style features of each sentence in the target text, and storing the semantic features and the style features of each sentence to an anchor corpus of an anchor; and finally, according to a preset hierarchical clustering strategy, performing clustering based on the semantic features and style features of each sentence in the anchor corpus to obtain a plurality of target sentences, and taking each target sentence as a training sample of a role playing model corresponding to the anchor. Wherein the role playing model is used for simulating the language style of the anchor. The text capable of accurately representing the anchor language style is selected to train the role playing model, so that the training effect and the imitation ability of the model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a method, device, electronic device, and storage medium for selecting training samples. Background Art

[0002] Currently, the ASR (Automatic Speech Recognition) technology is usually used to convert the speech of the anchor during the live broadcast into text, and the representative text of the anchor is selected from it as a sample to train the role-playing model corresponding to the anchor, so that the role-playing model can imitate the language style of the anchor.

[0003] For the method of training the role-playing model with Few-Shot (few samples), whether the samples used can accurately represent the language style of the anchor will directly affect the imitation ability of the role-playing model. The related technology generally uses the TF-IDF (Term Frequency-Inverse Document Frequency) technology to select samples after converting the live broadcast speech of the anchor into text by using the ASR technology. However, the text directly converted from the live broadcast speech contains interference information, which will affect the training effect of the model, and the TF-IDF technology is difficult to capture the unique language style of the anchor, resulting in the selected samples not being representative, thus leading to poor imitation ability of the model. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a method, device, electronic device, and storage medium for selecting training samples.

[0005] To achieve the above purpose, the technical solutions adopted in the embodiments of the present invention are as follows:

[0006] In the first aspect, the present invention provides a method for selecting training samples, and the method includes:

[0007] Convert the live broadcast speech of the anchor into live broadcast text, and filter out the interference information in the live broadcast text to obtain target text;

[0008] Determine the semantic features and style features of each sentence in the target text, and store the semantic features and style features of each sentence in the anchor corpus of the anchor;

[0009] According to the preset hierarchical clustering strategy, perform clustering based on the semantic features and style features of each sentence in the anchor corpus to obtain multiple target sentences, and use each target sentence as a training sample for the role-playing model corresponding to the anchor; wherein, the role-playing model is used to imitate the language style of the anchor.

[0010] In an alternative embodiment, the step of filtering out interference information in the live text to obtain the target text includes:

[0011] Determine each regular interaction sentence and / or each redundant sentence in the live text;

[0012] Delete each regular interaction sentence in the live text, and / or delete redundant words in each redundant sentence to obtain the target text.

[0013] In an alternative embodiment, the step of determining the semantic features and style features of each sentence in the target text includes:

[0014] Use a preset language model to extract features from each sentence in the target text to obtain the semantic features of each sentence;

[0015] For each sentence in the target text, calculate the saliency parameter of the sentence and determine the interaction flag of the sentence according to each word in the sentence, and use the saliency parameter and interaction flag of the sentence as its style features to obtain the style features of each sentence;

[0016] Wherein, the saliency parameter represents the degree of correlation between the sentence and the host's language style, and the interaction flag represents whether the sentence is an interactive sentence.

[0017] In an alternative embodiment, the step of clustering based on the semantic features and style features of each sentence in the host corpus according to a preset hierarchical clustering strategy to obtain multiple target sentences includes:

[0018] Cluster based on the semantic features of each sentence in the host corpus to obtain multiple clusters;

[0019] For each cluster, cluster based on the semantic features and style features of each sentence in the cluster to obtain each sub-cluster corresponding to the cluster, and obtain multiple sub-clusters;

[0020] For each sub-cluster, select the n sentences closest to the center of the sub-cluster from all the sentences in the sub-cluster and use them as target sentences to obtain multiple target sentences, where n is a positive integer.

[0021] In an alternative embodiment, the step of clustering based on the semantic features of each sentence in the host corpus to obtain multiple clusters includes:

[0022] Cluster the semantic features of all sentences in the host corpus according to a preset first clustering algorithm to obtain multiple clusters; wherein, the difference between the center of the cluster and the average value of all semantic features in the cluster does not exceed a preset threshold.

[0023] In an alternative embodiment, the step of clustering based on the semantic features and style features of each sentence in the cluster to obtain each sub-cluster corresponding to the cluster includes:

[0024] Concatenate the semantic features and style features of each sentence in the cluster to obtain the concatenated features of each sentence in the cluster;

[0025] Cluster the concatenated features of all sentences in the cluster according to a preset second clustering algorithm to obtain each sub-cluster corresponding to the cluster; wherein, the total number of concatenated features in the sub-cluster is greater than a preset number and the distance between each concatenated feature in the sub-cluster and at least one other concatenated feature does not exceed a preset neighborhood radius.

[0026] In an alternative embodiment, the method further includes:

[0027] Convert the new live voice of the host into a new live text, and filter out the interference information in the new live text to obtain a new target text;

[0028] Determine the semantic features and style features of each new sentence in the new target text;

[0029] Determine each expired sentence in the host corpus according to the number of days since each sentence in the host corpus was stored;

[0030] Add the semantic features and style features of each new sentence to the host corpus, and delete the semantic features and style features of each expired sentence to update the host corpus.

[0031] In a second aspect, the present invention provides a training sample selection device, the device includes:

[0032] A preprocessing module, configured to convert the live voice of the host into a live text, and filter out the interference information in the live text to obtain a target text;

[0033] A determination module, configured to determine the semantic features and style features of each sentence in the target text, and store the semantic features and style features of each sentence in the host corpus of the host;

[0034] A selection module, configured to perform clustering based on the semantic features and style features of each sentence in the host corpus according to a preset hierarchical clustering strategy, obtain a plurality of target sentences, and use each target sentence as a training sample for the role-playing model corresponding to the host; wherein, the role-playing model is used to imitate the language style of the host.

[0035] In a third aspect, the present invention provides an electronic device, including a processor and a memory, the memory stores a computer program, and when the processor executes the computer program, the training sample selection method according to any one of the foregoing embodiments is implemented.

[0036] In a fourth aspect, the present invention provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the training sample selection method according to any one of the foregoing embodiments is implemented.

[0037] The training sample selection method, device, electronic device and storage medium provided by the embodiments of the present invention, the method includes: first converting the live voice of the host into a live text, and filtering out the interference information in the live text to obtain a target text; then determining the semantic features and style features of each sentence in the target text, and storing the semantic features and style features of each sentence in the host corpus of the host; finally, performing clustering based on the semantic features and style features of each sentence in the host corpus according to a preset hierarchical clustering strategy, obtaining a plurality of target sentences, and using each target sentence as a training sample for the role-playing model corresponding to the host; wherein, the role-playing model is used to imitate the language style of the host. By filtering out the interference information of the live text, the content quality of the text is improved. By selecting texts that can accurately represent the host's language style to train the role-playing model, the training effect and imitation ability of the model are improved.

[0038] To make the above objects, features and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0040] Figure 1 The block diagram of the electronic device provided by the embodiment of the present invention is shown;

[0041] Figure 2Shows one of the schematic flowcharts of the training sample selection method provided by the embodiments of the present invention;

[0042] Figure 3 Shows another schematic flowchart of the training sample selection method provided by the embodiments of the present invention;

[0043] Figure 4 Shows the functional module diagram of the training sample selection device provided by the embodiments of the present invention.

[0044] Icons: 100 - electronic device; 110 - processor; 120 - memory; 130 - communication module; 300 - training sample selection device; 310 - preprocessing module; 330 - determination module; 350 - selection module; 370 - update module. Detailed implementation manners

[0045] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Usually, the components of the embodiments of the present invention described and shown in the accompanying drawings here can be arranged and designed in various different configurations.

[0046] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed present invention, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present invention.

[0047] It should be noted that relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

[0048] Please refer to Figure 1, which is a block diagram of an electronic device provided by an embodiment of the present invention. The electronic device 100 includes a processor 110, a memory 120, and a communication module 130. Each component is electrically connected directly or indirectly to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0049] The processor 110 is used to read / write data or programs stored in the memory 120 and execute corresponding functions. It can be a general-purpose processor, including a CPU (Central Processing Unit, central processor), an NP (Network Processor, network processor), etc.; it can also be a DSP digital signal processor, an ASIC application-specific integrated circuit, an FPGA field-programmable gate array, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0050] The memory 120 is used to store programs or data. It can be a RAM (Random Access Memory, random access memory), a ROM (Read Only Memory, read-only memory), a PROM (Programmable Read-Only Memory, programmable read-only memory), an EPROM (Erasable Programmable Read-Only Memory, erasable read-only memory), an EEPROM (Electric Erasable Programmable Read-Only Memory, electrically erasable read-only memory), etc.

[0051] The communication module 130 is used to communicate signaling or data with other devices.

[0052] It can be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device 100. The electronic device 100 may also include more or fewer components than Figure 1 shown therein, or have a configuration different from Figure 1 shown therein. Figure 1 Each component shown therein can be implemented by hardware, software, or a combination thereof.

[0053] Next, the above-mentioned electronic device 100 will be used as the execution subject to execute each step in each method provided by the embodiments of the present invention and achieve the corresponding technical effects.

[0054] Please refer to Figure 2 , which is a schematic flowchart of a training sample selection method provided by an embodiment of the present invention.

[0055] Step S202: Convert the live broadcast voice of the host into live broadcast text, and filter out the interference information in the live broadcast text to obtain the target text.

[0056] Step S204: Determine the semantic features and style features of each sentence in the target text, and store the semantic features and style features of each sentence in the host's host corpus.

[0057] Step S206: According to the preset hierarchical clustering strategy, perform clustering based on the semantic features and style features of each sentence in the host corpus to obtain multiple target sentences, and use each target sentence as a training sample for the role-playing model corresponding to the host; wherein, the role-playing model is used to imitate the host's language style.

[0058] In this embodiment, the voice of the host during the live broadcast can be collected to obtain the live broadcast voice, and the ASR technology can be used to convert the live broadcast voice into text to obtain the live broadcast text. Moreover, a filtering operation is performed on the live broadcast text to filter out the interference information in the live broadcast text to obtain the target text.

[0059] It can be understood that there are multiple sentences in the target text, and these sentences can be regarded as candidate samples for training the role-playing model corresponding to the host. Then, the semantic features and style features of each sentence in the target text can be determined first, where the semantic features are used to represent the content and the style features are used to represent the style; then, the semantic features and style features of these sentences are stored in the host's host corpus, and then samples for training the role-playing model are selected based on the host corpus.

[0060] Moreover, this embodiment of the present invention will preset a hierarchical clustering strategy, and according to this hierarchical clustering strategy, perform clustering based on the semantic features and style features of each sentence in the host corpus, and then select each sentence that can accurately represent the host's language style from all the sentences in the host corpus according to the clustering result to obtain multiple target sentences. These multiple target sentences are the training samples for the role-playing model. The hierarchical clustering strategy refers to a strategy for clustering through a hierarchical structure, and this strategy can capture the diversity and representativeness of data at different levels.

[0061] It can be understood that this embodiment of the present invention improves the content quality of the text by filtering out the interference information in the live broadcast text. And by establishing a host corpus, it improves the convenience of updating the host corpus, so as to facilitate the selection of new training samples to update and optimize the role-playing model, so that the model can change with the change of the host's language style, improving the adaptability of the model to the host. Moreover, through the hierarchical clustering strategy, representative texts are selected from multiple levels for model training, thereby improving the training effect of the model and enhancing the imitation ability of the model.

[0062] It can be seen that based on the above steps, first, the live voice of the host is converted into live text, and the interference information in the live text is filtered out to obtain the target text; then, the semantic features and style features of each sentence in the target text are determined, and the semantic features and style features of each sentence are stored in the host's corpus; finally, according to the preset hierarchical clustering strategy, clustering is performed based on the semantic features and style features of each sentence in the host's corpus to obtain multiple target sentences, and each target sentence is used as a training sample for the role-playing model corresponding to the host; wherein, the role-playing model is used to imitate the host's language style. By selecting texts that can accurately represent the host's language style to train the role-playing model, the training effect and imitation ability of the model are improved.

[0063] Optionally, for the process of filtering out the interference information in the live text to obtain the target text in step 202, an embodiment of the present invention provides a possible implementation manner.

[0064] Step 202-1, determine each regular interaction sentence and / or each redundant sentence in the live text.

[0065] Step 202-3, delete each regular interaction sentence in the live text, and / or, delete redundant words in each redundant sentence to obtain the target text.

[0066] In this embodiment, a regularization expression can be constructed in advance based on the commonly used interaction words in the live broadcast scenario. For example, the commonly used interaction words in the live broadcast scenario are "thank", "gift", "subscribe", "get on the bus", "card", then the regularization expression constructed based on these interaction words can be \b(thank|gift|subscribe|get on the bus|card)\b. And, some redundant words can be set in advance, for example, the redundant words can be repetitive words such as "666", "hahaha", etc., or meaningless onomatopoeic words such as "oh", "woo", etc. It should be understood that the commonly used interaction words and redundant words can be set according to actual applications, and the embodiments of the present invention are not limited thereto.

[0067] Then, based on the obtained live text, each sentence in the live text can be respectively matched with the preset regularization expression to obtain the sentence that matches the regularization expression, that is, each regular interaction sentence is obtained. And, based on each preset redundant word, each sentence in the live text is screened to obtain the sentence containing any one of the redundant words, that is, each redundant sentence is obtained.

[0068] For regular interactive sentences, since they contain common interactive vocabulary, such sentences are very likely to be general statements in the live stream. Therefore, they cannot represent the personal language style of the anchor. Thus, in the embodiments of the present invention, the regular interactive sentences in the live stream text are deleted to filter out such interfering information. For example, assume that there is a regular interactive sentence in the live stream text such as "Thank you, 'User 123', for the rocket!", then this regular interactive sentence will be deleted.

[0069] For redundant sentences, since they contain redundant words, and these redundant words usually do not have specific meanings, these redundant words cannot represent the speaking characteristics of the anchor. Thus, in the embodiments of the present invention, the redundant words in the redundant sentences are deleted to filter out such interfering information. For example, assume that there is a redundant sentence in the live stream text such as "The jungler on the other side is too bad hahaha", then the redundant word "hahaha" in this redundant sentence will be deleted to obtain the sentence after removing redundancy, that is, "The jungler on the other side is too bad".

[0070] Optionally, for the process of determining the semantic features and style features of each sentence in the target text in step S204, the embodiments of the present invention provide a possible implementation manner.

[0071] Step S204-1: Use a preset language model to extract features from each sentence in the target text to obtain the semantic features of each sentence.

[0072] For each sentence in the target text in step S204-3, according to each word in the sentence, calculate the saliency parameter of the sentence and determine the interaction flag of the sentence, and use the saliency parameter and interaction flag of the sentence as its style features to obtain the style features of each sentence; wherein, the saliency parameter represents the degree of correlation between the sentence and the language style of the anchor, and the interaction flag represents whether the sentence is an interactive sentence.

[0073] In this embodiment, the methods for determining the semantic features and style features of each sentence in the target text are similar. For the sake of brief description, an example of a sentence in the target text is used for illustration below. For example, first input the sentence into a preset language model, and use this language model to extract features from the sentence, that is, obtain the semantic features of the sentence. The language model can adopt the BERT (bert-base-uncased) model.

[0074] Then, calculate the significance parameter for each word in the sentence, where the significance parameter represents the degree of correlation between the sentence and the host's language style. For example, for each word in the sentence, the significance score of the word can be calculated based on the frequency of the word in the target text and the frequency of the word in a preset business corpus, and the combined significance scores of all the words in the sentence are used as the significance parameter of the sentence. Here, the business corpus refers to a corpus that matches the host's live broadcast business, and the business corpus includes multiple sentences obtained from relevant videos, social platforms, and community information. For example, assuming the host is engaged in live game broadcasting, then the business corpus is a game corpus, and the game corpus includes multiple sentences obtained from game live subtitles, game guides, and game community discussions.

[0075] It can be understood that the method for determining the significance score of each word is similar. Here, a word t is used as an example for illustration. For example, the ratio of the number of occurrences of word t in the target text to the total number of all words in the target text can be calculated to obtain the frequency of word t in the target text. This calculation process can be expressed by the formula: where t represents the currently processed word, f(t) represents the frequency of the currently processed word in the target text; S1(t) represents the number of occurrences of the currently processed word in the target text; T1 represents the total number of all words in the target text.

[0076] Also, the ratio of the number of occurrences of word t in the business corpus to the total number of all words in the business corpus can be calculated to obtain the frequency of word t in the business corpus. This calculation process can be expressed by the formula: where t represents the currently processed word, μ(t) represents the frequency of the currently processed word in the business corpus; S2(t) represents the number of occurrences of the currently processed word in the business corpus; T2 represents the total number of all words in the business corpus.

[0077] Moreover, all the sentences in the business corpus are divided into N sentence groups, each of which contains the same number of sentences, and the frequency of word t in each corpus group is calculated. Then, combined with the frequency of word t in the business corpus, the frequency standard deviation of word t is calculated. This calculation process can be expressed by the formula: where t represents the currently processed word, σ(t) represents the frequency standard deviation of the currently processed word, represents the frequency of the currently processed word in the i-th sentence group, μ(t) represents the frequency of the currently processed word in the business corpus; N represents the total number of sentence groups.

[0078] Furthermore, calculate the difference between the frequency of the word t in the target text minus the frequency of the word t in the business corpus, and calculate the ratio of this difference to the standard deviation of the frequency of the word t, that is, obtain the significance score of the word t. This calculation process can be expressed by the formula: Among them, t represents the currently processed word, and z(t) represents the significance score of the currently processed word. It can be understood that the larger the significance score of the word, the higher the frequency of the host using this word compared to the frequency of this word mentioned in this business scenario, that is, the more this word can reflect the speaking characteristics of the host, then the more relevant this word is to the host's language style.

[0079] Next, determine the interaction flag according to each word in the sentence, where the interaction flag indicates whether the sentence is an interactive sentence. It can be understood that the host generally interacts with the audience by asking questions, and the language when the host interacts with the audience by asking questions can reflect the speaking characteristics of the host. Therefore, in the embodiments of the present invention, it is determined whether the sentence is an interactive sentence according to whether the sentence contains a question word, so as to determine the interaction flag of the sentence.

[0080] For example, some question words indicating the meaning of asking questions such as "how", "what", "right" etc. can be preset in advance, and then determine the interaction flag of the sentence according to whether there are preset question words in all the words of the sentence. If there is a question word in the sentence, it means that the sentence is an interactive sentence, then the preset first identifier such as 1 is used as the interaction flag of the sentence; if there is no question word in the sentence, it means that the sentence is not an interactive sentence, then the preset second identifier such as 0 is used as the interaction flag of the sentence. It should be understood that the question words, the first identifier and the second identifier can be set according to the actual situation, and the embodiments of the present invention are not limited thereto.

[0081] Finally, in a similar manner, each sentence in the target text is processed, and the semantic features and style features of each sentence in the target text can be obtained.

[0082] Optionally, for the process of clustering based on the semantic features and style features of each sentence in the host corpus according to the preset hierarchical clustering strategy in step S206 to obtain multiple target sentences, the embodiments of the present invention provide a possible implementation manner.

[0083] Step S206-1, cluster based on the semantic features of each sentence in the host corpus to obtain multiple clusters.

[0084] Step S206-3, for each cluster, cluster based on the semantic features and style features of each sentence in the cluster to obtain each sub-cluster corresponding to the cluster, and obtain multiple sub-clusters.

[0085] Step S206-5: For each sub-cluster, select the n sentences closest to the center of the sub-cluster from all the sentences in the sub-cluster as the target sentences, obtaining multiple target sentences, where n is a positive integer.

[0086] In this embodiment, based on the hierarchical clustering strategy, a two-layer clustering method can be adopted to select target sentences from the host corpus. First, the first-layer clustering is performed based on the semantic features of all the sentences in the host corpus to cluster sentences with similar meanings together to obtain multiple clusters.

[0087] Then, the second-layer clustering is performed based on the semantic features and style features of all the sentences in each cluster to cluster sentences with similar meanings and styles together to obtain sub-clusters corresponding to each cluster. Next, select the n sentences closest to the center of each sub-cluster from all the sentences in the sub-cluster as the target sentences, then multiple sentences are obtained. These multiple target sentences are samples that can represent the host's language style in multiple semantics.

[0088] It can be understood that in the embodiment of the present invention, through the hierarchical clustering strategy, two-layer clustering is performed on the semantic features and style features of the sentences in the host corpus, so as to ensure that the selected sentences are semantically coherent and can fully reflect the speaking characteristics of the host, thereby improving the diversity and representativeness of the training samples.

[0089] Optionally, for step S206-1, the embodiment of the present invention provides a possible implementation manner, that is: cluster the semantic features of all the sentences in the host corpus according to a preset first clustering algorithm to obtain multiple clusters; wherein, the difference between the center of the cluster and the average value of all the semantic features in the cluster does not exceed a preset threshold.

[0090] In this embodiment, the first clustering algorithm can adopt K-means (K-means clustering algorithm). For the convenience of understanding, the implementation manner of the first-layer clustering will be described below taking the K-means algorithm as an example. For example, first, according to the preset cluster parameter K, randomly obtain K semantic features from the semantic features of all the sentences in the host corpus and use them as the centers of the K clusters respectively. For example, K can be 6. It should be understood that the cluster parameter can be set according to the actual situation, and the embodiment of the present invention is not limited thereto.

[0091] Then, for each semantic feature in the host corpus, calculate the distance between the semantic feature and the center of each cluster, and assign the semantic feature to the nearest cluster, that is, determine the cluster to which each semantic feature belongs. Then, for each cluster, calculate the average value based on all the semantic features in the cluster to obtain the new center of the cluster, and calculate the center movement distance of the cluster based on the center and the new center of the cluster. Then, compare the center movement distance of each cluster with a preset threshold respectively.

[0092] If the center movement distance of any one cluster exceeds the preset threshold, then re-execute the process of determining the cluster to which each semantic feature belongs, calculating the center movement distance of each cluster, and comparing it with the preset threshold. If the center movement distances of all clusters do not exceed the preset threshold, then obtain K clusters. In this way, the sentences with similar meanings in the host corpus are grouped together.

[0093] Optionally, for the process of clustering based on the semantic features and style features of each sentence in the cluster in step S206-3 to obtain each sub-cluster corresponding to the cluster, the embodiment of the present invention provides a possible implementation manner, that is: splice the semantic features and style features of each sentence in the cluster to obtain the splicing features of each sentence in the cluster; according to a preset second clustering algorithm, cluster the splicing features of all sentences in the cluster to obtain each sub-cluster corresponding to the cluster; where the total number of splicing features in the sub-cluster is greater than a preset number and the distance between each splicing feature in the sub-cluster and at least one other splicing feature does not exceed a preset neighborhood radius.

[0094] In this embodiment, the manner of obtaining sub-clusters based on each cluster is similar. For the sake of brief description, the following takes one cluster as an example for illustration. For example, first, splice the semantic features and style features of each sentence in the cluster to obtain the splicing features of each sentence in the cluster.

[0095] Then, according to the second clustering algorithm, cluster the splicing features of all sentences in the cluster. The second clustering algorithm can adopt DBSCAN (Density-Based Spatial Clustering of Applications with Noise, density clustering algorithm). For the sake of easy understanding, the following takes the DBSCAN algorithm as an example to illustrate the implementation manner of the second-layer clustering.

[0096] For each splicing feature in the cluster, determine each neighborhood feature of the splicing feature, and count the number of neighborhood features of the splicing feature to obtain the total number of neighborhood features of the splicing matrix, and compare the total number of neighborhood features of the splicing matrix with a preset number such as min_samples. Among them, the distance between the neighborhood feature and the splicing feature does not exceed a preset neighborhood radius such as ∈. For example, the preset number min_samples can be 3, and the neighborhood radius can be ∈ 0.5. It should be understood that the preset number and the neighborhood radius can be set according to the actual situation, and the embodiments of the present invention are not limited thereto.

[0097] If the total number of neighborhood features of the splicing matrix is greater than the preset number, then use the splicing feature as a core point, and create a sub-cluster and add all the neighborhood features of the splicing feature to the sub-cluster. If the total number of neighborhood features of the splicing feature is not greater than the preset number and there is a core point among the neighborhood features of the splicing feature, then add the splicing feature to the sub-cluster corresponding to the core point. In a similar manner, process each splicing feature in the cluster, and then each sub-cluster corresponding to the cluster can be obtained. In this way, sentences with similar meanings and styles in each cluster are grouped together.

[0098] Optionally, after the above step S204 or step S206, the embodiments of the present invention also provide an implementation method for updating the anchor corpus. Please refer to Figure 3 。

[0099] Step S208, convert the new live voice of the anchor into a new live text, and filter out the interference information in the new live text to obtain a new target text.

[0100] Step S210, determine the semantic features and style features of each new sentence in the new target text.

[0101] Step S212, determine each expired sentence in the anchor corpus according to the number of days since each sentence was stored in the anchor corpus.

[0102] Step S214, add the semantic features and style features of each new sentence to the anchor corpus, and delete the semantic features and style features of each expired sentence to update the anchor corpus.

[0103] In this embodiment, when new live voice of the anchor is collected, the anchor corpus can be updated based on the new live voice. For example, in a similar manner as above, convert the new live voice of the anchor into a new live text, and after filtering out the interference information in the new live text to obtain a new target text, determine the semantic features and style features of each new sentence in the new target text.

[0104] Then, based on the number of days since each sentence was stored in the host's corpus, each expired sentence is determined. For example, according to a preset weight formula, the weight of each sentence in the host's corpus can be calculated, and sentences with a weight lower than a preset weight threshold, such as 0.02, are regarded as expired sentences. The weight formula is as follows: where, w j represents the weight of the j-th sentence in the host's corpus, e represents the natural constant; t j is the number of days since the j-th sentence was stored in the host's corpus, σ represents the decay parameter, and σ can be 0.01. It should be understood that the weight threshold and the decay parameter can be set according to the actual situation, and the embodiments of the present invention are not limited thereto.

[0105] Finally, the semantic features and style features of each new sentence are added to the host's corpus, and the semantic features and style features of each expired sentence are deleted to update the host's corpus. It can be understood that for the updated host's corpus, in a similar manner as above, it can be clustered through a hierarchical clustering strategy to select new training samples to update and optimize the role-playing model, so that the model can change with the change of the host's language style to improve the adaptability of the model to the host.

[0106] To execute the corresponding steps in the above embodiments and each possible manner, an implementation manner of a training sample selection device is given below. Please refer to Figure 4 , which is a functional module diagram of the training sample selection device provided by the embodiments of the present invention. It should be noted that for the training sample selection device 300 provided in this embodiment, its basic principle and the technical effects generated are the same as those in the above embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding content in the above embodiments. The training sample selection device 300 includes:

[0107] A preprocessing module 310, configured to convert the live voice of the host into a live text and filter out the interference information in the live text to obtain a target text.

[0108] A determination module 330, configured to determine the semantic features and style features of each sentence in the target text and store the semantic features and style features of each sentence in the host's corpus.

[0109] A selection module 350, configured to perform clustering based on the semantic features and style features of each sentence in the host's corpus according to a preset hierarchical clustering strategy to obtain a plurality of target sentences, and use each target sentence as a training sample for the role-playing model corresponding to the host; wherein, the role-playing model is used to imitate the host's language style.

[0110] Optionally, the preprocessing module 310 is further configured to: determine each regular interaction sentence and / or each redundant sentence in the live text; delete each regular interaction sentence in the live text, and / or, delete redundant words in each redundant sentence to obtain a target text.

[0111] Optionally, the determination module 330 is further configured to: extract features of each sentence in the target text by using a preset language model to obtain semantic features of each sentence; for each sentence in the target text, calculate a significance parameter of the sentence and determine an interaction flag of the sentence according to each word in the sentence, and use the significance parameter and the interaction flag of the sentence as its style features to obtain style features of each sentence; wherein, the significance parameter represents the degree of correlation between the sentence and the host's language style, and the interaction flag represents whether the sentence is an interaction statement.

[0112] Optionally, the selection module 350 is further configured to: perform clustering based on semantic features of each sentence in the host corpus to obtain multiple clusters; for each cluster, perform clustering based on semantic features and style features of each sentence in the cluster to obtain each sub-cluster corresponding to the cluster, and obtain multiple sub-clusters; for each sub-cluster, select the n sentences closest to the center of the sub-cluster from all sentences in the sub-cluster and use them as target sentences to obtain multiple target sentences, where n is a positive integer.

[0113] Optionally, the selection module 350 is further configured to: perform clustering on semantic features of all sentences in the host corpus according to a preset first clustering algorithm to obtain multiple clusters; wherein, the difference between the center of the cluster and the average value of all semantic features in the cluster does not exceed a preset threshold.

[0114] Optionally, the selection module 350 is further configured to: splice semantic features and style features of each sentence in the cluster to obtain splicing features of each sentence in the cluster; perform clustering on splicing features of all sentences in the cluster according to a preset second clustering algorithm to obtain each sub-cluster corresponding to the cluster; wherein, the total number of splicing features in the sub-cluster is greater than a preset number and each splicing feature in the sub-cluster is at least not more than a preset neighborhood radius away from one other splicing feature.

[0115] Optionally, the training sample selection device 300 further includes an update module 370, configured to: convert the host's new live speech into a new live text, and filter out interference information in the new live text to obtain a new target text; determine semantic features and style features of each new sentence in the new target text; determine each expired sentence in the host corpus according to the number of days since each sentence in the host corpus was stored; add semantic features and style features of each new sentence to the host corpus, and delete semantic features and style features of each expired sentence to update the host corpus.

[0116] An embodiment of the present invention also provides an electronic device, including a processor and a memory. The memory stores a computer program. When the processor executes the computer program, the method for selecting training samples disclosed in the embodiments of the present invention is implemented.

[0117] An embodiment of the present invention also provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for selecting training samples disclosed in the embodiments of the present invention is implemented.

[0118] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of apparatuses, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0119] In addition, in each embodiment of the present invention, the functional modules may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0120] If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present invention. The foregoing storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs, etc., which can store program codes.

[0121] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for selecting training samples, characterized in that, The method includes: Converting the live broadcast voice of the host into live broadcast text, and filtering out interference information in the live broadcast text to obtain target text; Determining the semantic features and style features of each sentence in the target text, and storing the semantic features and style features of each sentence in the host's host corpus; According to a preset hierarchical clustering strategy, clustering based on the semantic features and style features of each sentence in the host corpus to obtain multiple target sentences, and using each target sentence as a training sample for the role-playing model corresponding to the host; wherein, the role-playing model is used to imitate the language style of the host.

2. The training sample selection method according to claim 1, wherein The step of filtering out interference information in the live broadcast text to obtain target text includes: Determining each regular interaction sentence and / or each redundant sentence in the live broadcast text; Deleting each regular interaction sentence in the live broadcast text, and / or deleting redundant words in each redundant sentence to obtain the target text.

3. The training sample selection method according to claim 1, wherein, The step of determining the semantic features and style features of each sentence in the target text includes: Using a preset language model to extract features from each sentence in the target text to obtain the semantic features of each sentence; For each sentence in the target text, calculating the significance parameter of the sentence and determining the interaction flag of the sentence according to each word in the sentence, and using the significance parameter and interaction flag of the sentence as its style features to obtain the style features of each sentence; Wherein, the significance parameter represents the degree of correlation between the sentence and the language style of the host, and the interaction flag represents whether the sentence is an interactive sentence.

4. The training sample selection method according to claim 1, wherein The step of clustering based on the semantic features and style features of each sentence in the host corpus according to a preset hierarchical clustering strategy to obtain multiple target sentences includes: Clustering based on the semantic features of each sentence in the host corpus to obtain multiple clusters; For each cluster, clustering based on the semantic features and style features of each sentence in the cluster to obtain each sub-cluster corresponding to the cluster, and obtaining multiple sub-clusters; For each sub-cluster, selecting the n sentences closest to the center of the sub-cluster from all the sentences in the sub-cluster and using them as target sentences to obtain multiple target sentences, where n is a positive integer.

5. The training sample selection method according to claim 4, wherein The step of clustering based on the semantic features of each sentence in the host corpus to obtain multiple clusters includes: Clustering the semantic features of all sentences in the host corpus according to a preset first clustering algorithm to obtain multiple clusters; wherein, the difference between the center of the cluster and the average value of all semantic features in the cluster does not exceed a preset threshold.

6. The training sample selection method according to claim 4, wherein The step of clustering based on the semantic features and style features of each sentence in the cluster to obtain each sub-cluster corresponding to the cluster includes: Concatenating the semantic features and style features of each sentence in the cluster to obtain the concatenated features of each sentence in the cluster; Cluster the concatenation features of all sentences in the cluster according to a preset second clustering algorithm to obtain each sub-cluster corresponding to the cluster; wherein, the total number of concatenation features in the sub-cluster is greater than a preset number and the distance between each concatenation feature in the sub-cluster and at least one other concatenation feature does not exceed a preset neighborhood radius.

7. The training sample selection method according to any one of claims 1-6, characterized in that The method further includes: Convert the new live voice of the anchor into new live text, and filter out the interference information in the new live text to obtain a new target text; Determine the semantic features and style features of each new sentence in the new target text; Determine each expired sentence in the anchor corpus according to the number of days since each sentence in the anchor corpus was stored; Add the semantic features and style features of each new sentence to the anchor corpus, and delete the semantic features and style features of each expired sentence to update the anchor corpus.

8. A training sample selection device, characterized in that, The device includes: A preprocessing module, configured to convert the live voice of the anchor into live text, and filter out the interference information in the live text to obtain a target text; A determination module, configured to determine the semantic features and style features of each sentence in the target text, and store the semantic features and style features of each sentence in the anchor corpus of the anchor; A selection module, configured to cluster based on the semantic features and style features of each sentence in the anchor corpus according to a preset hierarchical clustering strategy to obtain a plurality of target sentences, and use each target sentence as a training sample for the role-playing model corresponding to the anchor; wherein, the role-playing model is used to imitate the language style of the anchor.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory stores a computer program, and when the processor executes the computer program, it implements the training sample selection method according to any one of claims 1-7.

10. A storage medium, characterized in that, A computer program is stored on the storage medium, and when the computer program is executed by a processor, it implements the training sample selection method according to any one of claims 1-7.