A context-based semantic matching method, apparatus and device

By concatenating the sentence to be matched with the context and using a multiple-choice reading comprehension model for semantic prediction, the problems of high construction cost, poor robustness and slow inference speed in existing technologies are solved, and efficient intent recognition in automotive business scenarios is achieved.

CN116070637BActive Publication Date: 2026-07-14IFLYTEK CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
IFLYTEK CO LTD
Filing Date
2022-12-12
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing contextual reasoning methods suffer from high construction costs, poor robustness, slow reasoning speed, and insufficient scalability in automotive business scenarios, especially in multi-turn dialogue interactions where it is difficult to accurately identify the intentions of sales personnel and users.

Method used

A multi-choice reading comprehension model is adopted. The sentence to be matched is concatenated with the context and then input into the machine reading comprehension model for semantic prediction. By filtering knowledge base tags and using the BERT model for semantic matching, sentences are classified into sentences that require context and sentences that do not require context.

Benefits of technology

It improves the model's inference efficiency and robustness, reduces construction costs, and is scalable, enabling it to more accurately identify intents in multi-turn dialogues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116070637B_ABST
    Figure CN116070637B_ABST
Patent Text Reader

Abstract

The application discloses a context-based semantic matching method, device and equipment, the semantic matching method comprises the following steps: splicing a to-be-matched sentence and its context in sequence to form a context text; splicing all second labels in a first knowledge base to obtain a candidate answer; inputting the to-be-matched sentence, the context text and the candidate answer into a machine reading comprehension model to obtain a probability distribution of the to-be-matched sentence on each candidate answer, and taking a first label of a candidate answer corresponding to the maximum probability as a semantic prediction result of the to-be-matched sentence. The application adopts a multiple-choice reading comprehension scheme to reconstruct the task, the model is simple, the reasoning efficiency can be obviously improved, and the model has scalability; meanwhile, data in the knowledge base are sentences and labels, a database with context is not needed, the model construction cost is reduced, and the robustness of the model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a context-based semantic matching method, apparatus, and device. Background Technology

[0002] With the development of the internet age, countless pieces of information have exploded, making manual processing of massive amounts of text extremely complex and time-consuming. Intent recognition primarily involves automatically matching specific semantic tags required for business scenarios from large amounts of sales and customer dialogue text. It automatically categorizes and reconstructs massive amounts of content, extracting important information from unstructured text and using deep learning models to identify semantics within the text. Intent recognition involves tasks such as keyword matching and semantic matching. Taking the automotive industry as an example, by performing semantic matching on dialogue text in car sales scenarios, we can obtain relevant salesperson language tags in a conversation, such as customer greetings and introductions to car body colors. This transforms manual sampling inspection into fully automated quality inspection and scoring, solving the problems of low coverage in sampling inspections and the high subjectivity and low efficiency of manual quality inspections.

[0003] As the number of dialogue rounds increases, a single sales process may involve multiple rounds of interaction. Matching only single sentences of text cannot accurately represent the intentions of both the salesperson and the user. For example, Figure 1 In the dialogue shown, the salesperson's "Hello Xiaohu" would be mistakenly identified as a customer greeting by single-sentence text matching. However, by considering the salesperson's "Try the navigation" mentioned above and / or the navigation's "Please speak" mentioned below, it can be inferred that the actual intention of this sentence is no intention.

[0004] Therefore, relevant contextual information needs to be introduced for intent reasoning in order to obtain the true intent.

[0005] Existing contextual reasoning methods fall into two categories:

[0006] 1. Sliding window approach: In order to obtain the relevant context of the sentence to be matched, a sliding window is used to take the n tokens or m sentences before and after the sentence and concatenate them with the sentence to be matched as additional information to assist the semantic matching model in matching sentences in the knowledge base.

[0007] The sliding window approach simply concatenates the text. For this type of sentence matching, to achieve better model performance, a contextual knowledge base needs to be built for the semantic matching model. This requires extensive annotation and is labor-intensive. Furthermore, due to the richness of the contextual expressions, the constructed contextual knowledge base is not robust to matching.

