A large model-based code search method
By constructing an iterative reasoning process through a multi-agent collaborative mechanism and IOF semantic structured representation, the problem of insufficient retrieval accuracy and stability in code search in complex queries and large-scale code libraries in existing technologies is solved, and higher retrieval accuracy and recall are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHONGQING UNIV
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-05
AI Technical Summary
Existing code search technologies lack the ability to iterate and optimize when faced with complex queries or semantically ambiguous scenarios, making it difficult to improve retrieval accuracy and stability, especially in large-scale code repositories where it is difficult to accurately locate target code snippets.
A multi-agent collaborative mechanism is adopted, including code understanding, query understanding, evaluation, and re-ranking agents. Through the IOF semantic structured representation mechanism, an iterative reasoning process is constructed. The evaluation agent automatically adjusts the strategy when the initial retrieval fails, and performs "retrieval-evaluation-adjustment-re-retrieval". The re-ranking agent performs semantic-level relevance scoring and fine-tuning.
It significantly improves retrieval accuracy and recall in complex queries and large-scale codebase environments, enhances system stability and interpretability, and can gradually approach the target code in multiple iterations, thereby improving the matching quality of code search.
Smart Images

Figure CN122153039A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer software engineering and artificial intelligence technology, and in particular to a code search method based on a large model. Background Technology
[0002] As the scale of open-source software continues to expand, the number of code repositories and the size of code snippets are growing rapidly. Developers are increasingly relying on code search technologies to find reusable functionalities during software development. Currently, mainstream code search technologies can be broadly categorized into three types: keyword-based matching methods, vector semantic matching methods, and understanding-based retrieval methods based on large models.
[0003] Early code search systems primarily employed keyword matching mechanisms, such as TF-IDF and BM25 information retrieval models. These models returned results by matching user query text with code comments or identifiers. While simple to implement and computationally efficient, these methods inherently rely on surface-level text similarity and struggle to understand the functional semantics of the code. When users describe their needs using natural language, or when there is no significant keyword overlap between the code and the query, the matching results can easily become irrelevant to the actual functionality, leading to low search accuracy.
[0004] To improve semantic understanding, deep learning-based code search methods, such as CodeBERT and GraphCodeBERT, have emerged in recent years. These methods map code and natural language queries to a unified vector space for similarity calculation, thereby achieving semantic-level retrieval. These methods alleviate the problem of insufficient keyword matching to some extent and have become the mainstream technology in the current code search field. However, existing vector retrieval methods typically employ a single-round similarity calculation mechanism, generating a vector based on a single query and returning Top-K candidate results. This retrieval process lacks dynamic adjustment capabilities. When user queries are incomplete, semantically imprecise, or the codebase contains numerous semantically similar but functionally different distractors, a single retrieval may struggle to accurately locate the target code segment, easily leading to significant recall bias or insufficient precision.
[0005] On the other hand, with the development of large language models (LLMs) in the field of code understanding and generation, they possess strong semantic reasoning and logical analysis capabilities, enabling a deeper understanding of code functionality. However, existing technologies that directly utilize large models for code search still have significant limitations: first, large models are limited by the length of their context windows, making it difficult to directly handle large-scale codebases; second, the single-inference mode lacks a feedback correction mechanism, making it susceptible to the impact of initial query quality; and third, in the absence of structured intermediate representations, the stability and controllability of the retrieval process are weak.
[0006] Therefore, existing technologies generally suffer from the following problems: when faced with complex queries or semantically ambiguous scenarios, the code search process relies on single vector matching and lacks the ability to analyze, reflect on, and iteratively optimize based on intermediate results, making it difficult to further improve retrieval accuracy and stability.
[0007] How to leverage the semantic understanding and reasoning capabilities of large models to build an iteratively optimized code search mechanism on the basis of the existing vector retrieval framework, enabling the system to dynamically adjust the query strategy based on the initial retrieval results and gradually approach the target code, is a technical problem that urgently needs to be solved in the current code search field. Summary of the Invention
[0008] In view of the above-mentioned problems in the existing technology, the technical problem to be solved by the present invention is: how to improve the accuracy of code search through iterative query.
[0009] To solve the above technical problems, the present invention adopts the following technical solution: a code search method based on a large model, comprising the following steps:
[0010] S1: Obtain a code library containing several original code fragments, input the code library into the code understanding agent, and obtain an IOF database composed of IOF data corresponding to each original code fragment;
[0011] Then, the IOF database is input into the pre-trained Embedding model to obtain a vector database composed of high-dimensional feature vectors corresponding to each IOF data point;
[0012] S2: Obtain any original user query description, input the original user query description into the query understanding agent to obtain initial retrieval metadata, and use the pre-trained Embedding model to convert the initial retrieval metadata into a target query vector;
[0013] Calculate the similarity value between the target query vector and each high-dimensional feature vector in the vector database, sort all similarity values in descending order, select the high-dimensional feature vectors corresponding to the top N high similarity values, and use the IOF data corresponding to these high-dimensional feature vectors to form an initial candidate set;
[0014] S3: Input the original user query description and the initial candidate set into the evaluation agent. The evaluation agent scores all IOF data in the initial candidate set one by one according to the original user query description, and then obtains the final cumulative candidate set based on the scoring results.
[0015] S4: Input the final cumulative candidate set into the reordering agent. The reordering agent calculates the semantic relevance value between the original user query description and each IOF data in the final cumulative candidate set and sorts them in descending order. It selects the original code fragments corresponding to the top few IOF data as the matching results that conform to the original user query description and outputs them.
[0016] Preferably, the process of obtaining the final cumulative candidate set in S3 is as follows:
[0017] Preset iteration count T;
[0018] S3-1: Construct scoring rules and evaluate the agent. Based on the scoring rules and the original user query description, evaluate the IOF data in the initial candidate set one by one, and then output the score value and corresponding evaluation description of each IOF data as the current candidate set.
[0019] S3-2: If at least one of the IOF data in the current candidate set has a perfect score, then the current candidate set will be used as the final cumulative candidate set.
[0020] Otherwise, the evaluation agent regenerates a new user query description based on the original user query description and the evaluation descriptions corresponding to all IOF data, and uses the method described in S2 to obtain a new set of candidates for the next iteration.
[0021] S3-3: Using the new user query description and the candidate set for the new iteration, the evaluation agent evaluates each IOF data in the candidate set for the new iteration according to the scoring rules and the new user query description. Then, it outputs the score value and corresponding evaluation description of each IOF data as the current candidate set. Then, it determines whether the current iteration round is greater than T. If it is greater than T, the current candidate set is output as the final cumulative candidate set; otherwise, proceed to the next step.
[0022] S3-4: Let the total number threshold of IOF data be L. Merge the candidate set of the new round of iteration with the initial candidate set to obtain the total number of candidates set. If the total number of candidates set is greater than L, then output the current candidate set obtained in S3-3 as the final cumulative candidate set; otherwise, return to S3-2.
[0023] Preferably, the scoring rules in S3-1 include evaluation dimensions, evaluation scores, and evaluation criteria, wherein the evaluation score is out of 10 points;
[0024] Compared with the prior art, the present invention has at least the following advantages:
[0025] This invention upgrades code search from simple similarity matching to an iterative reasoning process with cognitive capabilities by introducing a multi-agent collaborative mechanism (code understanding, query understanding, evaluation, and re-ranking). In particular, the introduction of the evaluation agent and the iterative loop enables the system to automatically adjust its strategy to "follow up" or "expand the scope" when the initial retrieval fails, significantly improving the retrieval accuracy and recall for complex queries or long-tail problems.
[0026] 1. By constructing a multi-agent collaborative retrieval framework consisting of a code understanding agent, a query understanding agent, an evaluation agent, and a reordering agent, and introducing an Input-Output-Function (IOF) semantic structured representation mechanism, the deep semantic information of code fragments is fully extracted, alleviating the problems of insufficient semantic expression and low matching accuracy caused by relying solely on original code text modeling in existing technologies; by utilizing query understanding and semantic expansion mechanisms, semantic parsing and reconstruction of user natural language queries are performed, effectively improving the system's ability to understand fuzzy queries, long text queries, and complex requirement descriptions;
[0027] 2. By introducing an evaluation agent and an iterative feedback mechanism, the system can automatically analyze the reasons for deviations and generate new query descriptions when the initial search results are not ideal, realizing a dynamic optimization process of "retrieval—evaluation—adjustment—re-retrieval". This solves the problem that existing vector retrieval methods cannot continuously approach the target code in a single round of matching. Through the accumulation of candidate sets and multi-round semantic reasoning strategies, the coverage of potentially relevant codes is fully expanded, and the risk of omission caused by a single Top-K search is reduced.
[0028] 3. By employing a re-ranking agent to perform semantic-level relevance scoring and fine-tuning of candidate codes, the functional matching capability is further enhanced, solving the problem of inaccurate results caused by relying solely on vector similarity ranking. This invention not only significantly improves the recall and precision of code search but also enhances the stability and interpretability of the retrieval process, enabling the system to maintain high matching quality even in complex query scenarios and large-scale codebase environments. It possesses significant engineering practical value and promising prospects for widespread application. Attached Figure Description
[0029] Figure 1 This is a schematic diagram of the method model framework of the present invention.
[0030] Figure 2 The figure shows the experimental results of the test conducted according to the present invention.
[0031] Figure 3 A visualization of the embedding for t-SNE code lookup. Detailed Implementation
[0032] The present invention will now be described in further detail.
[0033] See Figures 1-3 A code search method based on a large model includes the following steps:
[0034] S1: Obtain a code library containing several original code fragments, input the code library into the code understanding agent, and obtain an IOF database composed of IOF data corresponding to each original code fragment; the IOF data includes semantic information such as code fragment input description, code fragment output description, and code fragment functional summary; the code understanding agent is an existing technology and can be a strong code natural language semantic understanding model such as deepseek-coder-v2 or qwen3-coder.
[0035] The IOF database is then input into a pre-trained embedding model to obtain a vector database consisting of high-dimensional feature vectors corresponding to each IOF data point. The pre-trained embedding model used here is an existing technology. The vector database reflects the index mapping between the high-dimensional feature vector corresponding to each IOF data point and its corresponding original code segment. Traditional indexing methods only retain the source code text, which may result in semantic loss due to inconsistent variable naming in the code. This invention extracts semantic information including input description, output description, and function summary to form IOF data. For example, for a Java function, the code understanding AI generates: "Input: integer array; Output: sorted array; Function: implements the quicksort algorithm". Subsequently, a pre-trained embedding model (such as OpenAI text-embedding-ada-002 or a code-specific embedding model on HuggingFace) is used to convert the IOF data into high-dimensional feature vectors, and the feature vectors are stored in a local vector database (such as FAISS or Milvus), thus constructing an index mapping from IOF feature vectors to original code segments.
[0036] S2: Obtain any original user query description, input the original user query description into the query understanding agent to obtain initial retrieval metadata, and use a pre-trained Embedding model to convert the initial retrieval metadata into a target query vector; the query understanding agent is an existing technology and can be a strong natural semantic understanding embedding model such as bge-large-en-v1.5 or qwen3-embedding.
[0037] Calculate the similarity value between the target query vector and each high-dimensional feature vector in the vector database, sort all similarity values in descending order, select the high-dimensional feature vectors corresponding to the top N high similarity values, and use the IOF data corresponding to these high-dimensional feature vectors to form an initial candidate set;
[0038] S3: The original user query description and initial candidate set are input into the evaluation agent. The evaluation agent scores each IOF data in the initial candidate set according to the original user query description, and then obtains the final cumulative candidate set based on the scoring results. The evaluation agent is an existing technology and can be a model such as qwen3. The evaluation agent does not only perform similarity scoring, but also performs logical reasoning. It checks whether the function description of the current candidate IOF data covers the core needs of the user query (Function Coverage), and whether the input / output interface constraints (IO Constraints) are consistent with the user query. For example, if the user query is "Python read Excel file and convert to Dict", and the candidate code is "read CSV file", the evaluation agent will identify "file format mismatch" and determine it as an inaccurate match, thereby triggering subsequent extended searches.
[0039] The process of obtaining the final cumulative candidate set in S3 is as follows:
[0040] Preset iteration count T;
[0041] S3-1: Construct scoring rules and evaluate the agent. Based on the scoring rules and the original user query description, evaluate the IOF data in the initial candidate set one by one, and then output the score value and corresponding evaluation description of each IOF data as the current candidate set.
[0042] The scoring rules in S3-1 include evaluation dimensions, evaluation scores, and evaluation criteria, with a maximum evaluation score of 10 points.
[0043] The evaluation system scores each candidate code snippet against the query's IOF data based on similarity, with a maximum score of 10. The score is composed of four dimensions: behavior matching, data structure matching, specific requirement matching, and API or library matching. The detailed scoring rules for each dimension are shown in Table 1 below.
[0044] Table 1 Scoring Rules
[0045]
[0046] Specific scoring example:
[0047] “[·]” represents the score for that subject.
[0048] Example 1: Perfect match (10 points)
[0049] Query: "read csv file with pandas" Code: import pandas as pd; df =pd.read_csv('file.csv')
[0050] score:
[0051] Action[4]: Read file √
[0052] Type[3]: CSV file √
[0053] Specificity[2]: CSV format√
[0054] Library[1]: Using pandas √
[0055] Total score: 10
[0056] Example 2: Incorrect direction (7 points)
[0057] Query: "sort list in ascending order" Code: def sort_desc(lst):return sorted(lst, reverse=True)
[0058] score:
[0059] Action[4]: Sort √
[0060] Type[3]: List √
[0061] Specificity[0]: Ascending order requirement but implementing descending order ×
[0062] Library[0]: No library required ×
[0063] Total score: 7
[0064] Example 3: Type error (7 points)
[0065] Query: "sort list in ascending order" Code: def sort_dict(d): returndict(sorted(d.items()))
[0066] score:
[0067] Action[4]: Sort √
[0068] Type[1]: Dictionary instead of list ×
[0069] Specificity[2]: Ascending order √
[0070] Library[0]: No library required ×
[0071] Total score: 7
[0072] Example 4: Incorrect action (3 points)
[0073] Query: "check if list is empty" Code: def create_empty_list(): return[]
[0074] score:
[0075] Action[0]: Create instead of inspect ×
[0076] Type[3]: List √
[0077] Specificity[0]: No emptyness check ×
[0078] Library[0]: No library required ×
[0079] Total score: 3
[0080] After scoring each IOF data point, if the existing candidate pool already contains data with a score of 10, proceed directly to the next step to reorder the agent. However, if there is no IOF data with a score of 10, reinterpret the query and candidate pool, generate a new query, and return to the previous step for iteration.
[0081] S3-2: If at least one of the IOF data in the current candidate set has a perfect score, then the current candidate set will be used as the final cumulative candidate set.
[0082] Otherwise, the evaluation agent regenerates a new user query description based on the original user query description and the evaluation descriptions corresponding to all IOF data, and uses the method described in S2 to obtain a new set of candidates for the next iteration.
[0083] S3-3: Using the new user query description and the candidate set for the new iteration, the evaluation agent evaluates each IOF data in the candidate set for the new iteration according to the scoring rules and the new user query description. Then, it outputs the score value and corresponding evaluation description of each IOF data as the current candidate set. Then, it determines whether the current iteration round is greater than T. If it is greater than T, the current candidate set is output as the final cumulative candidate set; otherwise, proceed to the next step.
[0084] S3-4: Let the total number threshold of IOF data be L. Merge the candidate set of the new round of iteration with the initial candidate set to obtain the total number of candidates set. If the total number of candidates set is greater than L, then output the current candidate set obtained in S3-3 as the final cumulative candidate set; otherwise, return to S3-2.
[0085] By analyzing why the data obtained in the previous round of retrieval failed to meet the user's query, the query focus is adjusted, relevant domain terms are expanded, or exclusionary constraints are added based on the reasons. This generates new and more relevant user query description information, thereby generating more targeted new retrieval metadata. The iterative loop process uses a combination of whether the iteration number threshold is reached and whether the total number of IOF data in the final cumulative candidate set reaches L as the loop termination condition. Here, an iterative loop operation is performed until the condition is met. Obtaining the final cumulative candidate set through both quality and quantity indicators can minimize errors. The evaluation and understanding agent is based on existing technologies, such as deepseek-r1, qwen3, and other inference models.
[0086] S4: The final cumulative candidate set is input into the re-ranking agent. The re-ranking agent calculates the semantic relevance value between the original user query description and each IOF data in the final cumulative candidate set and sorts them in descending order. The original code snippets corresponding to the top few IOF data are selected as the matching results that match the original user query description and output. The large model is used to score the relevance of the user query description and IOF data pairs or generate a list-level ranking. IOF data with high semantic matching and deemed exact matches by the evaluation agent are ranked at the top of the result list, while IOF data with only partial matches are ranked at the bottom. The final cumulative candidate set is input into the re-ranking agent. Since vector retrieval is based on distance-based fuzzy matching, semantic drift may occur. The re-ranking agent uses the powerful attention mechanism of the large model to compare the semantic relevance between the user query description and each IOF data in the candidate set, performing refined list-wise ranking. The original code snippets with exact matches and the highest code quality are output as the final search results to the user. The re-ranking agent is an existing technology, and inference models such as Deepseek-R1 and Qwen3 can be selected.
[0087] Experimental content and results
[0088] Experimental setup
[0089] Dataset Introduction: Following standard settings in the code search field, this experiment conducted extensive evaluation tests on the large-scale CodeSearchNet (CSN) dataset. This dataset, built from an open-source project on GitHub, covers six mainstream programming languages. In this experiment, we focused on validating the model using two of the most representative language subsets: Python and Java. The CSN-Python dataset contains 412,178 training samples and 22,176 test samples; the CSN-Java dataset contains 454,451 training samples and 26,909 test samples. To ensure the rigor of the experiment, we followed standard procedures to deduplicate and clean the data, filtering out low-quality code and samples lacking documentation comments. Furthermore, to verify the model's generalization ability in complex scenarios, we also constructed a "Hard-Case" test set containing 500 challenging, semantically ambiguous queries to evaluate the effectiveness of the iterative retrieval mechanism.
[0090] Implementation Details: This experiment uses DeepSeek-Coder-V2 as the base model for code understanding and evaluation agents, leveraging its powerful code reasoning capabilities to extract IOF (Input-Output-Function) data. In the vectorization stage, the BGE-Large-En-v1.5 pre-trained model is used for feature extraction and embedding, with the output dimension set to 1024. FAISS is used for efficient indexing and retrieval of the vector database. During training and inference, the maximum sequence length is truncated to 512, and the temperature parameter is set to 0.2 to ensure the determinism of the output. For the iterative retrieval mechanism, the maximum iteration threshold T=3, the candidate set size N=100, and the incremental retrieval expansion number K=20 are set. All experiments are performed on a single Nvidia A800 (80GB) GPU based on the PyTorch 2.1 framework.
[0091] Comparison with the current best method
[0092] This section compares the proposed large-model collaborative iterative search method (named Agent-IOF-Search) with current mainstream code search methods. The comparison baseline includes:
[0093] 1. Traditional keyword-based matching method: BM25;
[0094] 2. Pre-trained model methods based on dense vector retrieval: CodeBERT, GraphCodeBERT, and UniXcoder;
[0095] 3. A method based on general large model embedding: OpenAI-Ada-002.
[0096] The main evaluation metrics for the experiment include: Mean Reciprocal Rank (MRR), and Precision@K and Normalized Diminished Cumulative Gain@K in the Top-K case, where K = {1, 5, 10}. MRR reflects the position of the first correct result in the list and is the most crucial metric for code search.
[0097] Table 2 presents the overall comparison results on the CodeSearchNet dataset. Our method achieves state-of-the-art performance on both Python and Java subsets, improving the MRR by 8.3% and 7.7% respectively compared to the current top-performing baseline model (UniXcoder). Specifically, on the Python dataset, with K=1, our Precision@1 reaches 0.685, significantly outperforming GraphCodeBERT's 0.592. This significant advantage is primarily attributed to the IOF structured semantic representation introduced in our method, which more accurately captures the functional logic of code than simple code text; simultaneously, the multi-agent iterative feedback mechanism effectively addresses the "query intent drift" problem.
[0098] Table 2 Comparative experiments on the CodeSearchNet dataset
[0099]
[0100] ablation experiment
[0101] To verify the effectiveness of the various innovative modules (IOF semantic extraction, evaluation iteration mechanism, and reordering mechanism) in this invention, an ablation experiment was designed, and three variant models were constructed for testing:
[0102] • w / o IOF: Removes the code-understanding agent and directly performs vectorized indexing on the original code text;
[0103] • w / o Iteration: Removes the evaluation agent and iterative loop, performing only a single round of retrieval (i.e., outputting directly after step S2);
[0104] • w / o Rerank: Removes the reranking agent and directly outputs the Top-K results of vector retrieval.
[0105] Discussion of IOF semantic representation. As shown in Table 2, the MRR decreased by approximately 8.2% after removing the IOF semantic extraction module (w / o IOF). This demonstrates that relying solely on the raw code text is insufficient to capture deep logical functions. IOF data, by explicitly decoupling "input constraints," "output behavior," and "functional summary," makes the code representation in the vector space denser and more discriminative, which is crucial for improving the semantic matching accuracy of retrieval.
[0106] Discussion of the iterative feedback mechanism. Table 3 shows that removing the iterative mechanism (without Iteration) resulted in a 6.5% decrease in NDCG@5. Analysis of failed cases revealed that when faced with fuzzy user queries (such as describing only a function without specifying a particular library), a single-round retrieval easily retrieves a large amount of low-relevance code. The evaluation agent of this invention can "examine" the results like a human expert and automatically expand query keywords (such as adding domain-specific terms), thereby correcting the retrieval direction in the second or third iteration.
[0107] Discussion of the Reranking Agent. Experiments show that the introduction of the Reranking Agent (w / o Rerank) improves Precision@1 by 4.3%. While vector retrieval can efficiently recall relevant code, ranking based on cosine similarity often fails to distinguish subtle logical differences. The Reranking Agent leverages the logical reasoning capabilities of a large model to perform a deep, one-to-one comparison of the candidate set, ensuring that the first result presented to the user is the optimal solution.
[0108] Table 3. Impact of different modules on model performance (Ablation Study)
[0109]
[0110] Discussion of hyperparameters for iteration rounds. This experiment further explores the impact of the iteration number threshold T on retrieval performance and time overhead. As the number of iterations increases from 1 to 3, the MRR value shows a steady upward trend; however, when T > 3, the performance improvement tends to plateau, while retrieval latency increases significantly. This indicates that most fuzzy queries can be resolved within 3 rounds of the "retrieval-evaluation-correction" loop. Therefore, this invention sets the default iteration threshold to 3, achieving the optimal balance between performance and efficiency.
[0111] 4. Visual Analysis
[0112] To more intuitively demonstrate the advantages of this method in handling fuzzy queries, this invention selects a specific case for visual analysis.
[0113] Example: The user query description is "parse date string to object", which is a very generalized description.
[0114] (1) Initial Retrieval (Iteration 1): Due to the lack of specific format constraints in the query, both the baseline model (CodeBERT) and this method's first-round retrieval recalled various string processing functions with different formats (such as ISO8601, RFC2822) and even irrelevant ones. The evaluation agent determined that the current result was "inaccurate" and generated extended query metadata: "parse date string python datetime strptime format handling".
[0115] (2) Iteration Optimization: Based on the expanded query, the system accurately located the standard implementation code using datetime.strptime in the second round.
[0116] (3) Final result: After reordering, the best practice-compliant general date parsing function is ranked first.
[0117] Figure 3 The t-SNE distribution of query vectors and candidate code vectors in the projection space is shown. It can be observed that after IOF enhancement, functionally similar codes are clustered more tightly in the vector space (as shown in the red area in the figure), and the query vectors generated by Agent-IOF-Search can more accurately fall at the center of the target code cluster, showing stronger directionality compared to traditional methods (blue scatter dots).
[0118] In experiments, this invention verified that the MRR metric on benchmark datasets such as CodeSearchNet is significantly better than that of existing baseline models such as CodeBERT.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A code search method based on a large model, characterized in that: Includes the following steps: S1: Obtain a code library containing several original code fragments, input the code library into the code understanding agent, and obtain an IOF database composed of IOF data corresponding to each original code fragment; Then, the IOF database is input into the pre-trained Embedding model to obtain a vector database composed of high-dimensional feature vectors corresponding to each IOF data point; S2: Obtain any original user query description, input the original user query description into the query understanding agent to obtain initial retrieval metadata, and use the pre-trained Embedding model to convert the initial retrieval metadata into a target query vector; Calculate the similarity value between the target query vector and each high-dimensional feature vector in the vector database, sort all similarity values in descending order, select the high-dimensional feature vectors corresponding to the top N high similarity values, and use the IOF data corresponding to these high-dimensional feature vectors to form an initial candidate set; S3: Input the original user query description and the initial candidate set into the evaluation agent. The evaluation agent scores all IOF data in the initial candidate set one by one according to the original user query description, and then obtains the final cumulative candidate set based on the scoring results. S4: Input the final cumulative candidate set into the reordering agent. The reordering agent calculates the semantic relevance value between the original user query description and each IOF data in the final cumulative candidate set and sorts them in descending order. It selects the original code fragments corresponding to the top few IOF data as the matching results that conform to the original user query description and outputs them.
2. The code search method based on a large model as described in claim 1, characterized in that: The process of obtaining the final cumulative candidate set in S3 is as follows: Preset iteration count T; S3-1: Construct scoring rules and evaluate the agent. Based on the scoring rules and the original user query description, evaluate the IOF data in the initial candidate set one by one, and then output the score value and corresponding evaluation description of each IOF data as the current candidate set. S3-2: If at least one of the IOF data in the current candidate set has a perfect score, then the current candidate set will be used as the final cumulative candidate set. Otherwise, the evaluation agent regenerates a new user query description based on the original user query description and the evaluation descriptions corresponding to all IOF data, and uses the method described in S2 to obtain a new set of candidates for the next iteration. S3-3: Using the new user query description and the candidate set of the new round of iteration, the evaluation agent evaluates the IOF data in the candidate set of the new round of iteration one by one according to the scoring rules and the new user query description, and then outputs the score value and corresponding evaluation description of each IOF data as the current candidate set. Then determine whether the current iteration number is greater than T. If it is greater than T, output the current candidate set as the final cumulative candidate set. Conversely, proceed to the next step; S3-4: Let the total number threshold of IOF data be L. Merge the candidate set of the new round of iteration with the initial candidate set to obtain the total number of candidates set. If the total number of candidates set is greater than L, then output the current candidate set obtained in S3-3 as the final cumulative candidate set; otherwise, return to S3-2.
3. The code search method based on a large model as described in claim 2, characterized in that: The scoring rules in S3-1 include evaluation dimensions, evaluation scores, and evaluation criteria, with a maximum evaluation score of 10 points.