A method and system for efficient output of a molecular generative language model

CN118248246BActive Publication Date: 2026-10-30SHANGHAI INST OF ORGANIC CHEM CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410387258.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-01
Publication Date
2026-10-30
Estimated Expiration
2044-04-01

AI Technical Summary

Technical Problem

[0007]一种方案是称为“贪心搜索”,即:每一个时间步都取出条件概率最大的一个输出,再将从开始到当前步的结果的组合作为输入去获得下一个时间步的输出,直到模型给出生成结束的标志;虽然采用该方案的时间复杂度最小,但无法保证所生成的分子序列整体的概率是最优的,从而也就无法保证所生成的分子序列一定是有效的;

Benefits of technology

[0047]通过采用本发明所述方法和系统,不仅可减少大量不必要的序列空间搜索,而且可保证生成分子结构数据的有效性,且生成的分子结构数据重复率低,可有效提高分子生成语言模型的性能,可用于基于化学结构的生成式大语言模型的优化,因此在化学人工智能研究领域具有重要应用价值。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118248246B_ABST
    Figure CN118248246B_ABST
Patent Text Reader

Abstract

The application discloses a method and system for realizing efficient output of a molecule generation language model, and the method comprises the following steps: converting a starting character into starting character encoding; expanding the starting character encoding and time step output encoding output by a time step output sampler to obtain an expanded encoding group; according to a preset parallel processing batch size, a sequence length threshold and a search threshold, cyclically expanding all encoding groups in the expanded encoding group list to obtain a terminated and expanded encoding group; calculating the probability score of the input terminated and expanded encoding group, and sorting and selecting according to the probability score to obtain a target encoding group; and converting the target encoding group into a SMILES string output after removing the starting character encoding and ending character encoding. The method and system can reduce a large amount of unnecessary sequence space search, ensure the effectiveness of generated molecule structure data, and effectively improve the performance of the molecule generation language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method and system for achieving efficient output of molecular generative language models, and belongs to the field of computer information processing technology. Background Technology

[0002] Molecules are the basic building blocks of matter, composed of multiple atoms bonded together in unique chemical ways (such as chemical bonds), retaining unique chemical properties determined by their specific structure. A comprehensive understanding of molecules allows scientists to effectively design materials, drugs, and products with different properties and functions, making them an important research subject in the field of chemical science.

[0003] Molecular generative language models refer to deep learning neural networks that use encoder and decoder architectures for sequence-to-sequence prediction. These networks are trained on specific large-scale molecular structure datasets to generate new molecular structures similar to those datasets. It is an important chemical artificial intelligence technology that can be widely applied in molecular design in the fields of chemistry, biology, and medicine.

[0004] Because molecular generative language models use SMILES format data to characterize chemical molecular structures, that is, using SMILES (Simplified molecular input line entry system) characters to represent molecular sequences (words) and SMILES strings to represent the entire molecular sequence (sentence), the percentage of molecular structure data that conforms to the SMILES specification in the molecular structure data output by the molecular generative language model (also known as the molecular generation efficiency) is often used as one of the most important indicators for validating and evaluating the performance of the molecular generative language model.

[0005] Because the output of a language model is obtained step-by-step, and the results of earlier time steps influence the results of later time steps—meaning that at each time step, the language model provides conditional probabilities based on the results generated in previous time steps—molecule generation language models require combining the outputs of multiple time steps to output a complete molecule sequence. Furthermore, the product of the conditional probabilities of each step in the final molecule sequence must be maximized. However, large language models often have large dictionaries. If all outputs from each time step—that is, the conditional probabilities of each word in the dictionary—are retained, obtaining the probability of the entire sequence would require calculating the combination of all time step outputs, resulting in an exponentially complex algorithm that is difficult to implement in practice.

[0006] Currently, the existing technologies mainly employ the following two simple solutions:

[0007] One approach is called "greedy search," which involves taking the output with the highest conditional probability at each time step and using the combination of results from the beginning to the current step as input to obtain the output of the next time step, until the model gives a sign that the generation is over. Although this approach has the lowest time complexity, it cannot guarantee that the overall probability of the generated molecular sequence is optimal, and therefore cannot guarantee that the generated molecular sequence is valid.

[0008] Another approach is called "bundle search," which involves retaining the N outputs with the highest conditional probability at each time step. Then, the top N results with the highest combined probability from the beginning to the current time step are used as input to obtain the output for the next time step, continuing until the model indicates the end of generation. N is typically small to ensure the algorithm's complexity doesn't become too high and consume excessive computation time. However, due to the unique characteristics of molecular sequences in molecular generative language models (SMILES character syntax), the conditional probability distribution of multiple outputs at each time step is uneven. Simply retaining the top N outputs introduces sequence word encoding with low conditional probabilities, leading to inefficient and repetitive molecular structure data, significantly impacting the performance of the molecular generative language model. Furthermore, since this approach retains N outputs at each time step, the overall time complexity still increases significantly when the predicted sequence is long and N is large, requiring substantial computation time and resources, thus reducing the output efficiency of the molecular generative language model. Summary of the Invention

