Data generation method and electronic device

By expanding the template statement pool and entity pool using electronic devices to generate training sample statements, the problem of low efficiency and high cost in acquiring training sample data in existing technologies is solved, achieving efficient and low-cost generation of training sample data and improving the performance of entity recognition models.

CN120764509BActive Publication Date: 2026-05-19HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-03-29
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In existing technologies, obtaining training sample data is inefficient and costly. In particular, obtaining training sample data through procurement requires a lot of financial and time resources, and it is difficult to obtain real data for newly developed business scenarios.

Method used

The template statement pool is automatically expanded by electronic devices, and training sample statements are generated by combining them with the entity pool. Sub-sentence pools are filtered by similarity and perplexity to generate labeled training sample data that matches the application scenario, reducing the need for manual labeling.

Benefits of technology

It improves the quality and efficiency of training sample data, reduces the human and financial costs of acquiring training sample data, ensures that the generated training sample data fits the application scenario, and improves the performance of the entity recognition model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120764509B_ABST
    Figure CN120764509B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a data generation method and an electronic device, which are suitable for the computer technology field, wherein the data generation method comprises the following steps: selecting a first entity group from an entity pool, generating a total sentence pool based on the first entity group and a template sentence pool; screening a plurality of sub-sentence pools from the total sentence pool according to the similarity between each sentence in the total sentence pool and a reference sentence; determining the important coefficient of each sub-sentence pool according to the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between each two sentences; determining the target sentence pool as the sub-sentence pool with the maximum value of the corresponding important coefficient, and adding the first template sentence corresponding to each sentence in the target sentence pool to the template sentence pool; and generating a training sample sentence used for training an entity recognition model according to the expanded template sentence pool and the entity pool. The embodiment of the application can improve the efficiency of obtaining training sample data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more particularly to a data generation method and an electronic device. Background Technology

[0002] Name Entity Recognition (NER) is an important technique in Natural Language Processing (NLP). It aims to identify and classify entities from text, such as categorizing them into time periods, people, etc., thereby helping electronic devices understand the information contained in the text and extract relevant knowledge. For example, when an entity recognition model is applied to an electronic device, it can help the device understand the intent behind the user's spoken or text input, thus making an appropriate response.

[0003] Training sample data is fundamental to ensuring model performance. In related technologies, training sample data is typically obtained through procurement. However, this method is costly, requiring both significant financial resources and considerable time for data annotation. In other words, current technologies for acquiring training sample data are inefficient and expensive. Summary of the Invention

[0004] In view of this, embodiments of this application provide a data generation method and an electronic device that can improve the efficiency of acquiring training sample data.

[0005] In a first aspect, embodiments of this application provide a data generation method, which includes: an electronic device can first expand a template statement pool multiple times using an entity pool, and then the electronic device can generate training sample statements for training an entity recognition model based on the expanded template statement pool and entity pool.

[0006] The process of expanding the template statement pool each time an electronic device does so may include the following steps:

[0007] First, the electronic device selects a first entity group from the entity pool. Based on the first entity group and the template statement pool, a total sentence pool is generated. The sentences in the total sentence pool differ from the basic statements, and the entity labels corresponding to the sentences in the total sentence pool are the same as those corresponding to the basic statements. The basic statements are combinations of the first entity group and template statements from the template statement pool. The entities in the first entity group have different entity types. Entities in the entity pool have entity labels indicating their entity types. The template statements in the template statement pool include entity labels. The entity pool and the template statement pool correspond to the first application scenario targeted by the entity recognition model. Each template statement can correspond to a combined basic statement. It should be noted that the entities in the combined basic statements have entity labels, and the entities in each sentence in the total sentence pool can also have entity labels.

[0008] Then, the electronic device can filter multiple sub-sentence pools from the total sentence pool based on the similarity between each sentence in the total sentence pool and the reference statement. The reference statement consists of the entities corresponding to the total sentence pool and the initial template statement, which belongs to the initial template statement pool.

[0009] Then, the electronic device can determine the importance coefficient of each sub-sentence pool based on the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between any two sentences.

[0010] Finally, the electronic device can determine the target sentence pool from multiple sentence pools by selecting the sentence pool with the highest importance coefficient, and add the first template statement corresponding to each sentence in the target sentence pool to the template statement pool. The first template statement is obtained by replacing entities in the sentence with their corresponding entity labels.

[0011] In this embodiment, on the one hand, the electronic device automatically expands a rich set of template statements by combining a small number of initial template statements (i.e., template statements in the initial template statement pool). Then, based on the rich set of template statements and the entity pool, it combines them to obtain training sample statements for training the entity recognition model. Without the need for extensive manual annotation, it can generate labeled training sample data that matches the first application scenario according to business requirements (or the usage requirements of the first application scenario). This ensures that the generated training sample data fits the first application scenario, thereby guaranteeing the performance of the trained entity recognition model, and also saves users manpower, financial resources, and time in obtaining training sample data.

[0012] On the other hand, since the reference statement is a statement obtained by combining the entity group corresponding to the total sentence pool with the initial template statement, and since the initial template statement is usually a manually written template statement, it usually has a high degree of fit with the first application scenario. When the electronic device expands the template statement pool, it can filter multiple sub-sentence pools from the total sentence pool based on the similarity between each sentence in the total sentence pool and the reference statement. This can achieve the filtering of sub-sentence pools that match the first application scenario, thereby ensuring that the expanded template statement matches the first application scenario.

[0013] On the other hand, since the perplexity of a sentence can indicate its fluency and the similarity between sentences can indicate the magnitude of their differences, for each sub-sentence pool, combining the fluency of each sentence in that sub-sentence pool with the similarity between pairs of sentences can determine the importance of that sub-sentence pool. This allows for a more comprehensive and accurate assessment of the overall fluency and the discriminative power between sentences in that sub-sentence pool. It helps to select sub-sentence pools that are fluent and have high discriminative power between sentences, which can result in better discriminative power and fluency among the expanded template sentences, thus improving the quality of the generated training sample data.

[0014] As an embodiment of this application, before filtering multiple sub-sentence pools from the total sentence pool based on the similarity between each sentence in the total sentence pool and the reference sentence, the electronic device may also delete sentences whose corresponding edit distance is greater than the upper limit of the edit distance from the total sentence pool.

[0015] In this embodiment, since the reference statement is a statement obtained by combining the entity group corresponding to the total sentence pool with the initial template statement, and since the initial template statement is usually a manually written template statement, it usually has a high degree of fit with the first application scenario. For any statement (or extended statement) in the total sentence pool, if the edit distance between the extended statement and the reference statement is greater than the upper limit of the edit distance, it usually indicates that the extended statement is not very consistent with the first application scenario. Deleting the extended statement from the total sentence pool can ensure that the generated training sample data fits the first application scenario, thereby ensuring the performance of the trained entity recognition model.

[0016] As one embodiment of this application, the aforementioned upper limit of edit distance may be positively correlated with the length of the reference statement. That is, the longer the reference statement, the larger the upper limit of edit distance.

[0017] In this embodiment, since the length of the reference statement is usually variable, determining the upper limit of the edit distance based on the length of the reference statement helps to more accurately filter out extended statements that do not conform to the first application scenario, thereby ensuring the quality of the generated training sample data.

[0018] As one embodiment of this application, the electronic device generates a total sentence pool based on a first entity group and a template statement pool. This can be achieved as follows: First, the electronic device combines the first entity group with each template statement in the template statement pool to obtain multiple basic statements. Each template statement corresponds to one basic statement. Then, the electronic device generates a first statement for each basic statement. Finally, the electronic device determines the total sentence pool by summing the first statements.

[0019] As one embodiment of this application, the electronic device generating a first statement for a basic statement may include: the electronic device inputting the basic statement into a model, such as a fewshot model, generating a statement with the same entity as the basic statement, and obtaining the first statement.

[0020] As an embodiment of this application, generating a first statement for a basic statement by an electronic device may include: the electronic device performing EDA expansion on the parts of the basic statement other than entities to obtain the aforementioned first statement.

[0021] As an embodiment of this application, the electronic device generating a first statement for a basic statement may include: the electronic device first inputs the basic statement into a model, such as a few-shot model, and generates a statement (or format statement) with the same entity as the basic statement; then, the electronic device may perform EDA expansion on the part of the format statement other than the entity to obtain the aforementioned first statement.

[0022] It is understood that the embodiments of this application do not specifically limit the process or method by which the electronic device generates the total sentence pool.

[0023] In the first possible implementation of the first aspect, the first application scenario is a dialogue scene in a voice assistant application, and the entity types include: time, place, person and event.

[0024] In a second possible implementation of the first aspect, the electronic device filters multiple sub-sentence pools from the total sentence pool based on the similarity between each sentence in the total sentence pool and the reference statement. This can include: first, the electronic device determines the edit distance between each sentence in the total sentence pool and the reference statement; then, the electronic device determines multiple filtering intervals based on the value of the edit distance corresponding to each sentence in the total sentence pool; finally, the electronic device filters sentences whose corresponding edit distances belong to the corresponding filtering intervals for each filtering interval, thus obtaining a sub-sentence pool.

[0025] In this embodiment of the application, since the value of the edit distance is usually an integer and the number of possible values ​​is very small, the sub-sentence pool is selected from the total sentence pool based on the edit distance corresponding to each sentence. This can greatly reduce the amount of computation and thus improve the speed of template sentence expansion. In other words, it can greatly improve the speed of generating training sample data.