[0008] 2. Contextual Semantic Representation: Currently, deep learning typically addresses contextual issues by encoding the contextual text into a semantic representation, fusing it with the sentence to be matched, and then making a judgment. The specific method is as follows:

[0009] 1) Direct concatenation: The context representation and sentence representation obtained by the encoder are concatenated and passed through a fully connected layer to obtain the probability distribution of the corresponding category.

[0010] 2) Dot product: The context representation matrix and sentence representation matrix obtained by the encoder are multiplied by the dot product, and then passed through a fully connected layer to obtain the probability distribution of the corresponding category.

[0011] 3) Gated Unit Fusion: The context representation matrix obtained by the encoder and the sentence are passed through a gated unit to obtain the fused representation. The fused representation is then passed through a fully connected layer to obtain the probability distribution of the corresponding category.

[0012] 4) Encoder optimization: During the encoding process, the context representation and sentence representation are fused together to output a fused representation.

[0013] However, because the semantic representation method described above treats intent recognition as a classification task, the categories supported by the classification model are fixed and lack scalability. When a new category needs to be added, the classification model must be retrained, thus losing the advantages of the semantic matching model.

[0014] Furthermore, the first three contextual semantic representation methods mentioned above can introduce contextual information by simply fusing the encoded contextual representations to assist semantic matching models in prediction, but the improvement in performance is limited and there is no significant improvement in the current automotive business scenario. Meanwhile, in the fourth encoder optimization method, the model parameters increase exponentially, the inference speed slows down significantly, and the performance is unstable, making it unsuitable for practical use in real automotive applications. Summary of the Invention

[0015] In view of the above, the present invention aims to provide a context-based semantic matching method, apparatus, and device. This method involves concatenating the sentence to be matched with its context and inputting it into a multiple-choice reading comprehension model for semantic prediction. The task is reconstructed using a multiple-choice reading comprehension scheme. The model is simple, significantly improves reasoning efficiency, and is scalable. Furthermore, the knowledge base contains sentences and tags, eliminating the need for a context-based database, thus reducing model construction costs and improving model robustness.

[0016] The technical solution adopted in this invention is as follows:

[0017] In a first aspect, the present invention provides a context-based semantic matching method, comprising:

[0018] The sentence to be matched is concatenated with its preceding and following text in order to form the context text;

[0019] Concatenate all the second tags in the first knowledge base to obtain the candidate answer;

[0020] The sentence to be matched, the context text, and the candidate answers are input into the machine reading comprehension model to obtain the probability distribution of the sentence to be matched on each candidate answer, and the first label of the candidate answer with the highest probability is used as the semantic prediction result of the sentence to be matched.

[0021] In one possible implementation, the semantic matching method also includes:

[0022] Filter the second tags in the first knowledge base to obtain candidate tags;

[0023] Concatenate all candidate labels to obtain the candidate answer.

[0024] In one possible implementation, the second tags in the first knowledge base are filtered to obtain candidate tags, including:

[0025] Input the sentence to be matched into the matching model, obtain the first matching value between each tagged sentence in the first knowledge base of the matching model and the sentence to be matched, and obtain the second matching value between the second tag of each category in the first knowledge base and the sentence to be matched, where each tagged sentence corresponds to the second tag of one category;

[0026] Sort all the second matching values ​​of the second tags and select the second tag with the largest number of second matching values ​​as the candidate tag.

[0027] In one possible implementation, the semantic matching method also includes:

[0028] Determine whether the sentence to be matched needs context during the semantic matching process;

[0029] If so, then semantic prediction is performed using a machine reading comprehension model.

[0030] In one possible implementation, the tag with the largest second matching value is used as the third tag of the sentence to be matched.

[0031] In one possible implementation, if the sentence to be matched does not require context during the semantic matching process, the third label is used as the semantic prediction result of the sentence to be matched.