[0009] To address the aforementioned problems in existing technologies, the purpose of this invention is to provide a method and system for achieving efficient output of molecular generative language models, thereby making the output of molecular generative language models more efficient and providing strong support for chemical artificial intelligence research.

[0010] To achieve the above-mentioned objectives, the present invention adopts the following technical solution:

[0011] A method for achieving efficient output of a molecular generative language model includes the following sequential steps:

[0012] S1) Convert the starting character into the starting character code according to the preset molecular sequence encoding table;

[0013] S2) Input the initial character encoding into the molecular generative language model, and then extract the corresponding number of time step output codes and time step conditional probability lists sorted from the output of the molecular generative language model in descending order of conditional probability according to the preset search threshold, and output them to the time step output sampler.

[0014] S3) The starting character encoding and the time step output encoding output by the time step output sampler described in step S2) are sequentially extended to obtain extended encoding groups, and all extended encoding groups are combined into an extended encoding group list. The probability of each extended encoding group in the extended encoding group list is the time step conditional probability corresponding to the current time step output encoding.

[0015] S4) According to the preset parallel processing batch size, sequence length threshold and search threshold, all coding groups in the extended coding group list are cyclically expanded to obtain the coding group that terminates the expansion, and the coding group that terminates the expansion and its corresponding probability are input into the molecular sequence probability container.

[0016] S5) The molecular sequence probability container is based on the following formula:

[0017] The probability scores of the input terminating extended coding groups are calculated and sorted and discarded according to the probability scores to obtain the target coding group; in the above formula: Score is the probability score; sum_logprobs is the input probability, that is: the sum of the output probabilities of all time steps; length_seq is the length of the coding group, that is: the number of codes in the coding group; length_penalty is the length penalty coefficient set to prevent the generation of excessively long sequences;

[0018] S6) After removing the start character encoding and end character encoding in the target encoding group, convert them sequentially into SMILES strings according to the preset molecular sequence encoding table, thus generating molecular structure data.

[0019] In one embodiment, the molecular sequence encoding table is composed of the start character, empty character, end character, and all SMILES characters used in the molecular generation language model, along with their corresponding character encodings and character attributes.

[0020] In a preferred embodiment, the character encoding is the sequence number corresponding to each character.

[0021] In one implementation, step S3) is to obtain the extended code group by adding the start character code to the front of the time step output code output by the time step output sampler.

[0022] One implementation scheme, step S4) specifically includes the following steps:

[0023] S41) Input a set of extended codes from the extended code group list into the molecular generative language model. Then, according to the preset search threshold, extract the corresponding number of time-step output codes and time-step conditional probability lists sorted from the output of the molecular generative language model in descending order of conditional probability, and output them to the time-step output sampler. If the time-step output sampler outputs a blank character code, an end character code, or a null value, then end further expansion, and then add the end character code to the end of the current extended code group to become the code group that terminates the expansion; otherwise, continue to execute the subsequent steps.

[0024] S42) Further expand the current extended coding group and the time step output code output by the time step output sampler described in step S41) to obtain a candidate coding group, and add it to the candidate coding group list. The probability of each candidate code in the candidate coding group list is the sum of the probability of the current extended coding group and the time step conditional probability corresponding to the time step output code.

[0025] S43) Repeat steps S41) and S42) according to the preset parallel processing batch size until all extended coding groups in the extended coding group list have completed time step output and further expansion. Sort the candidate coding groups in the obtained candidate coding group list in descending order of probability. If the number of candidate coding groups in the obtained candidate coding group list is less than or equal to N but greater than zero, then use the currently obtained candidate coding group list as the updated extended coding group list. If the number of candidate coding groups in the obtained candidate coding group list is greater than N, then select the first N candidate coding groups to form the updated extended coding group list. N is the preset search threshold. At the same time, the candidate coding group list is cleared.

[0026] S44) Repeat steps S41) to S43) on the obtained updated extended code group list. If the length of the extended code group reaches the preset sequence length threshold, the further extension ends, and then the end character code is added to the end of the current extended code group to become the code group that terminates the extension.

[0027] S45) Stop the cyclic expansion when all codecs in the updated expanded codec list have finished expanding.

[0028] In one implementation, step S42) is to obtain the candidate coding group by adding the current extended coding group before the time step output coding output by the time step output sampler described in step S41).

[0029] In one implementation scheme, the time-step output samplers all output according to the following rules:

[0030] ① If the conditional probabilities of all time steps in the list are less than or equal to zero, then output an empty value;

[0031] ②If there is only one output code for a time step in the list where the conditional probability of the time step is greater than zero, then output that code and its corresponding conditional probability.

[0032] ③ If the number of output codes for time steps with a conditional probability greater than zero in the list is greater than one, then output the code with the highest conditional probability for the time step that is ranked first, as well as the subsequent codes whose attributes are consistent with the first code and their corresponding conditional probabilities, as determined by the preset molecular sequence coding table, until the attributes of the subsequent codes are inconsistent with the attributes of the first code, or the conditional probability of the subsequent codes is less than or equal to zero, or the subsequent codes are at the end of the list.

[0033] One implementation scheme, step S5), selects or discards items according to the following rules:

[0034] ①If the number of coding groups stored in the molecular sequence probability container is less than the preset search threshold, then the current coding group is stored.

[0035] ② If the number of coding groups stored in the molecular sequence probability container is equal to the preset search threshold, then compare whether the probability score of the current coding group is greater than the minimum probability score among the existing coding groups in the molecular sequence probability container; if yes, store the current coding group and delete the existing coding group with the smallest probability score; if no, discard the current coding group.

[0036] In a preferred embodiment, the length penalty coefficient described in step S5) is set to 0.6.

[0037] A system for achieving efficient output of a molecular generative language model includes:

[0038] The encoder is used to preset the molecular sequence encoding table and convert the input start character into a start character encoding according to the preset molecular sequence encoding table, and output it to the molecular sequence generator;

[0039] The time step output sampler is used to sample the time step output code and the code in the time step conditional probability list input by the molecular sequence generator according to the set rules, and then output them to the molecular sequence generator for subsequent encoding expansion.

[0040] A molecular sequence generator is used to expand the starting character code and the time-step output code output by the time-step output sampler according to a preset search threshold and sequence length threshold, so as to generate a list of code groups to terminate the expansion and input them into the molecular sequence probability container; and to extract the target code group in the molecular sequence probability container and input it into the decoder.

[0041] A molecular sequence probability container is used to calculate the probability score of the terminating extended coding group input to the molecular sequence generator, and sorts and discards them according to the probability score to obtain a list of target coding groups.

[0042] The decoder is used to remove the start and end character codes from the target encoding group, convert them sequentially into SMILES strings according to the preset molecular sequence encoding table, and output the generated molecular structure data.

[0043] In addition, the present invention also provides a storage medium storing one or more computer programs including execution instructions, which can be read and executed by electronic devices (including but not limited to computers, servers, or network devices) to realize the method described above for achieving efficient output of molecular generative language models.

[0044] The present invention also provides an electronic device comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores program instructions executable by the at least one processor, the program instructions being executed by the at least one processor to enable the at least one processor to perform the method described above for achieving efficient output of a molecular generative language model.

[0045] The present invention also provides a computer program product, including a computer program stored on a storage medium, the computer program including program instructions, which, when executed by a computer, can realize the method described above for efficiently outputting a molecular generative language model.

[0046] Compared with the prior art, the beneficial technical effects of the present invention are as follows:

[0047] By employing the method and system described in this invention, not only can a large number of unnecessary sequence space searches be reduced, but the validity of the generated molecular structure data can also be guaranteed. Furthermore, the generated molecular structure data has a low repetition rate, which can effectively improve the performance of molecular generative language models. It can be used for the optimization of generative large language models based on chemical structures, and therefore has important application value in the field of chemical artificial intelligence research. Attached Figure Description

[0048] Figure 1 The diagram shown is a flowchart of a method for achieving efficient output of a molecular generative language model provided by the present invention.

[0049] Figure 2 The diagram shown is a system structure block diagram for achieving efficient output of a molecular generative language model provided by the present invention. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0051] The technical solutions provided in the embodiments of this application are described in detail below with reference to the accompanying drawings.

[0052] To simplify the description, this embodiment sets the parallel processing batch value to 1 (since the processing flow of each batch in multi-batch parallel processing is exactly the same, this embodiment uses single-batch processing for explanation to more clearly illustrate the method flow of the present invention), and sets the sequence length threshold to 100, the search threshold to 5, and the starting character to "SOS".

[0053] Figure 1 The diagram shown is a flowchart of the method for achieving efficient output of a molecular generative language model according to the present invention. Please refer to it. Figure 1 As shown in this embodiment, a method for achieving efficient output of a molecular generative language model includes the following sequential steps:

[0054] S1) The encoder converts the starting character into a starting character code according to the preset molecular sequence encoding table and outputs it to the molecular sequence generator. The molecular sequence encoding table is composed of the starting character, empty character, ending character, and all SMILES characters used in the molecular generation language model, the character codes corresponding to each character (in this embodiment, the corresponding character code is the ordinal number of each character) and the character attributes corresponding to each character (e.g., sequence marker, bond, ring cluster, branch, ring, element, etc.). There are no specific requirements for the numbers of each character code. Assuming the preset molecular sequence encoding table in this embodiment is as follows:

[0055]

[0056]

[0057] The encoder can convert the starting character "SOS" into the starting character code "2" according to the preset molecular sequence encoding table mentioned above;

[0058] S2) The molecular sequence generator inputs the starting character code "2" into the molecular generation language model, and then, according to a preset search threshold (set to 5 in this embodiment), extracts the corresponding number of time step output codes and time step conditional probability lists sorted in descending order of conditional probability from the output of the molecular generation language model, and outputs them to the time step output sampler; assuming the extracted list is:

[0059] [29:14.15;24:11.47;31:0.42;28:-0.57;1:-1.5];where: "[]" represents a list, and time step outputs in the list are separated by ";", with the time step output code before ":" and the time step conditional probability after ":".

[0060] Because the time-step output samplers described in this invention all output according to the following rules:

[0061] ① If the conditional probabilities of all time steps in the list are less than or equal to zero, then output an empty value;