[0026] In the third possible implementation of the first aspect, the filtering interval can have two distribution schemes. Distribution scheme one: the filtering interval is the interval formed by the values ​​of two adjacent edit distances. Distribution scheme two: the filtering interval is the interval formed by zero and the values ​​of the edit distance.

[0027] In this embodiment, when the filtering interval is the first distribution scheme described above, a sentence may belong to different sub-sentence pools simultaneously, which can expand to obtain rich template sentences in a shorter time, that is, it can speed up the generation of training sample data. When the filtering interval is the second distribution scheme described above, since there are no overlapping sentences between the sub-sentence pools, it is possible to filter out sub-sentence pools with high discriminative power among the sentences.

[0028] In the fourth possible implementation of the first aspect, the importance coefficient is inversely correlated with the perplexity of each sentence in the sub-sentence pool, and the importance coefficient is inversely correlated with the similarity between any two sentences in the sub-sentence pool.

[0029] In this embodiment of the application, the electronic device determines the sub-sentence pool with the highest importance coefficient as the target sentence pool. This can result in a target sentence pool with a low overall perplexity and low similarity between sentences. In other words, it can select a target sentence pool with good fluency and high distinction between sentences, which helps to improve the accuracy of template sentence expansion. This ensures the rapid generation of training sample sentences while improving the quality of the generated training sample sentences.

[0030] In the fifth possible implementation of the first aspect, the electronic device generates a total sentence pool based on the first entity group and the template statement pool. This can be achieved as follows: First, the electronic device combines the first entity group with each template statement in the template statement pool to obtain multiple basic statements. Then, the electronic device can generate a first statement, which differs from the basic statements, and the entities in the first statement are the same as those in the basic statements. Finally, the electronic device can replace each entity in the first statement with an entity of the corresponding entity type from the second entity group to obtain a second statement. The total sentence pool includes the second statement. The second entity group is an entity group selected from the entity pool, which differs from the first entity group, and the entity labels corresponding to the second entity group are the same as those corresponding to the first entity group.

[0031] In this embodiment, the generated first statement may contain some words with low general applicability. These words may be applicable in some scenarios but not in others. The electronic device replaces the entities in the first statement (i.e., the entities in the first entity group) with the corresponding entities in the second entity group (i.e., the correction entity group) to obtain the second statement (or expanded statement). Then, further filtering is performed based on the context of the second statement. This can filter out expanded statements that do not make sense when substituted into the second entity group, thereby filtering out the first template statement (i.e., the expanded template statement) corresponding to the incoherent expanded statement. This improves the general applicability (or universality) of the expanded template statement, which helps to improve the representativeness of the generated training sample data, that is, to improve the quality of the training sample data.

[0032] In the sixth possible implementation of the first aspect, the electronic device combines the first entity group with each template statement in the template statement pool to obtain multiple basic statements. Specifically, the electronic device combines the first entity group with the second template statement in the template statement pool to obtain basic statements.

[0033] Each second template statement corresponds to a basic statement.

[0034] The entity tags in the second template statement (or target template statement) are the same as the entity tags corresponding to the first entity group.

[0035] In this embodiment of the application, the first entity group and the second template statement are combined to obtain the above basic statement. Since the entity type (or entity type combination) corresponding to the first entity group is the same as the entity type (or entity type combination) corresponding to the second template statement, the template statements corresponding to different entity type combinations can be extended in a targeted manner, which can improve the efficiency of template statement extension.

[0036] In addition, since the corresponding template statements or applicable template statements may differ for different combinations of entity types, selecting appropriate template statements for each combination of entity types can make the resulting statements more closely match real-world scenarios, thus improving the accuracy of template statement expansion.

[0037] In the seventh possible implementation of the first aspect, the electronic device generates training sample statements for training the entity recognition model based on the expanded template statement pool and entity pool. Specifically, this can be implemented as follows: First, the electronic device selects a third entity group from the entity pool and a third template statement from the template statement pool. The entity labels in the third template statement are the same as the entity labels corresponding to the third entity group. Then, the electronic device writes each entity in the third entity group into the corresponding entity label position in the third template statement to obtain the training sample statements.

[0038] In other words, the third entity group has the same combination of entity types as the third template statement.

[0039] In this embodiment of the application, the training sample statement is obtained by combining the third entity group with the third template statement. This can generate training sample statements under different entity type combinations in a targeted manner, which can enrich the sample data for training the entity recognition model.

[0040] It should be noted that combining entity groups with template statements can produce training sample statements. Since each entity in the training sample statement has a labeled entity, the entity labels carried by each entity can ensure that the training sample statements are accurately labeled, thereby improving the quality of the generated training sample statements.

[0041] Secondly, embodiments of this application provide a model application method, which includes: an electronic device can respond to a first instruction input by a user in a first application scenario, identify entity information in the first instruction through an entity recognition model corresponding to the first application scenario, wherein the first instruction includes an entity to be identified; and then, the electronic device can respond to the first instruction based on the entity information.

[0042] In practice, in response to a user's first input command, an electronic device can display a corresponding interface that corresponds to the first command. The corresponding interface matches the entity information.

[0043] The first instruction mentioned above can be either voice or text. It is understood that this application embodiment does not specifically limit the form of the user-inputted instruction.

[0044] The training sample statements for the entity recognition model are obtained by combining the expanded template statement pool and the entity pool. The expansion process of the expanded template statement pool may include:

[0045] First, a first entity group is selected from the entity pool. Entities in the entity pool have entity tags that indicate their entity type, and the entities in the first entity group have different entity types.

[0046] Next, a total sentence pool is generated based on the first entity group and the template statement pool. The sentences in the total sentence pool differ from the basic statements, and the entity tags corresponding to the sentences in the total sentence pool are the same as those corresponding to the basic statements. The basic statements are obtained by combining the first entity group with the template statements in the template statement pool. The template statements in the template statement pool include entity tags. The entity pool and the template statement pool are consistent with the first application scenario.

[0047] Then, based on the similarity between each sentence in the main sentence pool and the reference statement, multiple sub-sentence pools are selected from the main sentence pool. The reference statement consists of each entity corresponding to the main sentence pool and the initial template statement, and the initial template statement belongs to the initial template statement pool.

[0048] Then, for each sub-sentence pool, the importance coefficient of the corresponding sub-sentence pool is determined based on the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between each pair of sentences;

[0049] Finally, from multiple sub-sentence pools, the sub-sentence pool with the highest corresponding importance coefficient is determined as the target sentence pool. The first template statement corresponding to each sentence in the target sentence pool is added to the template statement pool. The first template statement is obtained by replacing the entities in the sentence with the corresponding entity labels.

[0050] As an embodiment of this application, the first application scenario is a dialogue scene in a voice assistant application, and the entity types include: time, location, people and events.

[0051] In the embodiments of this application, for different application scenarios, such as dialogue-based scenarios, electronic devices can adopt entity recognition models that are consistent with the application scenario to identify entity information in user commands involved in the application scenario. This helps to improve the accuracy of entity recognition, thereby ensuring that electronic devices respond correctly to user commands and improving user experience.

[0052] As one embodiment of this application, an electronic device displays a corresponding interface in response to a first instruction input by a user, including: the electronic device displays a first interface in response to an instruction to generate video. The first interface includes first image material and / or a first video.

[0053] The first image material is obtained by filtering image materials that match the entity information, and the first video is generated by combining the filtered image materials.

[0054] In other words, when an electronic device receives an instruction to generate video, the first interface can have three possible scenarios. The first scenario is displaying the first image material that matches the entity information. The second scenario is directly displaying the first video composed of the first image material that matches the entity information. The third scenario is first displaying the first image material that matches the entity information, and then displaying the first video composed of the first image material that matches the entity information.

[0055] As an embodiment of this application, the process of generating training sample data for the entity recognition model used in the model application method is obtained by any of the methods described in the first aspect above.

[0056] Thirdly, embodiments of this application provide an electronic device, which includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the computer program, it implements the method as described in any of the first aspects above, or implements the method as described in any of the second aspects above.

[0057] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method as described in any of the first aspects above, or implements the method as described in any of the second aspects above.

[0058] Fifthly, embodiments of this application provide a chip system including a processor coupled to a memory. The processor executes a computer program stored in the memory to implement the method as described in any of the first aspects above, or to implement the method as described in any of the second aspects above. The chip system may be a single chip or a chip module composed of multiple chips.

[0059] Sixthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to execute the method described in any of the first aspects above, or to implement the method described in any of the second aspects above.

[0060] It is understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0061] Figure 1 A schematic diagram of a dialogue sequence in a voice assistant application provided in this application embodiment;

[0062] Figure 2A This is a flowchart illustrating the extended template statement pool in an embodiment of this application.

[0063] Figure 2BThis is a schematic diagram illustrating the process of filtering the target sentence pool in an embodiment of this application;

[0064] Figure 3 This is a schematic diagram of the process of providing an extended template statement pool in an embodiment of this application;

[0065] Figure 4 This is a schematic diagram of the structure of the data generation apparatus provided in the embodiments of this application;

[0066] Figure 5 This is a schematic diagram of the structure of the model application device provided in the embodiments of this application;

[0067] Figure 6 A schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application;

[0068] Figure 7 A schematic diagram of the software system of the electronic device provided in the embodiments of this application. Detailed Implementation

[0069] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0070] The following explains some concepts that may be involved in the embodiments of this application:

[0071] (1) Multiple: Unless otherwise specified, in the embodiments of this application, multiple refers to two or more.

