Word list generation method based on combination of code naming specifications and byte pair codes

Through the word list generation method based on code naming specifications and byte pair encoding, the problem of excessive vocabulary scale and no words in the prior art is solved, and the effect of reducing calculation complexity and improving the efficiency of the code completion model is achieved.

CN119180279APending Publication Date: 2024-12-24BEIJING GUIXIN TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411114173.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-12-24

AI Technical Summary

Technical Problem

During the word segmentation process of existing code completion models, the vocabulary scale is too large, resulting in increased computational complexity, and it is easy to have word problems not included in the vocabulary.

Method used

Using a word list generation method based on code naming specification and byte pair encoding, the sample code is segmented through the preset code naming specification, the occurrence frequency of word pairs is determined, the words are merged to meet the preset conditions, and the target word list is generated for use. Code completion model training.

Benefits of technology

The size of the vocabulary list is reduced, the computational complexity of the model is reduced, the words that do not exist in the vocabulary list are avoided, and the efficiency of the code completion model is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119180279A_ABST
    Figure CN119180279A_ABST
Patent Text Reader

Abstract

The invention provides a word list generation method based on combination of a code naming specification and byte pair coding. The method comprises the following steps: performing word segmentation on an obtained sample code through a preset code naming specification to obtain a first sequence; determining a plurality of word pairs of the first sequence; judging whether the plurality of word pairs meet a preset condition or not; if the plurality of word pairs meet a preset condition, determining the first sequence as a target word list; if the plurality of word pairs do not meet the preset condition, screening out a target word pair with the highest occurrence frequency from the plurality of word pairs; based on the target word pair, combining the plurality of words in the first sequence to obtain a second sequence; and taking the second sequence as a new first sequence, and repeatedly executing the step of determining the plurality of word pairs of the first sequence on the new first sequence until the plurality of word pairs meet a preset condition. According to the embodiment of the invention, the magnitude of the word list can be effectively reduced, the calculation complexity during model training and prediction is reduced, and then the completion efficiency of the code completion model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of large language models, and in particular to a vocabulary generation method based on a combination of code naming specifications and byte pair encoding. Background Art

[0002] With the development of deep learning and big model technology, more and more people are beginning to use deep learning or big model technology to solve code completion tasks in software development scenarios.

[0003] In the word segmentation process, existing code completion models generally use spaces or symbol separators to segment words to obtain a vocabulary. However, this word segmentation method is prone to the following problems: each word occupies a position in the vocabulary, causing the vocabulary to be too large, which will increase the computational complexity of the model.

[0004] Therefore, there is an urgent need for a vocabulary generation method based on a combination of code naming specifications and byte pair encoding to solve the above technical problems. Summary of the invention

[0005] In view of this, the present disclosure proposes a vocabulary generation method based on a combination of code naming specifications and byte pair encoding to solve the problem in the related art that the computational complexity of the model is increased due to the excessively large magnitude of the vocabulary.

[0006] The first aspect of the present disclosure provides a method for generating a vocabulary based on a combination of code naming specifications and byte pair encoding, the method comprising:

[0007] Segmenting the acquired sample code according to a preset code naming specification to obtain a first sequence; the first sequence includes a plurality of words;

[0008] Determine a plurality of word pairs of the first sequence; each word pair is obtained by combining any two adjacent words in the first sequence;

[0009] Determine whether the plurality of word pairs meet a preset condition; the preset condition is that the frequency of occurrence of each word pair in the plurality of word pairs is a preset frequency;

[0010] If the plurality of word pairs satisfy the preset condition, the first sequence is determined as a target vocabulary; the target vocabulary is used for training a code completion model;

[0011] If the plurality of word pairs do not satisfy the preset condition, selecting the target word pair with the highest occurrence frequency from the plurality of word pairs;

[0012] Based on the target word pair, merging multiple words in the first sequence to obtain a second sequence; the number of words in the second sequence is less than the number of words in the first sequence;

[0013] The second sequence is used as a new first sequence, and the step of determining a plurality of word pairs of the first sequence is repeated on the new first sequence until the plurality of word pairs meet the preset condition.

[0014] In an embodiment of the present disclosure, the method further includes:

[0015] The initial model is trained by using the target vocabulary to obtain a code completion model; the code completion model is used to complete the source code to be completed.

[0016] In the embodiment of the present disclosure, the acquired sample code is segmented according to a preset code naming specification to obtain a first sequence, including:

[0017] According to the root, each identifier in the sample code is segmented to obtain at least two words; and each non-identifier in the sample code is regarded as a word; wherein the first letter of the first word of the at least two words is lowercase, and the first letter of the subsequent words is capitalized.

[0018] In the embodiment of the present disclosure, determining a plurality of word pairs of the first sequence includes:

[0019] For any one of the multiple identifiers included in the sample code, every two adjacent words of at least two words included in the identifier are combined to obtain a word pair;

[0020] Based on at least one word pair corresponding to each identifier in the sample code, a first sequence of multiple word pairs corresponding to the sample code is obtained.

[0021] In the embodiment of the present disclosure, before determining whether the plurality of word pairs meet a preset condition, the method further includes:

[0022] A frequency of occurrence of each word pair in the plurality of word pairs in the plurality of word pairs is determined.

[0023] In the embodiment of the present disclosure, based on the target word pair, multiple words in the first sequence are merged to obtain a second sequence, including:

[0024] Determining two words corresponding to the target word pair from a plurality of words in the first sequence;

[0025] The two words in the first sequence are merged to obtain the second sequence.

[0026] In the embodiment of the present disclosure, the two words in the first sequence are merged to obtain the second sequence, including:

[0027] Setting a replacement character; the replacement character has a corresponding relationship with the two words, and the first sequence does not contain the replacement character;

[0028] The combined words in the first sequence are replaced by the replacement characters to obtain the second sequence; the second sequence includes the replacement words and the words.

[0029] In the embodiment of the present disclosure, the preset frequency is 1.

[0030] The embodiment of the second aspect of the present disclosure provides a vocabulary generation device based on a combination of code naming specification and byte pair encoding, including:

[0031] A code segmentation module, used to segment the acquired sample code according to a preset code naming specification to obtain a first sequence; the first sequence includes a plurality of words;

[0032] A word pair determination module, used to determine a plurality of word pairs in the first sequence; each word pair is obtained by combining any two adjacent words in the first sequence;

[0033] A conditional judgment module, used to judge whether the plurality of word pairs meet a preset condition; the preset condition is that the frequency of occurrence of each word pair in the plurality of word pairs is a preset frequency;

[0034] a target vocabulary determination module, configured to determine the first sequence as a target vocabulary if the plurality of word pairs meet the preset condition; the target vocabulary is used for training a code completion model;

[0035] A target word pair screening module, configured to screen out a target word pair with the highest occurrence frequency from the multiple word pairs if the multiple word pairs do not meet the preset condition;

[0036] A word merging module, configured to merge a plurality of words in the first sequence based on the target word pair to obtain a second sequence; the number of words in the second sequence is less than the number of words in the first sequence;

[0037] The second sequence is used as a new first sequence, and the step of determining a plurality of word pairs of the first sequence is repeated on the new first sequence until the plurality of word pairs meet the preset condition.

[0038] An embodiment of the third aspect of the present disclosure provides an electronic device, which includes a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the vocabulary generation method based on the combination of code naming specifications and byte pair encoding described in the first aspect by executing the computer instructions.

[0039] An embodiment of the fourth aspect of the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions are used to enable a computer to execute the vocabulary generation method based on the combination of code naming specifications and byte pair encoding as described in the first aspect above.

[0040] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will become apparent from the following description or be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] By reading the detailed description of the preferred embodiment below, various other advantages and benefits will become clear to those of ordinary skill in the art. The accompanying drawings are only used for the purpose of illustrating the preferred embodiment and are not considered to be limitations of the present disclosure. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings.

[0042] In the attached picture:

[0043] Figure 1 A flowchart of a vocabulary generation method based on a combination of code naming specifications and byte pair encoding provided by an embodiment of the present disclosure is shown;

[0044] Figure 2 A schematic diagram of the structure of a vocabulary generation device based on a combination of code naming specification and byte pair encoding provided by an embodiment of the present disclosure is shown;

[0045] Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown;

[0046] Figure 4 A schematic diagram of a storage medium provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0047] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0048] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present disclosure should have the common meanings understood by those skilled in the art to which the present disclosure belongs.

[0049] The following describes the technical scenarios involved in the embodiments of the present disclosure.

[0050] The existing word segmentation methods still have the following problems:

[0051] The code completion model may encounter words (tokens) that are not included in the vocabulary during reasoning;