[0062] ②If there is only one output code for a time step in the list where the conditional probability of the time step is greater than zero, then output that code and its corresponding conditional probability.

[0063] ③ If the number of output codes for time steps with a conditional probability greater than zero in the list is greater than one, then output the code with the highest conditional probability of the time step that is ranked first, as well as the subsequent codes that are consistent with the attributes of the first code according to the preset molecular sequence coding table and their corresponding conditional probabilities, until the attributes of the subsequent codes are inconsistent with the attributes of the first code, or the conditional probability of the subsequent codes is less than or equal to zero, or the subsequent codes are at the end of the list.

[0064] Therefore, according to the above rules, the codes output by the time step output sampler for the above list "[29:14.15; 24:11.47; 31:0.42; 28:-0.57; 1:-1.5]" in this embodiment are "29:14.15", "24:11.47", and "31:0.42" respectively.

[0065] S3) The molecular sequence generator sequentially expands the starting character code and the time step output code output by the time step output sampler described in step S2) to obtain an expanded code group (specifically, by adding the starting character code before the time step output code output by the time step output sampler described in step S2), and then compiles all the expanded code groups into an expanded code group list. The probability of each expanded code group in the expanded code group list is the time step conditional probability corresponding to the current time step output code; for example, after this step in this embodiment, the following expanded code group list is obtained:

[0066] [(2,29):14.15;(2,24):11.47;(2,31):0.42];where: "[]" represents a list, "()" represents a group of codes, the part before ":" is the code group, the part after ":" is the code group probability, code groups are separated by ";", and codes in a code group are separated by ",".

[0067] S4) The molecular sequence generator expands all coding groups in the expanded coding group list in a loop according to the preset parallel processing batch size (set to 1 in this embodiment), sequence length threshold (set to 100 in this embodiment), and search threshold (set to 5 in this embodiment) to obtain the coding group that terminates the expansion, and inputs the coding group that terminates the expansion and its corresponding probability into the molecular sequence probability container; specifically including the following steps:

[0068] S41) Input a set of extended codes from the extended coding group list into the molecular generative language model, and then extract the corresponding number of time step output codes and time step conditional probability lists sorted from the output of the molecular generative language model in descending order of conditional probability according to the preset search threshold, and output them to the time step output sampler.

[0069] Assuming that the first extended code "(2,29)" is input into the molecular generative language model in this embodiment, the list retrieved from the output of the molecular generative language model according to the preset search threshold 5 is: [22:21.02; 11:3.7; 13:2.74; 24:1.46; 4:-0.3];

[0070] The above list, after being processed by the time-step output sampler, outputs the code "22:21.02". This is because the list "[22:21.02;11:3.7;13:2.74;24:1.46;4:-0.3]" contains more than one code with a conditional probability greater than zero. According to the preset molecular sequence encoding table, the attribute of the second code "11" is "branch", which is inconsistent with the attribute of the first code "22" being "key". Therefore, after sampling, only the code "22:21.02", which has the highest conditional probability and is ranked first, is output.

[0071] If the time step output sampler outputs a blank character code, an end character code, or a null value, then further expansion ends, and the end character code is added to the end of the current expanded code group to become the code group that terminates the expansion; otherwise, the subsequent steps continue.

[0072] S42) Further expand the current extended coding group with the time-step output code output by the time-step output sampler described in step S41) to obtain a candidate coding group (specifically, by adding the current extended coding group before the time-step output code output by the time-step output sampler described in step S41), and add it to the candidate coding group list. The probability of each candidate code in the candidate coding group list is the sum of the probability of the current extended coding group and the time-step conditional probability corresponding to the time-step output code; for example:

[0073] The current extended coding group is “(2,29)”, and the time step output code output by the time step output sampler described in step S41) is “22”. After further expansion, the candidate coding group is “(2,29,22)”. The probability of this candidate coding group is the sum of the probability of the current extended coding group “(2,29)” (14.15) and the time step conditional probability of the time step output code “22” (21.02), that is: 14.15 + 21.02 = 35.17; therefore, the candidate coding group list is obtained as: [(2,29,22):35.17];

[0074] S43) Repeat steps S41) and S42) according to the preset parallel processing batch size until all extended coding groups in the extended coding group list have completed time step output and further expansion. Sort the candidate coding groups in the obtained candidate coding group list in descending order of probability. If the number of candidate coding groups in the obtained candidate coding group list is less than or equal to N but greater than zero, then use the currently obtained candidate coding group list as the updated extended coding group list. If the number of candidate coding groups in the obtained candidate coding group list is greater than N, then select the first N candidate coding groups to form the updated extended coding group list. N is the preset search threshold (5 in this embodiment). At the same time, clear the candidate coding group list.

[0075] The specific operation of this embodiment is as follows:

[0076] The second extended code "(2,24)" from the above extended code group list is input into the molecular generative language model. Assuming that the list taken from the output of the molecular generative language model according to the preset search threshold 5 is: [13:12.52; 11:12.34; 22:5.38; 24:2.93; 12:0.85], the code output by the time step output sampler is "13:12.52". After further expansion, the candidate code group is "(2,24,13)", and the probability of the candidate code group is 11.47+12.52=23.99. The candidate code group list obtained is: [(2,29,22):35.17; (2,24,13):23.99].

