A semantic recognition method, device, electronic device and computer-readable storage medium
By calculating the similarity between the intention sentence and the reference sentence, the problem of excessive resource occupancy in the existing technology is solved, a method of efficiently identifying the user's intention is realized, the resource occupancy is reduced and the judgment accuracy is improved.
Patent Information
- Application Number
- CN201910364347.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-30
- Publication Date
- 2024-09-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, due to the various forms of language expression combinations and the large amount of information, the sentence library is too large and takes up too many resources, making it difficult to efficiently identify user intentions.
Calculate the similarity between the intended sentence and the reference sentence through a preset algorithm to determine the semantic attributes of the intended sentence and reduce the occupation of resources. Use the Euclidean distance algorithm, cosine distance algorithm or inner product algorithm to calculate the similarity and select the similarity. The highest base sentence serves as the semantic property of the intentional sentence.
It achieves efficient identification of user intentions without the need for a large corpus, reduces resource usage, improves the accuracy of judgment, and further optimizes the judgment results by updating the benchmark sentences.
Smart Images

Figure CN111858865B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of semantic recognition, and in particular to a semantic recognition method, device, electronic device and computer-readable storage medium. Background Art
[0002] Some smart devices (such as smart speakers) or smart services (such as robot customer service) will determine the user's intention by asking questions in certain states. The user can answer by voice or text to express affirmation or negation. The smart device or service needs to determine whether the user is expressing affirmation or negation based on the intention sentence to enter different processing flows.
[0003] In the prior art, a large number of affirmative / negative sentences are usually collected through text matching (if it is speech, it is converted into text) to form a sentence library. If the user's intended sentence matches the sentence in the library, it is judged as the corresponding category. On this basis, it can be expanded to fuzzy matching, or a binary classifier can be realized by annotating data: through manual annotation, a large number of affirmative / negative sentences are collected as corpus, and then a certain machine learning algorithm is used to train the corpus to obtain a binary classifier.
[0004] However, if the existing technology is used, due to the various combinations of language expressions, a large amount of information will cause the sentence library to be too large and occupy too many resources. Summary of the invention
[0005] In view of this, the purpose of the present application is to provide a semantic recognition method, device, electronic device and computer-readable storage medium, which can calculate the similarity between the intended sentence and the benchmark sentence through a preset algorithm, so as to determine the semantic attributes of the intended sentence, and solve the problem existing in the prior art that due to the various combinations of language expressions and a large amount of information, the sentence library will be too large and occupy too many resources, thereby achieving the effect of reducing resource occupation.
[0006] In a first aspect of the present application, the present application provides a semantic recognition method, comprising:
[0007] Receive the user's intention statement for the target scenario;
[0008] Using a preset similarity algorithm to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences;
[0009] A preset reference sentence matching the intended sentence is determined according to the similarity, and a semantic attribute of the intended sentence is obtained according to the preset reference sentence matching the intended sentence.
[0010] Optionally, before respectively calculating the similarities between the intended sentence and a plurality of preset reference sentences using a preset similarity algorithm, the method further includes:
[0011] A plurality of preset reference sentences corresponding to the target scene are obtained, wherein the plurality of preset reference sentences include: affirmative reference sentences and negative reference sentences.
[0012] Optionally, the use of a preset similarity algorithm to respectively calculate the similarity between the intended sentence and multiple preset benchmark sentences includes: calculating the intended sentence vector corresponding to the intended sentence according to a preset model; and using a preset similarity algorithm to respectively calculate the similarity between each of the intended sentence vectors and the benchmark sentence vector corresponding to each of the preset benchmark sentences.
[0013] Optionally, the using a preset similarity algorithm to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences includes:
[0014] Calculate the intention sentence vector corresponding to the intention sentence according to the preset model;
[0015] A preset similarity algorithm is used to calculate the similarity between each of the intended sentence vectors and the reference sentence vector corresponding to each of the preset reference sentences.
[0016] Optionally, determining a target reference sentence matching the intended sentence according to the similarity, and acquiring a semantic attribute of the intended sentence according to the target reference sentence matching the intended sentence, includes:
[0017] Selecting a preset reference sentence having the highest similarity to the intended sentence as the target reference sentence;
[0018] The semantic attributes of the target reference sentence are used as the semantic attributes of the intended sentence.
[0019] Optionally, after determining a target reference sentence matching the intended sentence according to the similarity and acquiring a semantic attribute of the intended sentence according to the target reference sentence matching the intended sentence, the method further includes:
[0020] Acquire accuracy information corresponding to the semantic attributes of the intention statement.
[0021] Optionally, after obtaining the accuracy information corresponding to the semantic attribute of the intention statement, the method further includes:
[0022] If the accuracy information does not meet the preset requirement, preset benchmark sentence update information is received, and the preset benchmark sentence update information includes a new preset benchmark sentence corresponding to the target scene.
[0023] Furthermore, the preset similarity algorithm is any one of the following: Euclidean distance algorithm, cosine distance algorithm, inner product algorithm.
[0024] In a second aspect of the present application, the present application further provides a semantic recognition device, the device comprising: a receiving module, a calculating module, and a determining module, wherein:
[0025] The receiving module is used to receive the intention statement input by the user for the target scenario;
[0026] The calculation module is used to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences using a preset similarity algorithm;
[0027] The determination module is used to determine a preset reference sentence matching the intended statement according to the similarity, and obtain the semantic attribute of the intended statement according to the preset reference sentence matching the intended statement.
[0028] Optionally, it further includes a first acquisition module; the first acquisition module is used to acquire a plurality of preset reference sentences corresponding to the target scene, wherein the plurality of preset reference sentences include: affirmative reference sentences and negative reference sentences.
[0029] Optionally, the calculation module is specifically used to calculate the intention sentence vector corresponding to the intention sentence according to a preset model;
[0030] A preset similarity algorithm is used to calculate the similarity between each of the intended sentence vectors and the reference sentence vector corresponding to each of the preset reference sentences.
[0031] Optionally, the determination module is specifically configured to select a preset reference sentence having the highest similarity to the intended sentence as the target reference sentence;
[0032] The semantic attributes of the target reference sentence are used as the semantic attributes of the intended sentence.
[0033] Optionally, the device further includes a second acquisition module; the second acquisition module is used to acquire accuracy information corresponding to the semantic attributes of the intention statement.
[0034] Optionally, an updating module is further included, wherein if the accuracy information does not meet the preset requirement, the updating module is used to receive preset benchmark sentence updating information, wherein the preset benchmark sentence updating information includes a new preset benchmark sentence corresponding to the target scene.
[0035] Optionally, the preset similarity algorithm is any one of the following: Euclidean distance algorithm, cosine distance algorithm, inner product algorithm.
[0036] In the third aspect of the present application, an electronic device is provided, a processor, a storage medium and a bus, the storage medium stores machine-readable instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, the processor executes the machine-readable instructions to perform the steps of any method described in the first aspect. In the fourth aspect of the present application, the present application also provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is run by the processor, the steps of any method described in the first aspect are performed.
[0037] Based on any of the above aspects, the similarity between the intended sentence and the benchmark sentence can be calculated according to a preset algorithm to determine the semantic attributes of the intended sentence, and a large corpus is not required. The problem existing in the prior art that a large amount of information will lead to a large sentence library and occupy too many resources due to the diverse combinations of language expressions has never been solved, thereby achieving the effect of reducing resource occupation.
[0038] In addition, in some embodiments, the benchmark sentence can determine the feedback result of the semantic attribute according to the intention sentence, and update and adjust the benchmark sentence to further ensure the accuracy of the judgment. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 A schematic diagram of the architecture of a semantic recognition system provided by an embodiment of the present application is shown;
[0041] Figure 2 A flowchart of a semantic recognition method provided by an embodiment of the present application is shown;
[0042] Figure 3 A flowchart of a semantic recognition method provided by another embodiment of the present application is shown;
[0043] Figure 4 A flowchart of a semantic recognition method provided by another embodiment of the present application is shown;
[0044] Figure 5 A schematic diagram of the structure of a semantic recognition device provided by an embodiment of the present application is shown;
[0045] Figure 6A schematic diagram of the structure of a semantic recognition device provided by another embodiment of the present application is shown;
[0046] Figure 7 A schematic diagram of the structure of a semantic recognition device provided by another embodiment of the present application is shown;
[0047] Figure 8 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0048] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0049] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0050] In order to enable those skilled in the art to use the contents of this application, the following implementation methods are provided in combination with specific application scenarios such as "hailing a taxi" or "listening to music". For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is mainly described around hailing a taxi or listening to music, it should be understood that this is only an exemplary embodiment, and this application can be applied to various scenarios that require semantic recognition and semantic classification.
[0051] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0052] One aspect of the present application relates to a semantic recognition system. The system can calculate the similarity between an intended sentence and a reference sentence through a preset algorithm, thereby determining the semantic attributes of the intended sentence, wherein the semantic attributes can be used to represent the classification of the intended sentence, such as affirmative sentences, negative sentences, interrogative sentences, etc., which are not limited here.
[0053] It is worth noting that before the present application was filed, the prior art usually collected a large number of affirmative / negative intention sentences through text matching to form a sentence library. If the user's intended sentence matches the sentence in the library, it is judged as the corresponding category. On this basis, it can be expanded to fuzzy matching, or a binary classifier can be realized by annotating data: through manual annotation, a large number of affirmative / negative sentences are collected as corpus, and then a certain machine learning algorithm is used to train the corpus to obtain a binary classifier. However, if the prior art is used, due to the variety of language expression combinations, a large amount of information will cause the sentence library to be too large and occupy too many resources.
[0054] The semantic recognition method provided by the present application can calculate the similarity between the intended sentence and the reference sentence through a preset algorithm, thereby determining the semantic attributes of the intended sentence. Among them, the reference sentence can be a relatively representative sentence in the category to which it belongs. Therefore, through the scheme proposed by the present application, a large number of corpora may not be required, thereby solving the problem in the prior art that due to the various forms of language expression combinations, a large amount of information will lead to an excessively large sentence library and occupy too many resources, thereby achieving the effect of reducing resource occupation.
[0055] Figure 1 1 is a schematic diagram of the architecture of a semantic recognition system 100 provided in an embodiment of the present application. For example, the semantic recognition system 100 may be used for transportation services such as taxis, chauffeur services, express trains, carpooling, bus services, or shuttle services, or any platform or scenario involving smart devices or intelligent services such as families and voice customer service. The semantic recognition system 100 may include one or more of a server 110, a network 120, a service terminal 130, and a database 140.
[0056] In some embodiments, the server 110 may include a processor. The processor may process information and / or data related to the service request to perform one or more functions described in the present application. For example, the processor may be based on the service request obtained from the service terminal 130 to the user's intent. In some embodiments, the processor may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). By way of example only, the processor may include a central processing unit (CPU), an application specific integrated circuit (ASIC), an application specific instruction set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC), or a microprocessor, or any combination thereof.
[0057] In some embodiments, the device type corresponding to the service terminal 130 may be a mobile device, such as a smart home device, a wearable device, a smart mobile device, a virtual reality device, or an augmented reality device, etc., or a tablet computer, a laptop computer, or a built-in smart device in a motor vehicle, etc. Taking the "listening to music" scenario as an example, the service terminal 130 may be a user's mobile phone. The user opens a music listening client through the mobile phone, and the server pushes questions to the music listening client, such as "Do you want to listen to music now?" The user can reply through the reply function of the client, and the client identifies the semantic attributes of the intention statement according to the intention statement replied by the user.
[0058] In some embodiments, the database 140 can be connected to the network 120 to communicate with one or more components in the semantic recognition system 100 (e.g., the server 110, the service terminal 130, the service provider 140, etc.). One or more components in the semantic recognition system 100 can access data or instructions stored in the database 140 via the network 120. In some embodiments, the database 140 can be directly connected to one or more components in the semantic recognition system 100, or the database 140 can also be part of the server 110.
[0059] The following is combined with the above Figure 1 The contents described in the illustrated semantic recognition system 100 provide a detailed description of the semantic recognition method provided in the embodiment of the present application. The following semantic recognition method is applied to the above system. The execution subject may be a service terminal or a server. The preset scenarios may be designed and adjusted according to user needs. Any scenario involving smart terminals or smart services may be used, and is not limited to the two scenarios given in the embodiment.
[0060] Reference Figure 2 FIG. 1 is a flow chart of a semantic recognition method provided by an embodiment of the present application. The method can be executed by a server 110 or a service terminal in the semantic recognition system 100, and includes:
[0061] S101: receiving an intention statement input by a user for a target scenario.
[0062] It should be noted that the target scenario can be various interaction scenarios preset by the server, such as scenario statements pushed by the server.
[0063] Some smart devices (such as smart speakers, smart boxes, smartphones, etc.) or smart services (such as robot customer service, etc.) will determine the user's true intention by asking and receiving the user's intention statement in certain states, and make relevant answers or complete the relevant user's commands based on the user's true intention. For example, a target scenario is that after the user opens the car-hailing client, the client issues a voice prompt "Do you want to call an express car now?"
[0064] The inquiry method of the smart device or smart service can be voice inquiry or text inquiry. The specific inquiry method can be flexibly adjusted and is not limited here.
[0065] Among them, the input method of the user's intention statement can be manual text input or voice input. The specific input method is set or switched according to user needs and is not limited here.
[0066] It should also be noted that if the execution subject is a terminal, the intention statement is received directly through the input device. If the execution subject is a server, the terminal sends the received intention statement to the server.
[0067] S102: using a preset similarity algorithm to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences.
[0068] The preset benchmark sentences may be pre-configured according to different target scenarios, and the semantic attributes corresponding to each preset benchmark sentence may also be pre-marked.
[0069] It should be noted that the vector distance can be used to measure the similarity between the intended sentence and the preset reference sentence.
[0070] For example, the preset similarity algorithm can be any of the following: Euclidean distance algorithm (the smaller the distance, the greater the similarity), cosine distance algorithm (the smaller the distance, the greater the similarity), inner product algorithm (the larger the inner product, the greater the similarity). The selection of the specific algorithm is designed according to needs and is not limited here.
[0071] S103: Determine a preset reference sentence matching the intended sentence according to the similarity, and obtain the semantic attribute of the intended sentence according to the preset reference sentence matching the intended sentence.
[0072] It should be noted that the smart device or smart service needs to judge the semantic attributes of the user based on the similarity between the intent sentence and the preset benchmark sentence.
[0073] Among them, the judgment basis is: determining the preset benchmark sentence that matches the intention statement based on the similarity, that is, when the similarity between the intention statement and a preset benchmark sentence is the highest, the benchmark sentence is the preset benchmark sentence that matches the intention statement, and determining and obtaining the semantic attributes of the intention statement based on the preset benchmark sentence, and then the smart device or smart service enters different processing flows according to the different semantic attributes of the intention statement.
[0074] By adopting the semantic recognition method provided in the embodiment of the present application, the similarity between the intended sentence and the preset benchmark sentence can be calculated according to the preset algorithm, so as to determine the semantic attributes of the intended sentence, wherein the preset benchmark sentences for different scenarios can be a small number of typical sentences, and a large corpus is no longer required, thereby solving the problem existing in the prior art that due to the variety of language expression combinations and a large amount of information, the sentence library will be too large and occupy too many resources, thereby achieving the effect of reducing resource occupation.
[0075] Figure 3 A flowchart of a semantic recognition method provided by another embodiment of the present application is shown in FIG. Figure 3 As shown, before step S102, the following steps are also included:
[0076] S104: Acquire multiple preset reference sentences corresponding to the target scene.
[0077] Among them, the multiple preset benchmark sentences include: affirmative benchmark sentences and negative benchmark sentences.
[0078] It should be noted that, in one embodiment of the present application, the number of preset reference sentences corresponding to a target scenario is two, namely, an affirmative reference sentence and a negative reference sentence. In this embodiment, semantic recognition is simpler, more convenient and less costly.
[0079] The number of preset benchmark sentences corresponding to another target scenario can also be multiple, and there is no upper limit to the number, which can improve the accuracy of semantic recognition, wherein the number of preset benchmark sentences is specifically designed according to user needs and is not limited here. Optionally, based on scenarios that require positive benchmark sentences and negative benchmark sentences, two groups of benchmark sentences can be preset, one of which includes multiple positive benchmark sentences and the other includes multiple negative benchmark sentences, but is not limited to this. For example, in some scenarios, the classification of semantic attributes can be more, including interrogative sentences, exclamatory sentences, etc., which are not limited here.
[0080] Optionally, the basic structure of an affirmative reference sentence is: affirmative word + scene word; the basic structure of a negative reference sentence is: negative word + scene word. For example:
[0081] Scenario 1: The smart device or smart service asks, "Do you want to listen to the song "Red Bean"? "
[0082] Affirmative benchmark sentence: Listen to Hongdou.
[0083] Negative benchmark sentence: Don’t listen to Hongdou.
[0084] Among them, the affirmative word is "want", the negative word is "no", and the scene word is "listen to red beans".
[0085] Scenario 2: A smart device or smart service asks “Do you want a taxi?”
[0086] Affirmative benchmark sentence: I want to take a taxi.
[0087] Negative benchmark sentence: Don’t take a taxi.
[0088] Among them, the affirmative word is "want", the negative word is "don't want", and the scene word is "take a taxi".
[0089] S105: Calculate a benchmark sentence vector corresponding to each preset benchmark sentence according to the preset model.
[0090] It should be noted that after all preset benchmark sentences in the target scenario are obtained, the benchmark sentence vector corresponding to each preset benchmark sentence is calculated through the preset model.
[0091] Among them, the preset model is a trained sentence vector model with good semantic extraction performance, such as Bert, OpenAI GPT, ELMo, Quick-Thought, etc. The selection of the specific preset model is set according to user needs and there is no restriction here.
[0092] It should be noted that S104 and S105 may also be executed before S101. For example, when the preset benchmark sentences are preconfigured, the benchmark sentence vector corresponding to each preset benchmark sentence is obtained.
[0093] Further, step S102 includes:
[0094] The intention sentence vector corresponding to the intention sentence is calculated according to the preset model; and the similarity between each intention sentence vector and the benchmark sentence vector corresponding to each preset benchmark sentence is calculated using the preset similarity algorithm.
[0095] It should be noted that after obtaining the user's intention sentence, the intention sentence vector corresponding to the intention sentence is calculated through the preset model, and based on the intention sentence vector and multiple benchmark sentence vectors, the preset similarity algorithm is used to calculate the similarity between the intention sentence vector and each benchmark sentence vector.
[0096] Furthermore, step S103 further includes:
[0097] A preset benchmark sentence with the highest similarity to the intended sentence is selected as the target benchmark sentence; and the semantic attributes of the target benchmark sentence are used as the semantic attributes of the intended sentence.
[0098] If the intention sentence vector has a higher similarity to a positive reference sentence vector, the intention sentence can be judged as an affirmative sentence, otherwise the intention sentence is judged as a negative sentence.
[0099] In the specific implementation process, assuming that the measurement function for measuring similarity can be Dist(…,…), the semantic attribute judgment rule of the intention sentence is:
[0100] If Dist(intention vector, affirmative benchmark sentence vector)<=Dist(intention vector, negative benchmark sentence vector), the semantic attribute of the intention sentence is judged to be an affirmative sentence, otherwise the semantic attribute of the intention sentence is judged to be a negative sentence.
[0101] Figure 4 A flowchart of a semantic recognition method provided by another embodiment of the present application is shown in FIG. Figure 4 As shown, after step S103, the following steps are also included:
[0102] S106: Obtain accuracy information corresponding to the semantic attributes of the intention sentence.
[0103] Furthermore, after step S106, the method further includes:
[0104] S107: If the accuracy information does not meet the preset requirement, receiving preset benchmark sentence update information, where the preset benchmark sentence update information includes a new preset benchmark sentence corresponding to the target scenario.
[0105] If the accuracy information does not meet the preset requirements, the preset benchmark sentence corresponding to the scenario is adjusted and updated.
[0106] For example: In the above scenario 1, the question "Do you want to listen to the song "Red Bean"?" is asked. The baseline sentence set at the beginning is:
[0107] Affirmative benchmark sentence: Listen to Hongdou.
[0108] Negative benchmark sentence: Don’t listen to Hongdou.
[0109] Assuming that the user's intended sentence "this one" is mistakenly judged as a negative, the benchmark sentence can be adjusted to:
[0110] Affirmative benchmark sentence: I have to listen to the song Red Bean.
[0111] Negative benchmark sentence: I don’t listen to the song Red Bean.
[0112] That is, some key words in the sentence that was judged incorrectly are added to the benchmark sentence, and the new benchmark sentence is used as the preset benchmark sentence, or the new benchmark sentence is added to the preset benchmark sentence. If a new error is found again, the iteration can be continued. In this way, the accuracy of the semantic attribute judgment of the intended sentence can be continuously improved.
[0113] Based on the same inventive concept, a semantic recognition device corresponding to the semantic recognition method is also provided in the embodiment of the present application. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the above-mentioned semantic recognition method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repetition of the beneficial effects will not be repeated.
[0114] Reference Figure 5 As shown, it is a structural diagram of a semantic recognition device provided by an embodiment of the present application, such as Figure 5 As shown, the device includes: a receiving module 201, a calculating module 202, and a determining module 203; wherein:
[0115] The receiving module 201 is used to receive the intention statement input by the user for the target scenario.
[0116] The calculation module 202 is used to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences using a preset similarity algorithm.
[0117] The determination module 203 is used to determine a preset reference sentence matching the intended sentence according to the similarity, and obtain the semantic attribute of the intended sentence according to the preset reference sentence matching the intended sentence.
[0118] Reference Figure 6 As shown, it is a structural diagram of a semantic recognition device provided by an embodiment of the present application, such as Figure 6 As shown, the device further includes: an acquisition module 204, which is used to acquire a plurality of preset reference sentences corresponding to the target scene, wherein the plurality of preset reference sentences include: an affirmative reference sentence and a negative reference sentence.
[0119] Furthermore, the calculation module 202 is specifically used to calculate the intention sentence vector corresponding to the intention sentence according to the preset model; and use the preset similarity algorithm to calculate the similarity between each intention sentence vector and the benchmark sentence vector corresponding to each preset benchmark sentence.
[0120] Furthermore, the determination module 203 is specifically configured to select a preset reference sentence having the highest similarity to the intended sentence as the target reference sentence; and use the semantic attributes of the target reference sentence as the semantic attributes of the intended sentence.
[0121] Reference Figure 7 As shown, it is a structural diagram of a semantic recognition device provided by an embodiment of the present application, such as Figure 7 As shown, the device further includes: a second acquisition module 205 and an update module 206, wherein:
[0122] The second acquisition module 205 is used to acquire accuracy information corresponding to the semantic attributes of the intention sentence.
[0123] The updating module 206 is configured to receive preset benchmark sentence updating information if the accuracy information does not meet the preset requirement, wherein the preset benchmark sentence updating information includes a new preset benchmark sentence corresponding to the target scenario.
[0124] like Figure 8 FIG. 6 is a schematic diagram of a structure of an electronic device provided in an embodiment of the present application, and the electronic device may be the above-mentioned server or service terminal. The electronic device 600 includes: a processor 601 , a memory 602 , and a bus 603 .
[0125] The electronic device 600 may include one or more processors 601, a bus 603 and a memory 602. The memory 602 stores machine-readable instructions executable by the processor 601. When the electronic device 600 is running, the processor 601 communicates with the memory 602 via the bus 603. When the machine-readable instructions are executed by the processor 601, the following processing is performed:
[0126] Receive the user's intention statement for the target scenario;
[0127] Using a preset similarity algorithm to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences;
[0128] A preset reference sentence matching the intended sentence is determined according to the similarity, and a semantic attribute of the intended sentence is obtained according to the preset reference sentence matching the intended sentence.
[0129] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned semantic recognition method are executed.
[0130] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, the above-mentioned semantic recognition method can be executed, thereby solving the problem existing in the prior art that due to the various language expression combinations and a large amount of information, the sentence library will be too large and occupy too many resources, thereby achieving the effect of reducing resource occupation.
[0131] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0132] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0134] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0135] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A semantic recognition method, characterized in that: include: Receive the user's intention statement for the target scenario; Using a preset similarity algorithm to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences; Determining a preset reference sentence matching the intended sentence according to the similarity, and acquiring a semantic attribute of the intended sentence according to the preset reference sentence matching the intended sentence; After determining a preset reference sentence matching the intended sentence according to the similarity, and acquiring the semantic attribute of the intended sentence according to the preset reference sentence matching the intended sentence, the method further includes: Obtaining accuracy information corresponding to the semantic attributes of the intention sentence; If the accuracy information does not meet the preset requirement, receiving preset benchmark sentence update information, the preset benchmark sentence update information includes a new preset benchmark sentence corresponding to the target scenario, the new preset benchmark sentence is obtained by supplementing the preset benchmark sentence with the key word sample in the intention sentence; Before respectively calculating the similarities between the intended sentence and a plurality of preset reference sentences using a preset similarity algorithm, the method further includes: Acquire a plurality of preset benchmark sentences corresponding to the target scene, wherein the plurality of preset benchmark sentences include: an affirmative benchmark sentence and a negative benchmark sentence; the affirmative benchmark sentence includes an affirmative word and a scene word, and the negative benchmark sentence includes a negative word and a scene word; the preset benchmark sentences are pre-configured according to different target scenes, and the semantic attributes corresponding to the preset benchmark sentences are pre-marked; The benchmark sentence vector corresponding to each of the preset benchmark sentences is calculated according to the preset model.
2. The method according to claim 1, characterized in that The using of a preset similarity algorithm to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences comprises: Calculate the intention sentence vector corresponding to the intention sentence according to the preset model; A preset similarity algorithm is used to calculate the similarity between each of the intended sentence vectors and the reference sentence vector corresponding to each of the preset reference sentences.
3. The method according to claim 1 or 2, characterized in that Determining a preset reference sentence matching the intended sentence according to the similarity, and acquiring the semantic attribute of the intended sentence according to the preset reference sentence matching the intended sentence, includes: Selecting a preset reference sentence having the highest similarity to the intended sentence as the target reference sentence; The semantic attributes of the target reference sentence are used as the semantic attributes of the intended sentence.
4. A semantic recognition device, characterized in that: include: Receiving module, calculating module, determining module, wherein: The receiving module is used to receive the intention statement input by the user for the target scenario; The calculation module is used to respectively calculate the similarity between the intended sentence and a plurality of preset reference sentences using a preset similarity algorithm; The determination module is used to determine a preset reference sentence matching the intended sentence according to the similarity, and obtain the semantic attribute of the intended sentence according to the preset reference sentence matching the intended sentence; It also includes a second acquisition module and an update module, wherein: The second acquisition module is used to acquire accuracy information corresponding to the semantic attributes of the intention sentence; The updating module is used to receive preset benchmark sentence update information if the accuracy information does not meet the preset requirement, wherein the preset benchmark sentence update information includes a new preset benchmark sentence corresponding to the target scenario, and the new preset benchmark sentence is obtained by supplementing the preset benchmark sentence with the keyword sample in the intention sentence; It also includes a first acquisition module; the first acquisition module is used to acquire multiple preset benchmark sentences corresponding to the target scene, wherein the multiple preset benchmark sentences include: affirmative benchmark sentences and negative benchmark sentences; the affirmative benchmark sentences include affirmative words and scene words, and the negative benchmark sentences include negative words and scene words; the preset benchmark sentences are pre-configured according to different target scenes, and the semantic attributes corresponding to the preset benchmark sentences are pre-labeled; the benchmark sentence vector corresponding to each preset benchmark sentence is calculated according to the preset model.
5. The device according to claim 4, characterized in that The calculation module is specifically used to calculate the intention sentence vector corresponding to the intention sentence according to a preset model; and use a preset similarity algorithm to respectively calculate the similarity between each intention sentence vector and the benchmark sentence vector corresponding to each preset benchmark sentence.
6. The device according to claim 4 or 5, characterized in that The determination module is specifically used to select a preset reference sentence with the highest similarity to the intended sentence as a target reference sentence; and use the semantic attributes of the target reference sentence as the semantic attributes of the intended sentence.
7. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the storage medium communicate via the bus, and the processor executes the machine-readable instructions to perform the steps of any method as claimed in claims 1 to 3.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are executed.