[0032] In one possible implementation, if the pre-defined number of tags with the largest second matching value do not include tags without intent, then the tag with the smallest second matching value among the candidate tags is replaced with a tag without intent.

[0033] In one possible implementation, the matching value of the second tag of each category in the first knowledge base with the sentence to be matched is the average of the first matching values ​​of all tagged sentences with the second tag of the category.

[0034] In one possible implementation, when training the matching model, the input data is unlabeled sentences, and the output is the fourth label of the unlabeled sentences.

[0035] Secondly, the present invention provides a context-based semantic matching device, including an inference module, which includes a first splicing module, a second splicing module, and a prediction module.

[0036] The first concatenation module is used to concatenate the sentence to be matched with its preceding and following text in sequence to form context text;

[0037] The second splicing module is used to splice together all the second tags in the first knowledge base as candidate answers;

[0038] The prediction module is used to input the sentence to be matched, the context text, and the candidate answers into the machine reading comprehension model, obtain the probability distribution of the sentence to be matched on each candidate answer, and take the first label of the candidate answer with the highest probability as the semantic prediction result of the sentence to be matched.

[0039] In one possible implementation, the reasoning module further includes a filtering module, which is used to filter the second tags in the first knowledge base to obtain candidate tags;

[0040] The second concatenation module is used to concatenate all candidate labels to form a candidate answer.

[0041] In one possible implementation, the filtering module includes a matching module and a sorting module;

[0042] The matching module is used to input the sentence to be matched into the matching model, obtain the first matching value between each tagged sentence in the first knowledge base of the matching model and the sentence to be matched, and obtain the second matching value between the second tag of each category in the first knowledge base and the sentence to be matched, wherein each tagged sentence corresponds to the second tag of one category;

[0043] The sorting module is used to sort the second matching values ​​of all second tags and select the second tag with the largest number of second matching values ​​as the candidate tag.

[0044] In one possible implementation, the filtering module further includes a replacement module, which is used to replace the label with the smallest second matching value among the candidate labels with the label without intention when the label with the largest second matching value is not included in the preset number of labels with the largest second matching value.

[0045] Thirdly, the present invention provides a context-based semantic matching device, comprising:

[0046] One or more processors, memory, and one or more computer programs, wherein the one or more computer programs are stored in memory, and the one or more computer programs include instructions that, when executed by a semantic matching device, cause the semantic matching device to perform the aforementioned context-based semantic matching method.

[0047] The present invention provides a context-based semantic matching method, apparatus, and device. By concatenating the sentence to be matched with its context and inputting it into a machine reading comprehension model for semantic prediction, the task is reconstructed using a multi-choice reading comprehension scheme. The model is simple, significantly improves reasoning efficiency, and is scalable. Simultaneously, the data in the knowledge base consists of individual sentences and their tags, eliminating the need for contextual data, thus reducing model construction costs and improving model robustness. The invention effectively improves the model's prediction performance by filtering tags in the first knowledge base to provide the machine reading comprehension model with a preset number of tags that maximize matching values. Furthermore, the invention categorizes sentences into two classes based on whether context is required for semantic matching, only sending sentences requiring context to the machine reading comprehension model for prediction, which effectively improves reasoning speed. Attached Figure Description

[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described below with reference to the accompanying drawings, wherein:

[0049] Figure 1 This is an example of a single-sentence matching method in the prior art;

[0050] Figure 2 A flowchart of a first embodiment of the context-based semantic matching method provided by the present invention;

[0051] Figure 3 A flowchart of a second embodiment of the context-based semantic matching method provided by the present invention;

[0052] Figure 4 A schematic diagram of a preferred embodiment of the context-based semantic matching device provided by the present invention;

[0053] Figure 5 This is a schematic diagram of the structure of the context-based semantic matching device provided by the present invention. Detailed Implementation

[0054] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0055] The present invention provides a context-based semantic matching method, apparatus, and device. By concatenating the sentence to be matched with its context and inputting it into a machine reading comprehension model for semantic prediction, the task is reconstructed using a multi-choice reading comprehension scheme. The model is simple, significantly improves reasoning efficiency, and is scalable. Simultaneously, the data in the knowledge base consists of individual sentences and their tags, eliminating the need for contextual data, thus reducing model construction costs and improving model robustness. The invention effectively improves the model's prediction performance by filtering tags in the first knowledge base to provide the machine reading comprehension model with a preset number of tags that maximize matching values. Furthermore, the invention categorizes sentences into two classes based on whether context is required for semantic matching, only sending sentences requiring context to the machine reading comprehension model for prediction, which effectively improves reasoning speed.

