Self-adaptive code processing method and device based on artificial intelligence and intelligent agent

By measuring the overall and fragment similarity of candidate code, and selecting code with lower similarity for cross-mutation, the problem of balancing diversity and efficiency in code generation and optimization is solved, achieving efficient automatic code generation and optimization.

CN120909565AActive Publication Date: 2025-11-07BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202511430817.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2025-11-07
Estimated Expiration
2045-10-09

AI Technical Summary

Technical Problem

Existing technologies struggle to balance the diversity of evolutionary schemes with search performance optimization during code generation and optimization, resulting in low generation efficiency.

Method used

By using an AI-based adaptive code processing method, a candidate code set is obtained, the overall and fragment similarity of each candidate code is measured, and the code with lower similarity is selected for cross-mutation. This process is repeated multiple times to generate a target code set that meets the requirements.

Benefits of technology

While ensuring evolutionary diversity, it significantly improves code generation efficiency and enhances the effectiveness of automatic code generation, optimization, and repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909565A_ABST
    Figure CN120909565A_ABST
Patent Text Reader

Abstract

The invention provides a self-adaptive code processing method and device based on artificial intelligence and an intelligent agent, and relates to the technical field of artificial intelligence, in particular to the technical field of intelligent agents, coding agents, auxiliary programming, large language models, deep learning, retrieval enhancement generation and the like. According to the specific implementation scheme, a candidate code set is obtained, and the candidate code set comprises a plurality of candidate codes, first description information corresponding to each candidate code and second description information corresponding to all segments in the candidate codes; determining the similarity between every two candidate codes in the candidate code set according to the multiple pieces of first description information and the multiple pieces of second description information; performing crossover variation on the two candidate codes of which the corresponding similarity is smaller than a first threshold value to obtain a new candidate code set; and based on the new candidate code set, returning to execute the step of determining the similarity until a target code set meeting the requirement is obtained. Therefore, the generation efficiency of the code is improved while the diversity of evolution is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of artificial intelligence, in particular to the technical field of agents, encoding agents, auxiliary programming, large language models, deep learning, retrieval enhanced generation, and the like, and specifically relates to an adaptive code processing method and device based on artificial intelligence and an agent. BACKGROUND

[0002] The automatic generation and optimization of code play an important role in improving development efficiency, reducing technical threshold, and improving code quality. The evolution of program candidate solutions usually depends on the crossover and mutation of code segments. How to balance the diversity of evolution schemes and performance optimization in search has become a key bottleneck restricting technical development. SUMMARY

[0003] The present disclosure aims to at least partially solve one of the technical problems in the related art.

[0004] To this end, the present disclosure aims to provide an adaptive code processing method and device based on artificial intelligence and an agent. By measuring the similarity of the entire code and the segments in the code, the candidate code programs with low similarity are crossed, thereby ensuring the diversity of evolution while improving the generation efficiency of the code.

[0005] According to a first aspect of the present disclosure, an adaptive processing method based on artificial intelligence is provided, comprising: obtaining a candidate code set, wherein the candidate code set includes a plurality of candidate codes, first description information corresponding to each candidate code, and second description information corresponding to each segment in the candidate code; determining the similarity between each two candidate codes in the candidate code set according to a plurality of first description information and a plurality of second description information; crossing and mutating two candidate codes corresponding to a similarity less than a first threshold to obtain a new candidate code set; based on the new candidate code set, returning to the step of determining the similarity until a target code set meeting the requirements is obtained.

[0006] According to a second aspect of the present disclosure, an adaptive code processing device based on artificial intelligence is provided, comprising: a first obtaining module configured to obtain a candidate code set, wherein the candidate code set includes a plurality of candidate codes, first description information corresponding to each candidate code, and second description information corresponding to each segment in the candidate code; a first determining module configured to determine the similarity between each two candidate codes in the candidate code set according to a plurality of first description information and a plurality of second description information; The first processing module is configured to perform cross mutation on two candidate codes corresponding to the similarity less than the first threshold to obtain a new candidate code set. The second processing module is configured to return to the step of determining the similarity based on the new candidate code set until a target code set meeting the requirement is obtained.

[0007] According to a third aspect of the present disclosure, an agent is provided, comprising: An input module configured to receive a to-be-processed code and / or a code processing instruction; A processing module configured to invoke a large model to execute the AI-based adaptive code processing method according to the first aspect to obtain a target code set based on the to-be-processed code and / or the code processing instruction; An output module configured to output the target code set.

[0008] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the AI-based adaptive code processing method according to the first aspect.

[0009] According to a fifth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, and the computer instructions are used to enable the computer to execute the AI-based adaptive code processing method according to the first aspect.

[0010] According to a sixth aspect of the present disclosure, a computer program product is provided, comprising computer instructions for implementing the steps of the AI-based adaptive code processing method according to the first aspect when executed by a processor.

[0011] The AI-based adaptive code processing method, device and agent provided by the present disclosure have the following beneficial effects: In the present disclosure, the similarity between each two candidate codes in the candidate code set is measured according to the overall description information and the segment description information of each candidate code, and then the two candidate codes with smaller similarity are selected for cross mutation to obtain a new candidate code set and recalculate the similarity. After multiple iterations, a target code set meeting the requirement is obtained. The target code set can provide data reference for code automatic generation, optimization or repair, thereby improving the generation efficiency of the code while ensuring the diversity of evolution.

