Semantic reasoning method and device, electronic equipment and readable storage medium
By using the cascaded inference model structure in the semantic inference model, the hidden features and inference features are input to the second inference model for inference, which solves the problem of low efficiency and accuracy of the existing semantic inference model and achieves faster and more accurate results. Semantic reasoning avoids the problem of insufficient computing power of computer hardware.
Patent Information
- Application Number
- CN202410674268.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-10-01
AI Technical Summary
The reasoning efficiency and accuracy of existing semantic reasoning models are low, resulting in insufficient computing power of computer hardware, slow response speed, and prone to lags.
By obtaining the semantic unit and inputting it into the first inference model, the hidden features and inference features are obtained, and then input them into the second inference model for inference. The second inference model is used to connect more contextual content and improve the accuracy of the semantic inference results. Reduce computing resource usage.
While using less computing resources, we can obtain more accurate semantic reasoning results, avoid the problem of insufficient computing power of computer hardware, improve computer response speed, and reduce lags.
Smart Images

Figure CN118733722A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of information processing technology, and in particular relates to a semantic reasoning method, apparatus, electronic device and readable storage medium. Background Technology
[0002] With the continuous upgrading of electronic device technology, it is well known that large language models are one of the feasible paths to general artificial intelligence, and Natural Language Processing (NLP) is an important branch of artificial intelligence and linguistics. Its goal is to enable computers to understand, process, and generate human language.
[0003] Because current semantic reasoning models have low reasoning efficiency and accuracy, and their operation relies on the support of computer hardware computing power, there is a tendency for insufficient computing power, leading to problems such as poor response speed and lag in semantic reasoning models. Summary of the Invention
[0004] This application provides a semantic reasoning method, apparatus, electronic device, and readable storage medium, which can solve the problem that the reasoning efficiency and accuracy of current semantic reasoning models still need to be improved.
[0005] In a first aspect, embodiments of this application provide a semantic reasoning method, the method comprising:
[0006] Obtain the first semantic unit;
[0007] The first semantic unit is input into the first inference model, and inference is performed on the first semantic unit to obtain hidden features and first inference features; the first inference features include the inference features output by the first inference model each time.
[0008] The hidden features and the first inference features are input into the second inference model, and inference is performed on the hidden features and the first inference features to obtain the semantic inference result.
[0009] Secondly, embodiments of this application provide a model construction method, the method comprising:
[0010] An initial semantic reasoning model comprising multiple levels is constructed, the initial semantic reasoning model including a first initial model and a second initial model; each level of the first initial model includes a neural network layer for feature extraction; each level of the second initial model includes a neural network layer for feature extraction; the second initial model is used to reason about the output of the first initial model to obtain second sample features;
[0011] The initial semantic reasoning model is trained based on the second sample features and sample labels to determine the parameters of the trained multiple neural network layers at each of the multiple levels.
[0012] The trained initial semantic reasoning model is determined as the semantic reasoning model.
[0013] Thirdly, embodiments of this application provide a semantic reasoning apparatus applied to an electronic device, the apparatus comprising:
[0014] The acquisition module is used to acquire the first semantic unit;
[0015] The first reasoning module is used to input the first semantic unit into the first reasoning model, and to reason about the first semantic unit to obtain hidden features and first reasoning features; the first reasoning features include the reasoning features output by the first reasoning model each time.
[0016] The second reasoning module is used to input the hidden features and the first reasoning features into the second reasoning model, and to reason about the hidden features and the first reasoning features to obtain semantic reasoning results.
[0017] Fourthly, embodiments of this application provide an electronic device, which includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the method as described in the first aspect or any possible implementation of the first aspect.
[0018] Fifthly, embodiments of this application provide a readable storage medium storing computer program instructions that, when executed by a processor, implement the method as described in the first aspect or any possible implementation thereof.
[0019] In this embodiment, a first semantic unit is obtained, input into a first inference model, and inference is performed on the first semantic unit to obtain hidden features and a first inference feature. The first inference feature includes the inference feature output by the first inference model each time. In this embodiment, the second inference model can obtain all the output results of the first inference model's multiple forward propagations, i.e., the first inference feature. Then, through the second inference model, inference is performed on the hidden features and the first inference feature, which can connect more contextual content for inference to obtain semantic inference results. Therefore, with less computing resources, more accurate semantic inference results can be obtained, reducing the occupation of computing resources, avoiding insufficient computing power of computer hardware, improving the computer's response speed, and reducing computer lag. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of a semantic reasoning method provided in an embodiment of this application;
[0022] Figure 2 This is a schematic diagram of the structure of a semantic reasoning model provided in an embodiment of this application;
[0023] Figure 3 This is a schematic diagram of the structure of a first inference model provided in an embodiment of this application;
[0024] Figure 4 This is a flowchart of a model building method provided in an embodiment of this application;
[0025] Figure 5 This is a schematic diagram of the structure of a semantic reasoning device provided in an embodiment of this application;
[0026] Figure 6 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] The features and exemplary embodiments of various aspects of this application will now be described in detail. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain this application and are not configured to limit this application. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples of this application.
[0028] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0029] First, the technical terms used in the embodiments of this application will be introduced.
[0030] In natural language processing, a token is the smallest semantic unit in text. For example, a sentence can be segmented into several words, and each word is a token. For instance, the sentence "I love you" can be segmented into three tokens: "I", "love", and "you". Tokens can break down text into parts that are easier to process and analyze.
[0031] Forward propagation: The forward propagation algorithm is the process of obtaining an output from the input of a neural network through layers of neurons.
[0032] Attention mechanism: also known as attention mechanism, as the name suggests, is a technique that allows the model to focus on and fully learn and absorb important information. In simple terms, it means focusing attention on important points while ignoring other unimportant factors.
[0033] The degree of importance depends on the application scenario; for example, 1000 people will have 1000 different interpretations of Hamlet. Depending on the application scenario, attention is divided into spatial attention and temporal attention; the former is used for image processing, and the latter for natural language processing.
[0034] The semantic reasoning method provided in this application embodiment can be applied to at least the following application scenarios, which will be described below.
[0035] Natural Language Processing (NLP) is an important branch of artificial intelligence and linguistics. Its goal is to enable computers to understand, process, and generate human language to achieve human-computer interaction, improve machine intelligence, and expand the application areas of computers. Semantic network-based inductive reasoning algorithms are a method that utilizes semantic networks for automated reasoning and knowledge discovery.
[0036] As is well known, large language models are one of the feasible paths to general artificial intelligence, and semantic reasoning technology has wide applications in the field of artificial intelligence. The following examples illustrate this:
[0037] On the one hand, with the widespread adoption of smartphones and breakthroughs in voice technology, intelligent voice assistants have become an indispensable part of many people's lives. The application of semantic reasoning technology in intelligent voice assistants allows users to ask questions via voice, and the system can infer the user's true question based on its understanding of the voice content and provide an accurate answer.
[0038] For example, when a user says to a smart voice assistant, "I want to eat Peking duck tonight, are there any good restaurants nearby?" the voice assistant can analyze the user's intent using semantic reasoning technology, infer that the user wants to find nearby restaurants that serve Peking duck, and then provide a list of recommended restaurants in the vicinity. Through semantic reasoning technology, smart voice assistants can more accurately understand user needs and provide services that are more tailored to the user.
[0039] On the other hand, in modern society, intelligent customer service systems play a crucial role in enterprise customer service. The application of semantic reasoning technology in intelligent customer service systems can help the system understand customer questions and provide accurate answers.
[0040] For example, when a user asks the intelligent customer service, "When will my purchased product be shipped?", the intelligent customer service can analyze the user's intent using semantic reasoning technology, infer the user's desired shipping time, and provide an answer. Through semantic reasoning, the intelligent customer service can more accurately understand user needs and provide more personalized service.
[0041] Currently, due to limitations in semantic reasoning technology, inconsistencies often arise when semantic reasoning models output more content. For example, the first output of a semantic reasoning model might be: "Have you eaten tonight?"; the second might be: "What did you eat tonight?". The semantic meanings of the two outputs are completely different, and this situation is more common when semantic reasoning models output a large number of reasoning results.
[0042] Therefore, current semantic reasoning models struggle to guarantee effective reasoning when outputting a large number of inference results. Consequently, the inference accuracy of semantic reasoning models still needs improvement.
[0043] Based on the above application scenarios, the semantic reasoning method provided in the embodiments of this application will be described in detail below.
[0044] Figure 1 A flowchart of a semantic reasoning method provided in an embodiment of this application.
[0045] like Figure 1 As shown, the semantic reasoning method may include steps 110-130. This method is applied to a semantic reasoning device, as detailed below:
[0046] Step 110: Obtain the first semantic unit.
[0047] The first semantic unit can be a token. The first semantic unit can be a semantic unit input by the user, or a semantic unit generated based on information input by the user.
[0048] Step 120: Input the first semantic unit into the first inference model, perform inference on the first semantic unit, and obtain hidden features and first inference features; the first inference features include the inference features output by the first inference model each time.
[0049] Specifically, the first semantic unit can be input into the semantic reasoning model, which includes a cascaded first reasoning model and a second reasoning model.
[0050] like Figure 2 As shown, the semantic reasoning model includes: a cascaded first reasoning model 210 and a second reasoning model 220.
[0051] The second inference model 220 can be a single-layer Transformer model, but is not limited to a single-layer Transformer model. It can be a multi-layer model or a recurrent network.
[0052] The Transformer model is a deep learning model widely used in natural language processing tasks. It consists of an encoder and a decoder, and uses a self-attention mechanism to capture the relationships between different positions in the input sequence, thereby processing sequential data.
[0053] A circular network is a specific type of static interconnection network that achieves interconnection between arbitrary nodes by repeatedly using the same single-level interconnection network.
[0054] Both Transformer models and recurrent networks can be used to train NLP models and achieve good results.
[0055] The hidden features are composed of several feature vectors concatenated together.
[0056] like Figure 3 As shown, the network structure of the first inference model 210 includes:
[0057] The system includes an embedding layer 310, several cascaded transformer layers 320, a normalization layer 330, a linear layer 340, and an activation function 350.
[0058] The normalization layer 330 processes the features output by the converter layer 320 and outputs hidden features; or, the linear layer 340 processes the features output by the normalization layer 330 and outputs hidden features.
[0059] Therefore, during the forward inference process of the first inference model, the network structure in the first inference model will infer the first semantic unit to obtain hidden features and first inference features.
[0060] Step 130: Input the hidden features and the first inference features into the second inference model, and perform inference on the hidden features and the first inference features to obtain semantic inference results.
[0061] For example, the first semantic unit includes: A, B, C, D, E, F, G, H;
[0062] The first inference features include: B, C, D, E, F, G, H, and I;
[0063] Hidden features include: B', C', D', E', F', G', H', I';
[0064] Semantic reasoning results include: B”, C”, D”, E”, F”, G”, H”, I”;
[0065] The second reasoning model has the ability to determine whether the output of the first reasoning model is reasonable. The first reasoning model can obtain an output token for each forward reasoning, such as "I" in the example above. However, the first reasoning model will take the previous reasoning result for each reasoning and continue the next reasoning, so it cannot modify historical information.
[0066] In the embodiments of this application, the second reasoning model included in the semantic reasoning model can obtain all the output results of the first reasoning model after multiple forward propagations, and then modify them as a whole. Therefore, the second reasoning model is based on the complete output statement content of the first reasoning model. The second reasoning model has more contextual content input, so by reasoning about the hidden features and the first reasoning features through the second reasoning model, more accurate semantic reasoning results can be obtained.
[0067] Therefore, by using the second reasoning model to reason about the hidden features and the first reasoning features output by the first reasoning model each time, semantic reasoning results can be obtained. This can correct and rewrite the output content of the first reasoning model, effectively correct the output content of the first reasoning model, and improve the overall reasoning ability of the semantic reasoning model.
[0068] In this embodiment, a first semantic unit is obtained, input into a first inference model, and inference is performed on the first semantic unit to obtain hidden features and a first inference feature. The first inference feature includes the inference feature output by the first inference model each time. In this embodiment, the second inference model can obtain all the output results of the first inference model's multiple forward propagations, i.e., the first inference feature. Then, through the second inference model, inference is performed on the hidden features and the first inference feature, which can connect more contextual content for inference to obtain semantic inference results. Therefore, with less computing resources, more accurate semantic inference results can be obtained, reducing the occupation of computing resources, avoiding insufficient computing power of computer hardware, improving the computer's response speed, and reducing computer lag.
[0069] Steps 110-130 are explained below:
[0070] Step 110 is involved.
[0071] In some embodiments, step 110 may specifically include the following steps:
[0072] Get the first string entered by the user;
[0073] The first string is encoded to obtain the first semantic unit.
[0074] The encoding of the first string to obtain the first semantic unit can be achieved using a Tokenizer.
[0075] Tokenizer is a class used to vectorize text, converting it into a sequence. Computers cannot understand the meaning of words when processing spoken language; they typically convert a word into a positive integer, turning text into a sequence. This sequence is then vectorized, and the vectorized data is fed into the model for processing.
[0076] Step 120 is involved.
[0077] The first semantic unit is input into the first inference model, and inference is performed on the first semantic unit to obtain hidden features and first inference features; the first inference features include the inference features output by the first inference model each time.
[0078] Specifically, the first semantic unit can be input into the semantic reasoning model, which includes a cascaded first reasoning model and a second reasoning model.
[0079] The semantic reasoning model is a pre-trained semantic reasoning model with semantic reasoning capabilities. Both the first and second reasoning models have semantic reasoning capabilities. The training process of the semantic reasoning model can be described as follows:
[0080] In some embodiments, prior to step 120, the following steps may also be included:
[0081] Acquire training data, which includes sample semantic units and sample labels;
[0082] The sample semantic unit is input into the first initial model, and reasoning is performed on the sample semantic unit to obtain sample hidden features and first sample features; the first sample features include the reasoning features output by the first initial model each time.
[0083] The hidden sample features and the first sample features are input into the second initial model, and reasoning is performed on the hidden sample features and the first sample features to obtain the second sample features.
[0084] Based on the second sample features and the sample labels, train the first initial model and the second initial model until the training conditions are met, and obtain the first inference model and the second inference model.
[0085] Specifically, the step of inputting the sample semantic unit into the first initial model can be to input the sample semantic unit into the initial semantic reasoning model, which includes the first initial model and the second initial model.
[0086] The sample semantic units are inferred by the first initial model in the initial semantic reasoning model to obtain the sample hidden features and the first sample features; the first sample features include the reasoning features output by the first initial model each time.
[0087] The second sample features are obtained by reasoning about the hidden features and the first sample features using the second initial model in the initial semantic reasoning model;
[0088] Based on the features and labels of the second sample, an initial semantic reasoning model is trained until the initial semantic reasoning model meets the training conditions, thus obtaining the semantic reasoning model.
[0089] The sample semantic unit can be a token. The sample semantic unit can be a semantic unit input by the user, or a semantic unit generated based on the information input by the user.
[0090] The network structure of the first initial model includes: an embedding layer, several cascaded neural network layers, a normalization layer, a linear layer, and an activation function.
[0091] The normalization layer processes the features output by the neural network layer and outputs the hidden features of the sample; or, the linear layer processes the features output by the normalization layer and outputs the hidden features of the sample.
[0092] Therefore, during the forward inference process of the first initial model, the network structure in the first initial model will extract features from the sample semantic units to obtain the sample semantic units and sample hidden features.
[0093] The second initial model can be a single-layer Transformer model, but it is not limited to a single-layer Transformer model. It can be a multi-layer Transformer model or a recurrent network.
[0094] The sample hidden features of the first semantic unit output by the first initial model and the inference features output by the first initial model each time are input into the second initial model. The second initial model is used to infer the sample embedding features and sample hidden features to obtain the second sample features.
[0095] The loss function is determined based on the features of the second sample and the sample label. Backpropagation and weight updates are performed based on the loss function. The optimizers used during training may include Adam optimizer (Adaptive Moment Estimation optimizer) or stochastic gradient descent (SGD), etc.
[0096] In the embodiments of this application, the first sample features include the inference features output by the first initial model each time. That is, the second initial model included in the initial semantic inference model can obtain all the output results of the first initial model's multiple forward propagations and then modify them as a whole. Therefore, the second initial model is based on all the output statement content of the first initial model for inference. The second initial model has more context content input. Therefore, by inferring the hidden features and the first sample features through the second initial model, a more accurate semantic inference result can be obtained.
[0097] Therefore, by reasoning about the hidden features and the inference features output by the first initial model each time through the second initial model, semantic reasoning results can be obtained, which can correct and rewrite the output content of the first initial model. By reasoning about the hidden features of the sample and the first sample features through the second initial model, the second sample features can be obtained, which can effectively correct the output content of the first initial model.
[0098] Based on the features and labels of the second sample, an initial semantic reasoning model is trained until the initial semantic reasoning model meets the training conditions. This continuously improves the reasoning accuracy of the semantic reasoning model, resulting in a semantic reasoning model. In this way, the overall reasoning ability of the semantic reasoning model can be improved.
[0099] In some embodiments, the hidden features are the input features of a first inference model that are normalized to a single layer.
[0100] On the one hand, the normalization layer of the first inference model processes the features output by the neural network layer of the first inference model and outputs hidden features;
[0101] On the other hand, the linear layer of the first inference model processes the features output by the normalization layer of the first inference model and outputs hidden features.
[0102] In some embodiments, step 120 may specifically include the following steps:
[0103] If the inference features output by the first inference model do not include a terminator, repeat the step of inputting the inference features into the first inference model until the inference features output by the first inference model include a terminator.
[0104] If the reasoning features output by the first reasoning model do not include a terminator, it means that the reasoning still needs to continue. That is, the steps of inputting the reasoning features into the first reasoning model, reasoning on the first semantic unit through the first reasoning model, and obtaining the hidden features and the first reasoning features are repeated until the reasoning features output by the first reasoning model include a terminator.
[0105] If the output of the semantic reasoning model satisfies the reasoning condition, that is, if the reasoning features output by the first reasoning model do not include a terminator, reasoning can be stopped, all cached forward reasoning features can be obtained, and the tokenizer can be used to decode these forward reasoning features in cache order to obtain the second string, which is then returned to the user.
[0106] Step 130 is involved.
[0107] In some embodiments, step 130 may specifically include the following steps:
[0108] The hidden features and the first inference features are input into the second inference model, and inference is performed on the hidden features and at least one first inference feature to obtain the target inference features;
[0109] The semantic reasoning results are obtained by decoding the target reasoning features.
[0110] By using the second reasoning model to reason about the hidden features and the first reasoning features, we can connect more contextual content to make inferences and obtain more accurate target reasoning features.
[0111] Decoding the target reasoning features yields semantic reasoning results, which may specifically include:
[0112] The target inference features are decoded using a tokenizer in the order of caching to obtain the semantic inference results.
[0113] The semantic reasoning result can be a second string. After decoding the target reasoning features and obtaining the semantic reasoning result, the second string is returned to the user.
[0114] In this embodiment, a first semantic unit is obtained, input into a first inference model, and inference is performed on the first semantic unit to obtain hidden features and a first inference feature. The first inference feature includes the inference feature output by the first inference model each time. In this embodiment, the second inference model can obtain all the output results of the first inference model's multiple forward propagations, i.e., the first inference feature. Then, through the second inference model, inference is performed on the hidden features and the first inference feature, which can connect more contextual content for inference to obtain semantic inference results. Therefore, with less computing resources, more accurate semantic inference results can be obtained, reducing the occupation of computing resources, avoiding insufficient computing power of computer hardware, improving the computer's response speed, and reducing computer lag.
[0115] Based on the above Figure 1 The semantic reasoning method shown in this application also provides a model construction method, such as... Figure 4 As shown, the method includes:
[0116] Step 410: Construct an initial semantic reasoning model comprising multiple levels, the initial semantic reasoning model comprising a first initial model and a second initial model; each level of the first initial model comprises a neural network layer for feature extraction; each level of the second initial model comprises a neural network layer for feature extraction; the second initial model is used to reason about the output of the first initial model to obtain second sample features;
[0117] Specifically, the network structure of the first initial model includes: an embedding layer, several cascaded neural network layers, a normalization layer, a linear layer, and an activation function.
[0118] The second initial model can be a single-layer Transformer model, a multi-layer Transformer model, or a recurrent network.
[0119] The output of the first initial model includes: first sample inference features, sample embedding features, and sample hidden features. The second initial model is used to infer the output of the first initial model to obtain the second sample features.
[0120] Step 420: Train an initial semantic reasoning model based on the second sample features and sample labels to determine the parameters of the trained multiple neural network layers at each of the multiple levels.
[0121] The initial semantic reasoning model is trained by calculating a loss function based on the features and labels of the second sample, until the training conditions are met. Once the initial semantic reasoning model meets the training conditions, the parameters of the trained multiple neural network layers are determined at each of the multiple layers.
[0122] Step 430: The trained initial semantic reasoning model is determined as the semantic reasoning model.
[0123] Therefore, by defining the trained initial semantic reasoning model as the semantic reasoning model, a semantic reasoning model with efficient reasoning ability can be obtained.
[0124] In this embodiment, the constructed initial semantic reasoning model includes a first initial model and a second initial model. The second initial model infers from the output of the first initial model to obtain second sample features. The second initial model shares the reasoning work of the first initial model, thereby reducing the overall reasoning time of the initial semantic reasoning model. Therefore, the semantic reasoning model constructed and trained in this embodiment has efficient reasoning capabilities.
[0125] Based on the above Figure 1 The semantic reasoning method shown in this application also provides a semantic reasoning apparatus, such as... Figure 5 As shown, the device 500 may include:
[0126] Module 510 is used to acquire the first semantic unit;
[0127] The first reasoning module 520 is used to input the first semantic unit into the first reasoning model, perform reasoning on the first semantic unit, and obtain hidden features and first reasoning features; the first reasoning features include the reasoning features output by the first reasoning model each time.
[0128] The second reasoning module 530 is used to input the hidden features and the first reasoning features into the second reasoning model, and to reason about the hidden features and the first reasoning features to obtain semantic reasoning results.
[0129] In one possible implementation, the acquisition module 510 is further configured to acquire training data, the training data including sample semantic units and sample labels;
[0130] The first reasoning module 520 is further configured to input the sample semantic unit into the first initial model, perform reasoning on the sample semantic unit, and obtain sample hidden features and first sample features; the first sample features include the reasoning features output by the first initial model each time.
[0131] The second inference module 530 is further configured to input the sample hidden features and the first sample features into the second initial model, and to infer the sample hidden features and the first sample features to obtain the second sample features.
[0132] The device 500 may include:
[0133] The training module is used to train the first initial model and the second initial model based on the second sample features and the sample labels until the training conditions are met, thereby obtaining the first inference model and the second inference model.
[0134] In one possible implementation, the first inference module 520 is specifically used for:
[0135] If the inference features output by the first inference model do not include a terminator, repeat the step of inputting the inference features into the first inference model until the inference features output by the first inference model include a terminator.
[0136] In one possible implementation, the hidden features are the input features of the first inference model that are normalized to a single layer.
[0137] In one possible implementation, module 510 is specifically used for:
[0138] Get the first string entered by the user;
[0139] The first string is encoded to obtain the first semantic unit.
[0140] In one possible implementation, the second inference module 530 is specifically used for:
[0141] The hidden features and the first inference features are input into the second inference model, and inference is performed on the hidden features and the at least one first inference feature to obtain the target inference features;
[0142] The target reasoning features are decoded to obtain the semantic reasoning result.
[0143] In this embodiment, a first semantic unit is obtained, input into a first inference model, and inference is performed on the first semantic unit to obtain hidden features and a first inference feature. The first inference feature includes the inference feature output by the first inference model each time. In this embodiment, the second inference model can obtain all the output results of the first inference model's multiple forward propagations, i.e., the first inference feature. Then, through the second inference model, inference is performed on the hidden features and the first inference feature, which can connect more contextual content for inference to obtain semantic inference results. Therefore, with less computing resources, more accurate semantic inference results can be obtained, reducing the occupation of computing resources, avoiding insufficient computing power of computer hardware, improving the computer's response speed, and reducing computer lag.
[0144] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application is shown.
[0145] An electronic device may include a processor 601 and a memory 602 storing computer program instructions.
[0146] Specifically, the processor 601 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0147] Memory 602 may include a large-capacity memory for data or instructions. For example, and not limitingly, memory 602 may include a hard disk drive (HDD), a floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 602 may include removable or non-removable (or fixed) media. Where appropriate, memory 602 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 602 is a non-volatile solid-state memory. In a particular embodiment, memory 602 includes read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0148] The processor 601 implements any of the semantic reasoning methods in the embodiment shown in the figure by reading and executing computer program instructions stored in the memory 602.
[0149] In one example, the electronic device may also include a communication interface 603 and a bus 610. For example, Figure 6 As shown, the processor 601, memory 602, and communication interface 603 are connected through bus 610 and complete communication with each other.
[0150] The communication interface 603 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0151] Bus 610 includes hardware, software, or both, that couples components of an electronic device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 610 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0152] The electronic device can execute the semantic reasoning method in the embodiments of this application, thereby achieving a combination Figures 1 to 2 The semantic reasoning method described.
[0153] Furthermore, in conjunction with the semantic reasoning method in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; these computer program instructions are implemented when executed by a processor. Figures 1 to 4 Semantic reasoning methods in [the context of the text].
[0154] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0155] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0156] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0157] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A semantic reasoning method, characterized in that: The method comprises: Obtaining a first semantic unit; Inputting the first semantic unit into a first reasoning model, and performing reasoning on the first semantic unit to obtain a hidden feature and a first reasoning feature; the first reasoning feature includes a reasoning feature outputted by the first reasoning model each time; The hidden feature and the first reasoning feature are input into a second reasoning model, and the hidden feature and the first reasoning feature are reasoned to obtain a semantic reasoning result.
2. The method according to claim 1, characterized in that Before inputting the first semantic unit into the first reasoning model, the method further includes: Acquire training data, wherein the training data includes sample semantic units and sample labels; Input the sample semantic unit into the first initial model, perform inference on the sample semantic unit, and obtain sample hidden features and first sample features; the first sample features include the inference features output by the first initial model each time; Inputting the sample hidden feature and the first sample feature into a second initial model, and performing inference on the sample hidden feature and the first sample feature to obtain a second sample feature; The first initial model and the second initial model are trained according to the second sample feature and the sample label until a training condition is met, thereby obtaining the first inference model and the second inference model.
3. The method according to claim 1, characterized in that The step of inputting the first semantic unit into a first reasoning model, and performing reasoning on the first semantic unit to obtain a hidden feature and a first reasoning feature includes: When the inference features output by the first inference model do not include a terminator, the step of inputting the inference features into the first inference model is repeated until the inference features output by the first inference model include a terminator.
4. The method according to claim 1, characterized in that: The hidden features are input features of a normalized layer of the first inference model.
5. The method according to claim 1, characterized in that The obtaining of the first semantic unit comprises: Get the first string input by the user; The first character string is encoded to obtain the first semantic unit.
6. The method according to claim 1, characterized in that The step of inputting the hidden feature and the first reasoning feature into a second reasoning model, and reasoning the hidden feature and the first reasoning feature to obtain a semantic reasoning result includes: Inputting the hidden feature and the first inference feature into a second inference model, and performing inference on the hidden feature and the at least one first inference feature to obtain a target inference feature; The target reasoning feature is decoded to obtain the semantic reasoning result.
7. A model building method, characterized in that: The method comprises: Constructing an initial semantic reasoning model including multiple levels, the initial semantic reasoning model including a first initial model and a second initial model; each level of the first initial model includes a neural network layer for feature extraction; each level of the second initial model includes a neural network layer for feature extraction; the second initial model is used to infer the output of the first initial model to obtain a second sample feature; Training the initial semantic reasoning model according to the second sample features and sample labels to determine parameters of the plurality of trained neural network layers at each of the plurality of levels; The trained initial semantic reasoning model is determined as the semantic reasoning model.
8. A semantic reasoning device, characterized in that: The device comprises: An acquisition module, used for acquiring a first semantic unit; A first reasoning module, configured to input the first semantic unit into a first reasoning model, and perform reasoning on the first semantic unit to obtain a hidden feature and a first reasoning feature; the first reasoning feature includes a reasoning feature outputted by the first reasoning model each time; The second reasoning module is used to input the hidden feature and the first reasoning feature into a second reasoning model, and to reason the hidden feature and the first reasoning feature to obtain a semantic reasoning result.
9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the semantic reasoning method as described in any one of claims 1 to 7 is implemented.
10. A readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the semantic reasoning method according to any one of claims 1 to 7 is implemented.