[0056] It should be noted that the semantic matching object of the present invention can be a single sentence to be matched, and its input data is a single sentence to be matched and its context. The semantic matching object can also be one or more sentences in a dialogue text (e.g., a sales dialogue), that is, the input data is a dialogue text, which may include one or more rounds of dialogue, and at least one sentence in the dialogue text is used as the sentence to be matched.

[0057] The following explanation uses a single sentence to be matched as the semantic matching object. Based on this, when the input data is a dialogue text, the implementation of this invention involves simultaneously performing semantic matching of a single sentence to be matched on multiple sentences within the dialogue text.

[0058] To address the aforementioned core concept, this invention provides an embodiment of at least one context-based semantic matching method that can utilize Machine Reading Comprehension (MRC) models for semantic prediction. MRC is a technology where machines automatically answer user-posed questions based on given text. In one possible implementation, this invention employs a multiple-choice reading comprehension model, where given a question, multiple candidate answers, and a text, the answer to the question is predicted through reasoning.

[0059] In one possible implementation, MRC includes a 12-layer Transformer-based Bidirectional Encoder Representations from Transformer (BERT) model.

[0060] In one possible implementation, such as Figure 2 As shown, semantic prediction using MRC includes the following steps:

[0061] S210: Concatenate the sentence to be matched with its preceding and following text in order to form the context text (i.e., the article in the model input data).

[0062] S220: Concatenate all the second tags in the first knowledge base to obtain the candidate answer.

[0063] The data in the first knowledge base consists of tagged sentences. Each tagged sentence has a second tag that corresponds to its intent category, meaning that each tagged sentence corresponds to a second tag for a category.

[0064] S230: Input the sentence to be matched (i.e. the question in the model input data), the context text, and the candidate answers into the machine reading comprehension model, obtain the probability distribution of the sentence to be matched on each candidate answer, and take the first label of the candidate answer with the highest probability as the semantic prediction result of the sentence to be matched.

[0065] In a preferred implementation, in order to narrow the prediction range and improve the reasoning effect of MRC, the second tags in the first knowledge base are filtered to obtain candidate tags, and all candidate tags are concatenated to form a candidate answer.

[0066] In one possible implementation, a matching model is used to filter the second label. During the training phase of the matching model, the training task is a regular classification task, trained based on labeled data. Unlabeled sentences are used as input to the semantic matching model to obtain the sentence representation of the unlabeled sentence. This sentence representation is then input into a fully connected layer to obtain the probability distribution of the unlabeled sentence. The class with the highest probability is the output class (i.e., the fourth label corresponding to the unlabeled sentence). After training, each unlabeled sentence is labeled with its corresponding label to form labeled sentences. All labeled sentences constitute the first knowledge base of the matching model.

[0067] During the inference phase, the matching model's task is not classification, but rather to simultaneously input the labeled sentences from the first knowledge base and the sentences to be matched into the matching model and calculate their matching values.

[0068] In one possible implementation, the matching model includes a 6-layer BERT model.

[0069] Specifically, filtering the second label using a matching model includes the following steps:

[0070] P1: Input the sentence to be matched into the matching model, obtain the first matching value between each tagged sentence and the sentence to be matched in the first knowledge base of the matching model, and obtain the second matching value between the second label of each category and the sentence to be matched in the first knowledge base, where each tagged sentence corresponds to the second label of a category.