[0012] It is to be understood that the details set forth herein do not limit the scope of the embodiments of the present disclosure but merely constitute illustrative of typical embodiments. It will thus be apparent that modifications and variations can be effected while remaining within the scope of the application. BRIEF DESCRIPTION OF DRAWINGS

[0013] The above mentioned and / or additional aspects and advantages of the present disclosure will become apparent and easier to understand from the following description of the embodiments taken with reference to the accompanying drawings, which are intended to better understand the present solution and not to limit the present disclosure, wherein: Figure 1 is a flow diagram of an adaptive code processing method based on artificial intelligence according to an embodiment of the present disclosure; Figure 2 is a flow diagram of an adaptive code processing method based on artificial intelligence according to another embodiment of the present disclosure; Figure 3 is a flow diagram of an adaptive code processing method based on artificial intelligence according to another embodiment of the present disclosure; Figure 4 is a flow diagram of an adaptive code processing method based on artificial intelligence according to another embodiment of the present disclosure; Figure 5 is a structural diagram of an adaptive code processing device based on artificial intelligence according to an embodiment of the present disclosure; Figure 6 is a structural diagram of an intelligent agent according to an embodiment of the present disclosure; Figure 7 shows a block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure. DETAILED DESCRIPTION

[0014] Exemplary embodiments of the present disclosure are described herein with reference to the accompanying drawings, which are intended to be illustrative of various details of embodiments of the present disclosure and are not intended to limit the scope of the present disclosure. It will be apparent to those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Also, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0015] Embodiments of the present disclosure relate to the fields of artificial intelligence technologies such as intelligent agents, coding agents, assisted programming, large language models, deep learning, retrieval-augmented generation, etc.

[0016] Artificial Intelligence, commonly known as AI, is a new technology science that studies, develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence. AI is a branch of computer science that aims to understand the essence of intelligence and produce a new intelligent machine that can react in a similar way to human intelligence.

[0017] An agent is a computer system or entity that can autonomously act, perceive the environment, make decisions, and interact with the environment. It usually has a large language model as the core decision-making and processing unit, and has the ability to independently think and call tools to gradually complete given goals.

[0018] A coding agent is an artificial intelligence tool that can automatically perform programming tasks. It can understand natural language instructions and convert them into effective code snippets, thereby improving the efficiency of developers.

[0019] Programming assistance refers to a solution that provides support to developers at various stages of the software development life cycle through tools, techniques, or services, in order to reduce the difficulty of programming, reduce repetitive work, avoid errors, and improve development efficiency. It is not a complete replacement for manual programming, but rather a "collaborative partner" for developers, covering the entire process from code writing, debugging to maintenance, and is particularly suitable for solving repetitive tasks, syntax specifications, logic verification and other problems.

[0020] Large Language Model (LLM) refers to a deep learning model trained on a large amount of text data, allowing the model to generate natural language text or understand the meaning of language text. These models can provide in-depth knowledge and language production on various topics by training on large data sets. The core idea is to learn the patterns and structures of natural language through large-scale unsupervised training, to some extent, to simulate human language cognition and generation process.

[0021] Deep learning is the process of learning the internal rules and representation levels of sample data, which helps to interpret data such as text, images and sound. The ultimate goal of deep learning is to enable machines to have analytical learning ability like humans, and to recognize text, images and sound data.

[0022] Retrieval-augmented Generation, or RAG for short. Retrieval-augmented generation models combine language models and information retrieval techniques. Specifically, when the model needs to generate text or answer a question, it first retrieves relevant information from a large collection of documents, and then uses this retrieved information to guide the generation of text, thereby improving the quality and accuracy of predictions.

[0023] In the technical solutions of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the technical solutions comply with relevant laws and regulations and do not violate public order and good customs.

[0024] The AI-based adaptive code processing method, device and agent of the embodiments of the present disclosure are described below with reference to the accompanying drawings.

[0025] It should be noted that the execution subject of the AI-based adaptive code processing method of the present embodiment is an AI-based adaptive code processing device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which can include but is not limited to a terminal, a server, etc.

[0026] Figure 1 is a flowchart of the AI-based adaptive code processing method according to an embodiment of the present disclosure.

[0027] As shown in Figure 1 the AI-based adaptive code processing method comprises: S101: Obtain a candidate code set.

[0028] The candidate code set includes a plurality of candidate codes, first description information corresponding to each candidate code, and second description information corresponding to each segment in the candidate code.

[0029] The first description information can include any information describing the function, logic, and algorithm type of the code.

[0030] The second description information can include any information describing the algorithm, data structure, input data, and output data corresponding to the code segment.

[0031] In the embodiments of the present disclosure, the candidate code set can be obtained in different ways according to the needs of the user. For example, in the case of inputting a code for completion, optimization or repair, all solutions generated in the evolution process of the input code can be determined as candidate codes to obtain the candidate code set. Alternatively, the codes related to the user's needs can be queried from the historical code database as candidate codes to obtain the candidate set.

[0032] In the embodiments of the present disclosure, each candidate code can be represented as a plurality of code slices, and each slice can correspond to a solution to a sub-problem. Therefore, the second description information corresponding to the slice can be determined according to the algorithm, data structure, input data and output data of the sub-problem.