[0072] (2) Perplexity: In this embodiment, perplexity is a metric for measuring the performance of a language model, used to evaluate the model's predictive ability on given text data. In the field of natural language processing, perplexity is typically used to measure the predictive ability of a language model on a given text sequence. Generally, the value of perplexity is positive, and theoretically it can be any large positive number. In practical applications, perplexity is usually between 1 and positive infinity. The closer the perplexity is to 1, the more accurate the model's prediction of the given text; that is, the smaller the perplexity, the better.

[0073] In the embodiments of this application, for any statement, the higher the perplexity of the model for the statement, the less fluent the statement is considered; conversely, the lower the perplexity of the model for the statement, the more fluent the statement is considered.

[0074] (3) Rectified Linear Unit (ReLU): In this embodiment, the ReLU function is one of the commonly used activation functions in deep learning.

[0075] The ReLU function is characterized by the following: if the input value is greater than 0, the return value is the same as the input value; if the input value is 0 or less, the return value is 0.

[0076] (4) Edit distance. In this embodiment of the application, edit distance, also known as Levenshtein distance, is an indicator that measures the similarity between two strings.

[0077] Edit distance represents the minimum number of edit operations required to transform one string into another. These edit operations include character insertion, deletion, and replacement. A larger edit distance indicates a lower similarity between the two strings; a smaller edit distance indicates a higher similarity. For example, two identical strings have an edit distance of 0.

[0078] Entity recognition technology is an important technology in natural language processing. It aims to identify entities from the text to be processed and classify the identified entities, such as classifying the identified entities as time, people, etc., so as to help electronic devices understand the information contained in the text and extract relevant knowledge from it.

[0079] With the increasing demand for structuring and analyzing large-scale text data, entity recognition technology has become the foundation of many natural language processing applications and can be applied in many fields, such as search engines, social network analysis, and public opinion monitoring.

[0080] When entity recognition models are applied to electronic devices, they can help the devices understand the intent of the user's voice or text input, thereby making appropriate responses to the user's voice or text input.

[0081] The following example uses an entity recognition model applied to a mobile phone's voice assistant application (also known as a voice assistant, YOYO Assistant, or YOYO). Figure 1 This describes the process by which electronic devices respond to user-inputted speech or text based on entity recognition models.

[0082] in, Figure 1 This is a schematic diagram of a dialogue sequence in a voice assistant application provided in an embodiment of this application.

[0083] It is understood that the dialogue segments described are from a voice assistant application and are merely examples. In some cases, dialogue segments may also appear in other applications, such as a photo gallery application. That is, this application does not specifically limit which application the dialogue segments appear in.

[0084] like Figure 1 As shown in (a), when the voice assistant is activated, the phone responds to the user's voice input "I want to synthesize a video," and the phone can display a voice interaction window 20, which includes a dialog box 21 for the voice assistant. The dialog box 21 includes the text 211 of the dialogue "I want to synthesize a video," and also includes the text 212 of the dialogue "Immediately enter the intelligent video synthesis process for you" output by the phone in response to the text 211.

[0085] In practice, the methods for waking up a voice assistant can include, but are not limited to, at least one of the following:

[0086] Wake-up method 1, keyword wake-up: When the phone recognizes the user's wake-up voice input including keywords, such as "Hello YOYO", it can wake up the voice assistant.

[0087] Wake-up method 2: If the phone detects that the user has pressed and held the power button, the voice assistant can be activated.

[0088] Wake-up method 3, breath wake-up: The phone can wake up the voice assistant when it detects that the user has raised the phone and is facing the microphone. For example, when the voice assistant is wake-up using breath wake-up, the user can wake up the voice assistant by saying "I want to synthesize a video" to the phone, and the phone can respond to the user's command.

[0089] It is understood that the embodiments of this application do not specifically limit the wake-up method of the voice assistant.

[0090] like Figure 1 As shown in (b), the mobile phone displays a material display box 22 in the voice interaction window 20. The material display box 22 contains multiple material boxes 221. Each material box 221 can correspond to a material category, such as personal photos, cute pets, growth themes, heartwarming moments, family photos, food collections, etc. The material box 221 displays a frame 2211 of the corresponding material type, a material type description text 2212, and a function introduction text 2213 for the corresponding material type.

[0091] like Figure 1 As shown in (b), during the display of the material display box 22, the mobile phone can respond to the user clicking on the personal portrait material box 221 and enter the smart finished product dialog box 23.

[0092] like Figure 1 As shown in (c), the Smart Video Maker dialog box 23 displays a control 231 that says "Generate Personal Photo Collection Video". In response to the user clicking this control 231, the mobile phone displays the text "Generate Personal Photo Collection Video" 211a in the Smart Video Maker dialog box 23, followed by the text "Choose one of the following to generate a personal photo collection video?" 212a below the text 211a, and a character selection box 24 below the text 212a. The character selection box 24 displays multiple selectable character thumbnails 243, a "View All" control 241, and an "OK" control 244. The character thumbnails 243 display a thumbnail image 11 of a person and a selection control 242.

[0093] like Figure 1 As shown in (c), the mobile phone can respond to the user clicking the "View All" control 241 in the character selection box 24 to display more character thumbnails to choose from.

[0094] The mobile phone can also respond to the user's operation of first clicking the selection control 242 below the person thumbnail 243 in the person selection box 24, and then clicking the "OK" control 244. The text "Selected" 211b is displayed in the Smart Film Dialog Box 23, the text "The following photo materials have been selected, take a look~" is displayed below the text 211b, and the material thumbnail 25 for the selected person is displayed below the text 212b.

[0095] like Figure 1 As shown in (d), the material selection box 25 displays multiple thumbnail materials 251, and each thumbnail material 251 displays a selection control 252. The default state of the selection control 252 can be the checked state.

[0096] like Figure 1 As shown in (d), the mobile phone can respond to the user's action of clicking the "View All" control 253 on the material selection box 25, and display more materials of the selected character to the user.

[0097] The mobile phone can also respond to the user's operation of clicking the "OK" control 254 on the material selection box 25, and display the text "Selected" 211d, the text "Please enjoy Xiaohua's personal photo video" 212d, and the generated video 26 in the smart video dialog box 23.

[0098] like Figure 1 As shown in (d), the mobile phone can further respond to the user's click on video 26 and display the content of video 26 to the user.

[0099] The mobile phone can also respond to the user's voice input "Help me generate a video of my second daughter dancing", display the text 211e of "Help me generate a video of my second daughter dancing" in the smart video dialog box 23, display the text 212e below the text 211e "The following materials of my second daughter have been selected for you, take a look~", and display the content selection box 27 below the text 212e.

[0100] like Figure 1 As shown in (e), the content selection box 27 displays multiple image materials 271, a "View All" control 272, and a "Generate Video" control 273.

[0101] like Figure 1 As shown in (e), the "View All" control 272 indicates that 15 out of 20 clips are selected.

[0102] Optionally, the mobile phone can respond to the user clicking the "View All" control 272 to increase or decrease the number of image materials displayed in the content selection box 27.

[0103] like Figure 1 As shown in (e), the mobile phone can also respond to the user's click on the "Generate Video" control 273, displaying the text "Generate Video" 211f in the Smart Video Contest dialog box 23, the text "Video completed, come and enjoy the little cutie's dance~" below the text 211f, and the generated video 28 below the text 212f. Afterwards, the mobile phone can further respond to the user's click on video 28, displaying the content of video 28 to the user.

[0104] It should be understood that the above Figure 1 The user interface of the mobile phone shown is for illustrative purposes only and does not constitute any limitation on the user interface of the mobile phone to which the dialogue-based video production process provided in this application embodiment is adapted. For example, the above... Figure 1 The materials shown can be still images, animated images, or videos, etc.

[0105] Combination Figure 1 It can be observed that when entity recognition models are used in dialogue scenarios within a mobile phone's voice assistant, the phone is able to accurately respond to the user's voice or text input.

[0106] In practice, since the training sample sentences are the foundation for ensuring the model's effectiveness, the performance of an entity recognition model is closely related to the training sample sentences.

[0107] Currently, training sample data for model training is typically obtained through two methods: procurement. However, these two methods of obtaining training sample data may have the following drawbacks:

[0108] 1. Procurement requires considerable financial resources and is therefore costly.

[0109] 2. Data obtained through procurement still requires a significant amount of time for data annotation, resulting in high labor costs and a long time cycle for acquiring training sample data.

[0110] 3. The data source for procurement usually needs to be real data. However, for some newly developed business scenarios, there may not be corresponding real data. In other words, the required data may not be obtained through procurement.

[0111] In view of the above-mentioned technical problems existing in the prior art, in the embodiments of this application, the electronic device can combine a small number of initial template statements (that is, template statements in the initial template statement pool) to automatically expand to obtain rich template statements, and then combine the rich template statements with the entity pool to obtain training sample statements for training the entity recognition model. Without the need for manual annotation of a large amount of data, it can generate labeled training sample data that matches the application scenario of the model (or the first application scenario) according to business requirements (or the usage requirements of the application scenario targeted by the entity recognition model). This can not only make the generated training sample data fit the application scenario of the model, thereby ensuring the performance of the trained entity recognition model, but also save users manpower, financial resources and time in obtaining training sample data.

[0112] The embodiments of this application can be applied to scenarios where training sample data for an entity recognition model is generated for a specific application scenario.

[0113] The data generation method of this application is described below from three aspects: preparing initial data, expanding the template statement pool, and generating training sample statements.

[0114] (I) Preparing initial data

[0115] In this embodiment of the application, the initial data is the initial data used to train the entity recognition model.