[0052] Existing word segmentation methods also include character-based word segmentation methods. This method generates a very small vocabulary and treats each character as a token, which increases the amount of calculation. Deep learning requires learning the relationship between each character, but the relationship between each character of commonly used words is often unnecessary.

[0053] To this end, the present invention provides a vocabulary generation method, which can achieve the purpose of reducing the vocabulary and lowering the computational complexity of the model while avoiding the appearance of words that do not exist in the vocabulary.

[0054] According to an embodiment of the present disclosure, an embodiment of a vocabulary generation method based on a combination of code naming conventions and byte pair encoding is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0055] In this embodiment, a vocabulary generation method based on code naming specification and byte pair encoding is provided. Figure 1 is a flowchart of a vocabulary generation method based on a combination of code naming specifications and byte pair encoding according to an embodiment of the present disclosure, such as Figure 1 As shown, the process includes the following steps:

[0056] Step S101 , segmenting the acquired sample code according to a preset code naming specification to obtain a first sequence.

[0057] In some specific embodiments, the above-mentioned preset code naming conventions include but are not limited to: lower camel case, upper camel case, snake case and other naming conventions.

[0058] In some embodiments, the first sequence includes multiple words, and the multiple words are obtained by splitting multiple identifiers included in the sample code, and each identifier is split into at least two words. For example:

[0059] "backgroundColor" can be split into three words: "Back", "ground" and "color".

[0060] In some embodiments, the above step S101 includes step S1011:

[0061] Step S1011, segmenting each identifier in the sample code according to the root to obtain at least two words; and treating each non-identifier in the sample code as a word.

[0062] In some embodiments, identifiers include, but are not limited to, variable names and function names, and non-identifiers include, but are not limited to, keywords and symbols.

[0063] In some embodiments, in the process of segmenting each identifier to obtain at least two words, the first letter of the first word of the at least two words obtained can be lowercase, and the first letters of subsequent words can be capitalized, for example: "isUserLoggedIn→is, User, LoggedIn".

[0064] Step S102: determining a plurality of word pairs of the first sequence.

[0065] Specifically, each word pair is obtained by combining any two adjacent words in the first sequence.

[0066] In some embodiments, the above step S102 includes steps S1021 and S1022:

[0067] Step S1021: for any one of the multiple identifiers included in the sample code, every two adjacent words of at least two words included in the identifier are combined to obtain a word pair.

[0068] Specifically, for example: “is, User, LoggedIn” can get two word pairs, namely: “is-User” and “User-LoggedIn”.

[0069] Step S1022: Based on at least one word pair corresponding to each identifier in the sample code, a first sequence of multiple word pairs corresponding to the sample code is obtained.

[0070] Step S103, determining whether the plurality of word pairs meet a preset condition.

[0071] Specifically, the preset condition means that the appearance frequency of each word pair in the multiple word pairs is a preset frequency.

[0072] In some embodiments, the preset frequency is 1.

[0073] In some embodiments, before the above step S103, the method further includes step b1:

[0074] Step b1, determining the occurrence frequency of each word pair in the multiple word pairs.

[0075] Specifically, the following sample code is used as an example for explanation:

[0076] "ProjectReport...ProjectReport...marketingReport...isUserLoggedIn"

[0077] According to the above sample code, the following multiple word pairs can be obtained:

[0078] Word pair 1: Project-Report; Word pair 2: .Project-Report

[0079] Word pair 3: marketing-Report; Word pair 4: is-User; Word pair 5: User-LoggedIn

[0080] It can be seen that the occurrence frequency of "Project-Report" is 2.

[0081] Step S104: if the plurality of word pairs satisfy the preset condition, the first sequence is determined as a target vocabulary; the target vocabulary is used for training a code completion model.

[0082] Specifically, if the occurrence frequencies of multiple word pairs corresponding to the first sequence are all 1, the first sequence can be used as the target vocabulary.

[0083] Step S105: If the multiple word pairs do not meet the preset condition, select the target word pair with the highest occurrence frequency from the multiple word pairs.

[0084] Specifically, the above example is used for explanation: the target word pair with the highest occurrence frequency is "Project-Report", and the occurrence frequency is 2.

[0085] Step S106: Based on the target word pair, multiple words in the first sequence are merged to obtain a second sequence.

[0086] In some embodiments, the above step S106 includes steps S1061 and S1062:

[0087] Step S1061, determining two words corresponding to the target word pair from the multiple words in the first sequence.

[0088] The above example is used to illustrate step S1061:

[0089] The first sequence corresponding to the sample code “ProjectReport...ProjectReport...marketingReport...isUserLoggedIn” is “Project, Report, Project, Report, marketing, Report, is, User, LoggedIn”; two words corresponding to the target word pair “Project-Report”, namely “Project” and “Report”, are found therein.

[0090] Step S1062: merge the two words in the first sequence to obtain the second sequence.

[0091] Specifically, the words are merged to obtain the second sequence, namely, "Project-Report, Project-Report, marketing, Report, is, User, LoggedIn"

[0092] In some embodiments, the above step S1062 includes step c1-step c2:

[0093] Step c1, set the replacement character.

[0094] Specifically, the replacement character has a corresponding relationship with the two words, and the first sequence does not include the replacement character. For example, the replacement character may be set to n1, which corresponds to the two words "Project" and "Report", and the first sequence does not include n1.

[0095] Step c2: replace the merged words in the first sequence with the replacement characters to obtain the second sequence; the second sequence includes the replacement words and the words.

[0096] Specifically, the merged word “Project-Report” in the first sequence is replaced by replacing the character n1 to obtain a second sequence after replacement, for example, “n1, n1, marketing, Report, is, User, LoggedIn”.

[0097] More specifically, the number of words in the second sequence is less than the number of words in the first sequence; "Project" and "Report" in the first sequence occupy two character positions, and "n1" in the second sequence occupies one character position. It can be seen that the second sequence obtained after replacement reduces the amount of data and greatly reduces the complexity of data processing.

[0098] Step S107: taking the second sequence as a new first sequence, and repeating the step of determining a plurality of word pairs of the first sequence for the new first sequence until the plurality of word pairs meet the preset condition.

[0099] Specifically, after the second sequence is obtained, it needs to be used as a new first sequence, and the above steps S102 to S106 need to be repeatedly performed until each word pair corresponding to the first sequence satisfies the above preset conditions.

[0100] The following example illustrates the repeated execution of step S107:

[0101] Assume that the first sequence corresponding to the sample code is aaabdaaabac; wherein "a", "b" and "c" in the first sequence represent a word instead of a letter.

[0102] Among them, the word pair aa has the highest frequency of occurrence, so aa is replaced by the character Z which does not exist here; the second sequence is obtained, namely: ZabdZabac; wherein Z=aa;

[0103] At this time, it is found that ab has the highest frequency of occurrence. Similarly, Y is used to replace ab to obtain the third sequence, namely: ZYdZYac, where Y = ab Z = aa;

[0104] Similarly, ZY has the highest frequency of occurrence. Replace ZY with X to obtain the fourth sequence, namely: XdXac, where X=ZY Y=ab Z=aa;

[0105] Finally, when the occurrence frequency of each word pair in the fourth sequence is 1, the fourth sequence is determined to be the target vocabulary.

[0106] In some embodiments, the method further comprises:

[0107] Step S108, training the initial model through the target vocabulary to obtain a code completion model; the code completion model is used to complete the source code to be completed.

[0108] Corresponding to the implementation of the above-mentioned method for generating a vocabulary based on the combination of code naming specifications and byte pair encoding, the embodiment of the present disclosure also provides a vocabulary generating device based on the combination of code naming specifications and byte pair encoding, which is used to perform the above-mentioned Figure 1 The vocabulary generation method based on the code naming specification combined with byte pair encoding described in any of the illustrated embodiments. Figure 2 As shown, the vocabulary generation device based on the code naming specification combined with byte pair encoding includes:

[0109] A code segmentation module, used to segment the acquired sample code according to a preset code naming specification to obtain a first sequence; the first sequence includes a plurality of words;

[0110] A word pair determination module, used to determine a plurality of word pairs in the first sequence; each word pair is obtained by combining any two adjacent words in the first sequence;

[0111] A conditional judgment module, used to judge whether the plurality of word pairs meet a preset condition; the preset condition is that the frequency of occurrence of each word pair in the plurality of word pairs is a preset frequency;

[0112] a target vocabulary determination module, configured to determine the first sequence as a target vocabulary if the plurality of word pairs meet the preset condition; the target vocabulary is used for training a code completion model;

[0113] A target word pair screening module, configured to screen out a target word pair with the highest occurrence frequency from the multiple word pairs if the multiple word pairs do not meet the preset condition;

[0114] A word merging module, configured to merge a plurality of words in the first sequence based on the target word pair to obtain a second sequence; the number of words in the second sequence is less than the number of words in the first sequence;