[0033] S102: Determine the similarity between any two candidate codes in the candidate code set according to the plurality of first description information and the plurality of second description information.

[0034] In the embodiments of the present disclosure, the first description information of any two candidate codes in the candidate code set can be used to measure the closeness of the two candidate codes in terms of functional objectives and overall strategies to determine the overall similarity. The second description information of the two candidate codes can be used to measure the local differences of the slices of the two candidate codes in terms of methods, data structures, input and output to determine the local similarity. Then, the similarities in the two aspects can be fused, such as addition or weighted summation, to obtain the similarity between the two candidate codes, so as to determine the similarity between any two candidate codes in the candidate code set.

[0035] S103: Cross and mutate the two candidate codes corresponding to the similarity less than the first threshold value to obtain a new candidate code set.

[0036] The first threshold value can be a threshold value dynamically set according to experience or actual needs. The first threshold value is small, and is used to screen the candidate codes with small similarity in the candidate code set.

[0037] In the embodiments of the present disclosure, after determining the similarity between any two candidate codes in the candidate code set, each similarity obtained is compared with the first threshold value. In the case that the similarity corresponding to the two candidate codes is less than the first threshold value, the two candidate codes are quite different in terms of function, logic and algorithm type. By cross-mutating the two candidate codes, such as recombining the code slices, a new code structure can be generated to obtain a new candidate code, which avoids being limited to a local optimal solution too early during processing. The set of new candidate codes obtained by cross-mutating the two candidate codes corresponding to the similarity less than the first threshold value is the new candidate code set.

[0038] In the embodiments of the present disclosure, the two candidate codes with small similarity are cross-mutated, which can expand the structural diversity of the new candidate solution and ensure the diversity of code processing.

[0039] In S104, based on the new candidate code set, the step of determining the similarity is returned to be executed until the target code set meeting the requirement is obtained.

[0040] In the embodiments of the present disclosure, after obtaining the new candidate code set, the candidate code set can be evaluated to determine whether the current candidate code set meets the requirement. For example, the quality of the candidate code set can be scored by using an evaluation tool. In a case where the quality score of the candidate code set is higher than a score threshold set by a user, the candidate code set is determined as the target code set meeting the requirement. Alternatively, other conditions for determining whether the candidate code set is the target code set can be set according to actual needs, and the present disclosure is not limited in this regard.

[0041] In the embodiments of the present disclosure, in a case where the new candidate code set obtained does not meet the requirement, the similarity between each two candidate codes in the candidate code set is recalculated, and then two candidate codes with a similarity less than a first threshold are selected for cross-mutation to obtain a new candidate code set. The iteration can be performed for multiple times. In a case where the new candidate code set obtained in one iteration meets the requirement, the iteration is stopped, and the candidate code set is determined as the target code set.

[0042] In the embodiments of the present disclosure, after obtaining the target code set, the codes in the target code set can be used for code generation, code completion or optimization based on the task needs of the user, so as to significantly improve the efficiency and effect of code generation and optimization.

[0043] In the embodiments, the similarity between each two candidate codes in the candidate code set is measured according to the overall description information and the segment description information of each candidate code, and then two candidate codes with small similarity are selected for cross-mutation to obtain a new candidate code set and recalculate the similarity. After multiple iterations, the target code set meeting the requirement is obtained. The target code set can provide data reference for code automatic generation, optimization or repair, so as to improve the code generation efficiency while ensuring the diversity of evolution.

[0044] The adaptive code processing method based on artificial intelligence provided in the present disclosure can be applied to scenarios such as programming assistance, code automatic completion, code debugging and optimization, and automatic vulnerability repair and test case generation. For example, a developer can input part of a program in an integrated development environment (IDE), and obtain a target code set by using the adaptive code processing method based on artificial intelligence provided in the present disclosure, and recommend the target code set to the developer for use. Alternatively, a user can input a code segment containing defects, and obtain a target code functionally equivalent to the code segment but safer or more robust, to automatically replace or generate a repaired version, thereby improving system security.

[0045] Figure 2 is a flowchart of the adaptive code processing method based on artificial intelligence provided in another embodiment of the present disclosure.

[0046] As shown in Figure 2 , the adaptive code processing method based on artificial intelligence comprises the following steps. S201: Obtain a candidate code set.

[0047] The description of S201 can be specifically referred to the above embodiments, which will not be repeated here.

[0048] S202: Determine the global similarity between two candidate codes corresponding to each two first description information.

[0049] It should be noted that in the present disclosure, the global similarity measures the closeness of the candidate codes in the functional target and the overall strategy, which can also be referred to as overall similarity, semantic similarity, etc.

[0050] In the embodiments of the present disclosure, the global similarity between the candidate codes can be obtained by converting the first description information into a semantic vector and then calculating the cosine similarity, or by matching the keywords in the first description information and determining the global similarity between the candidate codes according to the matching ratio, or by using other calculation methods to determine the global similarity between the two candidate codes, etc. The present disclosure does not limit the comparison.

[0051] S203: Determine the local similarity between each two candidate codes based on the second description information corresponding to each segment in each two candidate codes.