[0116] The initial data may include an initial template statement pool and an initial entity pool. The template statement pool and entity pool are typically related to the specific application scenario of the entity recognition model to be trained. Specifically, the entity types in the entity pool are related to the application scenario of the entity recognition model, and the template statements in the template statement pool are also related to the application scenario of the entity recognition model.

[0117] In this embodiment of the application, for ease of description, the application scenario of the entity recognition model can be referred to as the model application scenario. The model application scenario may include scenarios with complete dialogues, or other scenarios. It is understood that this embodiment of the application does not specifically limit the specific scenarios described above.

[0118] In this embodiment, the entities in the entity pool are typically entities that might appear in the application scenarios of the aforementioned model. As an example, for scenarios with continuous dialogue, the entity types in the entity pool can include: time, location, person, and event. Entities corresponding to the time entity type can include, but are not limited to: today, yesterday, Spring Festival, Dragon Boat Festival, etc. Entities corresponding to the location entity type can include, but are not limited to: Beijing, hometown, Shenzhen, etc. Entities corresponding to the person entity type can include, but are not limited to: second daughter, father, mother, Teacher Wang, etc. Entities corresponding to the event entity type can include, but are not limited to: setting off firecrackers, dancing, visiting the Forbidden City, tourism, etc.

[0119] In practical applications, entities in an entity pool typically have entity tags. Entity tags indicate the type of the corresponding entity. As an example, an entity tag can be "tim" or "T," indicating that the corresponding entity type is time. It is understood that this application does not specifically limit the implementation form of entity tags.

[0120] In this embodiment of the application, the template statements in the template statement pool can be sentences that include one or more entity tags. As an example, the template statement could be: "More..." <tim> <loc> <cha> <eve>A photo of the scene. As another example, the template statement could also be: Add some more. <tim> <cha>exist <loc> <eve>The photos. Among them, <tim> 、 <loc> 、 <cha>and <eve>For entity labels, <tim>Indicates time, <loc>Indicate location, <cha>Instructing people, <eve>Indicator event.

[0121] In practice, various types of entities involved in the model's application scenario can be collected in advance, forming an initial entity pool. For example, 1000 entities can be collected to form the initial entity pool. Similarly, several template statements adapted to the model's application scenario can be manually written in advance, forming an initial template statement pool. For example, four template statements can be written to form the initial template statement pool. In this embodiment, for ease of description, the template statements in the initial template statement pool can be referred to as initial template statements.

[0122] Combining the template statement pool and the entity pool described above, we can see that selecting N entities of different types from the entity pool and embedding them into any template statement in the template statement pool yields a labeled statement that can be used to train the entity recognition model. Here, N is greater than or equal to 1. In the scenario of dialogue sequences, the entity types involved typically include four categories: time, location, people, and events. Therefore, in dialogue sequences, N is usually less than or equal to 4. Understandably, the upper limit of N corresponds to the number of entity types that the entity recognition model might involve in its application scenarios.

[0123] In practice, entity recognition models typically identify entities from statements.

[0124] Considering that in practical applications, the input statements to entity recognition models may contain all types of entities or only some types, taking a scenario where the model is used in dialogue mode as an example, the input statements to the entity recognition model may include four types of entities: time, location, person, and event, such as "Find some photos of my sister dancing in my hometown yesterday." The input statements may also contain only one type of entity, such as "Find some photos of my mother."

[0125] Therefore, to obtain a rich variety of training sample statements, corresponding template statements can be set in the initial template statement pool for various entity type combinations. Generally, m template statements can be set for each entity type combination; for example, m can be 2. The entity type combination can include N types of entities, where N is greater than or equal to 1. For example, in the above dialogue scenario, N is less than or equal to 4. As an example, an entity type combination could be: time + person. As another example, an entity type combination could be: time + location + person + event.

[0126] As is understandable, the above entity type combinations only describe the combination of entity types involved in a certain statement or entity group, and do not restrict the order of appearance of entities in the corresponding statement or entity group. For example, for the following two statements: "Find some photos of my sister dancing in my hometown yesterday" and "Find some photos of my sister dancing in my hometown yesterday", the entity type combinations corresponding to these two statements are the same, both being: time + place + person + event.

[0127] It should be noted that setting m corresponding template statements in the initial template statement pool for each entity type combination helps to expand the template statements corresponding to different entity type combinations in a targeted manner when expanding the template statement pool, which can improve the efficiency of template statement expansion.

[0128] In addition, since the corresponding template statements or applicable template statements may differ for different combinations of entity types, setting m corresponding template statements in the initial template statement pool for each combination of entity types can make the combination of the expanded template statements and entities more closely resemble real-world sentence scenarios. In other words, it can make the training sample data obtained by the combination more closely resemble real-world sentence scenarios, which helps to improve the quality of the generated training sample data.

[0129] (II) Template Statement Pool Expansion

[0130] In practice, after obtaining the entity pool and the template statement pool, electronic devices can expand the template statement pool to obtain a rich variety of template statements, thereby improving the generalization ability of the trained entity recognition model, that is, improving the stability of the model.

[0131] The following example uses the scenario of dialogue processing to illustrate the application of entity recognition models. Figure 2A and Figure 3 This paper describes the process of extending the template statement pool in the embodiments of this application.

[0132] in, Figure 2A This is a flowchart illustrating the extended template statement pool provided in an embodiment of this application. Figure 3 This is a schematic diagram illustrating the process of the extended template statement pool provided in the embodiments of this application.

[0133] S201, the electronic device selects a group of entities from the entity pool to obtain an entity group.

[0134] For ease of description, the filtered entity group can be denoted as the target entity group (or the first entity group).

[0135] The target entity group can include N types of entities, where N is greater than or equal to 1. In the scenario of the above-mentioned dialogue sequence, N is less than or equal to 4. Each entity in the target entity group has an entity label.

[0136] by Figure 3 For example, the target entity group obtained from the entity pool can be: {Time: Spring Festival; Location: Hometown; Person: Teacher Wang; Event: Setting off firecrackers}. In this case, the target entity group includes entities of four types: time, location, person, and event.

[0137] In practice, for each combination of entity types, the electronic device can filter entities from the entity pool that satisfy that combination. For example, when the entity type combination is time + location + person, the electronic device can randomly filter an entity of type time, an entity of type location, and an entity of type person from the entity pool.

[0138] In some optional implementations of this application's embodiments, the electronic device can also pre-arrange and combine the entities in the entity pool to obtain several entity groups. For example, if the entity pool contains four types of entities, one of each type, and they are Spring Festival, hometown, Teacher Wang, and setting off firecrackers, then according to the arrangement and combination method, the following 15 entity groups can be obtained: [List of entities would be inserted here] Each entity in the entity pool has an entity tag; that is, each entity in the entity group has an entity tag.

[0139] Understandably, when the electronic device has already pre-grouped the entities in the entity pool into entity groups, in the above S201, the electronic device can directly select an entity group from a batch of entity groups corresponding to the entity pool, thereby obtaining the target entity group.

[0140] S202, the electronic device combines the target entity group with the template statements in the template statement pool to obtain the basic statement.

[0141] The basic statements mentioned above are typically obtained by embedding each entity in the target entity group into a template statement. Each template statement corresponds to one basic statement. That is, there can be multiple basic statements.

[0142] It should be noted that each entity embedded in the template statement carries an entity tag. That is, the basic statement is a pre-annotated statement.

[0143] Optionally, electronic devices typically combine a target entity group with template statements from a template statement pool that are compatible with that target entity group. Combining entities with template statements usually means embedding entities into template statements, and specifically, it can involve replacing the entity tags in the template statements that correspond to the entity's type. For ease of description, the template statement compatible with the target entity group can be referred to as the target template statement, or the second template statement.

[0144] It should be noted that the target template statement may be a template statement in the initial template statement pool mentioned in the first aspect above, or it may be an extended template statement.

[0145] In practice, the matching of the target template statement and the target entity group usually means that the entity type corresponding to the entity tag in the target template statement is the same as the entity type corresponding to the target entity group, or in other words, the entity tags included in the target template statement are the same as the entity tags corresponding to the target entity group.

[0146] by Figure 3 For example, there can be two target template statements. For ease of description, we can refer to these two target template statements as template statement 1 and template statement 2, respectively. Template statement 1 is: [More details] <tim> <loc> <cha> <eve>For the scene photos, template statement 2 is: Add some more. <tim> <cha>exist <loc> <eve>The photo.

[0147] When target entity groups are combined with target template statements, a basic statement can be obtained for each target template statement. Further combinations... Figure 3 Given two target template statements, two basic statements can be obtained. Basic statement 1 for template statement 1 is: "Take more photos of Teacher Wang setting off firecrackers in his hometown during the Spring Festival." Basic statement 2 for template statement 2 is: "Add more photos of Teacher Wang setting off firecrackers in his hometown during the Spring Festival."

[0148] Understandable. Figure 3 The content of each entity group, each template statement, and each statement in this application is only for the purpose of better understanding the solution of this application, and does not limit the number or specific content of each statement (e.g., basic statement, format statement, extended statement, etc.) or template statement (e.g., target template statement, format template statement, extended template statement, etc.).

[0149] S203, Electronic devices combine basic statements to generate multiple format statements that conform to the format of the basic statements.

[0150] The number of formatting statements is usually greater than the number of basic statements. Formatting statements typically have the same entities as basic statements, or in other words, the entity types corresponding to formatting statements and basic statements are the same.

[0151] Here, the electronic device can employ relevant techniques to generate statements conforming to the given statement format, which will not be elaborated upon here. As an example, the electronic device can input a basic statement into a few-shot learning model, which will then generate the aforementioned formatted statement conforming to the basic statement format.

