Semantic understanding method and device
Through the language model, the multi-intention statement is split and intent recognition, and combined with templates and one-shot technology, the problem of explosion of intent quantity and omitted statement processing in the intelligent question-and-answer system is solved, which improves the accuracy and efficiency of semantic understanding and reduces the Label costs.
Patent Information
- Application Number
- PCT/CN2023/134119
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-30
- Filing Date
- 2023-11-24
- Publication Date
- 2025-01-02
AI Technical Summary
When handling multi-intentional statements, existing intelligent question-and-answer systems can easily lead to an explosion in the number of intentions, increasing the cost and complexity of manual labeling, and it is difficult to accurately identify and process when the statement completion is omitted, affecting the accuracy and reliability of semantic understanding.
The language model is used to split and identify multi-intention statements, judge statement types through keyword recognition and preset keywords, and combine the template input language model to split and complete statements, and use one-shot technology and double Tower model improves output accuracy and efficiency.
It reduces manual labeling work, improves the accuracy and reliability of semantic understanding of intelligent question-and-answer systems, reduces manual labeling costs, enhances the generalization ability and efficiency of the system, and reduces delays.
Smart Images

Figure CN2023134119_02012025_PF_FP_ABST
Abstract
Description
Semantic understanding methods and equipment
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese patent application number 202310800244.7, filed on June 30, 2023, entitled “A Semantic Understanding Method and Device,” the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present application relates to the field of data processing technology, and in particular to a semantic understanding method and device. Background Art
[0004] The intelligent question-answering system is mainly used to receive input sentences, perform semantic understanding of the sentences, and determine the intent and slot corresponding to the sentences. Slots refer to predefined data fields or tags used for specific tasks. These fields or tags can be found and used in text or other types of data.
[0005] Related intelligent question-answering systems primarily use classification models to identify intent and slots. Specifically, technicians construct sample sentences for each business category based on actual business needs. These sample sentences for each business category cover as many possible user phrases as possible. The intelligent question-answering system uses these sample sentences to train the classification model.
[0006] Summary of the Invention
[0007] Some embodiments of the present application provide a semantic understanding method, including:
[0008] Perform keyword recognition on the target sentence to be processed to determine the keyword corresponding to the target sentence. If the intentions corresponding to the keywords are different, or the keywords are preset keywords, then determine that the target sentence is a multi-intent sentence;
[0009] Adding the target sentence to a first template for sentence splitting, and inputting the first template into a large language model, to obtain a plurality of target sub-sentences corresponding to the target sentence output by the large language model;
[0010] Intention recognition is performed on each of the multiple target sub-sentences to determine the intentions corresponding to each of the multiple target sub-sentences.
[0011] On the other hand, some embodiments of the present application provide an electronic device, including:
[0012] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the semantic understanding method provided in the first aspect above.
[0013] Some embodiments of the present application provide a computer-readable non-volatile storage medium, wherein the storage medium stores a computer program, and the computer program is used to enable a computer to execute the above-mentioned semantic understanding method. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] FIG1 is a schematic diagram of a semantic understanding process provided by some embodiments of the present application;
[0015] FIG2 is a schematic diagram of a filled first template provided in some embodiments of the present application;
[0016] FIG3 is an overall flow chart of intelligent dialogue provided by some embodiments of the present application;
[0017] FIG4 is a schematic diagram of a filled second template provided in some embodiments of the present application;
[0018] FIG5 is a schematic diagram of the output of a large language model provided in some embodiments of the present application;
[0019] FIG6 is a schematic diagram of a second template after filling with one-shot technology provided in some embodiments of the present application;
[0020] FIG7 is a schematic diagram of the output of a large language model provided in some embodiments of the present application;
[0021] FIG8 is a schematic diagram of a flow chart of an intelligent question-answering system provided in some embodiments of the present application;
[0022] FIG9 is a schematic diagram of the time delay of each module of the intelligent question-answering system provided in some embodiments of the present application;
[0023] FIG10 is a schematic diagram of the structure of an electronic device provided in some embodiments of the present application. DETAILED DESCRIPTION
[0024] To further illustrate some embodiments of the present application, this is described in detail below in conjunction with the accompanying drawings and specific implementation methods. Although some embodiments of the present application provide method operation steps as shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on routine or no creative labor. In steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided in some embodiments of the present application. In the actual processing process or when the control device is executed, the method can be executed in the order of the method shown in the embodiments or drawings or in parallel.
[0025] The intelligent question-answering system performs keyword recognition on the target sentence to be processed and determines the keyword corresponding to the target sentence. If the intentions corresponding to the keywords are different, or the keywords are preset keywords, the target sentence is determined to be a multi-intent sentence; the target sentence is added to the first template used for sentence splitting, and the first template is input into the language model to obtain multiple target sub-sentences corresponding to the target sentence output by the language model; the intent recognition is performed on the multiple target sub-sentences respectively, and the intents corresponding to the multiple target sub-sentences are determined.
[0026] FIG1 is a schematic diagram of a semantic understanding process provided by some embodiments of the present application, which includes:
[0027] S101: Perform keyword recognition on the target sentence to be processed to determine the keyword corresponding to the target sentence. If the intentions corresponding to the keywords are different, or the keywords are preset keywords, the target sentence is determined to be a multi-intention sentence.
[0028] Some embodiments of the present application provide a semantic understanding method applied to an intelligent question-answering system.
[0029] Before performing semantic understanding, the intelligent question-answering system can first determine whether the target sentence to be processed is a multi-intent sentence. If the intelligent question-answering system determines that the target sentence is a multi-intent sentence, the intelligent question-answering system can split the target sentence into multiple sub-sentences with a single intent before performing semantic understanding.
[0030] The intelligent question-answering system can perform keyword recognition on the target sentence to be processed and determine the keyword corresponding to the target sentence. The intelligent question-answering system stores the correspondence between keywords and intents. After determining the keyword corresponding to the target sentence, the intelligent question-answering system can determine whether the target sentence is a multi-intent sentence based on the keyword corresponding to the target sentence. The keyword can be a word with an intent meaning or a representative word corresponding to the intent.
[0031] Specifically, in some embodiments of the present application, the intelligent question-answering system determines whether the target sentence corresponds to multiple keywords. If so, the intelligent question-answering system determines the intents corresponding to the multiple keywords based on the stored correspondence between keywords and intents. If the multiple keywords correspond to different intents, the intelligent question-answering system determines that the target sentence is a sentence with multiple intents; if the multiple keywords correspond to the same intent, but there is a preset keyword among the multiple keywords, the intelligent question-answering system will also determine that the target sentence is a sentence with multiple intents.
[0032] Among them, the preset keywords can be conjunctions, including but not limited to conjunctions that indicate transitional relationships, such as but, however, etc.; conjunctions that indicate parallel relationships, such as and, in addition, etc.; and connections that indicate causal relationships, such as therefore, so, etc.
[0033] In addition, in some embodiments of the present application, if the target sentence corresponds to one keyword, but the keyword is a preset keyword, the intelligent question-answering system will also determine the target sentence as a multi-intent sentence.
[0034] S102: Add the target sentence to a first template for sentence splitting, input the first template into a large language model, and obtain multiple target sub-sentences corresponding to the target sentence output by the large language model.
[0035] When processing multi-intent sentences, the intelligent question-answering system of related technologies generally uses one overall intent to represent multiple intents. However, in actual applications, the superposition of multiple single intents will cause an explosive growth in the total number of intents, followed by an explosive increase in the demand for annotated sentences, which greatly increases the cost of manual annotation.
[0036] Based on this, in some embodiments of the present application, the intelligent question-answering system processes multi-intent sentences through a large language model.
[0037] The language model, trained on massive amounts of data, possesses strong generalization capabilities. This generalization capability can overcome the challenges of insufficient data annotation and poor generalization in related intelligent question-answering systems, thereby reducing manual annotation work, saving costs, and improving efficiency. Furthermore, the language model, trained on massive amounts of data, utilizes prompts to distinguish between different tasks. Through the design of prompts and examples, the general capabilities of the language model can be applied to specific domains.
[0038] Based on this, in some embodiments of the present application, the intelligent question-answering system fully utilizes the language model's ability to understand language, offloading tasks requiring general semantic understanding, such as the segmentation of long and complex sentences, to the language model. This model then maps complex language questions to existing annotation problems, thereby reducing the overall annotation workload. Specifically, if the target sentence contains multiple intents, the intelligent question-answering system can segment the target sentence using the language model.
[0039] Among them, in some embodiments of the present application, a first template for sentence splitting is stored in the intelligent question-answering system, and the first template includes at least prompt words for prompting the language macro model to perform the sentence splitting task, and a preset field for filling in multi-intent sentences. The intelligent question-answering system can write the target sentence into the preset field for filling in multi-intent sentences in the first template, and input the first template into the language macro model. The language macro model splits the target sentence written in the first template according to the prompt words in the first template, and outputs multiple target sub-sentences obtained after the target sentence is split. The intelligent question-answering system obtains multiple target sub-sentences corresponding to the target sentence output by the language macro model.
[0040] Figure 2 is a schematic diagram of the filled first template provided in some embodiments of the present application. As shown in Figure 2, "Your task is to split the first sentence into single intention clauses" is a prompt word used to prompt the language large model to perform sentence splitting, and "Determine the high-tech enterprises in a certain district, and determine how many of them are private enterprises" is the target sentence to be written.
[0041] S103: Perform intention recognition on each of the multiple target sub-sentences to determine the intentions corresponding to each of the multiple target sub-sentences.
[0042] After determining the multiple target sub-models corresponding to the target sentence, the intelligent question-answering system performs intent recognition on each of the multiple target sub-sentences to determine the intents corresponding to each of the multiple target sub-sentences. The intelligent question-answering system can use an existing intent recognition model to perform intent recognition on the multiple target sub-sentences.
[0043] In some embodiments of the present application, the intelligent question-answering system performs keyword recognition on the target sentence and, based on the recognized keywords, determines whether the target sentence is a multi-intent sentence. If the target sentence is a multi-intent sentence, the intelligent question-answering system uses a large language model to split the multi-intent target sentence into multiple target sub-sentences and performs intent recognition on the multiple target sub-sentences. By using a large language model to split the multi-intent target sentence into multiple target sub-sentences and then performing intent recognition on the target sub-sentences, the intelligent question-answering system achieves semantic understanding of multi-intent sentences and improves the accuracy, reliability, and generalizability of the intelligent question-answering system.
[0044] In some embodiments of the present application, if the intentions corresponding to the keywords are the same, or the keywords are not preset keywords, the method further includes:
[0045] Perform intent recognition on the target sentence to determine the intent corresponding to the target sentence.
[0046] In some embodiments of the present application, if the intelligent question-answering system determines that the intents corresponding to the keywords of the target sentence are the same, or the keywords are not preset keywords, the intelligent question-answering system determines that the target sentence is not a multi-intent sentence. The intelligent question-answering system performs intent recognition on the target sentence and determines the intent corresponding to the target sentence.
[0047] In order to improve the accuracy, reliability, and generalizability of semantic understanding of the intelligent question-answering system, in some embodiments of the present application, before performing keyword recognition on the target sentence to be processed and determining the keyword corresponding to the target sentence, the method further includes:
[0048] Determining whether the target sentence is an omitted sentence according to a pre-stored omitted sentence determination condition;
[0049] If it is determined that the target sentence is an omitted sentence, the target sentence is completed according to the language macro model.
[0050] When users speak, they often omit information from the previous sentence. For example, if the first sentence asks "What's the weather like today?" and the second sentence asks "What about tomorrow?", the second sentence omits information from the first. Therefore, intelligent question-answering systems need to complete the target sentence based on the previous sentence.
[0051] In the intelligent question-answering system of the related technology, the completion operation of the target sentence will be placed after the language understanding of the target sentence, and the completion will be performed during the dialogue management. For the above example, when the intention of the target sentence and the previous sentence have not changed, the traditional method of completing the target sentence is applicable. However, if the intention of the target sentence and the previous sentence have changed, the traditional method cannot solve it. For example: if the previous sentence is "What is the GDP of a certain city in 2021?", and the target sentence is "How does it compare with another city?", the target sentence has been omitted based on the previous sentence, and the intention has changed from asking the GDP data value to asking the comparison of the GDPs of the two cities.
[0052] Among them, when completing the omitted target sentence in the related art, the coreference resolution scheme is usually used for processing. Coreference resolution refers to determining the specific object referred to by a pronoun or noun phrase. The goal of coreference resolution is to determine a referent. The coreference resolution scheme mainly includes two methods: the first is that the intelligent question answering system identifies the position of the target sentence's slot in the previous sentence based on the slot extraction algorithm, and then uses the target sentence's slot to replace the slot at the corresponding position in the previous sentence; the second scheme is that the intelligent question answering system uses a discriminant model to respectively identify the position information of the specific actual value and referential value of the two sentences, and then obtains the completed target sentence by position replacement. However, the processing of the first method is relatively simple and can only handle the situation where the slots of the two sentences are consistent; moreover, both the first and second methods have the problem of semantic incoherence in the completed target sentence. The reason for this problem is that the first and second methods complete the sentence based on rules or discriminant models, and do not follow the semantics. Therefore, it is inevitable that the results will have different semantics.
[0053] Furthermore, in the related art, when performing dialogue management, the dialogue management module completes the target sentence, but the dialogue management module does not have the capability of recognizing intent, and therefore cannot re-identify the intent of the completed target sentence.
[0054] Based on this, in some embodiments of the present application, in order to improve the accuracy, reliability and generalizability of the semantic understanding of the intelligent question-answering system, if the intelligent question-answering system determines that the target sentence is an omitted sentence, the intelligent question-answering system can complete the target sentence based on the language model.
[0055] Specifically, based on the pre-saved omitted sentence judgment conditions, it is determined whether the target sentence is an omitted sentence; if it is determined that the target sentence is an omitted sentence, the target sentence is completed according to the language macro model.
[0056] Figure 3 is an overall flow chart of the intelligent dialogue provided by some embodiments of the present application. As shown in Figure 3, the intelligent question-answering system receives the user input question audio and obtains the corresponding target sentence (question text) through the speech recognition module (ASR); determines the slot, intention and domain corresponding to the target sentence according to the natural semantic understanding module (NLU); generates the decision corresponding to the target sentence according to the dialogue tracking state module (DST) and the dialogue decision module (DPL); determines the reply sentence (reply text) corresponding to the decision according to the natural language generation module (NLG); and determines and outputs the reply audio corresponding to the reply sentence through the speech synthesis module (TTS).
[0057] Based on the disclosure in FIG3 , in related art, the dialogue state tracking module (DST) and the dialogue decision module (DPL) complete omitted sentences. However, these modules are unable to identify the intent of the completed sentences. This results in the related art being unable to process omitted target sentences that differ in intent from the previous sentence. In some embodiments of the present application, however, the natural language understanding module (NLU) completes omitted sentences, and this natural language understanding module (NLU) can identify the intent of the completed sentences.
[0058] In some embodiments of the present application, judging whether the target sentence is an omitted sentence based on the pre-stored omitted sentence judgment condition includes at least one of the following:
[0059] Obtaining a saved received semantic understanding instruction carrying the target sentence and whether the target sentence is a follow-up question; if the target sentence is a follow-up question, determining that the target sentence is not an omitted sentence;
[0060] Identify the target sentence to determine whether the target sentence has a subject and a predicate; if the target sentence has a subject and a predicate, determine that the target sentence is not an omitted sentence;
[0061] A pre-stored preset sentence is obtained, and if the target sentence is consistent with the preset sentence, it is determined that the target sentence is not an omitted sentence.
[0062] In some embodiments of the present application, the intelligent question-answering system still has a delay problem in the process of using the language large model to complete the target sentence. Due to the model size and hardware resource limitations of the language large model, the intelligent question-answering system takes about 3 seconds to call the language large model each time. This time consumption has a great impact on the semantic understanding of the entire intelligent question-answering system. Therefore, before calling the language large model, the intelligent question-answering system will first determine whether the target sentence is an omitted sentence, so that most of the sentences that are not omitted will skip the completion step, which can reduce the delay of the intelligent question-answering system as a whole.
[0063] Among them, the intelligent question-answering system has four main logics for determining whether the target sentence is an omitted sentence: First, if it is a follow-up question to the user's previous sentence and the user's targeted answer, there is no need to complete the user's answer sentence; Second, if the subject and predicate of the target sentence are complete, there is no need to complete the target sentence; Third, if the target sentence is a preset sentence, there is no need to complete the target sentence. This condition is mainly to avoid completing commonly used concise phrases such as "hello" and "goodbye"; Fourth, if the above three conditions do not exist, the target sentence needs to be completed.
[0064] Specifically, in some embodiments of the present application, the intelligent question-answering system obtains a stored, received semantic understanding instruction that carries information about the target sentence and whether the target sentence is a follow-up question; if the target sentence is a follow-up question, the intelligent question-answering system determines that the target sentence is not an omitted sentence; the intelligent question-answering system identifies the target sentence and determines whether the target sentence has a subject and a predicate; if the target sentence has a subject and a predicate, the intelligent question-answering system determines that the target sentence is not an omitted sentence; the intelligent question-answering system obtains a pre-stored preset sentence, and if the target sentence is consistent with the pre-stored preset sentence, the intelligent question-answering system determines that the target sentence is not an omitted sentence. Otherwise, the intelligent question-answering system determines that the target sentence is an omitted sentence.
[0065] In some embodiments of the present application, completing the target sentence according to the large language model includes:
[0066] Obtaining the previous statement corresponding to the saved target statement;
[0067] Filling a second template for sentence completion according to the target sentence and the previous sentence;
[0068] The filled second template is input into the language model to obtain the completed target sentence corresponding to the target sentence output by the language model.
[0069] In some embodiments of the present application, a second template for sentence completion is stored in the intelligent question-answering system, and the second template includes at least a prompt word for prompting the language model to perform a sentence completion task, and a preset field for filling in the omitted sentence and the previous sentence of the sentence. After the intelligent question-answering system determines that the target sentence is an omitted sentence, the intelligent question-answering system obtains the previous sentence corresponding to the target sentence. The intelligent question-answering system writes the previous sentence and the target sentence into the preset field for filling in the omitted sentence and the previous sentence of the sentence in the second template, and inputs the filled-in second template into the language model. The language model completes the target sentence written in the second template based on the prompt word in the second template, and outputs the completed target sentence. The intelligent question-answering system obtains the completed target sentence corresponding to the target sentence output by the language model.
[0070] In some embodiments of the present application, the second template at least includes prompt words for prompting the language macro model to complete the sentence.
[0071] Figure 4 is a schematic diagram of the filled second template provided in some embodiments of the present application. As shown in Figure 4, "Your task is to complete the information of the second sentence according to the form of the first sentence" is a prompt word used to prompt the language large model to complete the sentence, "How many high-tech enterprises are there in a certain district" is the first sentence, and "How many of them are private enterprises" is the target sentence.
[0072] Based on Figure 4, Figure 5 is a schematic diagram of the output of the language model provided by some embodiments of the present application. As shown in Figure 5, the completed target sentence output by the language model is "How many high-tech enterprises in a certain district are private enterprises?"
[0073] As shown in Figure 5, given the prompt, the language model is able to complete the following sentence (Sentence 2) based on the previous sentence (Sentence 1). However, the completed sentence still contains other redundant information.
[0074] Some embodiments of the present application can also use one-shot technology to give examples related to the language large model to standardize the output of the language large model. The One-Shot method is an efficient single-step learning method from data to model. By learning the similarities between samples, the One-Shot method can quickly build an accurate model with a small amount of data. Specifically, one-shot can be added to the second template, and the one-shot contains the previous sentence of the example, the target sentence of the example, and the completed target sentence of the example.
[0075] Figure 6 is a schematic diagram of the second template with one-shot technology added after filling provided in some embodiments of the present application. As shown in Figure 6, the second template with one-shot technology added includes prompt words, one-shot and input questions for prompting the language large model to complete sentences, among which "Your task is to complete the information of the second sentence according to the form of the first sentence" is the prompt word, "How many people are there in a certain city in 2021" is the example of the previous sentence, "What percentage of the population is rural" is the example target sentence, and "What percentage of the population is rural in a certain city in 2021" is the example to be completed.
[0076] Based on Figure 6, Figure 7 illustrates the output of a large language model provided in some embodiments of the present application. As shown in Figure 7, after adding the one-shot, the large language model outputs the completed target sentence, "How many private high-tech enterprises are there in XX District?" This target sentence is more accurate and reduces redundant information.
[0077] When processing different target sentences, using the same one-shot prompt, the results of the completed target sentences vary significantly. When the one-shot instance and the target sentence have a high degree of similarity, the large language model performs better. When the one-shot instance and the target sentence have a low degree of similarity, the large language model cannot learn more useful information from the instance, and the large model's fusion effect is poor. To address this issue, different types of commonly used multi-round fusion instances can be stored as candidate instances. The format of the stored instances is as follows:
[0078] Compare the stored conversation history and questions with the user's previous and current conversation information. Find the candidate instance with the highest textual similarity. Use this instance as the one-shot prompt word splicing to ensure that the spliced one-shot instance is most similar to the user's question.
[0079] Text similarity is measured using embedding techniques in a deep learning model. Embedding maps high-dimensional data into low-dimensional vectors. The embedding results are then calculated using cosine similarity. The training input is based on the A+B+C model. For example, the input text is "[cls] Who are the leaders of the Traffic Management Bureau? [sep] The director of the Traffic Management Bureau is Zhang San, and the deputy directors are Li Si and Wang Wu. [sep] What is Li Si's phone number?" This text is fed into the deep learning model, resulting in a 768-dimensional dense vector.
[0080] The BERT training model in related technologies is primarily designed to solve general problems. When comparing semantic similarity, high-dimensional semantic spaces exhibit heterogeneity. This means that even if two sentences have opposite meanings, their distribution distances in high-dimensional space remain very close. This results in the embedding results of many texts with dissimilar meanings still exhibiting high similarity.
[0081] To address this issue, some embodiments employ a twin-tower model. This model incorporates |uv| as input for the final classification. By taking the absolute value of the difference, the impact of dissimilar dimensions on the overall result can be amplified. This addresses the problem where, while the expressions "The weather is good today" and "The weather is bad today" are very similar in form, their actual semantic information differs significantly. By introducing the twin-tower model, the recall accuracy of candidate instances can be improved, thereby enhancing the accuracy of large-scale language model fusion.
[0082] In some embodiments of the present application, before performing keyword recognition on the target sentence to be processed and determining the keywords corresponding to the target sentence, the method further includes:
[0083] The target sentence is input into a text error correction model to obtain the corrected target sentence output by the text error correction model.
[0084] In actual applications, the target sentence may be converted from audio, and the speech-to-text model may make recognition errors when generating the target sentence based on speech. That is, the target sentence may contain erroneous text information, which will have a great impact on the accuracy of semantic understanding.
[0085] Based on this, the intelligent question-answering system will first perform text correction on the target sentence before semantically understanding it. Specifically, the intelligent question-answering system inputs the target sentence into a text correction model and obtains the corrected target sentence output from the text correction model.
[0086] In some embodiments of the present application, slot identification is performed on each of the plurality of target sub-sentences, and template processing is performed on the target sub-sentences using the identified slots;
[0087] Performing slot identification on each of the plurality of target sub-sentences, and performing template processing on the target sub-sentences using the identified slots;
[0088] According to the Elastic search (ES) database, candidate sentences corresponding to the multiple target sub-sentences are determined, and the candidate intentions corresponding to the candidate sentences stored in the ES database are determined as the intentions of the corresponding target sub-sentences.
[0089] In some embodiments of the present application, determining the candidate sentences corresponding to the multiple target sub-sentences respectively according to the flexible search of the ES database includes:
[0090] Sending the templated target sub-sentences to the flexible search ES database in sequence, and obtaining similar sentences and intentions of the similar sentences corresponding to the target sub-sentences sent by the ES database;
[0091] Determine the similarity between the multiple target sub-sentences and the corresponding similar sentences, and if the similarity reaches a preset similarity threshold, determine the intent of the similar sentences as the intent of the corresponding target sub-sentences.
[0092] In some embodiments of the present application, the intelligent question-answering system can determine the intent corresponding to the target sub-sentence based on the ES database. The ES database stores a large number of sentences and their corresponding intents, and the intelligent question-answering system can perform intent queries in a matching manner.
[0093] In practice, a slot corresponds to many values. If the ES database stored statements corresponding to each slot value, the database would become unmanageable. Therefore, to reduce the amount of data in the ES database and improve the efficiency of intent queries, the statements stored in the ES database are templated statements. That is, each statement only contains the slot and not the slot value, such as "How is [city] [time] [weather]?"
[0094] Before the intelligent question-answering system performs an intent query on a target sub-sentence based on the ES database, it first performs template processing on the target sub-sentence. Specifically, it performs slot identification on each of the multiple target sub-sentences and uses the identified slots to perform template processing on the target sub-sentences.
[0095] The intelligent question-answering system segments each target sub-sentence and uses a named entity recognition (NER) model to determine the slot corresponding to the target sub-sentence after segmentation, and uses the identified slot to template the target sub-sentence.
[0096] For example, the sub-target sentence is "What is the weather like in a certain city today?", where the slot corresponding to "a certain city" is "city" and the slot corresponding to "today" is "time". Then the target sub-sentence obtained by template processing is "What is the weather like in the city at that time".
[0097] After the intelligent question-answering system templates the target sub-sentence, it sends the templated target sub-sentence to the ES database. The ES database uses the built-in BM25 algorithm to determine multiple similar statements similar to the target sub-sentence, and determines the candidate statement from the multiple similar statements.
[0098] Specifically, the intelligent question-answering system determines the similarity between the target sub-sentence and the corresponding similar sentence. If the similarity with the largest value reaches a preset similarity threshold, the similar sentence corresponding to the largest similarity is determined as the candidate sentence.
[0099] Furthermore, by determining the intent of the target sub-statement through the ES database, the system increases the interpretability of the intelligent question-answering system while maintaining efficiency. Query results obtained through the ES database are clearly visible through the backend logging system, allowing errors to be pinpointed. Furthermore, as new statements are added, they can be quickly adapted by maintaining the stored statements in the ES database.
[0100] In some embodiments of the present application, if there is a target sub-sentence to be processed whose corresponding similarity does not reach a preset similarity threshold, the method further includes:
[0101] The target sub-sentence to be processed is input into the intent classification model, and the intent corresponding to the target sub-sentence to be processed output by the intent classification model is obtained.
[0102] In some embodiments of the present application, if the maximum numerical similarity corresponding to the target sub-sentence does not meet the preset similarity threshold, the intelligent question-answering system determines that it cannot find the intent corresponding to the target sub-sentence in the ES database. The intelligent question-answering system inputs the target sub-sentence to be processed into the intent classification model and obtains the intent corresponding to the target sub-sentence to be processed output by the intent classification model.
[0103] In some embodiments of the present application, the intelligent question-answering system also includes a syntax analysis module and a JSON output module. These two modules are reserved for logic modules to connect to backend development. All logic-related code is primarily handled by these two modules. This allows the entire intelligent question-answering system to adapt to different interfaces by changing these two modules while ensuring that the overall intelligent question-answering system architecture remains unchanged.
[0104] Figure 8 is a flow chart of the intelligent question-answering system provided by some embodiments of the present application. As shown in Figure 8, the intelligent question-answering system includes nine modules: text correction, multi-round completion, complex sentence splitting, word segmentation, NER, templateization, recall + similarity, intent classification and syntactic analysis. The design of the entire intelligent question-answering system revolves around five dimensions: low annotation volume, low latency, high accuracy, high generalization ability and strong interpretability. A balanced treatment was made in the five dimensions during the overall design to make up for the shortcomings of traditional semantic understanding.
[0105] Based on Figure 8, Figure 9 is a schematic diagram of the delay of each module of the intelligent question and answer system provided in some embodiments of the present application. As shown in Figure 7, a total of 7 sentences were tested, and the time it took for the intelligent question and answer system to perform semantic understanding of each sentence was within 150ms.
[0106] On the basis of the above embodiments, some embodiments of the present application further provide an electronic device. FIG10 is a schematic structural diagram of an electronic device provided in some embodiments of the present application. As shown in FIG10 , the electronic device includes: a processor 1101, a communication interface 1102, a memory 1103, and a communication bus 1104. The processor 1101, the communication interface 1102, and the memory 1103 communicate with each other via the communication bus 1104.
[0107] The memory 1103 stores a computer program, which, when executed by the processor 1101 , enables the processor 1101 to perform any of the steps of the above-mentioned semantic understanding method.
[0108] Since the principle of solving the problem by the above electronic device is similar to the semantic understanding method, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will be omitted.
[0109] Based on the above embodiments, some embodiments of the present application also provide a computer-readable storage medium, which stores a computer program that can be executed by a processor. When the program runs on the processor, the processor executes the steps of any of the above-mentioned semantic understanding methods.
[0110] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the semantic understanding method, the implementation of the above-mentioned computer-readable storage medium can refer to the embodiment of the method, and the repeated parts will not be repeated.
[0111] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A semantic understanding method, comprising: Perform keyword recognition on the target sentence to be processed to determine the keyword corresponding to the target sentence, and if the intentions corresponding to the keywords are different, or the keywords are preset keywords, determine that the target sentence is a multi-intention sentence; Adding the target sentence to a first template for sentence splitting, and inputting the first template into a large language model, to obtain a plurality of target sub-sentences corresponding to the target sentence output by the large language model; Intention recognition is performed on each of the multiple target sub-sentences to determine the intentions corresponding to each of the multiple target sub-sentences.
2. The method according to claim 1, further comprising: If the intentions corresponding to the keywords are the same, or the keywords are not preset keywords, Perform intent recognition on the target sentence to determine the intent corresponding to the target sentence.
3. The method according to claim 2, wherein before performing keyword recognition on the target sentence to be processed and determining the keyword corresponding to the target sentence, the method further comprises: According to the pre-stored omitted sentence determination condition, determining whether the target sentence is an omitted sentence; If it is determined that the target sentence is an omitted sentence, the target sentence is completed according to the language macro model.
4. The method according to claim 3, wherein judging whether the target sentence is an omitted sentence according to the pre-stored omitted sentence judgment condition comprises at least one of the following: Obtaining a saved received semantic understanding instruction carrying the target sentence and information on whether the target sentence is a question sentence; if the target sentence is a question sentence, determining that the target sentence is not an omitted sentence; Identify the target sentence to determine whether the subject and predicate exist in the target sentence; If the target sentence has a subject and a predicate, determining that the target sentence is not an omitted sentence; A pre-saved preset sentence is obtained, and if the target sentence is consistent with the preset sentence, it is determined that the target sentence is not an omitted sentence.
5. The method according to claim 3, wherein completing the target sentence according to the language macro model comprises: Obtaining the last statement corresponding to the target statement that is saved; Filling a second template for sentence completion according to the target sentence and the previous sentence; The filled second template is input into the language macro model to obtain the completed target sentence corresponding to the target sentence output by the language macro model.
6. The method according to claim 3, wherein completing the target sentence according to the language macro model comprises: Obtaining the last statement corresponding to the target statement that is saved; Determine prompt words and examples for prompting the language macro model to complete a sentence, wherein the example includes a previous sentence of the example, an example target sentence, and an example target sentence to be completed; The target sentence, the previous sentence, the prompt word, and the example are input into the language model together, and the completed target sentence corresponding to the target sentence output by the language model is obtained.
7. The method according to claim 6, further comprising: Comparing the target sentence and the previous sentence with a plurality of pre-stored examples for text similarity, wherein the examples include the previous sentence and the target sentence; Determine an example with the highest text similarity as the target example; The target sentence, the previous sentence, the prompt word, and the target example are input into the language model together, and the completed target sentence corresponding to the target sentence output by the language model is obtained.
8. The method according to claim 6, further comprising: Inputting the target sentence and the previous sentence, as well as an example previous sentence and an example target sentence in a plurality of pre-stored examples into a double-tower model; The twin tower model calculates text similarity by taking the absolute value of the difference; Determine an example with the highest text similarity as the target example; The target sentence, the previous sentence, the prompt word, and the target example are input into the language model together, and the completed target sentence corresponding to the target sentence output by the language model is obtained.
9. The method according to claim 1, wherein before performing keyword recognition on the target sentence to be processed and determining the keyword corresponding to the target sentence, the method further comprises: The target sentence is input into a text error correction model, and the corrected target sentence output by the text error correction model is obtained.
10. The method according to claim 1, wherein the step of performing intent recognition on the plurality of target sub-sentences respectively and determining that the plurality of target sub-sentences respectively correspond to intents comprises: Performing slot identification on the multiple target sub-sentences respectively, and performing template processing on the target sub-sentences using the identified slots; According to the flexible search of the ES database, the candidate sentences corresponding to the multiple target sub-sentences are determined, and the candidate intentions corresponding to the candidate sentences stored in the ES database are determined as the intentions of the corresponding target sub-sentences.
11. According to the method of claim 10, the step of determining the candidate sentences corresponding to the plurality of target sub-sentences respectively according to the flexible search of the ES database comprises: Sending the templated target sub-sentences to the ES database in sequence, and obtaining similar sentences and intentions of the similar sentences respectively corresponding to the target sub-sentences sent by the ES database; The similarities between the multiple target sub-sentences and the corresponding similar sentences are determined, and if the similarity with the largest value reaches a preset similarity threshold, the similar sentence corresponding to the similarity with the largest value is determined as the candidate sentence.
12. The method according to claim 11, further comprising: If there is a target sub-sentence to be processed whose corresponding maximum numerical similarity does not reach the preset similarity threshold; Input the target sub-sentence to be processed into the intent classification model, and obtain the intent classification model The intention corresponding to the target sub-sentence to be processed of the type output.
13. An electronic device comprising a processor and a memory, wherein the processor is used to implement the steps of the semantic understanding method as described in any one of claims 1 to 12 when executing a computer program stored in the memory.
14. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the semantic understanding method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Question and answer processing method and device, apparatus and storage medium
CN110287209A
Method and device for obtaining response verbal skill, computer equipment and storage medium
CN110765244A
Multi-intention identification method and related equipment
CN111738016A
Multi-round dialogue method and device based on artificial intelligence and storage medium
CN113806508A
Semantic understanding method and device
CN117034957A
Cited By
Power distribution system fault recovery method and device based on cooperation of large and small models
CN120012936A
Prompt word optimization method and system based on approximate submodule function and continuous learning
CN120597895A