[0077] Then, the third extended code "(2,31)" from the above extended code group list is input into the molecular generative language model. Assuming that the list taken from the output of the molecular generative language model according to the preset search threshold 5 is: [22:14.42; 11:10.68; 13:7.52; 24:1.49; 12:-0.06], the code output by the time step output sampler is "22:14.42". After further expansion, the candidate code group is "(2,31,22)", and the probability of the candidate code group is 0.42+14.42=14.84. The candidate code group list obtained is: [(2,29,22):35.17; (2,24,13):23.99; (2,31,22):14.84].

[0078] Since the number of candidate coding groups in the current candidate coding group list is less than the preset search threshold of 5, all candidate coding groups in the current candidate coding group list are sorted in descending order of probability to form the updated extended coding group list. At the same time, the candidate extended coding group list is cleared. The resulting updated extended coding group list is: [(2,29,22):35.17;(2,24,13):23.99;(2,31,22):14.84];

[0079] S44) Repeat steps S41) to S43) on the obtained updated extended code group list. If the length of the extended code group reaches the preset sequence length threshold, the further extension ends, and then the end character code is added to the end of the current extended code group to become the code group that terminates the extension.

[0080] Assumption:

[0081] When the updated extended coding group list is executed repeatedly for the second time from step S41) to S43), the candidate coding group list is as follows: [(2,29,22):35.17;(2,24,13):23.99;(2,31,22):14.84].

[0082] [(2,29,22,24,13):73.6;(2,29,22,24,15):53.78;(2,24,13,11,24):52.99;(2,24,13,11,29):43.65;(2,24,13,11,25):39.7;(2,29,22,31,13):55.13;(2,31,22,24,13):52.75;(2,31,22,31,13):32.99];because of the number of candidate coding groups. The probability is 7, which is greater than the set search threshold of 5. Therefore, after sorting by probability from largest to smallest, the top 5 coding groups are selected to form the updated extended coding group list, resulting in the following updated extended coding group list: [(2,29,22,24,13):73.6;(2,29,22,31,13):55.13;(2,29,22,24,15):53.78;(2,24,13,11,24):52.99;(2,31,22,24,13):52.75]. Simultaneously, the candidate coding group list is deleted.

[0083] [(2,29,22,24,13):73.6;(2,29,22,24,15):53.78;(2,24,13,11,24):52.99;(2,24,13,11,29):43.65;(2,24,13,11,25):39.7;(2,29,22,31,13):55.13;(2,31,22,24,13):52.75;(2,31,22,31,13):32.99].

[0084] Assuming that during the 36th iteration of steps S41) to S43), the time step output code output by the time step output sampler described in step S41) is a blank character code "1", then further expansion ends. The end character code "3" is added to the end of the current expansion code group to become the termination expansion code group. The obtained termination expansion code group and its corresponding probability are input into the molecular sequence probability container. The obtained termination expansion code group is:

[0085] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13,3):501.53;

[0086] Assuming that during the 42nd iteration of steps S41) to S43), the time step output code output by the time step output sampler described in step S41) is the end character code "3", then further expansion ends. The end character code "3" is added to the end of the current expansion code group to become the termination expansion code group. The obtained termination expansion code group and its corresponding probability are input into the molecular sequence probability container. The obtained termination expansion code group is:

[0087] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,24,12,24,13,3):588.16;

[0088] Assuming that during the 42nd iteration of steps S41) to S43), when expanding the last group of codes in the updated expanded coding group list, the output of the time step output sampler mentioned in step S41) is null, then further expansion ends, the ending character code "3" is added to the end of the current coding group to become the terminating coding group, and the obtained coding group and its corresponding probability are input into the molecular sequence probability container. The obtained terminating coding group is:

[0089] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,29,12,24,13,3):556.26;

[0090] S45) When all coding groups in the updated extended coding group list have finished expanding, that is, when the number of candidate coding groups in the obtained candidate coding group list is zero during the sequential execution of step S43), the cyclic expansion stops.

[0091] S5) The molecular sequence probability container is based on the following formula:

[0092] The probability scores of the input terminating extended coding groups are calculated and sorted and discarded according to the probability scores to obtain the target coding group; in the above formula: Score is the probability score; sum_logprobs is the input probability, that is: the sum of the output probabilities of all time steps; length_seq is the length of the coding group, that is: the number of codes in the coding group; length_penalty is the length penalty coefficient set to prevent the generation of excessively long sequences;

[0093] In addition, the molecular sequence probability container is selected based on the following rules:

[0094] ①If the number of coding groups stored in the molecular sequence probability container is less than the preset search threshold, then the current coding group is stored.

[0095] ② If the number of coding groups stored in the molecular sequence probability container is equal to the preset search threshold, then compare whether the probability score of the current coding group is greater than the minimum probability score among the existing coding groups in the molecular sequence probability container; if yes, then store the current coding group and delete the existing coding group with the smallest probability score; if no, then discard the current coding group.