[0152] Continue with Figure 3 For example, an electronic device can generate five format statements based on the above basic statement 1 and basic statement 2. For ease of description, these five format statements can be referred to as format statement 1, format statement 2, format statement 3, format statement 4 and format statement 5, respectively.

[0153] Among them, format statement 1 is: Add some Spring Festival firecrackers set off by Teacher Wang in his hometown.

[0154] Format statement 2 is: Find some additional photos of Teacher Wang setting off firecrackers in his hometown during the Spring Festival and add them to the video.

[0155] The format statement 3 is: Add the photos of Teacher Wang setting off firecrackers in his hometown during the Spring Festival to the video.

[0156] Format statement 4 is: Add the photos of Teacher Wang setting off firecrackers in his hometown during the Spring Festival to the video.

[0157] Format statement 5 is: Add a video of Teacher Wang setting off firecrackers in his hometown during the Spring Festival.

[0158] Understandable. Figure 3 The number and content of the format statements shown are merely examples, and the embodiments of this application do not specifically limit the number and specific content of the format statements.

[0159] S204, Electronic devices abstract the format statements into entities to obtain format templates.

[0160] Among them, the format template can also be called the format template statement.

[0161] Here, entity abstraction of formatting statements usually means replacing the entities in the formatting statements with the corresponding entity tags.

[0162] As an example, if the format statement is: "Find some photos of my sister dancing in my hometown yesterday," then after abstracting this format statement into an entity, the resulting format template statement can be: "Find some..." <tim>exist <loc> <cha> <eve>The photo.

[0163] Continue with Figure 3 For example, electronic devices can abstract the above format statements 1-5 into entities, resulting in five format template statements.

[0164] Among them, the format template statement 1 corresponding to format statement 1 is: Add some <tim>exist <loc> <cha> <eve>.

[0165] The format template statement corresponding to format statement 2 is: Find some additional... <tim> <cha>exist <loc> <eve>Add the photos to the video.

[0166] The format template statement corresponding to format statement 3 is: ... <tim> <cha>exist <loc> <eve>The photos were also added to the video.

[0167] The format template statement corresponding to format statement 4 is: [The format template statement 4 is missing from the original text] <tim> <cha>exist <loc> <eve>Add photos to videos.

[0168] The format template statement corresponding to format statement 5 is: Add <tim> <cha>exist <loc> <eve>The video.

[0169] Understandable. Figure 3 The number and content of the format template statements shown are merely examples, and the embodiments of this application do not specifically limit the number and specific content of the format template statements.

[0170] S205, The electronic device expands the format template to obtain an extended template.

[0171] Here, the extended template can also be called an extended template statement. It is understood that the format template statement and extended template statement in the embodiments of this application are statements containing entity tags.

[0172] Here, the electronic device can employ relevant extension techniques to expand the format template statement to obtain the aforementioned extended template statement, which will not be elaborated upon here. As an example, the electronic device can use the synonym substitution technique in Easy Data Argument (EDA) to expand the format template statement to obtain the aforementioned extended template statement.

[0173] Further with Figure 3 For example, after an electronic device performs EDA expansion on 5 format template statements, it can obtain 13 expanded template statements.

[0174] Figure 3 In the above format template statement 1, we can obtain extended template statement 1 - extended template statement 4.

[0175] Among them, extended template statement 1 is: add some <tim>exist <loc> <cha> <eve>.

[0176] Extended template statement 2 is: Add some <tim>exist <loc> <cha> <eve>.

[0177] Extended template statement 3 is: Add one <tim>exist <loc> <cha> <eve>.

[0178] Extended template statement 4 is: Add some <tim>exist <loc> <cha> <eve>.

[0179] Based on the above format template statement 2, we can obtain extended template statement 5 - extended template statement 6.

[0180] Among them, extended template statement 5 is: find some additional ones. <tim> <cha>exist <loc> <eve>Add the photos to the video.

[0181] Extended template statement 6 is: Search for some external... <tim> <cha>exist <loc> <eve>Add the photos to the video.

[0182] Based on the above format template statement 3, we can obtain extended template statements 7-8.

[0183] Among them, extended template statement 7 is: ... <tim> <cha>exist <loc> <eve>The photos were also added to the video.

[0184] Extended template statement 8 is: to <tim> <cha>exist <loc> <eve>The images were also added to the video.

[0185] Based on the above format template statement 4, we can obtain extended template statement 9 to extended template statement 11.

[0186] Among them, extended template statement 9 is: ... <tim> <cha>exist <loc> <eve>Add photos to videos.

[0187] Extended template statement 10 is: to <tim> <cha>exist <loc> <eve>Photos and videos.

[0188] Extended template statement 11 is: ... <tim> <cha>exist <loc> <eve>The photos were added to the video.

[0189] Based on the above format template statement 5, we can obtain extended template statement 12-extended template statement 13.

[0190] Among them, extended template statement 12 is: Add <tim> <cha>exist <loc> <eve>The video.

[0191] Extended template statement 13 is: Add <tim>of <cha>exist <loc> <eve>The video.

[0192] Understandable. Figure 3 The number of extended template statements and the content of each extended template statement obtained in the above description are only for the purpose of better understanding the solution of this application, and are not a limitation on the number or specific content of the extended template statements.

[0193] S206, The electronic device selects the entity group to be calibrated, and combines each entity in the calibration entity group with the extended template statement to obtain the extended statement.

[0194] In the embodiments of this application, for ease of description, the sum of the extended statements obtained by S206 can be referred to as the total sentence pool.

[0195] The aforementioned corrected entity group is the selected entity group used for correction. The corrected entity group (or second entity group) differs from the target entity group (or first entity group). The entity type combination corresponding to the corrected entity group is the same as the entity type combination corresponding to the target entity group.

[0196] For example, the target entity group could be: {Time: Spring Festival; Location: Hometown; Person: Teacher Wang; Event: Setting off firecrackers}. The corresponding entity type combination for the target entity group is: Time + Location + Person + Event. The corrected entity group could be: {Time: Yesterday; Location: Hometown; Person: My Sister; Event: Dancing}. The corresponding entity type combination for the target entity group is also: Time + Location + Person + Event.

[0197] Here, for each extended template statement, the electronic device can combine the correction entity group with the extended template statement. That is, it replaces the entity label in the extended template statement that matches the type of the entity with the entity in the correction entity group, thereby obtaining the extended statement. In other words, for each extended template statement, a corresponding extended statement can be obtained.

[0198] Further with Figure 3 For example, Figure 3 In the text, the corrected entity group can be: {Time: Yesterday; Location: Beijing; Person: My mother; Event: Visiting the Forbidden City}. Figure 3 In this process, electronic devices can embed correction entity groups into various extended template statements, thereby obtaining the extended statements corresponding to each extended template statement. For example... Figure 3 The content shown in the bottom middle box, when there are 13 extended template statements, can yield 13 corresponding extended statements.

[0199] It should be noted that, in the format statement generation operation in S203 above, or in the template statement expansion operation in S205 above, some words with low universal applicability may be generated in the statement. These words may be applicable in some scenarios, but not in others. In order to improve the universal applicability (or generality) of the expanded template statement, in this embodiment of the application, the electronic device combines the correction entity group that is different from the target entity group with the expanded template statement to obtain the expanded statement. Then, further filtering is performed based on the context of the expanded statement, which can filter out the expanded statements that do not make sense when the target entity group is substituted, thereby filtering out the expanded template statements corresponding to the incoherent expanded statements. It should be noted that improving the universal applicability of the expanded template statement can help improve the representativeness of the generated training sample data, that is, improve the quality of the training sample data.

[0200] To further illustrate, if the basic statement is: "Add more photos of Teacher Wang setting off firecrackers in my hometown during the Spring Festival," after the format statement generation operation in S203 above, the generated format statement includes the following statement: "Add some photos of Teacher Wang setting off firecrackers in my hometown during this year's Spring Festival." After abstracting this format statement into an entity, the resulting format template statement is: "Add some photos of this year's..." <tim>exist <loc> <cha> <eve>The photo is shown. If the corrected entity group is: {Time: Yesterday; Location: Hometown; People: My Sister; Event: Dancing}, then when the electronic device embeds the corrected entity group into the format template statement after the extended template statement includes this format template statement, the resulting statement is: Add some photos of my sister dancing in my hometown yesterday this year. This statement is clearly not grammatically correct. Therefore, add some photos of my sister dancing this year... <tim>exist <loc> <cha> <eve>This template statement is not very versatile and can be deleted.

[0201] S207, the electronic device filters extended statements that meet preset filtering conditions from the total sentence pool to obtain the target sentence pool.

[0202] In this embodiment of the application, for ease of description, the sum of extended statements that meet the preset filtering conditions selected by the electronic device can be referred to as the target sentence pool.

[0203] The above preset filtering conditions are usually pre-defined conditions used to filter extended statements.

[0204] Optionally, the above preset filtering conditions may include one or more of the following conditions 1 to 3.

[0205] Condition 1: The perplexity of the extended statement falls within the preset value range.

[0206] The upper limit of the aforementioned preset value range is the upper limit of the preset perplexity, and the lower limit of the preset value range is the lower limit of the preset perplexity. In practice, the aforementioned upper and lower limits of the preset perplexity are usually small positive numbers. As an example, the aforementioned lower limit of the preset perplexity can be 2.5, and the aforementioned upper limit of the preset perplexity can be 4.8.

[0207] It is understood that in the embodiments of this application, the above-mentioned preset perplexity upper limit and the above-mentioned preset perplexity lower limit are usually related to the application scenario of the entity recognition model. The embodiments of this application do not specifically limit the values ​​of the above-mentioned preset perplexity upper limit and the above-mentioned preset perplexity lower limit.