[0071] In one possible implementation, the sentence to be matched and all labeled sentences in the first knowledge base are input into a trained matching model to obtain sentence representations. Then, the similarity (e.g., cosine similarity) between the sentence representation of the sentence to be matched and the sentence representations of all labeled sentences is calculated to obtain a first matching value. Furthermore, the average (or variance, standard deviation) of the first matching values ​​of labeled sentences with the same second label category is calculated as the second matching value for that category's second label.

[0072] Based on this, the tag with the largest second matching value is used as the third tag of the sentence to be matched.

[0073] P2: Sort all the second matching values ​​of the second tags and select the second tag with the largest number of second matching values ​​as the candidate tag.

[0074] In one possible implementation, the second tag with the largest second matching value among the preset number of tags is directly used as the candidate tag, and candidate answers are formed accordingly. For example, if the preset number is 6, the six second tags can be concatenated in descending order of their second matching values ​​to form candidate answers.

[0075] It should be noted that in the first knowledge base, sentences that are not in the explicit intent category that the current model can identify are all marked as no intent. That is, in the knowledge base, one type of the second label is the no intent label, and the other types of the second label all correspond to explicit intent.

[0076] While the above filtering process works well for intentional data, the presence of some interfering data in the knowledge base means that obtaining a second matching value using this method can effectively reduce the impact of some low-quality sentences. However, when dealing with all data, the second matching value drops significantly. This is mainly because the expressions in data with no intentional tags are diverse. During the matching process, the first matching value of tagged sentences with no intentional tags is generally low. Therefore, once the overall score of no intentional tags is averaged, it will be significantly lower than the average of other intentional tags. Consequently, no no intentional tags will appear in the candidate tags. Therefore, the semantic matching results based on this filtering result will not contain any no intentional predictions. However, there is often a high probability of no intentional utterances in a dialogue, which will affect the overall semantic matching effect.

[0077] Based on the above explanation, in a preferred implementation, in step P2, if the preset number of tags with the largest second matching value do not include tags without intent, then the tag with the smallest second matching value among the candidate tags is replaced with a tag without intent, thereby forming a new set of candidate tags, and a candidate answer is constructed based on this. Otherwise, if the preset number of tags with the largest second matching value include tags without intent, then the candidate answer is directly constructed using the candidate tags. This ensures that tags without intent are present among the candidate tags.

[0078] Building upon the above, in a preferred implementation, to improve the inference speed of MRC, it is necessary to determine whether the sentence to be matched requires context during semantic matching. If so, semantic prediction is performed using a machine reading comprehension model (see the above explanation). Otherwise, the third label is used as the semantic prediction result of the sentence to be matched.

[0079] In one possible implementation, a context-aware model is used to determine whether the sentence to be matched needs context. Specifically, the sentence to be matched is input into the context-aware model to obtain a sentence representation. This sentence representation is then input into a fully connected layer to obtain a binary classification (i.e., context-aware and context-independent) probability distribution of the sentence to be matched, with the class with the highest probability being the output class.

[0080] In one possible implementation, the context-determining model comprises a 6-layer BERT model.

[0081] As can be seen from the above, if Figure 3 As shown, in a preferred implementation, the semantic matching method of the present invention includes:

[0082] S310: Determine whether the sentence to be matched needs context during semantic matching. If yes, execute S330; otherwise, execute S340.

[0083] S320: Filter the second tags in the first knowledge base to obtain candidate tags and the third tag. Then execute S330.

[0084] S330: Input the sentence to be matched and the candidate labels into the machine reading comprehension model for semantic prediction to obtain the semantic prediction result of the sentence to be matched.

[0085] S340: Use the third label as the semantic prediction result of the sentence to be matched.

[0086] It should be noted that the present invention does not restrict the execution order of S310 and S320 above; they can be executed sequentially or simultaneously.

[0087] Corresponding to the above embodiments and preferred solutions, the present invention also provides an embodiment of a context-based semantic matching device, such as... Figure 4 As shown, it may specifically include an inference module 410, which includes a first splicing module 4101, a second splicing module 4102, and a prediction module 4103.