[0052] It should be noted that in the present disclosure, the local similarity measures the local difference of the segments of the candidate codes in the method, data structure, input and output, such as the matching degree of the abstract syntax tree or the control flow graph, which can also be referred to as substructure similarity, etc.

[0053] In the embodiments of the present disclosure, the similarity between the two candidate codes can be determined by converting the second description information into a semantic vector, then calculating the similarity between the segments by cosine similarity, and then fusing the similarity of all segments to obtain the local similarity between the two candidate codes, or other calculation methods can also be used to obtain the local similarity between the two candidate codes. The present disclosure does not limit the comparison.

[0054] S204: Fuse the global similarity and the local similarity to obtain the similarity between each two candidate codes.

[0055] In the embodiments of the present disclosure, the fusion manner of the global similarity and the local similarity can be direct addition or weighted summation according to certain weights.

[0056] For example, when the global similarity and the local similarity are weighted summed according to certain weights, the similarity between the two candidate codes can be represented by the following formula (1): (1) Among them, denotes the similarity between the candidate code A and the candidate code B, denotes the local similarity between the candidate code A and the candidate code B, denotes the global similarity between the candidate code A and the candidate code B, is a weight proportion coefficient of the local similarity in the similarity, which can be set according to experience or actual needs.

[0057] Optionally, when the similarity between any two candidate codes is greater than or equal to the first threshold value, and the local similarity between some segments in any two candidate codes is less than the second threshold value, the some segments in any two candidate codes are crossed and mutated to obtain new candidate codes.

[0058] Among them, the second threshold value can be a threshold value dynamically set according to experience or actual needs. The second threshold value is smaller in value and is used to screen the segments with smaller similarity in the candidate codes. The second threshold value and the first threshold value are used to screen different targets. One candidate code, one segment of the candidate code, therefore, no specific size relationship is set between the second threshold value and the first threshold value.

[0059] In the embodiments of the present disclosure, when the similarity between any two candidate codes is greater than or equal to the first threshold value, it can be determined that the functions, logics, etc. of the two candidate codes are relatively similar as a whole. At this time, the segments with lower similarity in the candidate codes can be further determined, and the segments are crossed and mutated to introduce moderate differences and avoid falling into local optimization.

[0060] It should be noted that in the embodiments of the present disclosure, the two candidate codes corresponding to the similarity less than the first threshold value can be cross-mutated, and the two candidate codes with the similarity greater than or equal to the first threshold value and the local similarity between the partial segments less than the second threshold value can be cross-mutated.

[0061] Alternatively, the two candidate codes corresponding to the similarity less than the first threshold value can be cross-mutated, and the candidate code set can be updated for a certain number of rounds, and when the similarity between all candidate codes is greater than the first threshold value, the segment cross between the candidate codes can be performed again.

[0062] In the embodiments, by cross-mutating the segments with low local similarity in the case that the global similarity of the two candidate codes is high, new candidate codes can be obtained, moderate differences can be introduced, local optimization can be avoided, the diversity of the candidate codes can be maintained while ensuring rapid convergence, homogeneous codes can be avoided, and thus better solutions can be explored in complex problems.

[0063] S205: Cross-mutate the two candidate codes corresponding to the similarity less than the first threshold value to obtain a new candidate code set.

[0064] S206: Based on the new candidate code set, return to perform the step of determining the similarity until a target code set meeting the requirements is obtained.

[0065] The description of S205 and S206 can be specifically referred to the above embodiments, and will not be repeated here.

[0066] In the embodiments, by measuring the similarity between the candidate codes from the global and local perspectives, the target code determined based on the similarity not only guarantees the reliability of the syntax level, but also can match the user's requirements in the function and performance levels.

[0067] Figure 3 is a flowchart of an adaptive code processing method based on artificial intelligence according to another embodiment of the present disclosure.

[0068] As shown in Figure 3 , the adaptive code processing method based on artificial intelligence comprises: S301: Obtain a candidate code set.

[0069] Optionally, the code generated in the evolution process of the received code to be processed can be determined as a candidate code.

[0070] The code to be processed refers to the code provided by the user and needing to be optimized or completed.

[0071] In the embodiments of the present disclosure, the to-be-processed code can be modified, optimized, extended, refactored, etc. during evolution, and all code versions generated by all operations can be determined as candidate codes, so that the candidate codes can reflect the context logic, problem solution, etc. in the historical evolution, thereby facilitating improvement of code quality.

[0072] Alternatively, the candidate code associated with the received code processing instruction can also be obtained from the reference code library.

[0073] The reference code library can be a database storing historical codes.

[0074] In the embodiments of the present disclosure, each reference code in the reference code library can correspond to different functions or algorithm types, etc. The user can send a code processing quality to explicitly express a requirement (such as a code with what function, use, etc.), so that at least one candidate code associated with the received code processing instruction can be obtained from the reference code library, and a candidate code set is obtained.

[0075] In the embodiments, the candidate code can be obtained in multiple ways, which can be suitable for different task scenarios and improve the adaptability of code processing.

[0076] S302: Determine the similarity between each two candidate codes in the candidate code set according to the plurality of first description information and the plurality of second description information.

[0077] The description of S301 and S302 can be specifically referred to the above embodiments, and will not be repeated here.