[0208] It should be noted that the perplexity of the extended statement falls within a preset range, which usually indicates that the extended statement is relatively fluent. Filtering extended statements using condition 1 can yield more fluent extended statements.

[0209] Condition 2: The semantic similarity between any two expanded statements is less than a preset semantic similarity threshold. The preset semantic similarity threshold is a pre-defined value, ranging from 0 to 1. For example, the preset semantic similarity threshold could be 0.5.

[0210] It should be noted that if the semantic similarity between any two statements is less than the preset semantic similarity threshold, it usually indicates that the two statements are well distinguishable. Using condition 2 as the filtering condition for extended statements can filter out extended statements that are highly distinguishable from other statements.

[0211] Condition 3: The edit distance between the expanded statement and the reference statement is less than the upper limit of the edit distance.

[0212] The above-mentioned upper limit for editing distance can be a preset value, such as 25.

[0213] Optionally, the above-mentioned upper limit of the edit distance can also be positively correlated with the length of the reference statement. For example, if the length of the reference statement is L, then the upper limit of the edit distance can be w×L, where w is a coefficient greater than 0 and less than 1. For instance, if the length L of the reference statement is 25 and the value of w is 0.8, then the above-mentioned upper limit of the edit distance can be 20, where 20 = 25 × 0.8.

[0214] The aforementioned reference statements are typically obtained by combining the corrected entity group with any initial template statement. The initial template statement is a template statement from the initial template statement pool. Since the template statements in the initial template statement pool are usually manually written, they have high fluency and are well-suited to the application scenarios of the entity recognition model. Using template statements from the initial template statement pool to obtain reference statements ensures both fluency and scenario suitability. Thus, using reference statements to filter extended statements, and further filtering extended template statements, results in more versatile and scenario-suitable extended template statements, thereby improving their accuracy.

[0215] It should be noted that for any extended statement, if the edit distance between the extended statement and the reference statement is greater than the upper limit of the edit distance, it usually indicates that the extended statement is not compatible with the model's application scenario. Using condition 3 as the filtering condition for extended statements can filter out extended statements that are compatible with the model's application scenario.

[0216] In this embodiment of the application, after obtaining the total sentence pool, the electronic device can first calculate the first similarity between each extended statement in the total sentence pool and the reference statement. Then, based on the first similarity of each extended statement, the target sentence pool is selected from the total sentence pool. The first similarity measures the degree of similarity between the extended statement and the reference statement.

[0217] In this embodiment, the first similarity is typically edit distance. It is understood that in some application scenarios, the first similarity can also be other metrics, such as Euclidean distance.

[0218] It should be noted that since the edit distance value is usually an integer, the number of possible values ​​is very small. For example, when the reference statement length is 10, the edit distance value can be at most an integer between 0 and 10, that is, at most 11 values. When the first similarity is the edit distance, the amount of computation can be greatly reduced, and the speed of template statement expansion can be improved.

[0219] The following example uses the first similarity as the edit distance, combined with... Figure 2B This paper explains how electronic devices select the target sentence pool from the total sentence pool based on the first similarity of each extended sentence. Figure 2B This is a schematic diagram illustrating the process of filtering the target sentence pool provided in an embodiment of this application.

[0220] S2071, the electronic device determines the edit distance between each extended statement in the total sentence pool and the reference statement, and obtains the edit distance set.

[0221] In this embodiment of the application, for ease of description, the sum of the various edit distance values ​​corresponding to the total sentence pool can be referred to as the edit distance set.

[0222] by Figure 3 For example, with 13 expanded statements, we can obtain 13 edit distances. Understandably, some edit distances may be equal, and some may be unequal. For instance, among the 13 edit distances, there might be 5 edit distances of 5, 3 edit distances of 10, 4 edit distances of 3, and 1 edit distance of 20. In this case, we obtain 4 possible edit distance values ​​for the 13 expanded statements; that is, the set of edit distances includes the elements: 3, 5, 10, and 20.

[0223] S2072, The electronic device determines the filtering range for filtering the total sentence pool.

[0224] Optionally, the filtering interval is related to the values ​​of various edit distances (or the set of edit distances) corresponding to the total sentence pool, and at least one of the upper or lower limits of the filtering interval belongs to the set of edit distances.

[0225] In some alternative implementations, the electronic device can use each element in the edit distance set as the upper limit of the filter interval and 0 as the lower limit of the filter interval, thus obtaining a filter interval with the same number of elements as the edit distance set. For example, when the edit distance set is {3,5,10,20}, four filter intervals can be obtained: 0-3, 0-5, 0-10, and 0-20.

[0226] In other alternative implementations, the electronic device can also use two adjacent elements in the edit distance set as the upper and lower limits of the filtering interval, respectively, thus obtaining multiple filtering intervals. In this case, the number of filtering intervals is one less than the number of elements in the edit distance set. For example, when the edit distance set is {3,5,10,20}, three filtering intervals can be obtained: 3-5, 5-10, and 10-20.

[0227] It should be noted that using the values ​​of various edit distances corresponding to the total sentence pool as the upper or lower limit of the filtering interval to filter the expanded sentences in the total sentence pool can effectively reduce unnecessary filtering operations, thereby further improving the speed of template sentence expansion.

[0228] Considering that if the edit distance between the extended statement and the reference statement is too large, the extended statement may not be suitable for the model's application scenario.

[0229] In some optional implementations, the electronic device can, after obtaining the values ​​of various edit distances corresponding to the total sentence pool (i.e., the aforementioned set of edit distances), further determine whether there is an edit distance in the set that is greater than the upper limit of the edit distance. If so, it can delete the extended statement corresponding to the edit distance and remove the edit distance from the set of edit distances.

[0230] The above-mentioned upper limit for editing distance can be a preset value, such as 25.

[0231] Optionally, the above-mentioned upper limit of the edit distance can also be positively correlated with the length of the reference statement. For example, if the length of the reference statement is L, then the upper limit of the edit distance can be w×L, where w is a coefficient greater than 0 and less than 1. For instance, if the length L of the reference statement is 25 and the value of w is 0.8, then the above-mentioned upper limit of the edit distance can be 20, where 20 = 25 × 0.8.

[0232] It should be noted that deleting extended statements with an edit distance greater than the upper limit of the edit distance can remove statements that do not conform to the application scenario of the model. This makes the target extended template statements obtained later more suitable for the application scenario of the entity recognition model, that is, it can improve the accuracy of template statement extension.

[0233] S2073, the electronic device filters extended sentences whose corresponding edit distance belongs to the filter interval from the total sentence pool, and obtains a sub-sentence pool corresponding to the filter interval.

[0234] Understandably, in this embodiment of the application, for ease of description, the sum of the extended statements whose corresponding edit distances belong to the filtering interval is denoted as the sub-sentence pool.

[0235] When there are multiple filtering ranges, multiple sub-sentence pools can be obtained.

[0236] In this embodiment, the number of filtering intervals is typically the same as the number of sub-sentence pools. For example, if there are four filtering intervals, then four sub-sentence pools can be obtained accordingly.

[0237] S2074, the electronic device determines the importance coefficient of each sub-sentence pool and identifies the sub-sentence pool with the highest importance coefficient as the target sentence pool.

[0238] Among them, the aforementioned importance coefficient is inversely correlated with the perplexity of each expanded statement in the sub-sentence pool.

[0239] The importance coefficient is inversely correlated with the similarity between every two expanded statements in the sub-sentence pool.

[0240] Here, for ease of description, the similarity between every two expanded sentences in the sub-sentence pool can be denoted as the second similarity. Both the second similarity and the aforementioned first similarity can measure the similarity between two sentences, but the second similarity measures the similarity in a different way. In practice, the first similarity can be edit distance, while the second similarity can be semantic similarity.

[0241] It should be noted that, since the importance coefficient is inversely correlated with the perplexity of the expanded sentences and the similarity between any two expanded sentences, the electronic device identifies the sub-sentence pool with the highest importance coefficient as the target sentence pool. This ensures that the selected target sentence pool has a lower overall perplexity and less similarity between expanded sentences. In other words, it can select a target sentence pool with better fluency and higher sentence differentiation, which helps improve the accuracy of template sentence expansion. Thus, while ensuring the rapid generation of training sample sentences, the quality of the generated training sample sentences is improved.

[0242] In some alternative implementations, the formula for calculating the above-mentioned importance coefficient can be as shown in formula (1).

[0243]

[0244] Where Reward is the importance coefficient, n is the number of expanded statements in the sub-sentence pool, ReLU is the activation function, s1 is the preset upper limit of perplexity, s2 is the preset lower limit of perplexity, and ppl(x) is the maximum perplexity value. i Let ) represent the perplexity of the i-th expanded statement, α be the weighting coefficient, and x be the perplexity of the i-th expanded statement. i For the i-th expanded statement in the sub-sentence pool, x j This is the j-th extended statement in the sub-sentence pool.

[0245] In practice, the aforementioned preset perplexity upper limit s1 and preset perplexity lower limit s2 are usually small positive numbers. It is understood that in this embodiment, the preset perplexity upper limit s1, the preset perplexity lower limit s2, and the weight coefficient α are generally related to the application scenario of the entity recognition model. This embodiment does not specifically limit the values ​​of the preset perplexity upper limit s1, the preset perplexity lower limit s2, and the weight coefficient α, nor the process for determining these values.