[0088] The first splicing module 4101 is used to splice the sentence to be matched with its preceding and following text in sequence to form context text.

[0089] The second splicing module 4102 is used to splice together all the second tags in the first knowledge base as candidate answers.

[0090] The prediction module 4103 is used to input the sentence to be matched, the context text, and the candidate answers into the machine reading comprehension model, obtain the probability distribution of the sentence to be matched on each candidate answer, and take the first label of the candidate answer with the highest probability as the semantic prediction result of the sentence to be matched.

[0091] In one possible implementation, the reasoning module 410 further includes a filtering module 4104, which filters the second tags in the first knowledge base to obtain candidate tags. The second concatenation module 4102 concatenates all candidate tags to form a candidate answer.

[0092] In one possible implementation, the filtering module 4104 includes a matching module and a sorting module.

[0093] The matching module is used to input the sentence to be matched into the matching model, obtain the first matching value between each tagged sentence in the first knowledge base of the matching model and the sentence to be matched, and obtain the second matching value between the second tag of each category in the first knowledge base and the sentence to be matched, wherein each tagged sentence corresponds to the second tag of a category.

[0094] The sorting module is used to sort the second matching values ​​of all second tags and select the second tag with the largest number of second matching values ​​as the candidate tag.

[0095] In one possible implementation, the filtering module further includes a replacement module, which is used to replace the label with the smallest second matching value among the candidate labels with the label without intention when the label with the largest second matching value is not included in the preset number of labels with the largest second matching value.

[0096] In one possible implementation, the semantic matching device further includes a judgment module 420 and a result acquisition module 430. The judgment module 420 is used to determine whether the sentence to be matched needs context during the semantic matching process. The result acquisition module 430 is used to use the third label as the semantic prediction result of the sentence to be matched when the sentence to be matched does not need context.

[0097] The above should be understood Figure 4 The division of components in the semantic matching device shown is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. These components can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some components can be implemented in software via processing element calls, while others are implemented in hardware. For example, a particular module can be a separate processing element or integrated into a chip in an electronic device. The implementation of other components is similar. Furthermore, these components can be fully or partially integrated together, or implemented independently. During implementation, each step of the above method or each of the above components can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.

[0098] For example, these components can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, these components can be integrated together to form a System-On-a-Chip (SOC).

[0099] Based on the above embodiments and preferred solutions, those skilled in the art will understand that, in practice, the present invention is applicable to various implementation methods. The present invention is illustrated by the following carrier:

[0100] (1) A semantic matching device, which may include:

[0101] One or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the device, cause the device to perform the steps / functions of the foregoing embodiments or equivalent embodiments.

[0102] Figure 5 This is a schematic diagram illustrating the structure of an embodiment of the semantic matching device of the present invention. The device can be an electronic device or a circuit device built into such an electronic device. The electronic device can be a PC, server, smart terminal (mobile phone, tablet, watch, glasses, etc.), smart TV, audio equipment, speaker, set-top box, remote control, smart screen, ATM, robot, drone, ICV, smart (car) vehicle, and in-vehicle equipment, etc. This embodiment does not limit the specific form of the semantic matching device.

[0103] Specifically, such as Figure 5 As shown, the semantic matching device 900 includes an input unit 960, a display unit 970, a processor 910, and a memory 930. The processor 910 and the memory 930 can communicate with each other via an internal connection to transmit control and / or data signals. The memory 930 stores computer programs, and the processor 910 retrieves and runs the computer programs from the memory 930. The processor 910 and the memory 930 can be combined into a single processing device, but more commonly they are independent components. The processor 910 executes the program code stored in the memory 930 to achieve the aforementioned functions. In specific implementations, the memory 930 can be integrated into the processor 910, or it can be independent of the processor 910. The display unit 970 may include a display screen.