[0115] The second sequence is used as a new first sequence, and the step of determining a plurality of word pairs of the first sequence is repeated on the new first sequence until the plurality of word pairs meet the preset condition.

[0116] Optionally, the device also includes a model training module, which is used to train the initial model through the target vocabulary to obtain a code completion model; the code completion model is used to complete the source code to be completed.

[0117] Optionally, the code segmentation module is also used to: segment each identifier in the sample code according to the root to obtain at least two words; and treat each non-identifier in the sample code as a word; wherein the first letter of the first word of the at least two words is lowercase, and the first letter of the subsequent words is capitalized.

[0118] Optionally, the word pair determination module is also used to: for any one of the multiple identifiers contained in the sample code, combine every two adjacent words of the at least two words contained in the identifier to obtain a word pair; based on at least one word pair corresponding to each identifier in the sample code, obtain a first sequence of multiple word pairs corresponding to the sample code.

[0119] Optionally, the device further includes: an occurrence frequency determination module for determining the occurrence frequency of each word pair in the multiple word pairs before determining whether the multiple word pairs meet a preset condition.

[0120] Optionally, the word merging module is further used to: determine two words corresponding to the target word pair from multiple words in the first sequence; and merge the two words in the first sequence to obtain the second sequence.

[0121] Optionally, the word merging module is also used to: set a replacement character; the replacement character has a corresponding relationship with the two words, and the first sequence does not contain the replacement character; the merged word in the first sequence is replaced by the replacement character to obtain the second sequence; the second sequence includes the replacement word and the word.

[0122] The vocabulary generation device based on the combination of code naming conventions and byte pair encoding provided in the above-mentioned embodiments of the present disclosure and the vocabulary generation method based on the combination of code naming conventions and byte pair encoding provided in the embodiments of the present 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.

[0123] The disclosed embodiment also provides an electronic device to execute the above-mentioned word list generation method based on the code naming specification combined with byte pair encoding. Figure 3 , which shows a schematic diagram of an electronic device provided by some embodiments of the present disclosure. Figure 3 As shown, the electronic device 3 includes: a processor 300, a memory 301, a bus 302 and a communication interface 303, wherein the processor 300, the communication interface 303 and the memory 301 are connected via the bus 302; the memory 301 stores a computer program that can be run on the processor 300, and the processor 300 executes the aforementioned Figure 1 Any of the illustrated embodiments provides a vocabulary generation method based on a combination of code naming conventions and byte pair encoding.

[0124] The memory 301 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 303 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.

[0125] The bus 302 may be an ISA bus, a PCI bus, or an EISA bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 301 is used to store programs. After receiving the execution instruction, the processor 300 executes the program. Figure 1 The vocabulary generation method based on the code naming specification combined with byte pair encoding disclosed in any of the illustrated embodiments may be applied to the processor 300 or implemented by the processor 300 .

[0126] The processor 300 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 300. The above processor 300 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present disclosure can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 301, and the processor 300 reads the information in the memory 301 and completes the steps of the above method in combination with its hardware.

[0127] The electronic device provided by the embodiment of the present disclosure and the vocabulary generation method based on the combination of code naming specifications and byte pair encoding provided by the embodiment of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.

[0128] The present disclosure also provides a computer-readable storage medium corresponding to the vocabulary generation method based on the code naming specification and byte pair encoding provided in the above embodiment. Please refer to Figure 4 The computer-readable storage medium shown is a CD 30 on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it will execute the vocabulary generation method based on the combination of code naming specifications and byte pair encoding provided in any of the aforementioned embodiments.

[0129] It should be noted that examples of the computer-readable storage medium 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 or magnetic storage media, which are not listed here one by one.

[0130] The computer-readable storage medium provided by the above-mentioned embodiments of the present disclosure and the vocabulary generation method based on the combination of code naming specifications and byte pair encoding provided by the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.

[0131] It should be noted that:

[0132] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present disclosure can be practiced without these specific details. In some instances, well-known structures and technologies are not shown in detail so as not to obscure the understanding of this description.

[0133] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present disclosure, the various features of the present disclosure are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following schematic diagram: the claimed disclosure requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, the inventive aspects lie in less than all the features of the single embodiment disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present disclosure.

[0134] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of this disclosure and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.