[0246] Combining the above formula (1), in ppl(x) i When the value of ) is between s2 and s1, the ReLU(s1-ppl(x) on the left side of the above formula (1) is... i ))+ReLU(ppl(x i The value of )-s2) is usually small and fixed. In ppl(x i When the value of ) is not between s2 and s1, ReLU(s1-ppl(x) i ))+ReLU(ppl(x i The value of s2 is usually relatively large, which helps to more accurately filter out the target sentence pool with less confusion and less similarity between the extended sentences. In other words, it helps to further improve the accuracy of template sentence expansion.

[0247] It should be noted that in the embodiments of this application, the electronic device may use relevant perplexity calculation techniques to determine the perplexity of each extended statement, which will not be elaborated here.

[0248] In addition, electronic devices can also use relevant techniques to calculate semantic similarity to determine the semantic similarity between any two extended statements, which will not be elaborated here.

[0249] by Figure 3 For example, if the total sentence pool contains 13 extended statements, and the electronic device filters the total sentence pool, it can obtain 9 extended statements. In other words, the target sentence pool obtained by filtering contains 9 extended statements.

[0250] S208, the electronic device selects the extended template statements corresponding to each extended statement in the target sentence pool.

[0251] Here, each extended statement corresponds to an extended template statement. The electronic device can select the extended template statement corresponding to each extended statement in the target sentence pool.

[0252] Continue with Figure 3 For example, for the nine extended statements in the filtered target sentence pool, the electronic device can select nine corresponding extended template statements.

[0253] S209, the electronic device merges the selected extended template statement with the template statement pool and removes duplicates to obtain a new template statement pool.

[0254] Here, the electronic device can incorporate the expanded template statements into the original template statement pool, thereby obtaining the expanded template statement pool.

[0255] In addition, the electronic device can repeatedly execute the operations of S201-S209 above to obtain a template statement pool with a large amount of data.

[0256] Optionally, the conditions under which the electronic device ends execution of the above S201-S209, or the conditions for ending execution, may include: the number of template statements in the template statement pool is greater than or equal to the preset maximum number; and all combinations of entities in the entity pool have been traversed.

[0257] The aforementioned preset upper limit is usually a pre-set value. For example, it could be 2000.

[0258] In this embodiment of the application, when there are enough template statements in the template statement pool, or when the template statement expansion operation has been performed for every entity combination in the entity pool, the electronic device can stop executing the above S201-S209, that is, stop expanding the template statement pool.

[0259] (III) Generating training sample statements

[0260] In this embodiment of the application, the electronic device can combine the expanded template statement pool with the entity pool to obtain training sample statements for training the entity recognition model.

[0261] Specifically, the electronic device can select an entity group from the entity pool that has the same entity type combination as the template statement for any template statement in the template statement pool, and embed the selected entity group into the template statement to obtain the labeled statement, that is, to obtain the training sample statement used to train the entity recognition model.

[0262] For example, consider the following template statement in the template statement pool: Find a point <tim>exist <loc> <cha> <eve>The template statement corresponds to the entity type combination of: time + location + person + event. The electronic device can then select an entity group from the entity pool based on this entity type combination. This entity group includes an entity of type time, an entity of type location, an entity of type task, and an entity of type event. For example, this entity group could be {Time: Yesterday; Location: Hometown; Person: Second Daughter; Event: Dancing}. Embedding this entity group into the template statement yields a training sample statement. For example, this training sample statement could be: "Find some photos of my sister dancing in my hometown yesterday." And the tag for "yesterday" in this training sample statement is... <tim>The label for "hometown" is <loc>The tag "my sister" is <cha>The tag for "dancing" is <eve>.

[0263] In other words, the electronic device combines the template statements in the template statement pool with the entity groups selected from the entity pool to obtain labeled training sample statements. These training sample statements include not only the statements themselves, but also the annotation information of the entities within those statements, i.e., entity labels.

[0264] For each template statement in the template statement pool, multiple entity groups with the same entity type combination as the corresponding template statement can be selected from the entity pool. In other words, multiple training sample statements can be generated. This means that for the entire expanded template statement pool, a very large amount of training sample statements can be generated.

[0265] It should be noted that combining entity groups with template statements can produce training sample statements. Since each entity in the training sample statement has a labeled entity, the entity labels carried by each entity can ensure that the training sample statements are accurately labeled, thereby improving the quality of the generated training sample statements.

[0266] In summary, it can be seen that by automatically expanding the template statements based on real template statements, a large number of template statements that match the application scenarios of entity recognition models can be obtained. Electronic devices combine the entity pool with the expanded template statement pool to obtain training sample statements for the entity recognition model. This ensures that the obtained training sample statements meet the application scenario requirements of the entity recognition model, significantly reduces the cost of manual annotation, and greatly shortens the time required to obtain training sample data, thereby accelerating model training. In other words, the data generation scheme provided in this application embodiment can guarantee both the quantity and quality of the generated training sample data, while also significantly saving costs and time.

[0267] In practice, after obtaining a large number of training sample sentences, electronic devices can use the sentences in the obtained training sample sentences as input and the entity labels of each entity in the sentences as output to train the entity recognition model, thereby obtaining the trained entity recognition model.

[0268] In some application scenarios, electronic devices can divide the generated training sample data into two parts: one part is used to train the entity recognition model, and the other part is used to verify the effectiveness of the trained entity recognition model, thereby further ensuring that the trained entity recognition model can accurately and effectively identify entities in the first application scenario.

[0269] In practical applications, the electronic device used to train the entity recognition model and the electronic device that uses the trained entity recognition model may or may not be the same device. For example, the electronic device used to train the entity recognition model may be a server, while the electronic device that uses the trained entity recognition model may be a mobile phone.

[0270] Corresponding to the data generation method in the above embodiments, Figure 4 A schematic diagram of the data generation apparatus provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0271] Reference Figure 4 The data generation device includes:

[0272] The entity selection unit 401 is used to select a first entity group from the entity pool. The entities in the entity pool have entity labels that indicate the entity type. The entities in the first entity group have different entity types.

[0273] The sentence generation unit 402 is used to generate a total sentence pool based on the first entity group and the template statement pool. The sentences in the total sentence pool are different from the basic statements, and the entity labels corresponding to the sentences in the total sentence pool are the same as the entity labels corresponding to the basic statements. The basic statements are statements obtained by combining the first entity group and the template statements in the template statement pool. The template statements in the template statement pool include entity labels. The entity pool and the template statement pool are consistent with the first application scenario targeted by the entity recognition model.

[0274] Sentence grouping unit 403 is used to select multiple sub-sentence pools from the total sentence pool based on the similarity between each sentence in the total sentence pool and the reference statement. The reference statement is composed of each entity corresponding to the total sentence pool and the initial template statement. The initial template statement belongs to the initial template statement pool.

[0275] The coefficient determination unit 404 is used to determine the importance coefficient of each sub-sentence pool based on the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between each pair of sentences.

[0276] The template extension unit 405 is used to determine the sub-sentence pool with the largest corresponding importance coefficient value among multiple sub-sentence pools as the target sentence pool, and add the first template statement corresponding to each sentence in the target sentence pool to the template statement pool. The first template statement is obtained by replacing the entity in the sentence with the corresponding entity label.

[0277] The sample generation unit 406 is used to generate training sample statements for training the entity recognition model based on the expanded template statement pool and entity pool.

[0278] As one embodiment of this application, the data generation apparatus can achieve the following: Figures 1-3 The embodiments shown and other related method embodiments.

[0279] The process by which each module in the data generation apparatus provided in this application implements its respective function can be specifically referred to the foregoing. Figures 1-3 The descriptions of the embodiments shown and other related method embodiments are not repeated here.

[0280] Figure 5 A schematic diagram of the structure of the model application device provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0281] Reference Figure 5 The application device for this model includes:

[0282] Instruction input unit 501 is used to receive a first instruction input by the user;

[0283] The instruction response unit 502 is used to display the corresponding interface in response to the first instruction; the entity information in the first instruction is obtained by recognizing the entity through an entity recognition model.

[0284] The training sample sentences for the entity recognition model are obtained by combining the expanded template sentence pool and the entity pool. The expansion process of the expanded template sentence pool includes:

[0285] The first entity group is selected from the entity pool. Based on the first entity group and the template statement pool, a total sentence pool is generated. The sentences in the total sentence pool are different from the basic statements, and the entity tags corresponding to the sentences in the total sentence pool are the same as the entity tags corresponding to the basic statements. The basic statements are statements obtained by combining the first entity group and the template statements in the template statement pool. The entity types of each entity in the first entity group are different. The entities in the entity pool have entity tags that indicate the entity type. The template statements in the template statement pool include entity tags. The entity pool and the template statement pool are consistent with the first application scenario.

[0286] Based on the similarity between each sentence in the main sentence pool and the reference statement, multiple sub-sentence pools are selected from the main sentence pool. The reference statement consists of each entity corresponding to the main sentence pool and the initial template statement. The initial template statement belongs to the initial template statement pool.

[0287] For each sub-sentence pool, the importance coefficient of the corresponding sub-sentence pool is determined based on the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between any two sentences.

[0288] The sentence pool with the highest importance coefficient among multiple sentence pools is determined as the target sentence pool. The first template statement corresponding to each sentence in the target sentence pool is added to the template statement pool. The first template statement is obtained by replacing the entities in the sentence with the corresponding entity labels.

[0289] As an embodiment of this application, the training sample data of the entity recognition model used in the model application device can be obtained through, for example... Figures 1-3 The illustrated embodiments and other related method embodiments are used for scheme generation.