[0104] In addition, to further enhance the functionality of the semantic matching device 900, the device 900 may also include one or more of an audio circuit 980, a camera 990, and a sensor 901, etc. The audio circuit may also include a speaker 982, a microphone 984, etc.

[0105] Furthermore, the semantic matching device 900 may also include a power supply 950 for providing power to various devices or circuits in the device 900.

[0106] It should be understood that Figure 5The semantic matching device 900 shown can implement the various processes of the method provided in the foregoing embodiments. The operation and / or function of each component in the device 900 can respectively implement the corresponding processes in the above method embodiments. For details, please refer to the foregoing descriptions of the embodiments of methods, devices, etc., and detailed descriptions are appropriately omitted here to avoid repetition.

[0107] It should be understood that Figure 5 The processor 910 in the semantic matching device 900 shown can be a system-on-a-chip (SoC). The processor 910 may include a central processing unit (CPU) and may further include other types of processors, such as a graphics processing unit (GPU), which will be described in detail below.

[0108] In summary, the various processors or processing units inside the processor 910 can work together to implement the previous method flow, and the corresponding software programs of each processor or processing unit can be stored in the memory 930.

[0109] (2) A readable storage medium storing a computer program or the above-described device, which, when executed, causes a computer to perform the steps / functions of the foregoing embodiments or equivalent embodiments.

[0110] In several embodiments provided by this invention, any function, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, certain technical solutions of this invention, or the parts that contribute to the prior art, or parts of such technical solutions, can be embodied in the form of software products as described below.

[0111] (3) A computer program product (which may include the above-described apparatus) that, when run on a terminal device, causes the terminal device to execute the semantic matching method of the foregoing embodiments or equivalent embodiments.

[0112] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the above implementation methods can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the above-mentioned computer program products may include, but are not limited to, APP; continuing from the foregoing, the above-mentioned device / terminal may be a computer device (e.g., mobile phone, PC terminal, cloud platform, server, server cluster, or network communication device such as media gateway, etc.). Furthermore, the hardware structure of the computer device may specifically include: at least one processor, at least one communication interface, at least one memory, and at least one communication bus; the processor, communication interface, and memory can all communicate with each other through the communication bus. The processor may be a central processing unit (CPU), DSP, microcontroller, or digital signal processor, and may also include a GPU, an embedded neural network processing unit (NPU), and an image signal processor (ISP). The processor may also include a specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. Furthermore, the processor may have the function of operating one or more software programs, which may be stored in a storage medium such as a memory. The aforementioned memory / storage medium may include: non-volatile memory, such as a non-removable disk, USB flash drive, portable hard drive, optical disc, etc., as well as read-only memory (ROM), random access memory (RAM), etc.

[0113] In this embodiment of the invention, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, A and B simultaneously, or B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects have an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of singular or plural items. For example, at least one of a, b, and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, and c can be single or multiple.

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

[0115] Furthermore, the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. In particular, for embodiments such as apparatus and devices, since they are basically similar to the method embodiments, the relevant parts can be referred to the description of the method embodiments. The apparatus, devices, and other embodiments described above are merely illustrative, and the modules, units, etc., described as separate components may or may not be physically separate, that is, they may be located in one place or distributed in multiple places, such as nodes in a system network. Specifically, some or all of the modules and units can be selected according to actual needs to achieve the purpose of the above-described embodiment solutions. Those skilled in the art can understand and implement this without creative effort.

[0116] The above description of the structure, features, and effects of the present invention is based on the embodiments shown in the figures. However, the above are only preferred embodiments of the present invention. It should be noted that the technical features involved in the above embodiments and their preferred methods can be reasonably combined and matched by those skilled in the art to form a variety of equivalent solutions without departing from or changing the design concept and technical effects of the present invention. Therefore, the present invention is not limited to the scope of implementation shown in the figures. Any changes made in accordance with the concept of the present invention, or modifications to equivalent embodiments, that do not exceed the spirit covered by the specification and figures, should be within the protection scope of the present invention.

Claims