[0078] S303: Cross mutation is performed on the two candidate codes corresponding to the similarity less than the first threshold value to obtain a new candidate code.

[0079] In the embodiments of the present disclosure, after the similarity between each two candidate codes in the candidate code set is determined, each obtained similarity is compared with the first threshold value. In the case that the similarity corresponding to the two candidate codes is less than the first threshold value, the two candidate codes are quite different in function, logic, and algorithm type, etc. By cross mutation, such as recombination of code segments, etc., a new code structure can be generated, and a new candidate code is obtained.

[0080] S304: Determine an update strategy of the candidate code set according to the type of the code processing instruction and / or the first parameter in the code processing instruction.

[0081] The update strategy is used to indicate a parent code proportion, a parent code quantity, and / or a screening condition of the parent code included in the new candidate code set. The parent code is a code used to generate a new candidate code by cross mutation.

[0082] In the embodiments of the present disclosure, since the final obtained code has different effects due to different types of code processing instructions, different update strategies can be adopted. For example, if the target of the code processing instruction is to generate a brand-new logic code, the parent code can be discarded in the update strategy. However, if the target is to generate more optimized code on the basis of the existing framework, the parent code can be retained in the update strategy. Alternatively, if the code processing instruction is to optimize the code, part of the parent code can be retained to avoid losing excellent solutions in the parent code.

[0083] It should be noted that in the embodiments of the present disclosure, the user can also directly input the number or proportion of the parent code to be retained during the update of the candidate code set during use.

[0084] In the embodiments of the present disclosure, the user can also directly input the number or proportion of the parent code to be retained during the update of the candidate code set during use, that is, the first parameter in the code processing instruction. Thus, the update strategy of the candidate code set can be determined according to the first parameter in the code processing instruction.

[0085] In the present disclosure, the type of the code processing instruction and the first parameter in the code processing instruction can be combined to determine the update strategy of the candidate code set.

[0086] S305: Obtain the target parent code from the candidate code set based on the update strategy.

[0087] In the embodiments of the present disclosure, the target parent code can be determined from the plurality of candidate codes for cross variation according to the proportion or number of the parent code indicated in the update strategy and / or the screening condition of the parent code.

[0088] S306: Determine the new candidate code and the target parent code as a new candidate code set.

[0089] In the embodiments of the present disclosure, by putting the parent code into the new set when generating the new code set through cross variation, the stability and diversity in the code evolution process can be maintained, the optimal solution can be retained, and valuable information can be avoided from being lost due to excessive intergenerational replacement.

[0090] S307: Based on the new candidate code set, return to the step of determining the similarity until the target code set meeting the requirement is obtained.

[0091] The description of S307 can be specifically referred to the above embodiments, and will not be repeated here.

[0092] Figure 4 is a flowchart of an artificial intelligence-based adaptive code processing method according to another embodiment of the present disclosure.

[0093] AsFigure 4 As shown, the artificial intelligence-based adaptive code processing method comprises the following steps. S401: In a case where the evaluation service in the system is in an enabled state, or in a case where the received code processing instruction indicates to invoke the evaluation service, the evaluation service is invoked based on the new candidate code set to obtain an evaluation result output by the evaluation service.

[0094] The evaluation result comprises an evaluation value of the candidate code and / or a to-be-updated segment in the candidate code.

[0095] In the embodiments of the present disclosure, in a case where the evaluation service in the system is in an enabled state, or in a case where the received code processing instruction indicates to invoke the evaluation service, the evaluation service can be invoked to utilize the expert knowledge in the evaluation service to perform feedback from a global and local perspective to obtain an evaluation result.

[0096] In the embodiments of the present disclosure, the evaluation service can evaluate the overall optimization potential of the new candidate code set by scoring each candidate code to obtain an evaluation value, which is used to filter the candidate codes that can be retained or eliminated in the candidate code set, for example, the corresponding candidate code is retained if the evaluation value is high, and the candidate code is deleted from the candidate code set if the evaluation value is lower than a certain value. Alternatively, the evaluation service can also evaluate the segments in each candidate code to accurately locate the segments that need to be replaced or adjusted, and determine the to-be-updated segments in the candidate code. Moreover, the evaluation value of each candidate code can also be obtained, and the to-be-updated segments therein can also be determined.

[0097] S402: Updating the new candidate code set based on the evaluation result.

[0098] In the embodiments of the present disclosure, after obtaining the evaluation result, each candidate code can be deleted or retained, and the segments in the candidate code can be replaced or adjusted based on the evaluation result to complete the update of the new candidate code set.

[0099] In the embodiments, by utilizing the feedback of the evaluation service to drive the adaptive editing strategy, the redundant candidate solutions caused by blind search can be significantly reduced, and the convergence speed can be accelerated, thereby improving the response efficiency of the product and the user experience.

[0100] Optionally, when updating the new candidate code set, at least one of the following can be included: deleting the candidate code in the new candidate code set whose evaluation value is less than an evaluation threshold; and updating the to-be-updated segment in the candidate code to obtain a new candidate code.

[0101] The evaluation threshold can also be a value defined according to experience or actual demand, and the present disclosure does not limit this.

[0102] In the embodiments of the present disclosure, the candidate code set is updated from the overall and local two angles, which can improve the accuracy of code processing and improve the quality of code generation.

