Text processing method and apparatus, and electronic device and storage medium
Through the prediction model, the sub-request and target instruction information of spoken requests are solved, and the problems of complex and insufficient recognition capabilities of the intelligent voice assistant system model in the prior art are achieved, and more efficient text processing and recognition capabilities are achieved.
Patent Information
- Application Number
- PCT/CN2024/105480
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-18
- Filing Date
- 2024-07-15
- Publication Date
- 2025-03-27
AI Technical Summary
When existing intelligent voice assistant products deal with multi-intention and multi-round oral comprehension, the system model is complex, the training and iteration costs high, and the recognition ability is weak in cold start and small sample scenarios.
The prediction model predicts the number of sub-requests and sub-request text of the spoken request, and predicts the target instruction information corresponding to the sub-request text, including intent, domain and slots, to determine the response of the spoken request.
The system model is simplified, training and iterative costs are reduced, and recognition capabilities are improved in multi-intention and multi-round scenarios, especially in cold start and small sample scenarios.
Smart Images

Figure CN2024105480_27032025_PF_FP_ABST
Abstract
Description
Text processing method, device, electronic device and storage medium
[0001] Related applications
[0002] This application claims priority to Chinese patent application number 2023112010037, filed on September 18, 2023, entitled “Text processing method, device, electronic device and storage medium,” the entire text of which is hereby incorporated by reference. Technical Field
[0003] The present application relates to the field of artificial intelligence technology, and specifically to a text processing method, device, electronic device and storage medium. Background Art
[0004] In recent years, with the rapid development of artificial intelligence (AI), intelligent voice assistant products based on AI have been widely used in people's daily lives. Through intelligent voice assistant products, people can control smart devices using only voice. Among them, spoken language understanding is the core algorithm capability of intelligent voice assistant products.
[0005] In actual applications, when intelligent voice assistant products use spoken language understanding to sort out user questions, they typically face a variety of spoken language understanding scenarios, such as multi-intent spoken language understanding scenarios and single-intent spoken language understanding scenarios. Multi-intent spoken language understanding scenarios refer to scenarios where multiple intents are identified from a spoken sentence, while single-intent spoken language understanding scenarios refer to scenarios where a single intent is identified from a spoken sentence.
[0006] However, in related technologies, multiple separate models are usually set up in the system of intelligent voice assistant products to support the above-mentioned multiple spoken language comprehension problem scenarios respectively. For example, each of the multiple models can specifically process the text generated in a spoken language comprehension problem scenario, which leads to the complexity of the system model of the intelligent voice assistant product and the high cost of training and continuous iteration of the model in the system.
[0007] Summary of the Invention
[0008] Embodiments of the present application provide a text processing method, apparatus, electronic device, and storage medium.
[0009] In one aspect, a text processing method is provided, which is performed by an electronic device and includes:
[0010] Obtaining a spoken request text expressing a spoken request;
[0011] Using the spoken request text, the prediction model predicts the number N of sub-requests of the spoken request and the N sub-request texts corresponding to the N sub-requests; and
[0012] The prediction model predicts the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts. The target instruction information includes intention, field and slot. The target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request.
[0013] On the other hand, an embodiment of the present application further provides a text processing device, comprising:
[0014] an acquisition unit, configured to acquire a spoken request text expressing a spoken request;
[0015] a first prediction unit, configured to predict, by using a prediction model and the spoken request text, the number N of sub-requests of the spoken request and N sub-request texts corresponding to the N sub-requests, where N is a positive integer; and
[0016] The second prediction unit is used to predict the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts through the prediction model, wherein the target instruction information includes intention, field and slot, and the target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request.
[0017] On the other hand, an embodiment of the present application further provides an electronic device, comprising a memory storing multiple instructions; the processor loads instructions from the memory to execute the steps of any text processing method provided in the embodiment of the present application.
[0018] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps of any text processing method provided in the embodiment of the present application.
[0019] On the other hand, an embodiment of the present application further provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of any text processing method provided in the embodiment of the present application.
[0020] The details of one or more embodiments of the present application are set forth in the accompanying drawings and the description below. Other features, objects, and advantages of the present application will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the conventional technology, the following briefly introduces the drawings required for use in the embodiments or the conventional technology descriptions. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the disclosed drawings without any creative work.
[0022] FIG1 is a schematic diagram of a multi-scenario spoken language understanding process in a related art provided by an embodiment of the present application;
[0023] FIG2 is a schematic diagram of an application scenario of the text processing method provided in an embodiment of the present application;
[0024] FIG3 is a flow chart of a text processing method provided in an embodiment of the present application;
[0025] FIG4 is a schematic diagram of a process for constructing a training data set according to an embodiment of the present application;
[0026] FIG5 is a schematic diagram of a flow chart of updating a sample text according to an embodiment of the present application;
[0027] FIG6 is a flow chart of another text processing method provided in an embodiment of the present application;
[0028] FIG7 is a schematic diagram of a process for merging sample texts in a multi-round spoken language comprehension scenario provided by an embodiment of the present application;
[0029] FIG8 is a schematic diagram of the process of splicing sample text in a single-intent scenario provided by an embodiment of the present application;
[0030] FIG9 is a schematic diagram of the input and output of a generative large-scale language model provided in an embodiment of the present application;
[0031] FIG10 is a schematic diagram of a loss function for negative sample training according to an embodiment of the present application;
[0032] FIG11 is a schematic diagram of the training process and reasoning process of the prediction model provided in an embodiment of the present application;
[0033] FIG12 is a schematic diagram of the structure of a text processing device provided in an embodiment of the present application;
[0034] FIG13 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0036] Since spoken language understanding is the core algorithmic capability of intelligent voice assistant products, it plays a key role in many fields, including smart homes, smart speakers, and smart car control, and is an important part of improving user experience. Therefore, spoken language understanding technology is now widely used in various smart devices with voice assistants.
[0037] However, spoken language comprehension also faces many difficulties in practical application, such as large labeling systems, complex and changeable user spoken expressions, multiple rounds of continuous user requests, and negative user instructions. To address the above issues, related technologies mainly adopt the method of setting up multiple subsystems to provide independent support. The establishment of multiple models leads to high training and iteration costs. In addition, the system migration capability is also relatively weak. For example, when switching languages (such as switching foreign languages or dialects), multiple models need to be retrained and deployed.
[0038] As an example, as shown in Figure 1, the related art uses a multi-subsystem model to solve the user spoken language request (hereinafter referred to as spoken request) in the single-intent spoken language understanding (SLU, abbreviation of Spoken Language Understanding) scenario, the one-language multi-intent spoken language understanding scenario and the multi-round spoken language understanding scenario. The overall spoken language understanding system may include multiple subsystems, and the multiple subsystems are system 1: one-language multi-intent spoken language understanding module, system 2: single-intent spoken language understanding module, and system 3: multi-round spoken language understanding module.
[0039] Among them, system 1 includes a one-language multi-intention discrimination model and a multi-intention spoken language understanding model. The one-language multi-intention discrimination model is used to determine whether the received user spoken request has multiple intentions, and the multi-intention spoken language understanding model is used to output the corresponding spoken language understanding results according to the multi-intention user spoken request. Among them, the single-intent spoken language understanding model can implement three single-intent spoken language understanding methods, namely rule-based template spoken language understanding, expected matching spoken language understanding, and spoken language understanding recognition results based on the BERT deep model. Template spoken language understanding can match the spoken language understanding results corresponding to the template for the user spoken request. Expected matching spoken language understanding can match the spoken language understanding results in the user spoken language corpus.
[0040] For example, if a user's spoken request is "Where is the nearest Bank of Communications?", the multi-intent identification model is used to determine whether the user's spoken request has multiple intents. Based on the user's spoken request, the multi-intent spoken language understanding model is used to output the corresponding spoken language understanding results, including the domain, intent, and slot. The domain is navigation, the intent is location query, and the slot includes the sorting category and location category. The sorting category is nearby and / or nearest, and the location category is Bank of Communications.
[0041] System 2 includes a single-intent spoken language understanding model, which is used to output corresponding spoken language understanding results according to a single-intent user spoken language request.
[0042] System 3 includes a multi-round intent discrimination model and a multi-round rewriting model. The multi-round intent discrimination model is used to determine whether a received user spoken request is a multi-round intent request, for example, whether the current round of spoken request depends on the spoken request in the previous round. The multi-round rewriting model is used to rewrite a multi-round user spoken request into a single-intent user spoken request, for example, rewriting the current round of spoken request into a complete text that is unrelated to the spoken request in the previous round.
[0043] As can be seen, the multi-subsystem model adopted in related technologies results in complex system models, high deployment and ongoing iteration costs, and weak system migration capabilities to other languages. Furthermore, spoken language understanding and recognition capabilities are poor, especially in cold start and small sample scenarios. Furthermore, multi-round spoken language understanding capabilities are weak, processing only two rounds of requests, limiting practical application scenarios.
[0044] In response to the above problems, embodiments of the present application provide a text processing method, device, electronic device, and storage medium.
[0045] The text processing device can be integrated into an electronic device, such as a terminal, a server, or the like. The terminal may include, but is not limited to, a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, or the like; the server may be a single server or a server cluster consisting of multiple servers.
[0046] In some embodiments, the text processing device may be integrated into multiple electronic devices. For example, the text processing device may be integrated into multiple servers, with multiple servers collaborating to implement the text processing method of the present application. In some embodiments, a terminal may also function as a server, implementing some or all of the server's functions.
[0047] As an example, refer to FIG2 , which shows a schematic diagram of an application scenario of the text processing method provided in an embodiment of the present application.
[0048] As shown in FIG2 , the application scenario may include an electronic device 10 and a smart device 20 . The text processing method may be applied to the electronic device 10 , including but not limited to a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, a vehicle-mounted terminal, a smart wearable device, etc. The electronic device 10 may be communicatively connected to the smart device 20 .
[0049] The smart device 20 may be an object that the user currently needs to control via voice control. The smart device 20 may include, but is not limited to, a smart speaker, smart home appliances, a smart car, and the like. Alternatively, smart home appliances may include, but are not limited to, smart clothes drying racks, smart refrigerators, smart TVs, smart lighting devices, and the like. The number of smart devices 20 may be one or more, and is not limited thereto.
[0050] Among them, the electronic device 10 can obtain a spoken request text expressing a spoken request, and predict the number N of sub-requests of the spoken request and N sub-request texts through a prediction model, wherein N is a positive integer, and then predict the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts through the prediction model. The target instruction information includes intention, field, and slot, and the target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request. In actual application, when the electronic device 10 receives the user's target voice for the smart device 20, it can recognize the target voice as a spoken request text, and input the spoken request text into the prediction model to obtain the target instruction information corresponding to the spoken request text, and then send the control instruction corresponding to the target instruction information to the smart device 20 to control the smart device 20 to perform the corresponding action.
[0051] In some embodiments, the object that the user currently needs to control through voice may also be the electronic device 10 itself. For example, the electronic device 10 is a mobile phone. The user can ask questions to the mobile phone through the target voice. When the mobile phone receives the target voice, it can recognize the target voice as a spoken request text, and input the spoken request text into the prediction model to obtain the target instruction information corresponding to the spoken request text. After that, the mobile phone can query the control instruction corresponding to the target instruction information and answer the user's question based on the control instruction.
[0052] The following describes some concepts involved in this application.
[0053] Artificial intelligence (AI) is a technology that uses digital computers to simulate human-like perception of the environment, acquisition, and application of knowledge. This technology enables machines to possess human-like perception, reasoning, and decision-making capabilities. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and smart transportation.
[0054] Key technologies in speech technology include automatic speech recognition, speech synthesis, and voiceprint recognition. Enabling computers to hear, see, speak, and feel is the future direction of human-computer interaction, with speech becoming one of the most promising methods of human-computer interaction.
[0055] Natural language processing (NLP) is a key area of research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.
[0056] With the research and progress of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, Internet of Vehicles, automatic driving, smart transportation, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0057] Spoken Language Understanding (SLA): This technology understands command requests in spoken language, including the scope, intent, and slot of the command. This is then used to control machines (such as smart homes, car control systems, and smart speakers) to execute the corresponding commands.
[0058] BERT, short for Bidirectional Encoder Representations from Transformers, is a pre-trained language model based on the Transformer architecture. It learns language knowledge from large amounts of text data through large-scale unsupervised training, and can then be used for various natural language processing tasks.
[0059] Generative Large Language Models (LLMs): These are deep learning generative models trained using large amounts of text data. They can generate natural language text or understand the meaning of text. Large language models can handle a variety of natural language tasks, such as text classification, question answering, and conversation, and are an important path to artificial intelligence. Common large language models include ChatGPT, Llama, and Bloom.
[0060] Chain-of-Thought (CoT): This training model learns how to break down complex problems into multiple sub-steps, reasoning step by step to arrive at the correct answer, based on human thinking. This improves the model's reasoning ability when dealing with complex problems.
[0061] Spoken requests can be verbal requests sent by users to a machine device, such as voice commands or verbal questions. Through voice commands or verbal questions, users can interact with the intelligent assistant or voice interaction system and implement various functions based on their needs. Spoken requests can include, but are not limited to, single-intent requests, single-intention requests with multiple intents, and multi-intention requests.
[0062] Single-intent request: A round of spoken language request sent to a machine device, and the spoken language request only contains one intent under one domain. For example, the spoken language request: "I want to turn on the air conditioner" shows that the spoken language request includes an intent "turn on the air conditioner" under the "device control" domain.
[0063] A single-language, multi-intent request is a single verbal request sent to a device that contains only two or more domain and intent combinations. Specifically, this can include separate intents within two or more domains, or two or more intents within a single domain. For example, the verbal request "I want to turn on the air conditioner and navigate to the office" includes one intent, "Turn on the air conditioner," within the "Device Control" domain, and one intent, "Navigate to the office," within the "Navigation" domain.
[0064] Multi-round intent request: Multiple rounds of spoken language requests sent to the machine device. The current round of spoken language requests is related to other spoken language requests before the current round. For example, a multi-round intent request includes other rounds of spoken language requests: "What's the weather like today" and the current round request: "What about tomorrow?"
[0065] It can be understood that in the specific implementation of this application, related data such as user spoken requests, training data sets, sample texts, target voices, spoken request texts, etc. are involved. When the following embodiments of this application are applied to specific products or technologies, permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0066] In this embodiment, a text processing method involving artificial intelligence technology is provided. The method can be applied to the electronic device in FIG2 , as shown in FIG3 . The specific process of the text processing method can be as follows:
[0067] 301. Obtain a spoken request text expressing a spoken request.
[0068] Among them, the spoken request text is a text that expresses a spoken request. Among them, the spoken request means a request expressed in spoken language, and the spoken request can be expressed in voice form. The spoken request can be directed to a controllable object, and is used to request the controllable object to perform some actions. Among them, the spoken request can include one or more sub-requests, which are not limited here. Among them, the controllable object is an object that can be controlled, and can include a vehicle-mounted terminal, a mobile phone, a remote server or a sensor, etc. For example, the controllable object can be a vehicle-mounted terminal, and the spoken request can be a request for the vehicle-mounted terminal to display weather information, or a request for the vehicle-mounted terminal to play navigation information, or a request for the vehicle-mounted terminal to control the temperature in the car, etc.
[0069] Optionally, the spoken request text may be a text converted from the spoken request. The voice scenario may refer to a spoken language understanding scenario, in which the electronic device receives the user's spoken request and parses and understands it using natural language processing technology, thereby performing corresponding operations or providing accurate responses. In this embodiment, voice scenarios may include, but are not limited to, single-intent request scenarios, multi-intent request scenarios, and multi-round request scenarios.
[0070] The spoken request text is the text of the spoken request in a single-intent request scenario, the text of the spoken request in a multi-intent request scenario, or the text of one round of spoken request in a multi-round request scenario.
[0071] The text of the single-intent request scenario (hereinafter also referred to as the single-intent scenario) includes single-intent request content, and the single-intent request content represents the request content containing one intent.
[0072] As an example, the single-intent request content is "I want to turn on the air conditioner", where the request content only includes one intent "turn on the air conditioner".
[0073] Among them, the text of the multi-intent request scenario (hereinafter also referred to as the multi-intent scenario) includes multi-intent request content, and the multi-intent request content represents the request content containing multiple intents.
[0074] The multi-intent request can refer to the above-mentioned multi-intent request. As an example, the multi-intent request content can be "I want to turn on the air conditioner and navigate to the company", wherein the request content includes the intent "turn on the air conditioner" and the intent "I want to go to the company".
[0075] The text of the multi-round request scenario (hereinafter also referred to as the multi-round scenario) includes the text of the current round and the text of the previous round before the current round.
[0076] It is understandable that multiple rounds of requests can refer to the above-mentioned multiple rounds of intention requests. As an example, for example, the user issues a first round of spoken request: "I want to book a ticket from point A to point B tomorrow afternoon."; the electronic device: "OK, do you want economy class or business class?"; the user issues a second round (such as the current round) spoken request: "Economy class" scenario. Among them, the text corresponding to the first round of spoken request is the text of the previous round of the current round. The text corresponding to the second round of spoken request is the text of the current round. Among them, a single-intent scenario refers to a scenario in which the spoken request issued by the user is the above-mentioned single-intent request. A multi-intent scenario refers to a scenario in which the spoken request issued by the user is the above-mentioned one-word multi-intent request.
[0077] 302. Using the spoken request text and the prediction model, predict the number N of sub-requests of the spoken request and the N sub-request texts corresponding to the N sub-requests, where N is a positive integer.
[0078] The spoken request may include one or more sub-requests, and the sub-requests may be used to request the controllable object to perform some corresponding actions.
[0079] Among them, the prediction model can be obtained in advance through thought chain generation training. Since thought chain generation is a method of breaking down complex problems into multiple sub-steps according to human thinking through training models, reasoning step by step and finally obtaining the correct result, in this embodiment, thought chain generation training can be used to enable the prediction model to learn how to predict the number N of sub-requests in the spoken request text and break down the spoken request text into N sub-request texts.
[0080] 303. Predict the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts through the prediction model. The target instruction information includes intent, domain, and slot. The target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request.
[0081] Among them, the prediction model can be obtained by training based on a generative large-scale language model, and therefore is trained in combination with preset indication information. The trained prediction model can predict the target instruction information corresponding to each of the N sub-request texts based on the number of sub-requests N and the N sub-request texts. Among them, the indication information can instruct the generative large-scale language model to output target instruction information including intent, domain, and slot. It is understandable that the prediction model can predict a target instruction information for each of the N sub-request texts.
[0082] In some implementations, before step 302, the text processing method may further include a prediction model training method. The prediction model training method may include the following steps:
[0083] S1. Obtain training data sets under multiple scenarios, where the training data sets include at least one sample text corresponding to each scenario, and the multiple scenarios include at least two of a single-intent request scenario, a multi-intent request scenario, or a multi-round request scenario.
[0084] The sample text may be a text obtained by converting the user's spoken request through speech recognition. Therefore, the speech scene corresponding to the spoken request is also the speech scene corresponding to the sample text obtained by converting the spoken request.
[0085] In some embodiments, a specific implementation of obtaining a training data set in multiple voice scenarios may include: obtaining multiple spoken request samples and marking the type of each spoken request sample, then converting each spoken request sample into a corresponding sample text through voice recognition, and then establishing a correspondence between the sample text and the voice scenario based on the type of the spoken request sample corresponding to the sample text. For example, when the type of spoken request corresponding to the sample text is a single-language multi-intent request, a correspondence between the sample text and the multi-intent request scenario can be established. For another example, when the type of spoken request corresponding to the sample text is a single-intent request, a correspondence between the sample text and the single-intent request scenario can be established. For another example, when the type of spoken request corresponding to the sample text is a multi-round intent request, a correspondence between the sample text and the multi-round request scenario can be established, thereby obtaining a training data set in multiple voice scenarios. The multiple spoken request samples can be extracted from historical conversation records recorded by the electronic device, or can be automatically generated by the electronic device based on a preset spoken request template, which is not limited here.
[0086] In some embodiments, in step S1, the specific implementation of obtaining the training data set under multiple scenarios may include:
[0087] S11. Obtain a set of first-round dialogue templates and at least one set of second-round dialogue templates. Each first-round dialogue template in the set of first-round dialogue templates and each second-round dialogue template in the set of second-round dialogue templates include blank slots.
[0088] Among them, the set of first-round dialogue templates includes at least one first-round dialogue template. The first-round dialogue template can be a pre-annotated question template including blank slots. Among them, the blank slots can be regarded as positions to be filled or supplemented in the dialogue. These positions need to fill in appropriate information according to the context or prompts provided by the question. As shown in Figure 4, the first-round dialogue template can be "[location][datetime] What's the weather like", which means what's the weather like at a certain time and place. Among them, [location] and [datetime] are blank slots. [location] represents the location, address, and [datetime] represents the date and / or time.
[0089] Among them, each set of second-round dialogue templates includes at least one second-round dialogue template. The second-round dialogue template can include a reference template, an ellipsis template, etc. Among them, the ellipsis template is used to omit repeated information in the dialogue. When a certain information has been clearly mentioned and become obsolete in the context, the ellipsis template can be used to simplify the dialogue and only provide new or changed information. Among them, the reference template is used to use specific words or phrases to replace the information mentioned previously in the dialogue to reduce repetition and improve communication efficiency. Continuing with the above example, for example, the second-round dialogue template can be "[location]呢". Considering the first-round dialogue template "[location][datetime] What's the weather like" in the above example, this second-round dialogue template is an ellipsis template obtained by omitting "What's the weather like" based on the first-round dialogue template. Among them, please refer to Figure 4 again. In addition to [location] and [datetime], the blank slots can also include [activity], [description], etc. [activity] represents activities, etc., and [description] represents the object of description. Exemplarily, for example, the set of second-round dialogue templates includes "Is it suitable for [activity]?", which means is it suitable for a certain activity. Another example is that the set of second-round dialogue templates includes "[datetime] Will there be [description]?", which means will there be a certain object of description at a certain time. Among them, the object of description can be snow, rain, etc.
[0090] In some embodiments, the first-round dialogue template set and at least one second-round dialogue template set may be pre-labeled and stored in a preset template database. When the electronic device needs to construct training data for a multi-round scenario using dialogue templates in the preset template database, the required first-round dialogue template set and at least one second-round dialogue template set may be retrieved from the preset template database. The preset template database may be located locally on the electronic device or in a cloud device communicatively connected to the electronic device, without limitation.
[0091] S12: Combine each first-round dialogue template in the first-round dialogue template set with each second-round dialogue template in the second-round dialogue template set to obtain a plurality of dialogue combinations.
[0092] For example, referring again to Figure 4 , consider a first-round dialogue template and two second-round dialogue template sets (second-round dialogue template 1 and second-round dialogue template 2). The first-round dialogue template set includes seven first-round dialogue templates, second-round dialogue template set 1 includes six second-round dialogue templates, and second-round dialogue template set 2 includes six second-round dialogue templates. Each first-round dialogue template in the first-round dialogue template set is combined with the six second-round dialogue templates in second-round dialogue template set 1, resulting in 42 dialogue combinations. These 42 dialogue combinations can then be further combined with the six second-round dialogue templates in second-round dialogue template set 2, resulting in 42 * 6 dialogue combinations. Similarly, when there are more than two second-round dialogue template sets, further combinations can be obtained using the above method.
[0093] In some embodiments, when combining first-round dialogue templates with second-round dialogue templates, a dialogue turn order (e.g., second round, third round, etc.) can be first set for each dialogue template set. Then, according to the dialogue turn order, the second-round dialogue templates in each dialogue template set are combined with the first-round dialogue templates. For example, if the first-round dialogue template selected from the first-round dialogue template set (e.g., round 1 in FIG4 ) is "[location][datetime] how is the weather?", the second-round dialogue template selected from the second-round dialogue template set (e.g., round 2 in FIG4 ) is "[location] where?", and the second-round dialogue template selected from the third-round dialogue template set (e.g., round 3 in FIG4 ) is "[datetime] where?", then these three dialogue templates are combined to form the following dialogue combination: the first-round dialogue "[location][datetime] how is the weather?", the second-round dialogue "[location] where?", and the third-round dialogue "[datetime] where?"
[0094] S13. Based on the blank slots in the dialogue combination, entity information is extracted from a preset entity library.
[0095] Among them, entity information represents key information in natural language processing technology, which can usually be divided into two types. One is basically unrelated to the business and can be regarded as general information, such as mobile phone number, email address, date, time, address, etc.; the other is related to the business and customized according to the actual scenario.
[0096] In some embodiments, entity information divided into entity categories (personal names, place names, dates, organization names, or other) can be stored in a preset entity library in advance, and then entity information of the corresponding entity category can be selected from the entity library based on the meaning represented by the blank slots. For example, for the blank slot [datetime], it represents the meaning of time, so the entity information corresponding to the date (such as March 9) can be extracted from the entity library.
[0097] S14. Fill the entity information into the dialogue combination to obtain a training dataset for a multi-round request scenario.
[0098] Continuing with the above example, let's assume that the first-round dialogue template in the dialogue combination is "[location][datetime]How's the weather?", the entity information selected for [location] is "Place A" representing a city, and the entity information selected for [datetime] is "March 9th". By filling the entity information into the first-round dialogue template, we can obtain the first-round dialogue text "How's the weather at Place A on March 9th". Similarly, by filling the corresponding entity information into the second-round dialogue template in the dialogue combination using the above method, we can obtain the filled-in dialogue combination, and then use the filled-in dialogue combination as the training dataset in the multi-round scenario.
[0099] Taking into account the scarcity of training data sets and the high annotation cost in multi-round scenarios, in this embodiment, by obtaining a first-round dialogue template set and a second-round dialogue template set, and performing dialogue combinations based on the first-round dialogue template set and the second-round dialogue template set, and then filling in the blank template of each dialogue template in the dialogue combination, a training data set for a multi-round scenario can be obtained. Thus, a large number of training data sets for a multi-round scenario can be obtained by a small number of annotated dialogue templates, which can enhance the subsequent training effect of the multi-round scenario in the initial prediction model.
[0100] In some implementations, in step S14, the specific implementation of filling the entity information into the dialogue combination to obtain a training dataset in a multi-round request scenario may include:
[0101] S141. Fill the entity information into the dialogue combination to obtain multi-round dialogue sample text.
[0102] After obtaining multiple dialogue combinations, the corresponding entity information can be filled in the blank slots of each dialogue combination to obtain the multi-round dialogue sample text corresponding to the dialogue combination. For example, the specific method of filling the blank slots can refer to the example of step S4. For example, the multi-round dialogue sample text obtained may be: "What is the weather like at location A on March 9th" in the first round, "What about location B" in the second round, and "What about March 10th" in the third round.
[0103] S142. Obtain at least one interference text, and insert the at least one interference text into the multi-round dialogue sample text to obtain the target multi-round dialogue sample text.
[0104] For a multi-round conversation sample text, the interference text may be content that is irrelevant to the content of each round of conversation in the multi-round conversation sample text. The interference text may include text corresponding to a single-intent request and text corresponding to multiple-intent requests.
[0105] In some embodiments, the interference text can be pre-marked and stored in a preset text database, and the electronic device can retrieve the required interference text from the preset text database, wherein the interference text can also be marked with the type (such as a person's name, a place name, etc.), and the type of the interference text can be pre-associated with the type of the blank slot. Specifically, the type of a blank slot can be pre-associated with one or more types of unrelated annoying text. Therefore, after determining the type of the blank slot, the electronic device can filter out the corresponding interference text from the preset text database according to the type of the blank slot.
[0106] Then, the interference text can be inserted into the multi-round dialogue sample text. Continuing with the above example, taking the multi-round dialogue sample text: the first round of dialogue "What's the weather like at place A on March 9th", the second round of dialogue "What about place B", and the third round of dialogue "What about March 10th" as an example, the interference text can include interference text 1 (such as someone's phone number) and interference text 2 (such as the zip code of a certain place). Interference text 1 can be inserted between the first round of dialogue and the second round of dialogue, and interference text 2 can be inserted between the second round of dialogue and the third round of dialogue, thereby obtaining the target multi-round dialogue sample text. Among them, one or more interference texts can be inserted between two adjacent rounds. Among them, Qn in Figure 4 represents the Nth round of dialogue, where n is a positive integer.
[0107] S143. Use the target multi-round conversation sample text as a training dataset in a multi-round request scenario.
[0108] In this embodiment, irrelevant interference text is inserted into the multi-round dialogue sample text to obtain the target multi-round dialogue sample text, and the target multi-round dialogue sample text is used as a training data set in a multi-round scenario, so that when the training data set is subsequently used to train the initial prediction model, the model's ability to understand the previous text can be enhanced.
[0109] S2. Predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the predicted sample texts using the initial prediction model, where M is a positive integer.
[0110] The initial prediction model may refer to a generative large-scale language model to be trained. The model parameters of this large language model have not yet been determined, so it needs to be trained using sample text to obtain a prediction model. In this embodiment, the initial prediction model can establish multiple training tasks based on different speech scenarios (such as single-intent scenarios, multi-intent scenarios, and multi-round scenarios), and multiple training tasks can be jointly trained during training.
[0111] The sample text of a spoken request in a single-intent request scenario includes the single-intent request content, which represents the request content containing one intent. The number of sample sub-requests, M, equals the number of intents in the single-intent request content, 1, and the text of the sample sub-request is derived from the single-intent request content.
[0112] Among them, the sample text of the spoken request in the multi-intent request scenario includes multi-intent request content, and the multi-intent request content represents the request content containing multiple intents.
[0113] The sample texts in the multi-round request scenario include the texts of the current round and the texts of the rounds before the current round.
[0114] In some embodiments, the sample text of the spoken request in a single-intent request scenario includes multiple single-intent request contents. In step S2, using the initial prediction model, predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text may include:
[0115] Concatenate multiple single-intent request contents to obtain a concatenated content.
[0116] For example, when the sample text of the spoken request in the single-intent request scenario input into the initial prediction model includes: sample text 1 (such as current round: please tune in to the FM radio), sample text 2 (such as current round: continuously zoom in on the map), and sample text 3 (such as current round: where is the nearest Bank of Communications nearby), the multiple single-intent request contents included in the sample text of the spoken request in the single-intent request scenario can be directly spliced into a spliced content containing the above-mentioned multiple sample texts. The spliced content can be "Current round: sample text 1 sample text 2 sample text 3 (such as please tune in to the FM radio and continuously zoom in on the map to find out where is the nearest Bank of Communications nearby)".
[0117] The above-mentioned splicing operation can also be achieved by performing corresponding thought chain generation training on the initial prediction model.
[0118] In this embodiment, by splicing multiple single-intent request contents to obtain a spliced content, and training the initial prediction model based on the spliced content, the spoken language comprehension decoupling capability of the initial prediction model can be improved, and the overfitting phenomenon in the local small sample domain intent training can be avoided, thereby improving the training efficiency of the generative large-scale language model.
[0119] Through the initial prediction model, based on the spliced content, the number of sample sub-requests M and the texts of M sample sub-requests are predicted, where the number of sample sub-requests M is the number of single-intent request contents, and the text of each sample sub-request is obtained based on a single-intent request content.
[0120] Continuing with the above example, let's say the spliced content is "Please tune in to the FM radio and zoom in on the map to find out where the nearest Bank of Communications is." Using the initial prediction model, we can predict the number M of sample sub-requests and their text based on the spliced content. We can get M as 3 sample sub-requests, with the texts of the three sample sub-requests being: "Please tune in to the FM radio," "Zoom in on the map," and "Where is the nearest Bank of Communications?"
[0121] In other embodiments, for a sample text of a spoken request in a multi-intent request scenario, in step S2, using an initial prediction model, predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text may include:
[0122] Through the initial prediction model, the number M of sample sub-requests and the texts of M sample sub-requests in the sample text of the spoken request in the multi-intent request scenario are predicted. The number M of sample sub-requests is the number of intents in the multi-intent request content, and the text of each sample sub-request is obtained based on the request content of one intent in the multi-intent request content.
[0123] For example, for a sample text of a spoken request in a multi-intent request scenario, the sample text of the spoken request in the multi-intent request scenario can be decomposed by the initial prediction model to obtain texts of M sample sub-requests.
[0124] For example, the initial prediction model can first identify the number of intents in a sample text. For example, using the sample text "Open XX app, set the vehicle volume to 5," intent recognition can identify that the sample text contains two intent requests: "Open XX app" and "Set the vehicle volume to 5." Based on these two intents, the initial prediction model can then decompose the sample text into two sample sub-requests: "Open XX app" and "Set the vehicle volume to 5."
[0125] The above-mentioned disassembly operation can also be achieved by performing corresponding thought chain generation training on the initial prediction model, so that the model can acquire the thought chain generation and disassembly capability.
[0126] In some further embodiments, for sample text in a multi-round request scenario, in step S2, using an initial prediction model, predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text may include:
[0127] A1. Merge the text of the current round with the text of the previous round to obtain a merged text. The merged text is used to represent the text of the current round and the text of the previous round.
[0128] The current round may be the last round of multiple rounds. For example, if the multiple rounds include a first round, a second round, and a third round, the third round may be determined as the current round.
[0129] For example, take the first round: "How long did AAA live", where AAA is a historical figure, the second round: "I am sure at the age of 50", and the current round: "Why" as examples, where the text of the current round is "Why", and the text of the previous rounds of the current round are "How long did AAA live" and "I am sure at the age of 50".
[0130] As an implementation method, in step A1, merging the text of the current round with the text of the previous round to obtain a merged text may include:
[0131] Key information associated with the text of the current round is extracted from the text of the previous round, where the key information includes at least one of a keyword and a key sentence.
[0132] Continuing with the above example, according to the semantics represented by the above three rounds of text as a whole, the key sentence "AAA is alive" can be extracted from the first round of text "How long has AAA lived" in the previous round of text of the current round, and the keywords "50 years old" and "sure" can be extracted from the second round of text "I am sure at 50 years old".
[0133] Merge the key information with the text of the current round to obtain a merged text.
[0134] Continuing with the above example, the keywords "50 years old" and "sure", the key sentence "AAA is alive" and the current sample text "why" can be merged to obtain the merged text: "Why is it certain that AAA lived to be 50 years old?"
[0135] Taking into account that in multiple rounds of dialogue text, the current sample text corresponding to the current round is usually the most important, and the alternative sample texts corresponding to other rounds may be only partially related to the current sample text, in this embodiment, by extracting key information associated with the text of the current round from the text of the previous round, the key information is merged with the text of the current round to obtain a merged text, thereby improving the efficiency and accuracy of the merging.
[0136] A2. Using the initial prediction model, based on the merged text, predict the number M of sample sub-requests and the texts of the M sample sub-requests, where the number M of sample sub-requests is equal to the number 1 of texts in the current round, and the texts of the sample sub-requests are obtained by processing the texts of the current round in combination with the texts of the previous rounds of the current round.
[0137] Continuing with the above example, taking the merged text "Why is it certain that AAA lived to be 50 years old" as an example, after merging multiple rounds of text, the merged text obtained only contains one final request. Therefore, through the initial prediction model, based on the merged text, the number of sample sub-requests M is predicted to be 1.
[0138] It can be seen that by merging the sample texts of multiple rounds of request scenarios through the initial prediction model to obtain the merged text, and then using the initial prediction model to predict the number M of sample sub-requests and the texts of M sample sub-requests based on the merged text, the prediction efficiency can be effectively improved.
[0139] The above-mentioned merging operation can also be achieved by performing corresponding thought chain generation training on the initial prediction model, so that the model can acquire the thought chain generation and merging capability.
[0140] In some embodiments, in step S2, using the spoken request text through the prediction model, specific implementations of predicting the number N of sub-requests of the spoken request and the N sub-request texts corresponding to the N sub-requests may include:
[0141] Based on the preset prompt information and the sample text, input information is generated, where the preset prompt information includes the task description information corresponding to the predicted instruction information.
[0142] For example, the preset prompt information may be "The following is an instruction describing a task, with an input that provides more information. Write an answer that can complete the request."
[0143] Input information is input into the initial prediction model to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample texts through the initial prediction model.
[0144] In other embodiments, the sample text is a spoken text. In step S2, using the spoken request text through a prediction model, specific embodiments of predicting the number N of sub-requests of the spoken request and the N sub-request texts corresponding to the N sub-requests may include:
[0145] Based on the spoken text, preset prompt information and preset instruction information, input information is generated. The preset instruction information is used to instruct the initial prediction model to output instruction information. The instruction information includes intention, field and slot.
[0146] For example, the preset instruction information may be "assuming that you are a voice assistant, you need to perform semantic analysis on multiple rounds of user requests input, and output the domain, intent, and slot corresponding to the current round of requests."
[0147] The spoken text may be a text obtained by converting or translating a spoken request. For example, the spoken request may be “where is the nearest Bank of Communications?”
[0148] S3. Predict instruction information of the sample text in the corresponding scenario based on the number M of sample sub-requests and the texts of the M sample sub-requests through the initial prediction model to obtain predicted instruction information.
[0149] In some embodiments, in step S3, the initial prediction model is used to predict instruction information of the sample text in the corresponding scenario based on the number M of sample sub-requests and the texts of the M sample sub-requests. Specific implementations of obtaining the predicted instruction information may include:
[0150] S31. Match the texts of the M sample sub-requests with the preset entity library respectively to obtain the entity information corresponding to each sample sub-request.
[0151] Among them, the entity information corresponding to the sample text can be obtained from the preset entity library through the Maximum Matching of Entities technology, where the Maximum Matching of Entities is a technology used for text processing and natural language processing. It is mainly used to identify and extract entities (such as names of people, places, organizations, etc.) that appear in a given text. The basic idea of Maximum Matching of Entities is to segment the text to be processed according to a certain vocabulary or rules, and then gradually match the longest possible entity from left to right. In this way, it is possible to better identify situations where consecutive words are combined into entities. For example, for the sentence: "I like the products of Company C.", using the Maximum Matching of Entities method, "Company C" can be identified as an organizational entity.
[0152] As an example, as shown in Figure 5, taking the current round sample text as "play name X" as an example, if the preset entity library stores entity information about name X including "music: name X", "address: name X" and "electronic game: name X", then "music: name X", "address: name X" and "electronic game: name X" can all be used as entity information corresponding to the sample text.
[0153] S32. For each sample sub-request, update the sample sub-request based on the entity information corresponding to the sample sub-request to obtain an updated sample sub-request.
[0154] Continuing with the above example, a supplementary description of the sample text "play name X" can be generated based on "music: name X", "address: name X" and "electronic game: name X", and the supplementary description can be added to the sample text to obtain an updated sample text (such as "play name X, where name X may be music, address or electronic game").
[0155] The above-mentioned update operation can also be achieved by training the initial prediction model to generate thought chains. In Figure 5, \n represents a line break, and the answer can be the updated sample text. This updated sample text and the updated sample text can be used to train the initial prediction model to generate thought chains, thereby training the model's thought chain generation and update capabilities.
[0156] S33. Predict instruction information of the sample text in the corresponding scenario according to the updated sample sub-request using the initial prediction model to obtain predicted instruction information.
[0157] In this embodiment, by matching the sample sub-request with the preset entity library, the entity information corresponding to the sample sub-request is obtained, and the sample sub-request is updated based on the entity information to obtain the updated sample sub-request, and then the initial prediction model is used to predict the prediction instruction information based on the updated sample sub-request. When the obtained prediction result is used for model training, the prediction accuracy of the model can be effectively improved.
[0158] S4. Train the initial prediction model based on the prediction instruction information to obtain a prediction model.
[0159] In some embodiments, in step S4, the initial prediction model is trained based on the prediction instruction information to obtain a specific implementation of the prediction model, which may include:
[0160] S41. Based on the predicted instruction information, determine the initial loss value corresponding to each scenario in multiple scenarios.
[0161] In some embodiments, the sample text includes negative sample text and positive sample text, the negative sample text includes sample text in an incorrectly labeled area, and the positive sample text includes sample text other than the negative sample text. In step S41, based on the predicted instruction information, specific implementations of determining the initial loss value (hereinafter also referred to as initial loss) corresponding to each of the multiple scenarios may include:
[0162] S411 , filtering predicted instruction information corresponding to the positive sample text in the predicted instruction information to obtain the positive sample instruction information.
[0163] For example, the negative sample text can be a sample labeled "does not belong to domain x". In practical applications, in order to simplify the labeling, the label "does not belong to domain x" can be set to "0". Then, among multiple sample texts, the samples that do not carry "0" can be used as positive sample texts. Since the prediction instruction information is the output of the initial prediction model for all sample texts, the prediction instruction information includes the prediction instruction information corresponding to the positive sample text and the prediction instruction information corresponding to the negative sample text. The prediction instruction information corresponding to the positive sample text can be screened out from the prediction instruction information and used as the positive sample instruction information, wherein the positive sample instruction information can also include P pos , P pos Indicates the probability that the initial prediction model outputs the positive sample instruction information.
[0164] S412: Filter the predicted instruction information corresponding to the negative sample text in the predicted instruction information to obtain negative sample instruction information, and adjust the negative sample instruction information to obtain target negative sample instruction information.
[0165] For the predicted instruction information corresponding to the negative sample text, it can be filtered out from the predicted instruction information and used as the negative sample instruction information, wherein the negative sample instruction information can also include P neg , P neg It indicates the probability that the initial prediction model outputs the negative sample instruction information, and can also indicate the predicted probability of the label "0".
[0166] Among them, the negative sample instruction information is adjusted to obtain the target negative sample instruction information, specifically, the probability of "not belonging to domain x" in the negative sample instruction information is adjusted to 1-P neg .
[0167] S413. Determine the initial loss value corresponding to each scene based on the positive sample instruction information and the negative sample instruction information.
[0168] The specific implementation of step S413 may include:
[0169] S4131. Obtain positive sample labeling instruction information corresponding to the positive sample text and negative sample labeling instruction information corresponding to the negative sample text.
[0170] Among them, the positive sample labeling instruction information is used as a reference for the positive sample instruction information output by the initial prediction model based on the positive sample text, and is the target value of the positive sample instruction information. Therefore, the training status of the initial prediction model can be determined by comparing the positive sample labeling instruction information and the positive sample instruction information. Similarly, the negative sample labeling instruction information is used as a reference for the negative sample instruction information output by the initial prediction model based on the negative sample text, and is the target value of the negative sample instruction information. Therefore, the training status of the initial prediction model can be determined by comparing the negative sample labeling instruction information and the negative sample instruction information. Among them, the positive sample labeling instruction information corresponding to each positive sample text and the negative sample labeling instruction information corresponding to each negative sample text can be pre-stored in the above-mentioned training data set, and can therefore be obtained from the above-mentioned training data set.
[0171] S4132. Determine the positive sample loss corresponding to each scene based on the positive sample labeling instruction information and the positive sample instruction information.
[0172] The purpose of calculating the positive sample loss is to evaluate the accuracy or error of the initial prediction model. Since the positive sample labeling instruction information is the target value of the positive sample instruction information, the error value between the positive sample labeling instruction information and the positive sample instruction information can be determined by comparing the positive sample labeling instruction information and the positive sample instruction information, and the positive sample loss can be determined based on the error value. Specifically, commonly used loss functions such as mean squared error, cross entropy, and absolute error can be used for calculation.
[0173] S4133. Determine the negative sample loss corresponding to each scene according to the negative sample labeling instruction information and the negative sample instruction information.
[0174] The specific implementation of “determining the negative sample loss corresponding to each scene according to the negative sample labeling instruction information and the negative sample instruction information” in step S4133 may include:
[0175] Based on the negative sample labeling information and the negative sample instruction information, the initial negative sample loss of the target sample text corresponding to the negative sample is determined.
[0176] Exemplarily, for example, for each speech scene in a plurality of speech scenes, the plurality of sample texts corresponding to the speech scene, and then for each sample text in the plurality of sample texts, the initial negative sample loss of the sample text can be determined based on the negative sample annotation information and negative sample instruction information corresponding to the sample text. For example, the training data set corresponding to the single-intent scene includes sample text 1, sample text 2, and sample text 3. The initial negative sample loss 1 can be obtained based on the negative sample annotation information and negative sample instruction information corresponding to sample text 1, the initial negative sample loss 2 can be obtained based on the negative sample annotation information and negative sample instruction information corresponding to sample text 2, and the initial negative sample loss 3 can be obtained based on the negative sample annotation information and negative sample instruction information corresponding to sample text 3. For another example, the training data set corresponding to the multi-intent scene includes sample text 4, sample text 4, and sample text 5. The initial negative sample loss 4 can be obtained based on the negative sample annotation information and negative sample instruction information corresponding to sample text 4, and the initial negative sample loss 5 can be obtained based on the negative sample annotation information and negative sample instruction information corresponding to sample text 5.
[0177] At least one initial negative sample loss in the same scene is selected from the initial negative sample losses to obtain the initial negative sample loss set corresponding to each scene.
[0178] Continuing with the above example, initial negative sample loss 1, initial negative sample loss 2, and initial negative sample loss 3 can be determined as the initial negative sample loss set corresponding to the single-intent scenario. Initial negative sample loss 4 and initial negative sample loss 5 can be determined as the initial negative sample loss set corresponding to the multi-intent scenario.
[0179] The initial negative sample losses in the initial negative sample loss set are fused to obtain the negative sample loss corresponding to each scene.
[0180] Continuing with the above example, for single-intent scenarios, the initial negative sample loss 1, initial negative sample loss 2, and initial negative sample loss 3 can be fused to obtain the negative sample loss corresponding to the single-intent scenario. For multi-intent scenarios, the initial negative sample loss 4 and initial negative sample loss 5 can be fused to obtain the negative sample loss corresponding to the multi-intent scenario. Among them, the fusion operation for the initial negative sample loss can be specifically weighted addition. For example, weights w1, w2, and w3 are pre-configured for the initial negative sample loss 1, the initial negative sample loss 2, and the initial negative sample loss 3, respectively. Then, the negative sample loss corresponding to the single-intent scenario is: initial negative sample loss 1*w1+initial negative sample loss 2*w2+initial negative sample loss 3*w3. Among them, w1:w2:w3 can be 1:1:1, or other proportions. The specific setting can be based on actual needs and is not limited here.
[0181] Among them, in step S4132, the specific implementation method of determining the positive sample loss corresponding to each voice scene based on the positive sample labeling instruction information and the positive sample instruction information can also refer to step S4133, so it is not repeated here.
[0182] S4134. Fuse the positive sample loss and the negative sample loss to obtain the initial loss value corresponding to each scene.
[0183] For example, the positive sample loss and the negative sample loss can be fused using the following formula to obtain the initial loss value corresponding to each speech scene:
[0184] Loss = loss pos +λloss neg =-logP pos -λlog(1-P neg ), Loss is the initial loss value corresponding to a speech scene, loss pos is the positive sample loss corresponding to the speech scene, loss neg is the negative sample loss corresponding to the speech scene, and λ is the reverse gradient weight. λ can be 0.1 or other values such as 0.2 according to actual needs. The performance of the model trained under different reverse gradient weights can be tested to select the appropriate reverse gradient weight.
[0185] S42: Fuse the initial loss values to obtain the target loss value.
[0186] The specific implementation of step S42 may include:
[0187] Obtain the fusion weight corresponding to each speech scene, and weight the initial loss based on the fusion weight; fuse the weighted initial loss to obtain the target loss value (hereinafter also referred to as target loss).
[0188] After obtaining the initial loss corresponding to each speech scene through step S4134, the fusion weight corresponding to each speech scene can be obtained from the preset weight database, wherein the preset weight database includes the pre-set fusion weight of each speech scene.
[0189] As an example, for example, the fusion weight corresponding to the single-intent scenario is k1, the fusion weight corresponding to the multi-intent scenario is k2, the initial loss corresponding to the single-intent scenario is Loss1, and the initial loss corresponding to the multi-intent scenario is Loss2. Then the target loss value can be determined as (k1*Loss1+k2*Loss2).
[0190] In some embodiments, the weighted initial losses are fused to obtain a target loss value. A specific implementation method can be to perform weighted summation on the initial losses corresponding to each speech scene, and then solve the mean of the weighted summation results, such as the target loss value is (k1*Loss1+k2*Loss2) / 2.
[0191] After merging the sample texts of multiple request scenarios to obtain the merged text, the text processing method further includes:
[0192] Extract the labeled merged sample text corresponding to the sample text of the multi-round request scenario from the training data set.
[0193] For a sample text of a multi-round request scenario, the annotated merged sample text corresponding to the sample text of the multi-round request scenario may be a target value of the merged sample text corresponding to the sample text of the multi-round request scenario.
[0194] The merging loss is determined based on the labeled merged sample text and the merged sample text.
[0195] After the labeled merged sample text and the merged sample text are determined, the merging loss may be determined by referring to the method of calculating the loss in step S4132 .
[0196] Accordingly, in S42, the specific implementation of fusing the initial loss values to obtain the target loss value may include:
[0197] The initial loss and the merged loss are combined to obtain the target loss value.
[0198] Continuing with the above example, if the merged loss is Loss3 and the fusion weight pre-corresponding to the merged loss is L3, the target loss value can be obtained as (k1*Loss1+k2*Loss2+k3*Loss3) or (k1*Loss1+k2*Loss2+k3*Loss3) / 3. In this embodiment, by fusing the initial loss and the merged loss to obtain the target loss value, the initial prediction model's thought chain generation and merging capabilities can be trained simultaneously.
[0199] It can be understood that the thinking chain generation and splicing capabilities, thinking chain generation and disassembly capabilities, etc. of the initial prediction model mentioned in the above embodiments can also be trained by the above-mentioned training method of thinking chain generation and merging capabilities.
[0200] S43. According to the target loss value, the initial prediction model is converged to obtain a prediction model.
[0201] The gradient descent method can be used to optimize the initial prediction model. For example, the gradient of the initial prediction model can be determined based on the target loss value, and then the model parameters of the initial prediction model can be adjusted based on the gradient, so that the initial prediction model converges. The gradient is a vector whose direction points to the direction of the maximum growth rate of the function at a certain point, and its magnitude represents the maximum growth rate.
[0202] In some embodiments, during the training of the initial prediction model, each adjustment of the model parameters of the initial prediction model based on the gradient can be considered an iteration. When the number of iterations reaches a preset number, a prediction model can be obtained. The preset number can be determined based on the historical training records of the initial prediction model.
[0203] In some embodiments, after step 303, the text processing method may further include:
[0204] The controllable object is controlled through target instruction information.
[0205] Controlling the controllable object through target instruction information may include:
[0206] Obtain control instructions corresponding to target instruction information from a preset control instruction library; and control the controllable object based on the control instructions.
[0207] Among them, a plurality of control instructions are pre-stored in the control instruction library, and a mapping relationship is pre-established between the plurality of control instructions and the instruction information. Therefore, the control instruction corresponding to the target instruction information can be obtained from the preset control instruction library, and the controllable object can be controlled based on the control instruction. For example, the target instruction information includes the field: navigation, the intention: query route conditions; the slot: from home to company. The electronic device can obtain the control instruction "output the route from the starting point (home) to the destination (company)" based on the target instruction information, and send the control instruction to the controllable object to instruct the controllable object to output the route from the starting point (home) to the destination (company). The controllable object may include a vehicle-mounted terminal, a mobile phone, etc., and the output method may include but is not limited to: image display, voice broadcast, etc.
[0208] It can be seen that in this embodiment, after obtaining the spoken request text expressing the spoken request, the prediction model can be used to predict the number N of sub-requests and N sub-request texts of the spoken request, where N is a positive integer; then, the prediction model is used to predict the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts. The target instruction information includes intent, field, and slot. The target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request. Since the number of sub-requests contained in the texts in different spoken language comprehension problem scenarios is often different, in an embodiment of the present application, the prediction model is used to predict the number N of sub-requests of the spoken language request and the N sub-request texts, so that the processing of the texts in different spoken language comprehension problem scenarios can be converted into the processing of different numbers of sub-requests in the text. Then, the prediction model is used to predict the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts, thereby solving the problem of processing the texts in different spoken language comprehension problem scenarios with only one prediction model, avoiding the need to train multiple models and continuously iterate multiple models when multiple models need to be set up to support multiple spoken language comprehension problem scenarios, greatly reducing the complexity of the model, the training cost of the model and the iteration cost of the model, and improving the text processing efficiency.
[0209] The method described in the above embodiment will be further described below.
[0210] In this embodiment, text processing will be taken as an example to illustrate the method of the embodiment of the present application in detail.
[0211] As shown in FIG6 , a specific process of a text processing method is as follows:
[0212] 601. The electronic device obtains a training data set in multiple voice scenarios, where the training data set includes at least one sample text corresponding to each voice scenario.
[0213] Step 601 may include: obtaining a first-round dialogue template set and at least one second-round dialogue template set, wherein each first-round dialogue template in the first-round dialogue template set and each second-round dialogue template in the second-round dialogue template set includes a blank slot.
[0214] Each first-round dialogue template in the first-round dialogue template set is combined with each second-round dialogue template in the second-round dialogue template set to obtain multiple dialogue combinations.
[0215] Based on the blank slots in the dialogue combination, entity information is extracted from the preset entity library.
[0216] Fill the entity information into the dialogue combination to obtain a training dataset in a multi-round scenario.
[0217] Among them, the entity information is filled into the dialogue combination to obtain a training dataset in a multi-round scenario, including:
[0218] Fill the entity information into the dialogue combination to obtain multi-round dialogue sample text; obtain at least one interference text and insert the at least one interference text into the multi-round dialogue sample text to obtain the target multi-round dialogue sample text; use the target multi-round dialogue sample text as the training data set in the multi-round scenario.
[0219] For example, please refer to Figure 4 again. In actual applications, the implementation process of step 601 may include: first manually annotating a small number of first-round templates + multi-round domain templates (including reference / omitted templates and rewritten complete templates), wherein the rewritten complete templates can be used to train the corresponding thinking chain generation capability of the initial prediction model, that is, the ability to automatically generate training data sets in multi-round scenarios. Then perform dialogue template sampling: the first step is to sample the first-round dialogue template set, and then cyclically sample the second-round dialogue template set to construct multi-round template data (that is, the dialogue combination in the above embodiment); the second step is to use entity information to fill the slots of the multi-round template data; the third step is to insert text corresponding to irrelevant single / multi-intent requests into the filled multi-round data to enhance the model's writing comprehension ability.
[0220] 602. The electronic device rewrites the sample text based on the type of the voice scene to obtain a target sample text.
[0221] It is understood that rewriting the sample text based on the type of speech scene to obtain the target sample text can correspond to step S2 in the above embodiment, where the initial prediction model is used to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text, where M is a positive integer. The target sample text can be regarded as the text of the M sample sub-requests.
[0222] Among them, the speech scenarios include single-round scenarios and multi-round scenarios. Based on the type of speech scenario, the sample text is rewritten to obtain the target sample text, including:
[0223] When the speech scene corresponding to the sample text is a multi-round scene, the sample text is converted into an alternative sample text corresponding to a single-round scene, and the alternative sample text is used as the sample text corresponding to the single-round scene; when the speech scene corresponding to the sample text is a single-round scene, the sample text is rewritten based on the intention type of the sample text to obtain the target sample text.
[0224] The sample text includes sample texts from multiple rounds of dialogue. Converting the sample texts into candidate sample texts corresponding to a single round scenario includes:
[0225] Determine the current round among multiple rounds, and extract the current sample text corresponding to the current round and the alternative sample texts corresponding to other rounds from the dialogue sample text, where the other rounds include rounds other than the current round among the multiple rounds; merge the current sample text and the alternative sample texts to obtain a merged sample text corresponding to the current round; and use the merged sample text as the sample text corresponding to the single-round scenario.
[0226] Merging the current sample text with the candidate sample text to obtain a merged sample text corresponding to the current round includes: extracting key information associated with the current sample text from the candidate sample text, the key information including at least one of keywords and key sentences; and merging the key information with the current sample text to obtain a merged sample text corresponding to the current round. The candidate sample text may be equivalent to the text of the round before the current round in the above-mentioned embodiment.
[0227] For example, in practical applications, as shown in Figure 7, due to the scarcity of multi-turn annotated data and the high cost of annotation in multi-turn spoken language comprehension scenarios, to improve the ability of a generative large-scale language model (initial prediction model) to understand multi-turn user spoken requests, this embodiment can utilize publicly available general multi-turn dialogue rewriting data to train the generative large-scale language model's ability to generate and merge thought chains from sample text for multi-turn spoken language comprehension. For example, during training, the specific input format can be: "###Input: Round 1: {1st round of dialogue}\n…\nIth round {Ith round of dialogue}\nCurrent round: {I+1th round of dialogue}\n###Answer:". The specific output format can be: "Current round contains 1 request\n 1. {Rewritten dialogue\nField:}". For example, the input in Round 1 is: "How long did AAA live?", Round 2 is: "I am sure he is 50 years old.", and the current round is: "Why?" Through initial prediction model merging, the output can be "Why is it certain that AAA lived to be 50 years old?", where i is a positive integer. \n represents a line break.
[0228] The sample text is rewritten based on the intent type of the sample text to obtain the target sample text, including:
[0229] Obtain the intent identification information of the sample text, and determine the intent type of the sample text based on the intent identification information; when the intent type of the sample text is a single intent, splice at least one sample text corresponding to the single intent to obtain a target sample text.
[0230] For example, as shown in Figure 8, to improve the training efficiency of generative large-scale language models and avoid overfitting in localized, small-sample domain intent training, this embodiment proposes a multi-sample splicing thought chain generation training strategy. Specifically, during training, 1-3 single-intent spoken language comprehension training samples can be randomly sampled and organized according to the input format: "###Input: Current round: {Spoken request 1} {Spoken request 2} {Spoken request 3}\n###Answer:". The output is constructed in the form of: "Current round contains {n=1,2,3} requests\n 1. {Spoken request 1} Domain: {xxx}\nIntent: {xxx}\nSlot: {xxx}\n 2. {Spoken request 2} Domain: {xxx}\nIntent: {xxx}\nSlot: {xxx}\n 3. {Spoken request 3} Domain: {xxx}\nIntent: {xxx}\nSlot: {xxx}". Among them, Sample#1, Sample#2, and Sample#3 respectively represent sample text 1 corresponding to spoken request 1, sample text 2 corresponding to spoken request 2, and sample text 3 corresponding to spoken request 3.
[0231] When the intent type of the sample text is multiple intents, the sample text is disassembled to obtain multiple text sub-samples, and the text sub-samples are used as the target sample text.
[0232] The sample text is rewritten based on the intent type of the sample text to obtain the target sample text, including:
[0233] Obtain the intent identification information of the sample text, and determine the intent type of the sample text based on the intent identification information; when the intent type of the sample text is single intent, splice at least one sample text corresponding to the single intent to obtain the target sample text; when the intent type of the sample text is multiple intents, disassemble the sample text to obtain multiple text sub-samples, and use the text sub-samples as the target sample text.
[0234] The sample text is disassembled to obtain multiple text subsamples, including:
[0235] Perform text recognition on the sample text, and based on the text recognition results, determine the number of fields and the number of intents in the sample text; based on the number of fields and the number of intents, disassemble the sample text to obtain multiple text sub-samples.
[0236] 603. The electronic device uses the initial prediction model to predict instruction information corresponding to the target sample text to obtain predicted instruction information for each target sample text.
[0237] It is understood that the initial prediction model predicts the instruction information corresponding to the target sample text to obtain the predicted instruction information for each target sample text, which can correspond to step S3 in the above embodiment, where the initial prediction model predicts the instruction information of the sample text in the corresponding scenario based on the number M of sample sub-requests and the text of the M sample sub-requests to obtain the predicted instruction information. The predicted instruction information can be regarded as the instruction information of the sample text in the corresponding scenario.
[0238] For example, referring to Figure 9, for input in generative large-scale language model training, this embodiment can concatenate the user's spoken request Input with prompts and instructions: Prompt + Instruction + Input. Specifically, when training single- or multi-intent spoken language comprehension scenarios, the spoken request Input is constructed in the form "###Input:Current Round:{User Spoken Request}\n###Answer:".
[0239] For multi-round oral comprehension training, the oral request input is constructed in the form of "###input: round 1: {xxx}, ..., round i: {xxx}, current round: {user oral request}\n###answer".
[0240] Among them, single-intent natural language understanding (NLU, Natural Language Understanding) generates the predicted instruction information corresponding to the above-mentioned single-intent scenario, multi-intent natural language understanding generates the predicted instruction information corresponding to the above-mentioned multi-intent scenario, and multi-round natural language understanding generates the predicted instruction information corresponding to the above-mentioned multi-round scenario.
[0241] It can be understood that the user spoken request in this embodiment refers to the text corresponding to the user spoken request.
[0242] 604. The electronic device determines the initial loss corresponding to each voice scene based on the predicted instruction information, and fuses the initial losses to obtain a target loss value.
[0243] Exemplarily, the above-mentioned training data set may contain a large amount of negative sample data (i.e., the above-mentioned negative sample text). The negative sample data only has the label "does not belong to domain x" and does not have the label "belongs to domain y". This part of the data can significantly improve the accuracy of the model and reduce false recall. In multi-class 2-class discriminant training, the negative sample data can directly set the label of domain x to 0. In generative training, this embodiment proposes a negative gradient strategy for learning. Specifically, the output labels of negative sample data can be organized according to the output labels of positive sample text corresponding to the single-intent scenario, that is, "the current round contains 1 request\n 1.{user spoken request}\nDomain: {negative sample domain x}" (where "" is the sentence end symbol). Later, when calculating the loss Loss, the predicted probability O at "negative sample domain x" in the generated sequence will be generated. neg Transformed into 1-P neg , that is, the training model minimizes the predicted probability of "negative sample field x": -log(1-O neg ), realize the ability of the model not to predict the "negative sample field x". At the same time, the end character "" stops updating the gradient to avoid affecting the positive sample training and continue to predict the intent and slot results. Among them, the remaining part of the negative sample generation sequence is updated according to the positive sample -log(O pos ).
[0244] As shown in Figure 10, the total loss function of negative sample training is expressed as:
[0245] Loss = loss pos +λloss neg =-logP pos -λlog(1-P neg ), Loss is the initial loss corresponding to a speech scene, Loss pos is the positive sample loss corresponding to the speech scene, loss neg is the negative sample loss corresponding to the speech scenario, and λ is the reverse gradient weight. λ can be 0.1 or other values such as 0.2 according to actual needs. The performance of the model trained under different reverse gradient weights can be tested to select the appropriate reverse gradient weight.
[0246] Among them, the sample text includes negative sample text and positive sample text, the negative sample text includes sample text in the incorrectly marked area, and the positive sample text includes sample text other than the negative sample text in the sample text; based on the predicted instruction information, the initial loss corresponding to each voice scene is determined, including: filtering the predicted instruction information corresponding to the positive sample text in the predicted instruction information to obtain the positive sample instruction information; filtering the predicted instruction information corresponding to the negative sample text in the predicted instruction information to obtain the negative sample instruction information, and adjusting the negative sample instruction information to obtain the target negative sample instruction information; based on the positive sample instruction information and the negative sample instruction information, the initial loss corresponding to each voice scene is determined.
[0247] The initial loss corresponding to each speech scene is determined based on the positive sample instruction information and the negative sample instruction information, including:
[0248] Obtain positive sample labeling instruction information corresponding to the positive sample text and negative sample labeling instruction information corresponding to the negative sample text; determine the positive sample loss corresponding to each speech scene based on the positive sample labeling instruction information and the positive sample instruction information; determine the negative sample loss corresponding to each speech scene based on the negative sample labeling instruction information and the negative sample instruction information; fuse the positive sample loss and the negative sample loss to obtain the initial loss corresponding to each speech scene.
[0249] The negative sample loss corresponding to each speech scene is determined according to the negative sample labeling instruction information and the negative sample instruction information, including:
[0250] Based on the negative sample annotation information and negative sample instruction information, the initial negative sample loss of the target sample text corresponding to the negative sample is determined; at least one initial negative sample loss under the same speech scene is screened out from the initial negative sample loss to obtain the initial negative sample loss set corresponding to each speech scene; the initial negative sample losses in the initial negative sample loss set are fused to obtain the negative sample loss corresponding to each speech scene.
[0251] After merging the current sample text with the candidate sample text to obtain the merged sample text corresponding to the current round, the method further includes: extracting annotated merged sample text corresponding to the multi-round conversation sample text from the training dataset; and determining a merge loss based on the annotated merged sample text and the merged sample text. Accordingly, the initial loss is fused to obtain a target loss value, including: fusing the initial loss with the merged loss to obtain the target loss value.
[0252] 605. The electronic device converges the initial prediction model according to the target loss value to obtain a prediction model.
[0253] 606. The electronic device obtains a target text corresponding to the target voice for the controllable object, uses a prediction model to predict instruction information of the target text in the corresponding voice scenario, and obtains target instruction information.
[0254] 607. The electronic device obtains a control instruction corresponding to the target instruction information from a preset control instruction library.
[0255] 608. The electronic device controls the controllable object based on the control instruction.
[0256] For example, please refer to Figure 11, which shows the training process and reasoning process of the prediction model of this embodiment. During the training process, the prompt information and instruction information of the user's spoken request (that is, the above-mentioned sample text) are first spliced, and then the spliced result is predicted by the multi-scenario generative large-scale language model (that is, the above-mentioned initial prediction model) generated by the unified thinking chain. Through the single / multi-intent spoken language understanding training task, the single-intent spoken language understanding result (that is, the prediction instruction information corresponding to the above-mentioned single-intent scenario) and the multi-intent spoken language understanding result (that is, the prediction instruction information corresponding to the above-mentioned multi-intent scenario) can be obtained. Through the multi-round spoken language understanding training task, the multi-round spoken language understanding result (that is, the prediction instruction information corresponding to the above-mentioned multi-round scenario) can be obtained. After that, the above three results are combined with the preset single-intent spoken language understanding label, multi-intent spoken language understanding label and multi-round spoken language understanding label to calculate the loss of the initial prediction model, and the model parameters are updated based on the loss until the prediction model is obtained. During the reasoning process, the user's spoken request to be predicted is first input into the multi-scenario generative large-scale language model (i.e., the above-mentioned prediction model) generated by the trained unified thinking chain for prediction. The prediction model can first determine the speech scene corresponding to the input data, and then output the spoken understanding result corresponding to the speech scene based on the input data.
[0257] It can be seen that this embodiment combines the generative large language model LLM and the thinking chain generation training thinking chain generation strategy to unify the task modeling of the three scenarios of single-intent spoken language understanding, multi-intent spoken language understanding, and multi-round spoken language understanding, so as to realize information interaction between different scenarios, and the spoken language comprehension capabilities complement and enhance each other, greatly improving the spoken language comprehension effects in cold start scenarios and multi-round scenarios. In addition, multiple spoken language comprehension scenarios are unified into a single model, simplifying the deployment complexity and the difficulty of language migration; at the same time, the generalization ability of the generative large-scale language model is used to greatly improve the effects of cold start and low-resource spoken language comprehension scenarios; it can also greatly improve the generalization ability and effect of multi-round spoken language comprehension scenarios. And in the multi-round spoken language comprehension scenario, this solution can handle more contextual issues and greatly improve the user's multi-round interaction experience with the machine equipment.
[0258] To better implement the above method, embodiments of the present application further provide a text processing device, which can be integrated into an electronic device, such as a terminal, a server, or the like. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, or the like; the server can be a single server or a server cluster consisting of multiple servers.
[0259] For example, in this embodiment, the method of the embodiment of the present application will be described in detail by taking the specific integration of the text processing device into the text processing as an example.
[0260] For example, as shown in FIG12 , the text processing apparatus may include:
[0261] An acquiring unit 1201 is configured to acquire a spoken request text expressing a spoken request;
[0262] The first prediction unit 1202 is configured to predict the number N of sub-requests of the spoken request and N sub-request texts corresponding to the N sub-requests using the prediction model and the spoken request text, where N is a positive integer.
[0263] The second prediction unit 1203 is used to predict the target instruction information corresponding to each of the N sub-request texts based on the number N of sub-requests and the N sub-request texts through the prediction model. The target instruction information includes intent, field and slot. The target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request.
[0264] In some embodiments, the spoken request text is the text of a spoken request in a single-intent request scenario, the text of a spoken request in a multi-intent request scenario, or the text of a round of spoken request in a multi-round request scenario.
[0265] In some embodiments, the text processing apparatus further includes:
[0266] A data set acquisition unit 1201 is configured to acquire a training data set under multiple scenarios, the training data set including at least one sample text corresponding to each scenario, the multiple scenarios including at least two of a single-intent request scenario, a multi-intent request scenario, or a multi-round request scenario;
[0267] a third prediction unit, configured to predict, based on the sample texts, a number M of sample sub-requests and texts of the M sample sub-requests using an initial prediction model, where M is a positive integer;
[0268] a fourth prediction unit, configured to predict instruction information of the sample text in a corresponding scenario based on the number M of sample sub-requests and the texts of the M sample sub-requests using the initial prediction model, to obtain predicted instruction information;
[0269] A training unit is used to train the initial prediction model based on the prediction instruction information to obtain the prediction model.
[0270] In some embodiments, the sample text of the spoken request in the single-intent request scenario includes single-intent request content, where the single-intent request content represents a request content including one intent;
[0271] The number M of the sample sub-requests is the number 1 of intents in the single-intent request content, and the text of the sample sub-request is obtained based on the single-intent request content.
[0272] In some embodiments, the sample text of the spoken request in the single-intent request scenario includes multiple single-intent request contents, and the third prediction unit includes:
[0273] A splicing subunit, configured to splice the multiple single-intent request contents to obtain a spliced content;
[0274] The first prediction sub-unit is used to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the spliced content through an initial prediction model, where the number M of sample sub-requests is the number of the single-intent request content, and the text of each sample sub-request is obtained based on one of the single-intent request contents.
[0275] In some embodiments, the sample text of the spoken request in the multi-intent request scenario includes multi-intent request content, and the multi-intent request content represents request content containing multiple intents.
[0276] In some embodiments, the third prediction unit includes:
[0277] The second prediction sub-unit is used to predict the number M of sample sub-requests and the texts of the M sample sub-requests in the sample text of the spoken request in the multi-intent request scenario through an initial prediction model. The number M of sample sub-requests is the number of intents in the multi-intent request content, and the text of each sample sub-request is obtained based on the request content of one intent in the multi-intent request content.
[0278] In some embodiments, the sample text of the multi-round request scenario includes text of the current round and text of the previous round before the current round.
[0279] In some embodiments, the third prediction unit includes:
[0280] a merging subunit, configured to merge the text of the current round with the text of the previous round to obtain a merged text, wherein the merged text is used to represent the text of the current round and the text of the previous round;
[0281] The third prediction sub-unit is used to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the merged text through an initial prediction model, where the number M of sample sub-requests is 1, the number of texts in the current round, and the texts of the sample sub-requests are obtained by processing the text of the current round in combination with the texts of the previous rounds of the current round.
[0282] In some embodiments, the merging subunit is specifically configured to extract key information associated with the text of the current round from the text of the previous round, the key information including at least one of a keyword and a key sentence;
[0283] The key information is merged with the text of the current round to obtain the merged text.
[0284] In some embodiments, the third prediction unit further includes:
[0285] A generating subunit, configured to generate input information based on preset prompt information and the sample text, wherein the preset prompt information includes task description information corresponding to the predicted instruction information;
[0286] The input subunit is configured to input the input information into the initial prediction model, so as to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text through the initial prediction model.
[0287] In some embodiments, the sample text is a spoken text, and the generating subunit is specifically used to:
[0288] Based on the spoken text, preset prompt information and preset instruction information, input information is generated. The preset instruction information is used to instruct the initial prediction model to output instruction information, and the instruction information includes intention, field and slot.
[0289] In some embodiments, the training unit includes:
[0290] a loss determination subunit, configured to determine an initial loss value corresponding to each of the multiple scenarios based on the predicted instruction information;
[0291] The fusion subunit is used to fuse the initial loss value to obtain the target loss value;
[0292] The convergence subunit is used to converge the initial prediction model according to the target loss value to obtain the prediction model.
[0293] In some embodiments, the sample text includes negative sample text and positive sample text, the negative sample text includes sample text with incorrectly marked fields, and the positive sample text includes sample text other than the negative sample text in the sample text; the loss determination subunit is specifically configured to:
[0294] Filtering the predicted instruction information corresponding to the positive sample text in the predicted instruction information to obtain the positive sample instruction information;
[0295] Filtering the predicted instruction information corresponding to the negative sample text in the predicted instruction information to obtain negative sample instruction information, and adjusting the negative sample instruction information to obtain target negative sample instruction information;
[0296] Based on the positive sample instruction information and the negative sample instruction information, an initial loss value corresponding to each scene is determined.
[0297] In some embodiments, the data set acquisition unit 1201 includes:
[0298] a template acquisition subunit, configured to acquire a first-round dialogue template set and at least one second-round dialogue template set, wherein each first-round dialogue template in the first-round dialogue template set and each second-round dialogue template in the second-round dialogue template set includes a blank slot;
[0299] a combining subunit, configured to combine each first-round dialogue template in the first-round dialogue template set with each second-round dialogue template in the second-round dialogue template set to obtain a plurality of dialogue combinations;
[0300] The extraction subunit is used to extract entity information from a preset entity library based on the blank slots in the dialogue combination;
[0301] The filling subunit is used to fill the entity information into the dialogue combination to obtain a training data set in the multi-round request scenario.
[0302] In some embodiments, the filling subunit is specifically configured to:
[0303] Fill the entity information into the dialogue combination to obtain multi-round dialogue sample text;
[0304] Obtaining at least one interference text, and inserting the at least one interference text into the multi-round conversation sample text to obtain a target multi-round conversation sample text;
[0305] The target multi-round dialogue sample text is used as the training dataset for the multi-round request scenario.
[0306] In some embodiments, the third prediction unit is specifically configured to:
[0307] Match the texts of the M sample sub-requests with the preset entity library to obtain the entity information corresponding to each sample sub-request;
[0308] For each sample sub-request, updating the sample sub-request based on the entity information corresponding to the sample sub-request to obtain an updated sample sub-request;
[0309] The initial prediction model is used to predict instruction information of the sample text in a corresponding scenario according to the updated sample sub-request to obtain predicted instruction information.
[0310] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can be found in the previous method embodiments and will not be repeated here.
[0311] The present application also provides an electronic device, which may be a terminal, a server, or the like. The terminal may be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, or the like; the server may be a single server or a server cluster consisting of multiple servers, or the like.
[0312] In some embodiments, the text processing device can also be integrated into multiple electronic devices. For example, the text processing device can be integrated into multiple servers, and the text processing method of the present application can be implemented by multiple servers.
[0313] In this embodiment, the electronic device of this embodiment will be described in detail. For example, as shown in FIG13 , it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application. Specifically:
[0314] The electronic device may include components such as a processor 1301 with one or more processing cores, a memory 1302 with one or more computer-readable storage media, a power supply 1303, an input module 1304, and a communication module 1305. It will be understood by those skilled in the art that the electronic device structure shown in FIG13 does not limit the electronic device and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0315] Processor 1301 is the control center of the electronic device, connecting all parts of the electronic device using various interfaces and circuits. By running or executing software programs and / or modules stored in memory 1302 and accessing data stored in memory 1302, it performs various functions of the electronic device and processes data, thereby performing overall testing of the electronic device. In some embodiments, processor 1301 may include one or more processing cores. In some embodiments, processor 1301 may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 1301.
[0316] The memory 1302 can be used to store software programs and modules. The processor 1301 executes various functional applications and data processing by running the software programs and modules stored in the memory 1302. The memory 1302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1302 may also include a memory controller to provide the processor 1301 with access to the memory 1302.
[0317] The electronic device also includes a power supply 1303 for supplying power to various components. In some embodiments, the power supply 1303 can be logically connected to the processor 1301 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 1303 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0318] The electronic device may further include an input module 1304, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0319] The electronic device may also include a communication module 1305. In some embodiments, the communication module 1305 may include a wireless module. The electronic device may perform short-range wireless transmission via the wireless module of the communication module 1305, thereby providing the user with wireless broadband Internet access. For example, the communication module 1305 may be used to help the user send and receive emails, browse web pages, and access streaming media.
[0320] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically, in this embodiment, the processor 1301 in the electronic device loads the executable files corresponding to one or more application processes into the memory 1302 according to the following instructions, and the processor 1301 runs the application stored in the memory 1302 to implement various functions.
[0321] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0322] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0323] To this end, an embodiment of the present application provides a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute the steps of any text processing method provided in the embodiment of the present application. For example, the instructions can execute the following steps:
[0324] The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0325] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the method provided in the above embodiments.
[0326] Since the instructions stored in the storage medium can execute the steps in any text processing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any text processing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0327] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0328] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A text processing method, performed by an electronic device, comprising: Get a spoken request text expressing a spoken request; Predicting the number N of sub-requests of the spoken request and N sub-request texts corresponding to the N sub-requests by using the prediction model and the spoken request text, wherein N is a positive integer; and Through the prediction model, using the number N of sub-requests and N sub-request texts, the target instruction information corresponding to each of the N sub-request texts is predicted, the target instruction information including intent, domain and slot, and the target instruction information corresponding to each of the N sub-request texts is used to determine the response to the spoken request.
2. According to the text processing method of claim 1, the spoken request text is the text of the spoken request in a single-intent request scenario, the text of the spoken request in a multi-intent request scenario, or the text of a round of spoken request in a multi-round request scenario.
3. The text processing method according to claim 1 or 2, further comprising: Obtain training data sets in multiple scenarios, the training data sets including at least one sample text corresponding to each scenario, the multiple scenarios including at least two of a single-intent request scenario, a multi-intent request scenario, or a multi-round request scenario; Predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text by using an initial prediction model, where M is a positive integer; Predicting instruction information of the sample text in a corresponding scenario according to the number M of the sample sub-requests and the texts of the M sample sub-requests through the initial prediction model to obtain predicted instruction information; The initial prediction model is trained based on the prediction instruction information to obtain the prediction model.
4. According to the text processing method of claim 3, the sample text of the spoken request in the single-intent request scenario includes single-intent request content, and the single-intent request content represents the request content containing one intent; The number M of the sample sub-requests is the number 1 of intents in the single-intent request content, and the text of the sample sub-request is obtained according to the single-intent request content.
5. According to the text processing method of claim 4, the sample text of the spoken request in the single-intent request scenario includes a plurality of the single-intent request contents, and the step of predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text by using the initial prediction model comprises: Splicing the multiple single-intent request contents to obtain a spliced content; Through the initial prediction model, based on the spliced content, the number M of sample sub-requests and the texts of the M sample sub-requests are predicted, where the number M of sample sub-requests is the number of the single-intent request contents, and the text of each sample sub-request is obtained based on one of the single-intent request contents.
6. According to the text processing method of claim 3, the sample text of the spoken request in the multi-intent request scenario includes multi-intent request content, and the multi-intent request content represents the request content containing multiple intents.
7. The text processing method according to claim 6, wherein the predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text by using the initial prediction model comprises: Through the initial prediction model, the number M of sample sub-requests and the texts of the M sample sub-requests in the sample text of the spoken request in the multi-intention request scenario are predicted, where the number M of sample sub-requests is the number of intents in the multi-intention request content, and the text of each sample sub-request is obtained based on the request content of one intent in the multi-intention request content. 8 . The text processing method according to claim 3 , wherein the sample text of the multi-round request scenario includes the text of the current round and the text of the previous round before the current round.
9. The text processing method according to claim 8, wherein the predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text by using the initial prediction model comprises: Merging the text of the current round with the text of the previous round before the current round to obtain a merged text, wherein the merged text is used to represent the text of the current round and the text of the previous round before the current round; The initial prediction model is used to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the merged text, wherein the number M of sample sub-requests is the number 1 of the text of the current round, and the sample sub-requests are The text is obtained by processing the text of the current round in combination with the text of the previous round of the current round.
10. The text processing method according to claim 9, wherein merging the text of the current round with the text of the previous round of the current round to obtain a merged text comprises: Extracting key information associated with the text of the current round from the text of the previous round of the current round, wherein the key information includes at least one of a keyword and a key sentence; The key information is merged with the text of the current round to obtain the merged text.
11. The text processing method according to claim 3, wherein the predicting the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text by using the initial prediction model comprises: Generate input information based on preset prompt information and the sample text, wherein the preset prompt information includes task description information corresponding to the predicted instruction information; The input information is input into the initial prediction model, so as to predict the number M of sample sub-requests and the texts of the M sample sub-requests based on the sample text through the initial prediction model.
12. The text processing method according to claim 11, wherein the sample text is a spoken text, and the step of generating input information based on preset prompt information and the sample text comprises: Based on the spoken text, preset prompt information and preset indication information, input information is generated, and the preset indication information is used to instruct the initial prediction model to output instruction information, and the instruction information includes intention, field and slot.
13. The text processing method according to any one of claims 3 to 12, wherein the training of the initial prediction model based on the prediction instruction information to obtain the prediction model comprises: Based on the predicted instruction information, determining an initial loss value corresponding to each of the multiple scenarios; The initial loss values are merged to obtain a target loss value; According to the target loss value, the initial prediction model is converged to obtain the prediction model.
14. The text processing method according to claim 13, wherein the sample text includes negative sample text and positive sample text, the negative sample text includes sample text with annotated error fields, and the positive sample text includes sample text other than the negative sample text in the sample text; the determining the initial loss value corresponding to each of the multiple scenarios based on the prediction instruction information comprises: Filtering the predicted instruction information corresponding to the positive sample text in the predicted instruction information to obtain the positive sample instruction information; Filtering the predicted instruction information corresponding to the negative sample text in the predicted instruction information to obtain negative sample instruction information, and adjusting the negative sample instruction information to obtain target negative sample instruction information; Based on the positive sample instruction information and the negative sample instruction information, an initial loss value corresponding to each scene is determined.
15. The text processing method according to any one of claims 3 to 14, wherein the step of obtaining training data sets in multiple scenarios comprises: Acquire a first-round dialogue template set and at least one second-round dialogue template set, wherein each first-round dialogue template in the first-round dialogue template set and each second-round dialogue template in the second-round dialogue template set include a blank slot; Combining each first-round dialogue template in the first-round dialogue template set with each second-round dialogue template in the second-round dialogue template set to obtain a plurality of dialogue combinations; Based on the blank slots in the dialogue combination, extracting entity information from a preset entity library; The entity information is filled into the dialogue combination to obtain a training data set in the multi-round request scenario.
16. The text processing method according to claim 15, wherein the step of filling the entity information into the dialogue combination to obtain a training data set in the multi-round request scenario comprises: Filling the entity information into the dialogue combination to obtain multiple rounds of dialogue sample texts; Acquire at least one interference text, and insert the at least one interference text into the multi-round dialogue sample text to obtain a target multi-round dialogue sample text; The target multi-round dialogue sample text is used as a training data set in the multi-round request scenario.
17. The text processing method according to any one of claims 3 to 16, wherein the initial prediction model is used to predict instruction information of the sample text in a corresponding scenario according to the number M of sample sub-requests and the texts of the M sample sub-requests to obtain predicted instruction information, comprising: Match the texts of the M sample sub-requests with the preset entity library respectively to obtain entity information corresponding to each sample sub-request; For each sample sub-request, updating the sample sub-request based on the entity information corresponding to the sample sub-request to obtain an updated sample sub-request; The initial prediction model is used to predict instruction information of the sample text in a corresponding scenario according to the updated sample sub-request to obtain predicted instruction information.
18. A text processing device, comprising: An acquisition unit, used for acquiring a spoken request text expressing a spoken request; A first prediction unit, configured to predict, by using a prediction model and the spoken request text, the number N of sub-requests of the spoken request and N sub-request texts corresponding to the N sub-requests, wherein N is a positive integer; and The second prediction unit is used to predict the target instruction information corresponding to each of the N sub-request texts according to the number N of the sub-requests and the N sub-request texts through the prediction model, wherein the target instruction information includes an intention, a domain, and a slot, and the target instruction information corresponding to each of the N sub-request texts is used to determine a response to the spoken request.
19. An electronic device comprising a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the text processing method according to any one of claims 1 to 17.
20. A computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded by a processor to execute the steps of the text processing method according to any one of claims 1 to 17.
21. A computer program product, comprising computer instructions, which, when executed by a processor, implement the steps of the text processing method according to any one of claims 1 to 17.
Citation Information
Patent Citations
Dialogue intention recognition method and device, electronic equipment and storage medium
CN111368085A
Intelligent voice interaction system and method
CN111653262A
User intention recognition method and system oriented to intelligent home dialogue understanding
CN116151271A
Multi-intention recognition method and device based on event extraction and storage medium
CN116166785A
Responding to multi-intent user input to a dialog system
US20200019641A1
Cited By
Multi-round dialogue sample data generation method, device, equipment and product
CN120541528A
Interaction control method and system
CN121434349A