[0135] The above is only a preferred specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A vocabulary generation method based on code naming specification combined with byte pair encoding, characterized in that: The method comprises: Segmenting the acquired sample code according to a preset code naming specification to obtain a first sequence; the first sequence includes a plurality of words; Determine a plurality of word pairs of the first sequence; each word pair is obtained by combining any two adjacent words in the first sequence; Determine whether the plurality of word pairs meet a preset condition; the preset condition is that the frequency of occurrence of each word pair in the plurality of word pairs is a preset frequency; If the plurality of word pairs satisfy the preset condition, the first sequence is determined as a target vocabulary; the target vocabulary is used for training a code completion model; If the plurality of word pairs do not satisfy the preset condition, selecting the target word pair with the highest occurrence frequency from the plurality of word pairs; Based on the target word pair, multiple words in the first sequence are merged to obtain a second sequence; the number of words in the second sequence is less than the number of words in the first sequence; The second sequence is used as a new first sequence, and the step of determining a plurality of word pairs of the first sequence is repeated on the new first sequence until the plurality of word pairs meet the preset condition.

2. The method according to claim 1, characterized in that The method further comprises: The initial model is trained by using the target vocabulary to obtain a code completion model; the code completion model is used to complete the source code to be completed.

3. The method according to claim 1 or 2, characterized in that: The obtained sample code is segmented according to the preset code naming specification to obtain the first sequence, including: According to the root, each identifier in the sample code is segmented to obtain at least two words; and each non-identifier in the sample code is regarded as a word; wherein the first letter of the first word of the at least two words is lowercase, and the first letter of the subsequent words is capitalized.

4. The method according to claim 1 or 2, characterized in that: Determining a plurality of word pairs of the first sequence comprises: For any one of the multiple identifiers included in the sample code, every two adjacent words of at least two words included in the identifier are combined to obtain a word pair; Based on at least one word pair corresponding to each identifier in the sample code, a first sequence of multiple word pairs corresponding to the sample code is obtained.

5. The method according to claim 1 or 2, characterized in that: Before determining whether the plurality of word pairs meet a preset condition, the method further includes: A frequency of occurrence of each word pair in the plurality of word pairs in the plurality of word pairs is determined.

6. The method according to claim 1 or 2, characterized in that: Based on the target word pair, a plurality of words in the first sequence are merged to obtain a second sequence, including: Determining two words corresponding to the target word pair from a plurality of words in the first sequence; The two words in the first sequence are merged to obtain the second sequence.

7. The method according to claim 6, characterized in that The two words in the first sequence are merged to obtain the second sequence, comprising: Setting a replacement character; the replacement character has a corresponding relationship with the two words, and the first sequence does not contain the replacement character; The combined words in the first sequence are replaced by the replacement characters to obtain the second sequence; the second sequence includes the replacement words and the words.

8. The method according to claim 1 or 2, characterized in that: The preset frequency is 1.

9. A vocabulary generation device based on code naming specification combined with byte pair encoding, characterized in that: The device comprises: A code segmentation module, used to segment the acquired sample code according to a preset code naming specification to obtain a first sequence; the first sequence includes a plurality of words; A word pair determination module, used to determine a plurality of word pairs in the first sequence; each word pair is obtained by combining any two adjacent words in the first sequence; A conditional judgment module, used to judge whether the plurality of word pairs meet a preset condition; the preset condition is that the frequency of occurrence of each word pair in the plurality of word pairs is a preset frequency; a target vocabulary determination module, configured to determine the first sequence as a target vocabulary if the plurality of word pairs meet the preset condition; the target vocabulary is used for training a code completion model; A target word pair screening module, configured to screen out a target word pair with the highest occurrence frequency from the multiple word pairs if the multiple word pairs do not meet the preset condition; A word merging module, configured to merge a plurality of words in the first sequence based on the target word pair to obtain a second sequence; the number of words in the second sequence is less than the number of words in the first sequence; The second sequence is used as a new first sequence, and the step of determining a plurality of word pairs of the first sequence is repeated on the new first sequence until the plurality of word pairs meet the preset condition.

Citation Information

Patent Citations

  • Decision-based code annotation generation method fusing information retrieval and deep learning

    CN113743064A

  • Low-frequency word perception source code annotation generation method and tool

    CN114327612A

  • Code completion method based on structural features and sequence features

    CN114924741A

  • Identifier normalization method based on deep learning

    CN115358218A

  • Word list updating method and device, electronic equipment and storage medium

    CN118485062A