[0103] Optionally, when updating the to-be-updated segment in the candidate code, the similarity between the second description information of the to-be-updated segment and the third description information of each code segment in the gene pool can be determined, and then the target segment or the target parent code containing the target segment can be obtained from the gene pool based on the similarity. Then, the to-be-updated segment can be updated by using the target segment or the target parent code to obtain a new candidate code.

[0104] In the embodiments of the present disclosure, the gene pool of the code segment can be constructed based on the vector database, and the high-quality segments and their feature indexes such as the third description information are stored. Therefore, the retrieval augmented generation (RAG) technology can be used to obtain the target segment or the target parent code in the gene pool, and the to-be-updated segment is cross-enhanced or mutation-enhanced to update the to-be-updated segment to obtain a new candidate code. The cross-enhancement can provide additional parent code or segment for the candidate code, and improve the diversity of cross. The mutation-enhancement can provide a target segment with similar function but better performance at the feedback-located segment position, and reduce the invalid search space.

[0105] In the embodiments of the present disclosure, when updating the to-be-updated segment, the to-be-updated segment can be directly replaced, or the to-be-updated segment can be crossed with the target segment or the target parent code, and the to-be-updated segment is replaced based on the cross result to obtain a new candidate code.

[0106] In the embodiments of the present disclosure, by obtaining high-quality segments in the gene pool and adding them to the evolution process of the candidate code, and eliminating low-quality or redundant segments, it is ensured that the updated candidate code is more representative and the code processing is more efficient.

[0107] Optionally, when obtaining the target parent code from the gene pool, the target segment or the target parent code containing the target segment can be obtained from the gene pool based on the control signal and the similarity in the case that the control signal is received. The control signal is used to indicate the retrieval logic and / or the number of retrieval results.

[0108] The retrieval logic can be semantic similarity retrieval, functional similarity retrieval, target algorithm retrieval, and the like.

[0109] The number of retrieval results is used to indicate how many target segments or target parent codes containing the target segments are obtained to update the candidate code.

[0110] In this embodiment of the disclosure, by receiving control signals, the logic used to retrieve the gene pool and the amount of data used to update the candidate code are dynamically adjusted, so that users can adjust the candidate code update process independently, which can ensure that the code update results better meet the user's needs and optimize the user experience.

[0111] Optionally, the index corresponding to a candidate code can be determined based on the first and / or second descriptive information associated with candidate codes whose evaluation values ​​are greater than the evaluation threshold. The candidate codes and their indexes are then associated and stored in the gene pool.

[0112] In this embodiment of the disclosure, by adopting a dynamic update mechanism for the gene pool, the system will continuously accumulate and screen high-quality fragments during operation, forming a positive feedback loop of continuous improvement, making the product increasingly intelligent over time.

[0113] Figure 5 This is a schematic diagram of the structure of an artificial intelligence-based adaptive code processing device proposed in an embodiment of this disclosure.

[0114] like Figure 5 As shown, the AI-based adaptive code processing device 50 includes: The first acquisition module 501 is used to acquire a candidate code set, wherein the candidate code set includes multiple candidate codes, a first description information corresponding to each candidate code, and a second description information corresponding to each segment in the candidate code; The first determining module 502 is used to determine the similarity between every two candidate codes in the candidate code set based on multiple first description information and multiple second description information; The first processing module 503 is used to perform cross mutation on two candidate codes with a similarity of less than a first threshold to obtain a new set of candidate codes; The second processing module 504 is used to return to the step of determining similarity based on the new candidate code set until a target code set that meets the requirements is obtained.

[0115] Optionally, the first determining module 502 can be specifically used for: Based on each pair of first description information, determine the global similarity between the corresponding two candidate codes; Based on the second description information corresponding to each segment in each pair of candidate codes, the local similarity between each pair of candidate codes is determined. The global similarity and local similarity are fused to obtain the similarity between each pair of candidate codes.

[0116] Optionally, the first processing module 503 can also be used for: The similarity between any two candidate codes is greater than or equal to a first threshold, and the local similarity between the partial segments in any two candidate codes is less than a second threshold, and the partial segments in any two candidate codes are crossed and mutated to obtain new candidate codes. Optionally, the first acquisition module 501 can be further configured to perform at least one of the following: The code generated in the evolution process of the received to-be-processed code is determined as a candidate code. The candidate code associated with the received code processing instruction is acquired from the reference code library.

[0117] Optionally, the first processing module 503 can be specifically configured to perform at least one of the following: The two candidate codes corresponding to the similarity less than the first threshold are crossed and mutated to obtain new candidate codes. According to the type of the code processing instruction and / or the first parameter in the code processing instruction, an update strategy of the candidate code set is determined, wherein the update strategy is used to indicate a parent code proportion, a parent code quantity, and / or a parent code screening condition included in the new candidate code set. The target parent code is acquired from the candidate code set based on the update strategy. The new candidate code and the target parent code are determined as the new candidate code set.

[0118] Optionally, the first processing module 503 can be further configured to perform at least one of the following: In a case where the evaluation service in the system is in a selected state, or in a case where the received code processing instruction indicates that the evaluation service is called, the evaluation service is called based on the new candidate code set to obtain an evaluation result output by the evaluation service, wherein the evaluation result includes an evaluation value of the candidate code and / or a to-be-updated segment in the candidate code. The new candidate code set is updated based on the evaluation result.

