Code generation method and device, electronic equipment and storage medium
By generating the difference distribution between the first and second probability distributions, the target word sequence is determined, which solves the problem of inaccurate code caused by the reduced importance of key information in the prior art, and improves the accuracy and matching degree of code generation.
Patent Information
- Application Number
- CN202511522735.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2026-03-17
AI Technical Summary
In the existing technology, the importance of key information is reduced during the code generation process, resulting in inaccurate generated code.
By parsing natural language search text, the difference distribution between the first and second probability distributions is generated to determine the target word sequence. The difference distribution between masked semantic features and original semantic features is used to enhance the importance of key information and generate target code.
It improves the accuracy of target word sequences and enhances the matching degree between the generated code and the corresponding information in the natural language search text.
Smart Images

Figure CN121680852A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, specifically to a code generation method, apparatus, electronic device, and storage medium. Background Technology
[0002] Code generation is a technology that uses a code generation model to output code based on input requirements described in natural language. Typically, the process of a code generation model generating code based on requirements information involves parsing key information within the requirements and generating corresponding code based on that information.
[0003] However, in related technologies, the importance of some key information in the requirement information is reduced during the code generation process, which leads to inaccurate generated code. Summary of the Invention
[0004] This disclosure proposes a code generation method, apparatus, electronic device, and storage medium.
[0005] A first aspect of this disclosure provides a code generation method, the method comprising: In response to obtaining natural language search text, at least one key piece of information in the corresponding demand information of the natural language search text is parsed; the key piece of information is a phrase representing the user's intent; For any key information, a difference distribution between a first probability distribution and a second probability distribution is generated; wherein, the first probability distribution represents the word probability distribution corresponding to a preset word library obtained based on mask semantic features, and the mask semantic features refer to the semantic features corresponding to the natural language search text after hiding the key information; the second probability distribution represents the word probability distribution corresponding to a preset word library obtained based on the semantic features of the natural language search text. The target word sequence corresponding to the key information is determined based on the second probability distribution and the difference distribution. Having obtained the target word sequences corresponding to each key piece of information, target code is generated based on each target word sequence.
[0006] In this embodiment of the disclosure, generating the difference distribution between the first probability distribution and the second probability distribution includes: Extract the first semantic features of the natural language search text; The key information is hidden to obtain the masked text, and the second semantic feature of the masked text is extracted to obtain the masked semantic feature; The first probability distribution is generated based on the second semantic feature, and the second probability distribution is generated based on the first semantic feature; By comparing the second probability distribution with the first probability distribution, the difference distribution is obtained.
[0007] In this embodiment of the disclosure, determining the target word sequence corresponding to the key information based on the difference distribution includes: Based on the second probability distribution and the difference distribution, the target word for the current search round is determined; If the preset search conditions are not met, the step of parsing the natural language search text until the target word is obtained is repeated to obtain the target word corresponding to the next search round; wherein, the preset search conditions include at least one of the following: the last word in the target word sequence is the end word, and the current search round is the maximum value of the preset search round number; If the preset search conditions are met, a target word sequence corresponding to the key information is generated based on the target word and historical target word; wherein, the historical target word represents the target word sequence obtained in the historical search rounds.
[0008] In this embodiment of the disclosure, the target term further includes term probabilities; determining the target term for the current search round based on the second probability distribution and the difference distribution includes: Using a preset set of influence factors, multiple sequences of first influence parameters are generated for the difference distribution; each of the multiple initial influence parameter sequences corresponds one-to-one with a preset influence factor. Based on the second probability distribution and the plurality of first influence probability sequences, a plurality of second influence parameter sequences are obtained; For any second influence parameter sequence, determine the initial influence parameter that meets the preset conditions in the second influence parameter sequence; The lexical units corresponding to the initial influence parameters are used as the target lexical units corresponding to the influence parameter sequence.
[0009] In this embodiment of the disclosure, the method further includes: If at least two second influence parameter sequences correspond to the same target word, and the target word is the same word, then the target influence parameter corresponding to the same target word is determined based on the initial influence parameter corresponding to the same target word.
[0010] In this embodiment of the disclosure, if the target lexical units corresponding to the plurality of second influence parameter sequences include at least two, the step of generating the target lexical unit sequence corresponding to the key information based on the target lexical units and historical target lexical units includes: The historical target word is combined with the at least two target word to form word sequences, resulting in multiple word sequences; If the number of word sequences is greater than the preset number, then the sequences to be deleted are determined based on the sequence probability of each word sequence. The target lexical sequence is obtained by deleting the sequence to be deleted from the plurality of lexical sequences.
[0011] In this embodiment of the disclosure, the sequence probability is the mean or product of the target word probabilities of the word sequence corresponding to the word words.
[0012] A second aspect of this disclosure provides a code generation apparatus, the apparatus comprising: The parsing module is used to, in response to obtaining natural language search text, parse at least one key piece of information in the corresponding demand information of the natural language search text; the key piece of information is a phrase representing the user's intent; The difference generation module is used to generate a difference distribution between a first probability distribution and a second probability distribution for any key information; wherein, the first probability distribution represents the word probability distribution corresponding to a preset word library obtained based on mask semantic features, and the mask semantic features refer to the semantic features corresponding to the natural language search text after hiding the key information; the second probability distribution represents the word probability distribution corresponding to a preset word library obtained based on the semantic features of the natural language search text. The lexical sequence determination module is used to determine the target lexical sequence corresponding to the key information based on the second probability distribution and the difference distribution. The code generation module is used to generate target code based on the target word sequences corresponding to each key information.
[0013] According to a third aspect of the present application, an electronic device is provided, 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 method as described in the first aspect or any optional embodiment of the first aspect.
[0014] According to a fourth 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 method as described in the first aspect or any optional embodiment of the first aspect.
[0015] The technical solutions provided in this disclosure have at least the following technical effects or advantages: In response to acquiring natural language search text, at least one key piece of information in the corresponding demand information of the natural language search text is parsed. For any key piece of information, to determine its importance, a second probability distribution obtained from the semantic features of the natural language search text and a first probability distribution corresponding to a preset lexicon library obtained from masked semantic features are generated. Since the masked semantic features are the semantic features of the natural language search text after hiding the key information, the influence of the key information on the generated lexicon probability distribution can be determined by the difference distribution between the first and second probability distributions. A target lexicon sequence is then determined based on this difference distribution and the second probability distribution, which improves the accuracy of the target lexicon sequence to a certain extent. Finally, target code is generated based on the target lexicon sequence, improving the matching degree between the target code and the demand information corresponding to the natural language search text.
[0016] 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
[0017] 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. In the drawings: Figure 1 A flowchart of a code generation method provided in an embodiment of this disclosure is shown; Figure 2 A schematic diagram of a code generation method provided in yet another embodiment of this disclosure is shown; Figure 3 A schematic diagram of the structure of a code generation apparatus provided in yet another embodiment of this disclosure is shown; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure is shown; Figure 5 A schematic diagram of a storage medium provided according to an embodiment of the present disclosure is shown. Detailed Implementation
[0018] 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.
[0019] 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.
[0020] Code generation is a technique that uses a code generation model to output code based on input natural language descriptions of requirements. Typically, the code generation model identifies requirements information in a natural language search text and searches for corresponding target terms in a pre-defined lexicon based on the key information within those requirements. During the search process, the importance of some key information is gradually reduced, resulting in inaccurate target terms and consequently, inaccurate generated code.
[0021] In view of this, embodiments of this disclosure propose a code generation method to solve the above-mentioned problems. For example... Figure 1 As shown, the code generation method of this disclosure embodiment may include the following steps: In step S11, in response to obtaining the natural language search text, at least one key piece of information in the corresponding demand information of the natural language search text is parsed.
[0022] Among them, the key information is phrases that represent the user's intent.
[0023] For example, the natural language search text can be the language text input by the user into the code generation model. After obtaining the natural language search text, corresponding semantic features can be identified, and the corresponding code generation requirements can be obtained based on these semantic features. The requirements include at least one key piece of information corresponding to the generated code, such as restrictions on the code looping method, restrictions on the calculation method, etc.
[0024] In step S12, for any key information, the difference distribution between the first probability distribution and the second probability distribution is generated.
[0025] The first probability distribution represents the probability distribution of the lexicon corresponding to the preset lexicon library obtained based on the mask semantic features. The mask semantic features refer to the mask semantic features of the natural language search text after hiding key information. The second probability distribution represents the probability distribution of the lexicon corresponding to the preset lexicon library obtained based on the original semantic features of the natural language search text.
[0026] For example, the mask semantic features replace key information with special symbols (such as [MASK]), and then the encoder obtains the context vector. The preset lexicon can be a candidate word list pre-built by the code generation model, which can be the entire vocabulary or a subset filtered according to the business logic of the natural language search text, containing N tokens. The difference distribution can be the difference between the first probability distribution and the second probability distribution, and this difference distribution has the same dimension as the preset lexicon.
[0027] Searching is performed separately based on the original semantic features and the masked semantic features to obtain the probability of each word in the corresponding preset lexical table. The probability of each word in the preset lexical table is the corresponding probability distribution. That is, it is the second probability distribution corresponding to the original semantic features and the first probability distribution corresponding to the masked semantic features. The first probability distribution and the second probability distribution are compared to obtain the difference distribution. This difference distribution is the original probability of the corresponding word in the preset lexical table corresponding to the first probability distribution minus the masked probability of the corresponding word in the preset lexical table corresponding to the second probability distribution, to obtain the difference probability of the corresponding word; the difference probabilities corresponding to each word in the preset lexical table constitute the difference distribution.
[0028] In some embodiments, the above-mentioned generation of the difference distribution between the first probability distribution and the second probability distribution can also be achieved by: extracting the first semantic features of the natural language search text; obtaining a masked text by hiding key information, extracting the second semantic features of the masked text, and obtaining the masked semantic features; generating the first probability distribution based on the second semantic features, and generating the second probability distribution based on the first semantic features; comparing the second probability distribution and the first probability distribution to obtain the difference distribution.
[0029] For example, the natural language search text after hiding key information and the natural language search text input encoder are used. The mask semantic features and the original semantic features are obtained by taking the corresponding mask position in the last layer (if the mask is a single symbol) or by taking the whole sentence pooling vector, respectively. This process ensures that the parameters are shared between the two forward propagations, avoiding the introduction of additional randomness. The mask semantic features and the original semantic features are then mapped to a preset lexicon dimension N, respectively, to obtain a first probability distribution and a second probability distribution.
[0030] The probability distributions of two N-dimensional vectors are arithmetically different: the difference distribution = first probability distribution - second probability distribution. The resulting vector can also be normalized to obtain the difference distribution. In this distribution, a significantly positive value indicates that the "key information" strongly supports the selection of the word; a significantly negative value indicates that the "key information" inhibits the selection of the word; and a value close to zero indicates that the word is almost unaffected by the key information.
[0031] In step S13, the target word sequence corresponding to the key information is determined according to the second probability distribution and the difference distribution.
[0032] For example, the difference probability corresponding to each word in the difference distribution can be used to select word elements that satisfy a predetermined probability threshold from the probability of the difference distribution plus the corresponding probability in the second probability distribution as target word elements. The predetermined probability threshold can be the probability of a positive difference. Word elements with positive difference probabilities are ranked from high to low, and the top K (e.g., K=5) are selected to obtain the initial screening list of "words most favored by key information". This initial screening list can be used as the target word element sequence.
[0033] If the target word corresponding to the current difference distribution is not the end word, further searching is needed to obtain the end word or trigger the end of the search. Therefore, the above method of determining the target word sequence corresponding to key information based on the difference distribution can also be implemented in the following way: determine the target word of the current search round based on the second probability distribution and the difference distribution; if the preset search conditions are not met, repeat the step of parsing the natural language search text until the target word is obtained, so as to obtain the target word corresponding to the next search round; if the preset search conditions are met, generate the target word sequence corresponding to the key information based on the target word and the historical target word; wherein, the historical target word represents the target word sequence obtained in the historical search round. The preset search conditions include at least one of the following: the last word in the target word sequence is the end word, and the current search round is the maximum value of the preset search round number. For example, the target word can be a word whose probability in the difference probability plus the probability in the second probability distribution satisfies a predetermined preset probability threshold. If the current target word is the end word in the preset word list (which can be determined according to the word identifier, etc.), then each target word is used as a target word sequence; if there are historical target words before generating the target word, then the corresponding target word sequence is generated based on the historical target words and the current target word. There is also a case where, if the current target word is not the end word in the preset word list, further searching can be performed to obtain the target word corresponding to the next search round, until the end word is obtained or the search round reaches the maximum search round. Based on the target words corresponding to each search round, a target word sequence is obtained by combining them.
[0034] like Figure 2 As shown, assuming the target terms in the previous search round were A and B, and neither A nor B is an ending term, and the search round is not the maximum search round, the search continues. Based on target term A, the search yields target terms A1, A2, and A3; based on target term B, there is no next target term. In this case, if A1, A2, and A3 are ending terms, or the search round for A1, A2, and A3 is the maximum search round, then the target term sequence is obtained based on A1, A2, A3, and A and B. The corresponding target term sequences are: Sequence 1 (key information - A - A1), Sequence 2 (key information - A - A2), Sequence 3 ((key information - A - A3)), and Sequence 4 (key information - B).
[0035] In some embodiments, to further improve the accuracy of the difference distribution and avoid the influence of outliers such as maximum or minimum values corresponding to the difference distribution, the target word can be determined in the following way: using a preset set of influence factors, a plurality of first influence parameter sequences of the difference distribution are generated; the plurality of initial influence parameter sequences correspond one-to-one with the preset influence factors; according to the second probability distribution and the plurality of first influence probability sequences, a plurality of second influence parameter sequences are obtained; for any second influence parameter sequence, an initial influence parameter that meets a preset condition is determined in the second influence parameter sequence; the word corresponding to the initial influence parameter is taken as the target word corresponding to the influence parameter sequence.
[0036] For example, the preset impact factor set can be a set of numbers from 0 to 1, such as {0.1, 0.3, 0.5, 0.7, 0.9}. The embodiments of this application do not limit the above-mentioned preset impact factor set, and those skilled in the art can set it according to the actual situation.
[0037] Given a set of influencing factors, each influencing factor in the set can be used as a weight coefficient, multiplied by the differences in the difference distribution, and then added to a second probability distribution to obtain multiple sequences of second influencing parameters corresponding to each influencing factor. Each influencing parameter sequence is the product of the difference and the influencing factor. Each of the multiple first influencing parameter sequences is also a product of the difference and the influencing factor. For any given second influencing parameter sequence, those in the sequence with influencing parameters greater than a preset threshold are taken as initial influencing parameters; and the word corresponding to this initial influencing parameter is taken as the target word in that influencing parameter sequence.
[0038] When multiple second influence parameter sequences correspond to target words, if at least two second influence parameter sequences correspond to the same target word, the target influence parameter corresponding to the same target word is determined based on the initial influence parameters corresponding to the same target word. For example, if the initial influence parameters corresponding to the same target word are 60% and 30%, the target influence parameter can be the product of the two initial influence parameters, or the mean, etc.
[0039] To reduce the computational load during the target word sequence search process, a limit can be set on the number of target word sequences, and corresponding deletions can be made when the number exceeds a preset threshold. In some embodiments, if the target words corresponding to multiple second influence parameter sequences include at least two, a target word sequence corresponding to the key information is generated based on the target word words and historical target word words. This includes: combining historical target word words with at least two target word words to form word sequences, obtaining multiple word sequences; if the number of word sequences is greater than a preset limit, determining the sequences to be deleted based on the sequence probability of each word sequence; and deleting the sequences to be deleted from the multiple word sequences to obtain the target word sequence.
[0040] For example, in Figure 2 In this scenario, the number of target word sequences is 4. If the preset threshold is 3, then one needs to be removed. The removal criteria can be determined based on the product or mean of the target influence parameters corresponding to each word sequence. For example, if the mean of the target influence parameters for each word in sequence 1 is 20%, the mean of the target influence parameters for each word in sequence 2 is 40%, the mean of the target influence parameters for each word in sequence 3 is 15%, and the mean of the target influence parameters for each word in sequence 4 is 50%, then the sequence to be removed in the current search round is sequence 3, and the target word sequences are sequence 1, sequence 2, and sequence 4.
[0041] If the current search round is not the last search round, the search continues in the next round based on Sequence 1, Sequence 2, and Sequence 4; if the current search round is the last search round, the target word sequence corresponding to the key information is determined based on Sequence 1, Sequence 2, and Sequence 4. In this step, the sequence with the largest mean of the target influence parameter is selected as the target word sequence.
[0042] In step S14, after obtaining the target word sequence corresponding to each key information, target code is generated based on each target word sequence.
[0043] For example, the target word sequences corresponding to each key piece of information are converted into target code strings using a decoder (such as a Transformer-based decoder). Code formatting tools (such as autopep8 for Python) can also be used to ensure consistent code style. When generating multiple code segments, variable scope and function call relationships need to be integrated (e.g., ensuring function definitions are used before they are called).
[0044] The code generation method provided in this disclosure, in response to obtaining natural language search text, parses at least one key piece of information in the corresponding demand information of the natural language search text; for any key piece of information, to determine the importance of the key piece of information, it generates a second probability distribution obtained from the semantic features of the natural language search text, and a first probability distribution corresponding to a preset lexicon obtained from masked semantic features. Since the masked semantic features are the semantic features corresponding to the natural language search text after hiding the key information, the influence of the key information on the generated lexicon probability distribution can be determined by the difference distribution between the first probability distribution and the second probability distribution. A target lexicon sequence is determined based on this difference distribution, which improves the accuracy of the target lexicon sequence to a certain extent. Finally, target code is generated based on the target lexicon sequence, improving the matching degree between the target code and the demand information corresponding to the natural language search text.
[0045] Corresponding to the above implementation of the code generation method, this disclosure also provides a code generation method apparatus, which is used to execute the above... Figure 1 Code generation methods for any of the illustrated embodiments. For example... Figure 3 As shown, the code generation device includes: The parsing module 301 is used to parse at least one key piece of information in the request information corresponding to the natural language search text in response to obtaining the natural language search text; the key piece of information is a phrase that represents the user's intent; The difference generation module 302 is used to generate a difference distribution between a first probability distribution and a second probability distribution for any key information; wherein, the first probability distribution represents the word probability distribution corresponding to a preset word library obtained based on mask semantic features, and the mask semantic features refer to the mask semantic features corresponding to the natural language search text after hiding the key information; the second probability distribution represents the word probability distribution corresponding to a preset word library obtained based on the original semantic features of the natural language search text. The lexical sequence determination module 303 is used to determine the target lexical sequence corresponding to the key information based on the second probability distribution and the difference distribution. The code generation module 304 is used to generate target code based on the target word sequences corresponding to each key information.
[0046] Optionally, the difference generation module is further configured to: extract the original semantic features of the natural language search text; obtain a masked text by hiding key information, extract the masked semantic features of the masked text, and obtain masked semantic features; generate the first probability distribution based on the second semantic features, and generate the second probability distribution based on the first semantic features; compare the second probability distribution and the first probability distribution to obtain a difference distribution.
[0047] Optionally, the module for determining the word sequence is further configured to: determine the target word for the current search round based on the difference distribution; If the preset search conditions are not met, the step of parsing the natural language search text until the target word is obtained is repeated to obtain the target word corresponding to the next search round; wherein, the preset search conditions include at least one of the following: the last word in the target word sequence is the end word, and the current search round is the maximum value of the preset search round number; If the preset search conditions are met, a target word sequence corresponding to the key information is generated based on the target word and historical target word; wherein, the historical target word represents the target word sequence obtained in the historical search rounds.
[0048] Optionally, the module for determining the word sequence is further configured to: generate multiple influence parameter sequences of the difference distribution using a preset set of influence factors; the multiple influence parameter sequences correspond one-to-one with the preset influence factors; For any sequence of influence parameters, determine the initial influence parameters that satisfy the preset conditions in the sequence of influence parameters; The lexical corresponding to the initial influence parameter is used as the target lexical corresponding to the influence parameter sequence.
[0049] Optionally, the module for determining the word sequence is further configured to: when the target words corresponding to the plurality of influence parameter sequences are obtained respectively, if the target words corresponding to at least two influence parameter sequences are the same word words, then determine the target influence parameters corresponding to the same target word words based on the initial influence parameters corresponding to the same target word words respectively.
[0050] Optionally, if the target lexical units corresponding to the plurality of influence parameter sequences include at least two, the lexical unit sequence determination module is further configured to combine the historical target lexical units with the at least two target lexical units to form lexical units sequences, thereby obtaining a plurality of lexical units sequences; If the number of word sequences is greater than the preset number, then the sequences to be deleted are determined based on the sequence probability of each word sequence. The target lexical sequence is obtained by deleting the sequence to be deleted from the plurality of lexical sequences.
[0051] Optionally, the sequence probability is the mean or product of the target word probabilities of the corresponding word words in the word sequence.
[0052] The code generation apparatus and the code generation method provided in the above 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.
[0053] This disclosure also provides an electronic device for performing the above-described data transmission method. Please refer to... Figure 4 This illustrates a schematic diagram of an electronic device provided by some embodiments of the present disclosure. For example... Figure 4 As shown, the electronic device includes: a processor 400, a memory 401, a bus 402, and a communication interface 404. The processor 400, the communication interface 404, and the memory 401 are connected via the bus 402. The memory 401 stores a computer program that can run on the processor 400. When the processor 400 runs the computer program, it executes the aforementioned provisions of this disclosure. Figure 1 The method provided by any of the illustrated embodiments.
[0054] The memory 401 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 404 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.
[0055] Bus 402 can be an ISA bus, PCI bus, or EISA bus, etc. Buses can be divided into address buses, data buses, control buses, etc. Memory 401 is used to store programs; after receiving execution instructions, processor 400 executes the program, as described above. Figure 1 The method disclosed in any of the illustrated embodiments can be applied to or implemented by the processor 400.
[0056] The processor 400 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 400 or by instructions in software form. The processor 400 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 401. The processor 400 reads the information in memory 401 and, in conjunction with its hardware, completes the steps of the above method.
[0057] 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.
[0058] This disclosure also provides a computer-readable storage medium corresponding to the data transmission method provided in the foregoing embodiments. Please refer to... Figure 5 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.
[0059] 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.
[0060] 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.
[0061] It should be noted that: 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.
[0062] 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.
[0063] 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.
[0064] 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 code generation method characterized by, The method comprises: In response to obtaining the natural language search text, parsing at least one key information in the demand information corresponding to the natural language search text; the key information is a phrase representing the user's intention; For any key information, generate a difference distribution of a first probability distribution and a second probability distribution; wherein the first probability distribution represents the word element probability distribution corresponding to the preset word element library obtained according to the mask semantic feature; the mask semantic feature refers to the mask semantic feature corresponding to the natural language search text after hiding the key information; the second probability distribution represents the word element probability distribution corresponding to the preset word element library obtained according to the original semantic feature of the natural language search text; Determine the target word element sequence corresponding to the key information according to the second probability distribution and the difference distribution; In the case of obtaining the target word element sequence corresponding to each key information, generate a target code according to each target word element sequence.
2. The method of claim 1, wherein, The generation of the difference distribution of the first probability distribution and the second probability distribution comprises: Extract the original semantic feature of the natural language search text; Extract the mask semantic feature of the mask text obtained by hiding the key information, to obtain the mask semantic feature; Generate the first probability distribution based on the second semantic feature, and generate the second probability distribution based on the first semantic feature; Compare the second probability distribution and the first probability distribution to obtain the difference distribution.
3. The method of claim 1, wherein, The determination of the target word element sequence corresponding to the key information according to the second probability distribution and the difference distribution comprises: Determine the target word element of the current search round according to the second probability distribution and the difference distribution; If the preset search condition is not met, repeat the steps of parsing the natural language search text to obtain the target word element to obtain the target word element corresponding to the next search round; wherein the preset search condition is at least one of the following: the last word element in the target word element sequence is an end word element, and the current search round is the maximum value of the preset search round number; If the preset search condition is met, generate the target word element sequence corresponding to the key information according to the target word element and the historical target word element; wherein the historical target word element represents the target word element sequence obtained in the historical search round.
4. The method of claim 3, wherein, The target word element further comprises a word element probability; the determination of the target word element of the current search round according to the second probability distribution and the difference distribution comprises: Generate a plurality of first influence parameter sequences of the difference distribution by using a preset influence factor set; the plurality of initial influence parameter sequences correspond one by one to the preset influence factor; Obtain a plurality of second influence parameter sequences according to the second probability distribution and the plurality of first influence probability sequences; For any second influence parameter sequence, determine an initial influence parameter in the second influence parameter sequence that satisfies a preset condition; The word element corresponding to the initial influence parameter is taken as the target word element corresponding to the influence parameter sequence.
5. The method of claim 4, wherein, The method further comprises: In a case where the plurality of second influence parameter sequences respectively correspond to target word units, if at least two second influence parameter sequences correspond to the same target word unit, a target influence parameter corresponding to the same target word unit is determined according to an initial influence parameter corresponding to the same target word unit.
6. The method of claim 4, wherein, If the target word units corresponding to the plurality of second influence parameter sequences include at least two, the target word unit sequence corresponding to the key information is generated according to the target word units and historical target word units, including: The historical target word units are respectively combined with the at least two target word units to form word unit sequences, to obtain a plurality of word unit sequences. If the number of word unit sequences is greater than a preset number, a sequence to be pruned is determined according to sequence probabilities of the word unit sequences. The target word unit sequence is obtained by deleting the sequence to be pruned from the plurality of word unit sequences.
7. The method of claim 6, wherein, The sequence probability is a mean value or a product of target word unit probabilities of the word units corresponding to the word unit sequence.
8. A code generation apparatus characterized by comprising: The device includes: The parsing module is configured to parse at least one key information in the demand information corresponding to the natural language search text in response to obtaining the natural language search text; the key information is a phrase representing a user's intention; The difference generation module is configured to generate a difference distribution of a first probability distribution and a second probability distribution for any key information; wherein the first probability distribution represents a word unit probability distribution of a preset word unit library obtained according to a mask semantic feature; the mask semantic feature refers to a mask semantic feature corresponding to the natural language search text after the key information is hidden; the second probability distribution represents a word unit probability distribution of a preset word unit library obtained according to an original semantic feature of the natural language search text; The target word unit sequence determination module is configured to determine a target word unit sequence corresponding to the key information according to the second probability distribution and the difference distribution; The code generation module is configured to generate a target code according to the target word unit sequence corresponding to each key information in a case where the target word unit sequence corresponding to each key information is obtained.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The computer program is run by the processor to enable the electronic device to perform the method of any one of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1-7.