[0290] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0291] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0292] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0293] It should also be understood that the term "and / or" as used in this application specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0294] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [the described condition or event] is detected," or "in response to detection of [the described condition or event]."

[0295] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. It should also be understood that although the terms "first," "second," etc., are used in the text to describe various elements in some embodiments of this application, these elements should not be limited by these terms. These terms are merely used to distinguish one element from another.

[0296] References to "one embodiment" or "some embodiments" as used in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0297] The data generation method provided in this application can be applied to electronic devices, such as tablets, mobile phones, wearable devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not limit the specific type of electronic device.

[0298] The hardware and software structures of the electronic device will be described in detail below with reference to the accompanying drawings.

[0299] Figure 6 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application.

[0300] The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a sensor module 180, buttons 190, a camera 193, a touch screen 194, and a SIM card interface 195, etc.

[0301] The audio module 170 may include a speaker and a microphone.

[0302] The sensor module 180 may include a pressure sensor, an inertial sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a touch sensor, and an ambient light sensor (of course, the electronic device may also include other sensors, such as a temperature sensor, a bone conduction sensor, etc., which are not shown in the figure).

[0303] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, memory, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). Different processing units may be independent devices or integrated into one or more processors. The controller may serve as the nerve center and command center of the electronic device. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.

[0304] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0305] The processor 110 can run the data generation method provided in the embodiments of this application. The processor 110 may include different devices. For example, when integrating a CPU and a GPU, the CPU and GPU can cooperate to execute the data generation method provided in the embodiments of this application. For example, some algorithms in the data generation method are executed by the CPU, and other algorithms are executed by the GPU to obtain faster processing efficiency.

[0306] It should be understood that the illustrated electronic device is merely an example, and electronic devices may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations.

[0307] The hardware system of the electronic device has been described in detail above. The software system of the electronic device is described below. The software system can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment takes a layered architecture as an example to exemplify the description of the software system of the electronic device.

[0308] For example, Figure 7 This is a schematic diagram of the software system of the electronic device provided in an embodiment of this application. See also... Figure 7 The software system adopts a layered architecture.

[0309] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0310] The application layer can include a series of application packages, such as voice assistants, cameras, gallery, and video applications. The application layer can also include models, such as entity recognition models. Entity recognition models can identify entities in user commands. Electronic devices can then respond correctly to user commands based on the entity information identified by the entity recognition model.

[0311] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0312] like Figure 7 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

[0313] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.

[0314] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, and more.

[0315] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.

[0316] A phone manager is used to provide communication functions for electronic devices. For example, it manages call status (including connection and disconnection).

[0317] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

[0318] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.

[0319] Android Runtime consists of core libraries and a virtual machine. Android Runtime is responsible for scheduling and managing the Android system.

[0320] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0321] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0322] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0323] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

[0324] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.164, MP3, AAC, AMR, JPG, and PNG.

[0325] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0326] A 2D graphics engine is a graphics engine for 2D drawing.

[0327] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.

[0328] Furthermore, those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. In the various embodiments of this application, each functional unit can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0329] This application also provides an electronic device, which includes at least one memory, at least one processor, and a computer program stored in at least one memory and executable on at least one processor. When the processor executes the computer program, it causes the electronic device to perform the steps in any of the above method embodiments.

[0330] Furthermore, those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. In the various embodiments of this application, each functional unit can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0331] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps described in the various method embodiments above.

[0332] This application provides a computer program product that, when run on an electronic device, enables the electronic device to implement the steps described in the various method embodiments above.

[0333] This application also provides a chip system, which includes a processor coupled to a memory. The processor executes a computer program stored in the memory to implement the steps in the above-described method embodiments.

[0334] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0335] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0336] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0337] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0338] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.< / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / cha> < / loc> < / tim> < / eve> < / loc> < / cha> < / tim> < / eve> < / cha> < / loc> < / tim>

Claims

1. A data generation method, characterized in that, The method includes: Select a first entity group from the entity pool, wherein the entities in the entity pool have entity labels indicating the entity type, and the entities in the first entity group have different entity types; Based on the first entity group and the template statement pool, a total sentence pool is generated. The sentences in the total sentence pool are different from the basic statements, and the entity labels corresponding to the sentences in the total sentence pool are the same as the entity labels corresponding to the basic statements. The basic statements are statements obtained by combining the first entity group and the template statements in the template statement pool. The template statements in the template statement pool include entity labels. The entity pool and the template statement pool are consistent with the first application scenario targeted by the entity recognition model. Based on the similarity between each sentence in the total sentence pool and the reference statement, multiple sub-sentence pools are selected from the total sentence pool. The reference statement is composed of each entity corresponding to the total sentence pool and the initial template statement. The initial template statement belongs to the initial template statement pool. For each sub-sentence pool, the importance coefficient of the corresponding sub-sentence pool is determined based on the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between any two sentences. The sentence pool with the largest corresponding importance coefficient among the multiple sentence pools is determined as the target sentence pool. The first template statement corresponding to each sentence in the target sentence pool is added to the template statement pool. The first template statement is obtained by replacing the entities in the sentence with the corresponding entity tags. Based on the expanded template statement pool and the entity pool, training sample statements are generated for training the entity recognition model.

2. The data generation method according to claim 1, characterized in that, The first application scenario is a dialogue sequence in a voice assistant application, and the entity types include: time, location, person, and event.

3. The data generation method according to claim 1, characterized in that, The step of selecting multiple sub-sentence pools from the total sentence pool based on the similarity between each sentence in the total sentence pool and a reference sentence includes: Determine the edit distance between each sentence in the total sentence pool and the reference statement; Based on the value of the edit distance corresponding to each sentence in the total sentence pool, multiple filtering intervals are determined; For each filtering interval, sentences whose corresponding edit distance belongs to the corresponding filtering interval are filtered to obtain the sub-sentence pool.

4. The data generation method according to claim 3, characterized in that, The multiple filtering intervals are either intervals formed by the values ​​of two adjacent edit distances, or intervals formed by zero and the values ​​of each edit distance.

5. The data generation method according to any one of claims 1-4, characterized in that, The importance coefficient is inversely correlated with the perplexity of each sentence in the sub-sentence pool, and the importance coefficient is inversely correlated with the similarity between any two sentences in the sub-sentence pool.

6. The data generation method according to claim 1, characterized in that, The step of generating a total sentence pool based on the first entity group and the template statement pool includes: The first entity group is combined with each template statement in the template statement pool to obtain a plurality of the basic statements; Generate a first statement, which is different from the basic statement, and the entities in the first statement are the same as the entities in the basic statement; Each entity in the first statement is replaced with an entity of the corresponding entity type in the second entity group to obtain the second statement. The total sentence pool includes the second statement. The second entity group is an entity group selected from the entity pool. The second entity group is different from the first entity group. The entity tags corresponding to the second entity group are the same as the entity tags corresponding to the first entity group.

7. The data generation method according to claim 6, characterized in that, The step of combining the first entity group with each template statement in the template statement pool to obtain a plurality of the basic statements includes: combining the first entity group with the second template statement in the template statement pool to obtain the basic statements, wherein the entity tags in the second template statement are the same as the entity tags corresponding to the first entity group.

8. The data generation method according to any one of claims 1-7, characterized in that, The step of generating training sample statements for training the entity recognition model based on the expanded template statement pool and the entity pool includes: A third entity group is selected from the entity pool, and a third template statement is selected from the template statement pool, wherein the entity tags in the third template statement are the same as the entity tags corresponding to the third entity group; Each entity in the third entity group is written into the corresponding entity label position in the third template statement to obtain the training sample statement.

9. A method for applying a model, characterized in that, The method includes: In response to a first command input by the user, a corresponding interface is displayed that responds to the first command; the entity information in the first command is obtained through entity recognition model. The training sample statements for the entity recognition model are obtained by combining an expanded template statement pool and an entity pool. The expansion process of the expanded template statement pool includes: A first entity group is selected from the entity pool, wherein the entities in the entity pool have entity labels indicating the entity type, and the entities in the first entity group have different entity types; Based on the first entity group and the template statement pool, a total sentence pool is generated. The sentences in the total sentence pool are different from the basic statements, and the entity labels corresponding to the sentences in the total sentence pool are the same as the entity labels corresponding to the basic statements. The basic statements are statements obtained by combining the first entity group and the template statements in the template statement pool. The template statements in the template statement pool include entity labels. The entity pool and the template statement pool are consistent with the first application scenario targeted by the entity recognition model. Based on the similarity between each sentence in the total sentence pool and the reference statement, multiple sub-sentence pools are selected from the total sentence pool. The reference statement is composed of each entity corresponding to the total sentence pool and the initial template statement. The initial template statement belongs to the initial template statement pool. For each sub-sentence pool, the importance coefficient of the corresponding sub-sentence pool is determined based on the perplexity of each sentence in the corresponding sub-sentence pool and the similarity between any two sentences. The sentence pool with the highest importance coefficient among the multiple sentence pools is determined as the target sentence pool. The first template statement corresponding to each sentence in the target sentence pool is added to the template statement pool. The first template statement is obtained by replacing the entities in the sentence with the corresponding entity labels.

10. The model application method according to claim 9, characterized in that, The step of displaying a corresponding interface in response to a first command input by the user includes: In response to an instruction to generate a video, a first interface is displayed, the first interface including a first image material and / or a first video, wherein the first image material is obtained by filtering image materials that are compatible with the entity information, and the first video is generated by combining the filtered image materials.

11. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the computer program, it implements the data generation method as described in any one of claims 1-8, or the model application method as described in any one of claims 9-10.