[0119] Optionally, the first processing module 503 can be further configured to perform at least one of the following: The candidate code with an evaluation value less than an evaluation threshold in the new candidate code set is deleted. The to-be-updated segment in the candidate code is updated to obtain new candidate codes.

[0120] Optionally, the first processing module 503 can be specifically configured to perform at least one of the following: The similarity between the second description information of the to-be-updated segment and the third description information of each code segment in the gene pool is determined. The target segment or the target parent code containing the target segment is acquired from the gene pool based on the similarity. The to-be-updated segment is updated by using the target segment or the target parent code to obtain new candidate codes.

[0121] Optionally, the first processing module 503 can be specifically used for: In the case of receiving the control signal, the target fragment or the target parent code containing the target fragment is obtained from the gene pool based on the control signal and the similarity, wherein the control signal is used to indicate the retrieval logic and / or the number of retrieval results.

[0122] Optionally, the first processing module 503 can also be at least one of the following: According to the first description information and / or the second description information associated with the candidate code whose evaluation value is greater than the evaluation threshold, the index corresponding to the candidate code is determined; The candidate code and the index are associated and stored in the gene pool.

[0123] It should be noted that the above explanation and description of the artificial intelligence-based adaptive code processing method also applies to the artificial intelligence-based adaptive code processing device of the present embodiment, which will not be described here.

[0124] In the present embodiment, the similarity between each two candidate codes in the candidate code set is measured according to the overall description information and the fragment description information of each candidate code, then two candidate codes with smaller similarity are selected for crossover and mutation to obtain a new candidate code set and recalculate the similarity, and after multiple iterations, a target code set meeting the requirements is obtained. The target code set can provide data reference for code automatic generation, optimization or repair, thereby improving the code generation efficiency while ensuring the diversity of evolution.

[0125] The present disclosure also provides an agent. Figure 6 As shown in the structure schematic diagram of the agent 60 provided by the present disclosure, the agent 60 can include an input module 601, a processing module 602 and an output module 603. Figure 6 As shown in the structure schematic diagram of the agent 60 provided by the present disclosure, the agent 60 can include an input module 601, a processing module 602 and an output module 603.

[0126] The input module 601 is configured to receive the to-be-processed code and / or the code processing instruction; the processing module 602 is configured to call the large model to execute the artificial intelligence-based adaptive code processing method described in the above embodiments based on the to-be-processed code and / or the code processing instruction received by the input module 601, to obtain a target code set; and the output module 603 is configured to output the target code set.

[0127] In the present disclosure, the user can obtain the target code set output by the agent by only inputting at least one of the to-be-processed code and the code processing instruction, thereby providing data reference for code automatic generation, optimization or repair, assisting the user in programming, and improving work efficiency. Figure 5 As shown in the structure schematic diagram of the agent 60 provided by the present disclosure, the agent 60 can include an input module 601, a processing module 602 and an output module 603.

[0128] According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0129] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present disclosure described and / or claimed in this document.

[0130] As shown in Figure 7 The device 700 includes a computing unit 701 that can perform various appropriate actions and processes in accordance with a computer program stored in a read-only memory (ROM) 702 or a computer program loaded into a random access memory (RAM) 703 from a storage unit 708. Various programs and data required for the operation of the device 700 can also be stored in the RAM 703. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0131] Various components in the device 700 are connected to the I / O interface 705, including an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; the storage unit 708, such as a magnetic disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0132] The computing unit 701 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, and the like. The computing unit 701 performs various methods and processes described above, such as the code processing method. For example, in some embodiments, the code processing method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded onto the RAM 703 and executed by the computing unit 701, one or more steps of the code processing method described above can be performed. Alternatively, in other embodiments, the computing unit 701 can be configured to perform the code processing method by any other suitable means, such as by means of firmware.

[0133] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0134] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or the block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0135] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0136] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0137] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0138] The computer system can include clients and servers. This relationship can be. The servers are typically remote from the clients with the interactions typically occurring over the network. The relationship can be created by the use of computer programs running on the respective computers and having a client-server relationship with one another. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS (Virtual Private Server, or simply VPS). The server can also be a server of a distributed system, or a server combined with a blockchain.

[0139] It should be understood that the various forms of flow shown above can be reordered, steps added or removed. For example, the steps described in the present disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of the present disclosure can be achieved, which are not limited herein.

[0140] In addition, the terms "first", "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "a plurality of" is at least two, for example, two, three, etc., unless otherwise explicitly and specifically limited. In the description of the present disclosure, the word "if" and "if" can be interpreted as "when" or "when" or "in response to determining" or "in the case of".

[0141] The above detailed description does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.

Claims

1. An artificial intelligence-based adaptive code processing method, comprising: obtaining a candidate code set, wherein the candidate code set comprises a plurality of candidate codes, first description information corresponding to each of the candidate codes, and second description information corresponding to each segment of the candidate codes; determining similarity between each two candidate codes in the candidate code set according to the plurality of first description information and the plurality of second description information; crossing and mutating the two candidate codes corresponding to the similarity less than a first threshold to obtain a new candidate code set; based on the new candidate code set, returning to the step of determining the similarity until a target code set meeting the requirement is obtained.