[0096] Assuming the length penalty coefficient is set to 0.6 in this embodiment, the probability score of the input terminating extension coding group can be calculated using the above formula. For example, if the input terminating extension coding group is:

[0097] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13,3):501.53;

[0098] This means that the value of "sum_logprobs" in the formula is 501.53, the value of "length_seq" in the formula is 38, and the value of "length_penalty" in the formula is 0.6. Therefore, the probability score of the coding group that terminates the expansion can be calculated to be 56.55.

[0099] Since the molecular sequence probability container is currently empty, the coded group of the termination expansion and its corresponding probability score are directly stored into the molecular sequence probability container, resulting in:

[0100] [(2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13,3):56.55]; where: the part before “:” is the coding group, and the part after “:” is the corresponding probability score;

[0101] Similarly, the coded group for terminating the input can be:

[0102] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,24,12,24,13,3):588.16 The probability score of the terminating extended coding group calculated using the above formula is 59.92;

[0103] Assuming the number of coding groups already stored in the molecular sequence probability container is 4, which is less than the preset search threshold of 5, the current coding group is still directly stored and sorted in descending order of probability score, resulting in:

[0104] [(2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,24,12,24,13,3):59.92;

[0105] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,24,13,3):59.13;

[0106] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13,3):56.55;

[0107] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,29,12,29,12,24,11,29,12,11,24,12,24,13,3):56.36;

[0108] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,25,12,24,13,3):56.12];

[0109] Assume that subsequent expansions result in the following terminating encoding group:

[0110] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,31,13,3):576.56;

[0111] The probability score of the terminating coding group can be calculated using the above formula as 58.74. At this point, the number of coding groups stored in the molecular sequence probability container is equal to the set search threshold of 5. However, the probability score of the current coding group to be stored, 58.74, is greater than the lowest probability score of 56.12 among the existing coding groups in the current molecular sequence probability container. Therefore, the current coding group is stored, and the existing coding group with the lowest probability score is deleted. The coding groups are then sorted in descending order of probability score, resulting in:

[0112] [(2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,24,12,24,13,3):59.14;

[0113] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,24,13,3):59.13;

[0114] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,31,13,3):58.74;

[0115] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13,3):56.55;

[0116] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,29,12,29,12,24,11,29,12,11,24,12,24,13,3):56.36];

[0117] Assume that subsequent expansions result in the following terminating encoding group:

[0118] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,29,12,24,13,3):556.26;

[0119] The probability score of the terminating coding group can be calculated as 55.93 according to the above formula. At this time, the number of coding groups stored in the molecular sequence probability container is equal to the set search threshold of 5. Since the probability score of the current coding group to be stored, 55.93, is less than the minimum probability score of 56.36 among the existing coding groups in the current molecular sequence probability container, the current coding group is discarded and not stored.

[0120] S6) After removing the start character encoding and end character encoding in the target encoding group, convert them sequentially into SMILES strings according to the preset molecular sequence encoding table, thus generating molecular structure data;

[0121] Assuming that in this embodiment, the molecular sequence generator extracts 5 target encoding groups from the molecular sequence probability container and inputs them into the decoder (because the preset search threshold N=5 in this embodiment), the following are assumed to be present:

[0122] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,24,12,24,13,3):59.14;

[0123] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,24,13,3):59.13;

[0124] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,31,13,3):58.74;

[0125] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13,3):56.55;

[0126] (2,29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,29,12,29,12,24,11,29,12,11,24,12,24,13,3):56.36;

[0127] After the decoder removes the start character and end character codes from each of the above target encoding groups, the following encoding groups are obtained:

[0128] (29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,24,12,11,24,12,24,13);

[0129] (29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,24,13);

[0130] (29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,24,11,29,12,11,24,12,31,13);

[0131] (29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,24,24,11,22,29,12,29,12,24,12,29,13);

[0132] (29,22,24,13,24,11,24,12,22,24,11,29,12,24,11,24,12,11,24,22,24,24,11,22,29,12,29,12,24,11,29,12,11,24,12,24,13);

[0133] Based on the preset molecular sequence encoding table, each code in each of the above encoding groups is converted into the SMILES character in sequence, and the SMILES string is output in order, thus generating the following molecular structure data:

[0134] O=C1C(C)=C(O)C(C)(C=CC(=CC(=O)O)C)C(C)(C)C1;

[0135] O=C1C(C)=C(O)C(C)(C=CC(=CC(=O)O)C)C(O)(C)C1;

[0136] O=C1C(C)=C(O)C(C)(C=CC(=CC(=O)O)C)C(O)(C)S1;

[0137] O=C1C(C)=C(O)C(C)(C=CC(=CC(=O)O)C)O1;

[0138] O=C1C(C)=C(O)C(C)(C=CC(=O)O)C(O)(C)C1;

[0139] The resulting molecular structures are shown below in sequence:

[0140]

[0141]

[0142] As can be seen from the results above, the molecular structure data generated by the method of the present invention are all valid molecular structures that do not repeat.

[0143] Figure 2 The diagram shown is a system structure block diagram for achieving efficient output of a molecular generative language model provided by the present invention. Figure 2 As shown, the system for achieving efficient output of a molecular generative language model according to the present invention includes:

[0144] The encoder is used to preset the molecular sequence encoding table and convert the input start character into a start character encoding according to the preset molecular sequence encoding table, and output it to the molecular sequence generator;

[0145] The time step output sampler is used to sample the time step output code and the code in the time step conditional probability list input by the molecular sequence generator according to the set rules, and then output them to the molecular sequence generator for subsequent encoding expansion.

[0146] A molecular sequence generator is used to expand the starting character code and the time-step output code output by the time-step output sampler according to a preset search threshold and sequence length threshold, so as to generate a list of code groups to terminate the expansion and input them into the molecular sequence probability container; and to extract the target code group in the molecular sequence probability container and input it into the decoder.

[0147] A molecular sequence probability container is used to calculate the probability score of the terminating extended coding group input to the molecular sequence generator, and sorts and discards them according to the probability score to obtain a list of target coding groups.

[0148] The decoder is used to remove the start and end character codes from the target encoding group, convert them sequentially into SMILES strings according to the preset molecular sequence encoding table, and output the generated molecular structure data.

[0149] The aforementioned functional modules generally include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. Each module can exist physically separately, or two or more can be integrated into one module. The modules can be implemented in hardware or as software functional modules. If the physical or integrated modules are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium.

[0150] The present invention also provides a storage medium storing one or more programs including execution instructions, which can be read and executed by electronic devices (including but not limited to computers, servers, or network devices) to perform the method described above for achieving efficient output of a molecular generative language model.

[0151] The present invention also provides an electronic device comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores program instructions executable by the at least one processor, the program instructions being executed by the at least one processor to enable the at least one processor to perform the method described above for achieving efficient output of a molecular generative language model.

[0152] The memory may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the system for efficiently outputting the molecular generative language model. Furthermore, the memory may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, which can be connected via a network to the system for efficiently outputting the molecular generative language model. The network includes, but is not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0153] The electronic device can exist in various forms, including but not limited to:

[0154] (1) Mobile communication devices: These devices are characterized by having mobile communication functions and are primarily designed to provide voice and data communication. These terminals include: smartphones (such as iPhones), multimedia phones, feature phones, and low-end phones, etc.

[0155] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, have computing and processing functions, and generally also have mobile Internet access capabilities. These terminals include: PDA, MID and UMPC devices, such as iPad;

[0156] (3) Portable entertainment devices: These devices can display and play multimedia content. Such devices include: audio and video players (e.g., iPod), handheld game consoles, e-books, as well as smart toys and portable car navigation devices;

[0157] (4) Server: A device that provides computing services. The components of a server include a processor, hard disk, memory, system bus, etc. Servers are similar to general computer architectures, but because they need to provide highly reliable services, they have higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0158] (5) Other electronic devices with data interaction functions.

[0159] This invention also provides a computer program product, comprising a computer program stored on a storage medium, the computer program including program instructions that, when executed by a computer, enable the computer to perform the method described above for efficiently outputting a molecular generative language model. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or certain portions of the embodiments.

[0160] Additionally, logic and / or steps represented in the flowchart or otherwise described herein, for example, executable instructions that can be considered for implementing logical functions, can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: electrical connections having one or more wires (electronic devices), portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0161] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. Those skilled in the art will understand that all or part of the steps carried out by the methods of the above embodiments can be implemented by a program instructing related hardware, the program being stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiments.

[0162] Finally, it should be pointed out that the above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. In the absence of conflict, the embodiments and features in the embodiments of this application can be combined with each other. Furthermore, for the foregoing method embodiments, for the sake of simplicity, they are all described as a combination of a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously; secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments.

Claims

1. A method for achieving efficient output of a molecular generative language model, characterized in that, The steps are as follows: S1) Convert the starting character into the starting character code according to the preset molecular sequence encoding table; S2) Input the initial character encoding into the molecular generative language model, and then extract the corresponding number of time step output codes and time step conditional probability lists sorted from the output of the molecular generative language model in descending order of conditional probability according to the preset search threshold, and output them to the time step output sampler. S3) The starting character encoding and the time step output encoding output by the time step output sampler described in step S2) are sequentially extended to obtain extended encoding groups, and all extended encoding groups are combined into an extended encoding group list. The probability of each extended encoding group in the extended encoding group list is the time step conditional probability corresponding to the current time step output encoding. S4) According to the preset parallel processing batch size, sequence length threshold and search threshold, all coding groups in the extended coding group list are cyclically expanded to obtain the coding group that terminates the expansion, and the coding group that terminates the expansion and its corresponding probability are input into the molecular sequence probability container. S5) The molecular sequence probability container is based on the following formula: The probability scores of the input terminating extended coding groups are calculated and sorted and discarded according to the probability scores to obtain the target coding group; in the above formula: Score is the probability score; sum_logprobs is the input probability, that is: the sum of the output probabilities of all time steps; length_seq is the length of the coding group, that is: the number of codes in the coding group; length_penalty is the length penalty coefficient set to prevent the generation of excessively long sequences; S6) After removing the start character encoding and end character encoding in the target encoding group, convert them sequentially into SMILES strings according to the preset molecular sequence encoding table, thus generating molecular structure data.