1. A context-based semantic matching method, characterized in that, include: A first knowledge base without context is constructed from labeled sentences, where each labeled sentence has a second label representing its intent category; The sentence to be matched is concatenated with its preceding and following text in order to form the context text; Based on the similarity between the sentence to be matched and each tagged sentence in the first knowledge base, the second tags in the first knowledge base are filtered to obtain candidate tags. All candidate tags are then concatenated to form a candidate answer. The sentence to be matched, the context text, and the candidate answers are input into a machine reading comprehension model to obtain the probability distribution of the sentence to be matched on each candidate answer, and the label of the candidate answer with the highest probability is used as the semantic prediction result of the sentence to be matched.

2. The context-based semantic matching method according to claim 1, characterized in that, Methods for filtering the second tags in the first knowledge base to obtain candidate tags include: The sentence to be matched is input into the matching model to obtain the first matching value between each tagged sentence in the first knowledge base of the matching model and the sentence to be matched, and the second matching value between the second tag of each intent category in the first knowledge base and the sentence to be matched is obtained. Sort all the second matching values ​​of the second tags and select the second tag with the largest number of second matching values ​​as the candidate tag.

3. The context-based semantic matching method according to claim 1, characterized in that, Also includes: Determine whether the sentence to be matched requires context during the semantic matching process; If so, semantic prediction is performed using the machine reading comprehension model.

4. The context-based semantic matching method according to claim 2, characterized in that, The tag with the largest second matching value is used as the third tag of the sentence to be matched.

5. The context-based semantic matching method according to claim 4, characterized in that, If the sentence to be matched does not require context during the semantic matching process, the third label is used as the semantic prediction result of the sentence to be matched.

6. The context-based semantic matching method according to claim 2, characterized in that, If the preset number of tags with the largest second matching value do not include tags without intent, then the tag with the smallest second matching value among the candidate tags will be replaced with a tag without intent.

7. The context-based semantic matching method according to claim 2, characterized in that, The matching value between the second tag of each category in the first knowledge base and the sentence to be matched is the average of the first matching values ​​of all tagged sentences with the second tag of the category.

8. The context-based semantic matching method according to claim 2, characterized in that, When training the matching model, the input data is unlabeled sentences, and the output is the fourth label of the unlabeled sentences.

9. A context-based semantic matching device, characterized in that, It includes an inference module, which comprises a first splicing module, a filtering module, a second splicing module, and a prediction module; The first splicing module is used to splice the sentence to be matched with its preceding and following text in sequence to form context text; The filtering module is used to filter the second tags in the first knowledge base based on the similarity between the sentence to be matched and each tagged sentence in the first knowledge base, so as to obtain candidate tags; The second splicing module is used to splice all candidate labels together as candidate answers; wherein, a first knowledge base without context data is constructed from labeled sentences, and each labeled sentence has a second label representing its intention category; The prediction module is used to input the sentence to be matched, the context text, and the candidate answers into a machine reading comprehension model to obtain the probability distribution of the sentence to be matched on each candidate answer, and to use the label of the candidate answer with the highest probability as the semantic prediction result of the sentence to be matched.

10. The context-based semantic matching device according to claim 9, characterized in that, The filtering module includes a matching module and a sorting module; The matching module is used to input the sentence to be matched into the matching model, obtain the first matching value between each tagged sentence in the first knowledge base of the matching model and the sentence to be matched, and obtain the second matching value between the second tag of each intent category in the first knowledge base and the sentence to be matched. The sorting module is used to sort the second matching values ​​of all second tags and select the second tag with the largest number of second matching values ​​as a candidate tag.

11. The context-based semantic matching device according to claim 10, characterized in that, The filtering module further includes a replacement module, which is used to replace the label with the smallest second matching value among the candidate labels with a label without intent when the preset number of labels with the largest second matching value do not include labels without intent.

12. A context-based semantic matching device, characterized in that, include: One or more processors, a memory, and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions that, when executed by the semantic matching device, cause the semantic matching device to perform the context-based semantic matching method as described in any one of claims 1 to 8.