2. The method of claim 1, wherein, The step of determining the similarity between each two candidate codes in the candidate code set according to the plurality of first description information and the plurality of second description information comprises: determining global similarity between the two candidate codes corresponding to each two first description information; determining local similarity between the two candidate codes based on the second description information corresponding to each segment of the two candidate codes; fusing the global similarity and the local similarity to obtain the similarity between the two candidate codes.

3. The method of claim 1, wherein, After the step of determining the similarity between each two candidate codes in the candidate code set, further comprising: crossing and mutating the part of segments in the two candidate codes if the similarity between the two candidate codes is greater than or equal to the first threshold and the local similarity between the part of segments is less than a second threshold to obtain a new candidate code.

4. The method of claim 1, wherein, The step of obtaining the candidate code set comprises at least one of the following: determining the code generated in the evolution process of the received code to be processed as the candidate code; obtaining the candidate code associated with the received code processing instruction from a reference code library.

5. The method of claim 4, wherein, The step of crossing and mutating the two candidate codes corresponding to the similarity less than the first threshold to obtain the new candidate code set comprises: crossing and mutating the two candidate codes corresponding to the similarity less than the first threshold to obtain the new candidate code; determining an update strategy of the candidate code set according to the type of the code processing instruction and / or the first parameter in the code processing instruction, wherein the update strategy is used to indicate the proportion, the number of parent codes included in the new candidate code set, and / or the screening condition of the parent codes; obtaining a target parent code from the candidate code set based on the update strategy; determining the new candidate code and the target parent code as the new candidate code set.

6. The method of any one of claims 1-5, wherein, After the step of obtaining the new candidate code set, further comprising: in a case that the evaluation service in the system is in a selected state or in a case that the received code processing instruction indicates to call the evaluation service, calling the evaluation service based on the new candidate code set to obtain an evaluation result output by the evaluation service, wherein the evaluation result comprises an evaluation value of the candidate code and / or a segment to be updated in the candidate code; updating the new candidate code set based on the evaluation result.

7. The method of claim 6, wherein, The updating of the new candidate code set based on the evaluation result comprises at least one of the following: deleting a candidate code in the new candidate code set whose evaluation value is less than an evaluation threshold value; updating a to-be-updated segment in the candidate code to obtain a new candidate code.

8. The method of claim 7, wherein, The updating of the to-be-updated segment in the candidate code to obtain a new candidate code comprises: determining a similarity between second description information of the to-be-updated segment and third description information of each code segment in a gene pool; based on the similarity, obtaining a target segment or a target parent code containing the target segment from the gene pool; updating the to-be-updated segment by using the target segment or the target parent code to obtain a new candidate code.

9. The method of claim 8, wherein, The obtaining of the target segment or the target parent code containing the target segment from the gene pool based on the similarity comprises: in a case where a control signal is received, obtaining the target segment or the target parent code containing the target segment from the gene pool based on the control signal and the similarity, wherein the control signal is used to indicate a retrieval logic and / or a number of retrieval results.

10. The method of claim 8, wherein, The method further comprises at least one of the following: determining an index corresponding to a candidate code according to first description information and / or second description information associated with the candidate code whose evaluation value is greater than an evaluation threshold value; storing the candidate code and the index in the gene pool in association.

11. An artificial intelligence-based adaptive code processing apparatus, comprising: a first obtaining module configured to obtain a candidate code set, wherein the candidate code set comprises a plurality of candidate codes, first description information corresponding to each of the candidate codes, and second description information corresponding to each segment in the candidate codes; a first determining module configured to determine a similarity between each two of the candidate codes according to the plurality of first description information and the plurality of second description information; a first processing module configured to perform cross mutation on two candidate codes corresponding to a similarity less than a first threshold value to obtain a new candidate code set; a second processing module configured to return to performing the step of determining the similarity based on the new candidate code set until a target code set meeting a requirement is obtained.

12. An intelligent agent, comprising: an input module configured to receive a to-be-processed code and / or a code processing instruction; a processing module configured to invoke a large model to execute the method of any one of claims 1-10 based on the to-be-processed code and / or the code processing instruction to obtain a target code set; an output module configured to output the target code set.

13. An electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the artificial intelligence-based adaptive code processing method of any one of claims 1-10.

14. A non-transitory computer-readable storage medium having stored thereon computer instructions, wherein the computer instructions, when executed by a processor, cause the processor to perform the method of any one of claims 1-13. wherein The computer instructions are for causing the computer to perform the artificial intelligence based adaptive code processing method of any one of claims 1-10.

15. A computer program product, characterised in that, A computer program product comprising computer instructions which, when executed by a processor, implement the steps of the artificial intelligence based adaptive code processing method according to any one of claims 1-10.

Citation Information

Patent Citations

  • Multi-path coverage method and system combining key point probability and path similarity

    CN111240995A

  • Intelligent code repetition comparison and integration method, computer equipment and storage medium

    CN115061931A

  • SDP system concurrent access link planning method and device and storage medium

    CN115883251A

  • Algorithm automatic matching and parameter optimization method and system

    CN118468061A

  • Code completion method and device, storage medium and computer equipment

    CN119225735A