Inference language model training, inference method, model and computer device based on differentiable stack
By performing multiple feature extractions and data fusions using a differentiable stack-based inference language model, the problem of traditional Transformer models being unable to understand formal language features is solved, achieving efficient recognition of formal languages.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PEKING UNIV
- Filing Date
- 2025-03-13
- Publication Date
- 2026-04-24
AI Technical Summary
Traditional Transformer models cannot accurately understand the abstract semantic features of formal languages.
A reasoning language model based on a differentiable stack is adopted. The model is trained by multiple feature extractions and data fusion of storage units to improve the recognition ability of semantic features.
It improves the accuracy of formal language recognition and is able to handle language tasks with a certain degree of complexity.
Smart Images

Figure CN120430398B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, specifically to a training and reasoning method, model, and computer device for a reasoning language model based on a differentiable stack. Background Technology
[0002] The Transformer model is a deep learning model based on a self-attention mechanism. It can be used to process natural language tasks, capturing the complex dependencies between elements in natural language to understand its contextual information.
[0003] However, in practical applications, there is a need not only to understand natural language, but also to understand and process other types of languages. For example, in computer science applications, there is a need to extract semantic features from formal languages. Formal languages have complex features such as abstract semantics, and the traditional Transformer model cannot accurately understand the features of formal languages. Summary of the Invention
[0004] This disclosure proposes a training and reasoning method for a reasoning language model based on a differentiable stack, a model, and a computer device.
[0005] The first aspect of this disclosure proposes a method for training a reasoning language model based on a differentiable stack. The method involves calling the model to be trained to sequentially extract initial semantic features of the language multiple times to obtain predicted semantic features. The model to be trained includes i feature extraction layers. The input data of any feature extraction layer includes data read from a preset storage unit and the output data of the previous feature extraction layer. The data in the preset storage unit is the stored output data from the previous feature extraction layer. The i is greater than or equal to 2.
[0006] Calculate the loss value between the predicted semantic features and the standard semantic features of the language;
[0007] If the loss value satisfies the preset convergence condition, the model to be trained is determined as the target inference language model based on a differentiable stack, and the target inference language model based on a differentiable stack has the function of recognizing the semantic features of the language.
[0008] In this embodiment of the disclosure, the preset storage unit includes multiple storage bits, and the data in the preset storage unit is the output data stored in the previous feature extraction layer, including:
[0009] For any storage bit, based on the data stored in the storage bit at the previous calculation moment, the data of the adjacent storage bits of the storage bit, and a preset probability, determine the data of the storage bit at the current calculation moment; the adjacent storage bits include the lower storage bit and the higher storage bit adjacent to the storage bit; the calculation moment refers to the moment when the corresponding feature extraction layer performs calculations and stores the output result in a preset storage unit, and one calculation moment corresponds to one feature extraction layer;
[0010] If the storage bit is the lowest storage bit among the multiple storage bits, the data of the lower storage bit in the adjacent storage bits is the output data of the feature extraction layer corresponding to the previous calculation moment;
[0011] If the storage bit is the highest storage bit among the multiple storage bits, the data stored in the higher storage bit in the adjacent storage bits is empty.
[0012] In the embodiments of the present disclosure, the preset probability includes a write probability, an unchanged probability, and a delete probability. The determining the data of the storage bit at the current calculation moment based on the data stored in the storage bit at the previous calculation moment, the data of the adjacent storage bits of the storage bit, and the preset probability includes:
[0013] Determine the weighted result of the first storage data, the second storage data, and the third storage data at the previous calculation moment as the data stored in the storage bit at the current calculation moment;
[0014] Wherein, the first storage data is the product of the data stored in the lower storage bit and the write probability; the second storage data is the product of the data stored in the storage bit and the unchanged probability; the third storage data is the product of the data stored in the higher storage bit and the delete probability.
[0015] In the embodiments of the present disclosure, the calling the to-be-trained model to sequentially perform multiple feature extractions on the initial semantic features of the language to obtain predicted semantic features includes:
[0016] If 1 < j < i, perform feature extraction based on the fused semantic features and the j-th feature extraction layer to obtain the semantic features output by the j-th feature extraction layer; the fused semantic features are obtained according to the first semantic features output by the (j - 1)-th feature extraction layer and the second semantic features extracted from the preset storage unit; 1 < j ≤ i;
[0017] If j = 1, the second semantic features are empty, and the first semantic features are the initial semantic features;
[0018] If j = i, use the semantic features output by the j-th feature extraction layer as the predicted semantic features.
[0019] In this embodiment of the disclosure, a fused feature is obtained based on the first semantic feature output by the (j-1)th feature extraction layer and the second semantic feature extracted from the preset storage unit, including:
[0020] The first semantic feature and the second semantic feature are concatenated to obtain the third semantic feature;
[0021] The probability of each element in the third semantic feature is obtained by performing a dot product operation between the third semantic feature and the preset weight matrix.
[0022] The fusion feature is obtained based on each element in the third semantic feature and the probability corresponding to each element.
[0023] In this embodiment of the disclosure, obtaining the fused feature based on each element in the third semantic feature and the probability corresponding to each element includes:
[0024] Each element in the third semantic feature is multiplied by its corresponding probability to obtain the probability fusion feature;
[0025] The probability fusion features corresponding to each element in the third semantic feature are added together to obtain the initial fusion feature;
[0026] The initial fusion feature is divided by the number of elements to obtain the fusion feature.
[0027] In this embodiment of the disclosure, the feature extraction layer is an encoding layer and / or a decoding layer; and / or,
[0028] The feature extraction layer is a self-attention layer and / or a feedforward neural network layer in the encoding layer and / or decoding layer.
[0029] The second aspect of this disclosure proposes a reasoning method for a reasoning language model based on a differentiable stack, the method comprising:
[0030] Obtain the language to be identified and extract the initial semantic features of the language to be identified;
[0031] The target inference language model based on a differentiable stack is invoked to extract features from the initial semantic features, thereby obtaining the semantic features of the language to be identified; the target inference language model based on a differentiable stack is trained by the method described in the first aspect or any optional implementation thereof.
[0032] The third aspect of this disclosure proposes a reasoning language model based on a differentiable stack, including an input layer, a recognition layer, and an output layer. The recognition layer includes i feature extraction layers and a storage unit, wherein the input data of any feature extraction layer includes data read from the storage unit and the output data of the previous feature extraction layer, and the data in the storage unit is the stored output data of the previous feature extraction layer; i is greater than or equal to 2.
[0033] A fourth aspect of this disclosure provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being executed by the processor to cause the electronic device to perform the methods described in the first aspect, any alternative implementation of the first aspect, or the second aspect.
[0034] According to a fifth aspect of the embodiments of this application, a computer-readable storage medium is provided having a computer program stored thereon, the program being executed by a processor to implement the methods described in the first aspect, any optional implementation of the first aspect, and the second aspect.
[0035] The technical solutions provided in this disclosure have at least the following technical effects or advantages:
[0036] The model to be trained is invoked to sequentially extract features from the initial semantic features of the language multiple times to obtain predicted semantic features; the loss value between the predicted semantic features and the standard semantic features of the language is calculated; if the loss value satisfies a preset convergence condition, the model to be trained is determined as the target inference language model based on a differentiable stack, and the target inference language model based on a differentiable stack has the function of recognizing the semantic features of the language.
[0037] The model to be trained includes i feature extraction layers. Since the input data of the next feature extraction layer includes data read from the preset storage unit and the output data of the previous feature extraction layer, when the next feature extraction layer extracts features, the input data is increased by the data stored in the preset storage unit, which is on top of the original output data of the previous feature extraction layer, thus improving the accuracy of language recognition. Furthermore, the target inference language model based on a differentiable stack, trained according to subsequent steps, can handle languages with a certain degree of complexity.
[0038] Additional aspects and advantages of this disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this disclosure. Attached Figure Description
[0039] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this disclosure. Furthermore, the same reference numerals denote the same parts throughout the drawings.
[0040] In the attached diagram:
[0041] Figure 1 This illustration shows a structural diagram of a reasoning language model based on a differentiable stack provided in an embodiment of the present disclosure;
[0042] Figure 2 This illustration shows a structural diagram of another reasoning language model based on a differentiable stack provided in an embodiment of the present disclosure;
[0043] Figure 3 A flowchart of a method for training a differentiable stack-based inference language model is shown in one embodiment of this disclosure.
[0044] Figure 4 A schematic diagram of a preset storage unit for a training method for a differentiable stack-based inference language model provided in an embodiment of this disclosure is shown.
[0045] Figure 5 A flowchart is shown below illustrating a reasoning method for a reasoning language model based on a differentiable stack, according to an embodiment of this disclosure.
[0046] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure is shown;
[0047] Figure 7 A schematic diagram of a storage medium provided according to an embodiment of the present disclosure is shown. Detailed Implementation
[0048] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0049] It should be noted that, unless otherwise stated, the technical or scientific terms used in this disclosure shall have the ordinary meaning as understood by one of ordinary skill in the art to which this disclosure pertains.
[0050] The following are explanations of the terms used in this application:
[0051] The Transformer model is a deep learning model based on a self-attention mechanism. However, its performance is limited in practical training because formal languages possess complex features such as abstract semantics, which traditional Transformer models cannot accurately understand.
[0052] The Transformer model is mainly composed of two parts: an encoder and a decoder. Each part enhances the model's representation and learning capabilities by stacking multiple identical layers.
[0053] The encoder consists of N identical stacked layers, each primarily composed of two sub-layers: a multi-head self-attention mechanism and a feedforward neural network. Residual connections and layer normalization are applied after each sub-layer in the encoder to stabilize the training process. The encoder layer is mainly responsible for processing the input sequence and generating a series of encoded representations. These encoded representations capture the contextual information in the input sequence.
[0054] The decoder also consists of N identical layers stacked together, but each layer, in addition to containing the same two sub-layers as the encoder, adds an extra multi-head attention sub-layer to process the encoder output: multi-head self-attention mechanism, multi-head encoder-decoder attention mechanism (sub-layer), and feedforward neural network. Residual connections and layer normalization are applied after each sub-layer in the decoder. The decoder layer is responsible for generating the next output based on the encoder's output and the previously generated output sequence (in the generation task).
[0055] Formal language theory is a branch of computer science that studies the abstract structure and rules of languages. The formal language hierarchy describes different types of languages and their generative capabilities.
[0056] This disclosure proposes a reasoning language model based on a differentiable stack, such as... Figure 1 As shown in the embodiments of this disclosure, the reasoning method for a differentiable stack-based reasoning language model may include the following:
[0057] It includes an input layer 101, a recognition layer 102, and an output layer 103. The recognition layer 102 includes i feature extraction layers and a storage unit. The input data of any feature extraction layer includes data read from the storage unit and the output data of the previous feature extraction layer. The data in the storage unit is the stored output data of the previous feature extraction layer. i is greater than or equal to 2.
[0058] Specifically, the input layer 101 can be used to extract preliminary semantic features from the input language to be recognized. For example, the language to be recognized can be a language with abstract semantics, including mathematical formulas, computer programming languages, and chemical formulas. The input layer 101 can convert the language directly input by the user into initial semantic features in the form of semantic vectors, etc., and these initial semantic features can be vector transformations, etc.
[0059] The recognition layer 102 is used to extract features from the initial semantic features to achieve semantic recognition. For example... Figure 2 The recognition layer 102 shown includes i feature extraction layers and storage units. Specifically, taking the Transformer model as an example, the recognition layer 102 may include the encoder layer and decoder layer of the Transformer model, as well as corresponding storage units. The encoder layer can serve as the first feature extraction layer, and the decoder layer can serve as the second feature extraction layer. The output data of the first feature extraction layer can be stored in the storage units. When performing feature extraction in the second feature extraction layer, the input data consists of the output data of the first feature extraction layer and the data obtained from the storage units.
[0060] Taking the Transformer model as an example, both the encoder and decoder include multiple sub-layers. Each sub-layer of the encoder includes a multi-head self-attention mechanism, a feedforward neural network, and residual connection layers and layer normalization layers for stabilization. In accordance with the embodiments of this application, for the layers within the multi-head self-attention mechanism and feedforward neural network sub-layers of the encoder, the output data of the multi-head self-attention mechanism can also be stored in the storage unit. The input data in the feedforward neural network consists of the output data of the multi-head self-attention mechanism and the data in the storage unit. Similarly, the decoder is similar, and will not be elaborated upon here. The feature extraction process of the recognition layer 102, as well as the storage and retrieval process of the storage unit, will be described in the embodiments below, and will not be repeated here.
[0061] Output layer 103 is used to integrate and output the data in recognition layer 102.
[0062] This disclosure proposes a method for training a reasoning language model based on a differentiable stack, such as... Figure 3 As shown in this embodiment, the method for training a differentiable stack-based inference language model may include the following steps:
[0063] In step S31, the model to be trained is invoked to sequentially extract the initial semantic features of the language multiple times to obtain the predicted semantic features.
[0064] The model to be trained includes i feature extraction layers. The input data of any feature extraction layer includes data read from a preset storage unit and the output data of the previous feature extraction layer. The data in the preset storage unit is the stored output data of the previous feature extraction layer; i is greater than or equal to 2.
[0065] For example, the semantic features of a language can be either natural language or formal language. This application does not limit the specific form of the language, but those skilled in the art can determine it according to the actual situation.
[0066] The model to be trained is Figure 1 The inference language model based on a differentiable stack is described in this application. In this embodiment, the Transformer model is also used as an example. When extracting features from the initial semantic features, each feature extraction layer further extracts the output data of the previous feature extraction layer. On this basis, data and output data are extracted from the storage unit as input data for the next feature extraction layer, realizing multi-dimensional feature extraction of the language to be recognized and improving the accuracy of feature extraction.
[0067] In some embodiments, the preset storage unit includes multiple storage bits, and the process of storing the output data of the previous feature extraction layer in the preset storage unit in step S11 is as follows: for any storage bit, the data of the storage bit at the current calculation time is determined based on the data stored in the storage bit at the previous calculation time, the data of the adjacent storage bits of the storage bit, and the preset probability; the adjacent storage bits include the low-order storage bits and the high-order storage bits adjacent to the storage bit; the calculation time refers to the time when the corresponding feature extraction layer performs calculation and stores the output result in the preset storage unit, and one calculation time corresponds to one feature extraction layer.
[0068] The preset storage unit can be a stack storage unit, such as... Figure 4 As shown, a preset storage unit may include n storage bits. When storing the output data of the previous feature extraction layer into the preset storage unit, the preset probabilities include the write probability, the invariance probability, and the deletion probability. Taking any storage bit as an example, the weighted result of the first, second, and third stored data from the previous calculation time is determined as the data stored in the storage bit at the current calculation time. Specifically, the first stored data is the product of the data stored in the lower storage bits and the write probability; the second stored data is the product of the data stored in the storage bit and the invariance probability; and the third stored data is the product of the data stored in the higher storage bits and the deletion probability.
[0069] Specifically, the data corresponding to the storage bit can be calculated using the following formula:
[0070] stack t [n] = stack t-1 [n-1]×action[push]t +stack t-1 [n] × action[noop] t
[0071] +stack t-1 [n + 1] × action[pop] t
[0072] Where t is the calculation time, n is the index of the storage bit, stack t [n] is the data stored in the nth storage bit at the current calculation time, stack t-1 [n - 1] is the data stored in the (n - 1)th storage bit (lower - order storage bit) at the previous calculation time, action[push] t is the write probability at the current calculation time, stack[[ID=For example, for any feature extraction layer, the input data of the feature extraction layer is the fused feature obtained by the output of the previous extraction layer and the data in the storage unit. Specifically, the fused feature can be obtained by directly concatenating two data, or by weighted summation of two data. The embodiments of this application do not limit the combination form of the fused feature, and those skilled in the art can determine it according to the actual situation.
[0077] If the feature extraction layer is the first layer, i.e., j=1, then the second semantic feature is empty, and the first semantic feature is the initial semantic feature; if the feature extraction layer is the last layer, then the output data needs to be stored in the storage unit, i.e., j=i, and the semantic feature output by the j-th feature extraction layer is used as the predicted semantic feature.
[0078] In some embodiments, the fusion feature can also be generated in the following manner: concatenating the first semantic feature and the second semantic feature to obtain the third semantic feature; performing a dot product operation between the third semantic feature and a preset weight matrix to obtain the probability of each element in the third semantic feature; and obtaining the fusion feature based on each element in the third semantic feature and the probability corresponding to each element.
[0079] For example, during feature fusion, the first and second semantic features can be concatenated to obtain the third semantic feature. After obtaining the third semantic feature, the probability of each element in the third semantic feature is calculated. Specifically, the probability of each element can be obtained by passing the third semantic feature through a fully connected layer. The fused feature is obtained by weighted summation of each element and its corresponding probability.
[0080] In some embodiments, regularization can be performed after weighted summation, and the fusion feature can be obtained after averaging. Specifically, each element in the third semantic feature is multiplied by its corresponding probability to obtain a probabilistic fusion feature; the probabilistic fusion features corresponding to each element in the third semantic feature are added together to obtain an initial fusion feature; the initial fusion feature is divided by the number of elements to obtain the fusion feature.
[0081] In step S32, the loss value between the predicted semantic features and the standard semantic features of the language is calculated.
[0082] In step S33, if the loss value meets the preset convergence condition, the model to be trained is determined as the target inference language model based on a differentiable stack. The target inference language model based on a differentiable stack has the function of recognizing the semantic features of the language.
[0083] For example, the loss function can be mean squared error, cross-entropy loss, etc., and the specific choice depends on the representation of the semantic features (continuous values or discrete categories). This application does not limit the specific form of the loss function, and those skilled in the art can determine it according to the actual situation.
[0084] The model is trained using optimization algorithms (such as Adam, SGD, etc.) to minimize the loss function. During training, the model weights are updated using the backpropagation algorithm.
[0085] Set a preset convergence condition, such as the loss value falling below a certain threshold, or the loss value no longer decreasing significantly after a certain number of training epochs. Use a validation set to monitor the model's performance to avoid overfitting, and complete the training of the inference language model based on a differentiable stack.
[0086] The method for training a differentiable stack-based inference language model provided in this disclosure involves calling the model to be trained to sequentially extract initial semantic features of a language multiple times to obtain predicted semantic features; calculating the loss value between the predicted semantic features and the standard semantic features of the language; and if the loss value meets a preset convergence condition, determining the model to be trained as the target differentiable stack-based inference language model, which has the function of recognizing the semantic features of a language. The model to be trained includes i feature extraction layers. Since the input data of the next feature extraction layer includes data read from a preset storage unit and the output data of the previous feature extraction layer, when the next feature extraction layer extracts features, the input data, in addition to the original output data of the previous feature extraction layer, includes the data stored in the preset storage unit, improving the accuracy of language recognition. Furthermore, the target differentiable stack-based inference language model trained according to subsequent steps can handle languages with a certain degree of complexity.
[0087] This disclosure also proposes a reasoning method based on a differentiable stack-based reasoning language model, such as... Figure 5 As shown in the embodiments of this disclosure, the reasoning method for a differentiable stack-based reasoning language model may include the following steps:
[0088] Step S51: Obtain the language to be recognized and extract the initial semantic features of the language to be recognized;
[0089] Step S52: Invoke the target's differential stack-based inference language model to extract features from the initial semantic features and obtain the semantic features of the language to be identified; the target's differential stack-based inference language model is trained by the differential stack-based inference language model training method of the above embodiment.
[0090] For example, the language to be identified is obtained from user input or a data source (database, file, etc.). Initial semantic features of the language are extracted using convolutional processing or other custom methods. These features may be Bag of Words, TF-IDF, word embeddings (such as Word2Vec, BERT), etc. The initial semantic features are inferred using a target-based differentiable stack-based inference language model, and the desired semantic features are obtained from the model's output. These features can be used for subsequent tasks, such as classification, clustering, information retrieval, etc. Specifically, the feature extraction process is the same as in the above embodiments, and will not be repeated here.
[0091] Corresponding to the above implementation of the reasoning language model training method based on a differentiable stack, this disclosure also provides a reasoning language model training device based on a differentiable stack, which is used to execute the above-described reasoning language model training method. Figure 3 A method for training a differentiable stack-based inference language model, illustrating any embodiment. The apparatus for training this differentiable stack-based inference language model includes:
[0092] The feature extraction module is used to call the model to be trained to sequentially extract the initial semantic features of the language multiple times to obtain the predicted semantic features; the model to be trained includes i feature extraction layers, and the input data of any feature extraction layer includes data read from a preset storage unit and the output data of the previous feature extraction layer, wherein the data in the preset storage unit is the stored output data of the previous feature extraction layer; i is greater than or equal to 2;
[0093] A loss calculation module is used to calculate the loss value between the predicted semantic features and the standard semantic features of the language;
[0094] An optimization module is used to determine the model to be trained as a target inference language model based on a differentiable stack if the loss value meets a preset convergence condition. The target inference language model based on a differentiable stack has the function of recognizing the semantic features of the language.
[0095] The inference language model training device based on a differentiable stack provided in the above embodiments of this disclosure and the inference language model training method based on a differentiable stack provided in the embodiments of this disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.
[0096] Corresponding to the above implementation of the reasoning method for a differentiable stack-based reasoning language model, this disclosure also provides a reasoning device for a differentiable stack-based reasoning language model, which is used to execute the above-described reasoning method for a differentiable stack-based reasoning language model. Figure 3 An illustrated embodiment of a reasoning method based on a differentiable stack for a language model. The language recognition apparatus includes:
[0097] The recognition module is used to acquire the language to be recognized and extract the initial semantic features of the language to be recognized;
[0098] The output module is used to call the target inference language model based on a differentiable stack to extract features from the initial semantic features and obtain the semantic features of the language to be identified; the target inference language model based on a differentiable stack is trained by the inference language model training method based on a differentiable stack described in the above embodiment.
[0099] The language recognition device provided in the above embodiments of this disclosure and the reasoning method based on a differentiable stack for reasoning language models provided in the embodiments of this disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.
[0100] This disclosure also provides an electronic device for performing the above-described data transmission method. Please refer to... Figure 6 This illustrates a schematic diagram of an electronic device provided by some embodiments of the present disclosure. For example... Figure 6 As shown, the electronic device includes: a processor 600, a memory 601, a bus 602, and a communication interface 603. The processor 600, the communication interface 603, and the memory 601 are connected via the bus 602. The memory 601 stores a computer program that can run on the processor 600. When the processor 600 runs the computer program, it executes the aforementioned provisions of this disclosure. Figure 3 or Figure 5 The method provided by any of the illustrated embodiments.
[0101] The memory 601 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 603 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.
[0102] Bus 602 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. Memory 601 is used to store programs. After receiving execution instructions, processor 600 executes the program, as described above. Figure 3 or Figure 5 The method disclosed in any of the illustrated embodiments can be applied to or implemented by the processor 600.
[0103] The processor 600 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 600 or by instructions in software form. The processor 600 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 601. Processor 600 reads the information in memory 601 and, in conjunction with its hardware, completes the steps of the above method.
[0104] The electronic device and the data transmission method provided in this disclosure are based on the same inventive concept and have the same beneficial effects as the methods they employ, operate, or implement.
[0105] This disclosure also provides a computer-readable storage medium corresponding to the data transmission method provided in the foregoing embodiments. Please refer to... Figure 7 The computer-readable storage medium shown is an optical disc 30, on which a computer program (i.e., a program product) is stored. When the computer program is run by the microprocessor, it executes the data transmission method provided in any of the aforementioned embodiments.
[0106] It should be noted that examples of computer-readable storage media may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be elaborated here.
[0107] The computer-readable storage medium provided in the above embodiments of this disclosure and the data transmission method provided in the embodiments of this disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.
[0108] It should be noted that:
[0109] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of this disclosure may be practiced without these specific details. In some instances, well-known structures and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0110] Similarly, it should be understood that, in order to simplify this disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of this disclosure, various features of this disclosure are sometimes grouped together in a single embodiment, figure, or description thereof. However, this approach to disclosure should not be construed as reflecting a schematic diagram in which the claimed disclosure requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of this disclosure.
[0111] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of this disclosure and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
[0112] The above are merely preferred embodiments of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A method for training a reasoning language model based on a differentiable stack, characterized in that, The method includes: Calling a to-be-trained model to sequentially perform multiple feature extractions on the initial semantic features of a language to obtain predicted semantic features; the to-be-trained model includes i feature extraction layers, the input data of any feature extraction layer includes data read from a preset storage unit and the output data of the previous feature extraction layer, and the data in the preset storage unit is the output data stored in the previous feature extraction layer; i is greater than or equal to 2; Calculating a loss value between the predicted semantic features and the standard semantic features of the language; If the loss value meets a preset convergence condition, determining the to-be-trained model as a target differentiable-stack-based inference language model, and the target differentiable-stack-based inference language model has the function of recognizing the semantic features of the language; The preset storage unit includes multiple storage bits, and the data in the preset storage unit is the output data stored in the previous feature extraction layer, including: For any storage bit, based on the data stored in the storage bit at the previous calculation moment, the data of the adjacent storage bits of the storage bit, and a preset probability, determining the data of the storage bit at the current calculation moment; the adjacent storage bits include the lower storage bit and the higher storage bit adjacent to the storage bit; the calculation moment refers to the moment when the corresponding feature extraction layer performs calculation and stores the output result in the preset storage unit, and one calculation moment corresponds to one feature extraction layer; If the storage bit is the lowest storage bit among the multiple storage bits, the data of the lower storage bit in the adjacent storage positions is the output data of the corresponding feature extraction layer at the previous calculation moment; If the storage bit is the highest storage bit among the multiple storage bits, the data stored in the higher storage bit in the adjacent storage positions is empty.
2. The method according to claim 1, characterized in that, The preset probability includes a write probability, an unchanged probability, and a delete probability, and the determining the data of the storage bit at the current calculation moment based on the data stored in the storage bit at the previous calculation moment, the data of the adjacent storage bits of the storage bit, and the preset probability includes: Determining the weighted result of the first storage data, the second storage data, and the third storage data at the previous calculation moment as the data stored in the storage bit at the current calculation moment; Among them, the first storage data is the product of the data stored in the lower storage bit and the write probability; the second storage data is the product of the data stored in the storage bit and the unchanged probability; the third storage data is the product of the data stored in the higher storage bit and the delete probability.
3. The method according to claim 1 or 2, characterized in that, The calling the to-be-trained model to sequentially perform multiple feature extractions on the initial semantic features of a language to obtain predicted semantic features includes: If 1 < j < i, performing feature extraction based on the fused semantic features and the j-th feature extraction layer to obtain the semantic features output by the j-th feature extraction layer; the fused semantic features are obtained according to the first semantic features output by the (j - 1)-th feature extraction layer and the second semantic features extracted from the preset storage unit; 1 < j ≤ i; If j = 1, the second semantic features are empty, and the first semantic features are the initial semantic features; If j = i, taking the semantic features output by the j-th feature extraction layer as the predicted semantic features.
4. The method according to claim 3, characterized in that, The fused features are obtained based on the first semantic features output by the (j-1)th feature extraction layer and the second semantic features extracted from the preset storage unit, including: The first semantic feature and the second semantic feature are concatenated to obtain the third semantic feature; The probability of each element in the third semantic feature is obtained by performing a dot product operation between the third semantic feature and the preset weight matrix. The fusion feature is obtained based on each element in the third semantic feature and the probability corresponding to each element.
5. The method according to claim 4, characterized in that, The fusion feature, obtained based on each element in the third semantic feature and the probability corresponding to each element, includes: Each element in the third semantic feature is multiplied by its corresponding probability to obtain the probability fusion feature; The probability fusion features corresponding to each element in the third semantic feature are added together to obtain the initial fusion feature; The initial fusion feature is divided by the number of elements to obtain the fusion feature.
6. The method according to claim 5, characterized in that, The feature extraction layer is an encoding layer and / or a decoding layer; and / or, The feature extraction layer is a self-attention layer and / or a feedforward neural network layer in the encoding layer and / or decoding layer.
7. A reasoning method for a reasoning language model based on a differentiable stack, characterized in that, The method includes: Obtain the language to be identified and extract the initial semantic features of the language to be identified; The target inference language model based on a differentiable stack is invoked to extract features from the initial semantic features, thereby obtaining the semantic features of the language to be identified; the target inference language model based on a differentiable stack is trained by the method described in any one of claims 1-6.
8. A reasoning language model based on a differentiable stack, characterized in that, It includes an input layer, a recognition layer, and an output layer. The recognition layer includes i feature extraction layers and a storage unit. The input data of any feature extraction layer includes data read from the storage unit and the output data of the previous feature extraction layer. The data in the storage unit is the stored output data of the previous feature extraction layer. The i is greater than or equal to 2. The differentiable stack-based reasoning language model is the target differentiable stack-based reasoning language model in the reasoning method based on the differentiable stack-based reasoning language model described in claim 7.
9. A computer device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to cause the at least one processor to perform the steps of the method as described in any one of claims 1-7.