2. The method according to claim 1, characterized in that: The molecular sequence encoding table consists of the start character, empty character, end character, and all SMILES characters used in the molecular generation language model, along with their corresponding character encodings and character attributes.

3. The method according to claim 1, characterized in that: Step S3) is to obtain the extended code group by adding the start character code to the front of the time step output code output by the time step output sampler.

4. The method according to claim 1, characterized in that, Step S4) specifically includes the following steps: S41) Input a set of extended codes from the extended code group list into the molecular generative language model. Then, according to the preset search threshold, extract the corresponding number of time-step output codes and time-step conditional probability lists sorted from the output of the molecular generative language model in descending order of conditional probability, and output them to the time-step output sampler. If the time-step output sampler outputs a blank character code, an end character code, or a null value, then end further expansion, and then add the end character code to the end of the current extended code group to become the code group that terminates the expansion; otherwise, continue to execute the subsequent steps. S42) Further expand the current extended coding group and the time step output code output by the time step output sampler described in step S41) to obtain a candidate coding group, and add it to the candidate coding group list. The probability of each candidate code in the candidate coding group list is the sum of the probability of the current extended coding group and the time step conditional probability corresponding to the time step output code. S43) Repeat steps S41) and S42) according to the preset parallel processing batch size until all extended coding groups in the extended coding group list have completed time step output and further expansion. Sort the candidate coding groups in the obtained candidate coding group list in descending order of probability. If the number of candidate coding groups in the obtained candidate coding group list is less than or equal to N but greater than zero, then use the currently obtained candidate coding group list as the updated extended coding group list. If the number of candidate coding groups in the obtained candidate coding group list is greater than N, then the first N candidate coding groups are selected to form an updated extended coding group list; N is the preset search threshold, and the candidate coding group list is cleared at the same time. S44) Repeat steps S41) to S43) on the obtained updated extended code group list. If the length of the extended code group reaches the preset sequence length threshold, the further extension ends, and then the end character code is added to the end of the current extended code group to become the code group that terminates the extension. S45) Stop the cyclic expansion when all codecs in the updated expanded codec list have finished expanding.

5. The method according to claim 1 or 4, characterized in that, The time-step output samplers all output according to the following rules: ① If the conditional probabilities of all time steps in the list are less than or equal to zero, then output an empty value; ②If there is only one output code for a time step in the list where the conditional probability of the time step is greater than zero, then output that code and its corresponding conditional probability. ③ If the number of output codes for time steps with a conditional probability greater than zero in the list is greater than one, then output the code with the highest conditional probability for the time step that is ranked first, as well as the subsequent codes whose attributes are consistent with the first code and their corresponding conditional probabilities, as determined by the preset molecular sequence coding table, until the attributes of the subsequent codes are inconsistent with the attributes of the first code, or the conditional probability of the subsequent codes is less than or equal to zero, or the subsequent codes are at the end of the list.

6. The method according to claim 1, characterized in that, Step S5) Select the appropriate option based on the following rules: ①If the number of coding groups stored in the molecular sequence probability container is less than the preset search threshold, then the current coding group is stored. ② If the number of coding groups stored in the molecular sequence probability container is equal to the preset search threshold, then compare whether the probability score of the current coding group is greater than the minimum probability score among the existing coding groups in the molecular sequence probability container; if yes, then store the current coding group and delete the existing coding group with the smallest probability score; if no, then discard the current coding group.

7. A system for achieving efficient output of a molecular generative language model, characterized in that, The system includes: The encoder is used to preset the molecular sequence encoding table and convert the input start character into a start character encoding according to the preset molecular sequence encoding table, and output it to the molecular sequence generator; The time step output sampler is used to sample the time step output code and the code in the time step conditional probability list input by the molecular sequence generator according to the set rules, and then output them to the molecular sequence generator for subsequent encoding expansion. A molecular sequence generator is used to expand the starting character code and the time-step output code output by the time-step output sampler according to a preset search threshold and sequence length threshold, so as to generate a list of code groups to terminate the expansion and input them into the molecular sequence probability container; and to extract the target code group in the molecular sequence probability container and input it into the decoder. A molecular sequence probability container is used to calculate the probability score of the terminating extended coding group input to the molecular sequence generator, and sorts and discards them according to the probability score to obtain a list of target coding groups. The decoder is used to remove the start character and end character codes from the target encoding group, convert them sequentially into SMILES strings according to the preset molecular sequence encoding table, and output the generated molecular structure data.

8. A storage medium having a computer program stored thereon, characterized in that: When executed by a processor, the program can implement the method described in any one of claims 1 to 6.

9. An electronic device comprising at least one processor and a memory communicatively connected to said at least one processor, wherein, The memory stores program instructions that can be executed by the at least one processor; characterized in that: the at least one processor is capable of executing the method according to any one of claims 1 to 6.

10. A computer program product comprising a computer program stored on a storage medium, the computer program including program instructions, characterized in that: When the program instructions are executed by the processor, they can implement the method described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Molecular generation method and device, electronic equipment and storage medium

    CN117198427A

  • Method and system for intelligently predicting molecular structure of microbial secondary metabolite

    CN117558360A