Multi-language code bin dialogue method and system
By parsing the code project to generate an index tree and using a large language model to handle natural language problems, the high cost and high threshold of existing tools are solved, enabling quick understanding of the code project's functions and details, and improving the efficiency of multilingual code comprehension.
Patent Information
- Application Number
- CN202511004894.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-11-07
AI Technical Summary
Existing intelligent programming tools require programmers to invest a lot of time in learning the project structure and code logic when faced with unfamiliar code projects, increasing development costs and the learning curve. This is especially true for complex code projects involving multiple languages, where cross-language knowledge and project analysis experience are highly required.
The code project is parsed to generate an index tree. The syntax structure of the code file is parsed using a large language model and abstract syntax tree. Natural language questions are received, and synonym questions and keyword sets are generated. The index tree is traversed hierarchically for retrieval. Candidate nodes are selected and answers are generated by combining keyword matching and scoring.
It eliminates the need for programmers to read large amounts of code, allowing them to quickly understand the main functions and implementation details of a code project, reducing development costs, improving the efficiency of understanding multi-language code, and avoiding the inefficiency and noise issues of global searches.
Smart Images

Figure CN120909563A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of code development, and in particular to a multi-language code repository dialogue method and system. BACKGROUND
[0002] With the rapid development of artificial intelligence technology, intelligent programming tools based on large language models are increasingly widely used in the field of programming and gradually become an important auxiliary tool for developers. However, the existing intelligent programming tools still have certain limitations in actual application. For example, when a developer faces an unfamiliar code project, he usually needs to invest a lot of time in learning the project structure, code logic and implementation principle, which not only increases the development cost, but also increases the threshold for starting the code project.
[0003] Therefore, how to help programmers quickly master the core information of unfamiliar code projects in a more efficient and convenient way has become a key problem to be solved in the field of intelligent programming assistance technology. SUMMARY
[0004] To overcome the problems in the related art, one of the purposes of the present application is to provide a multi-language code repository dialogue method, which can help programmers quickly understand the main functions of the code project and master the implementation principle of the detailed code, thereby reducing the development cost of the programmers and lowering the threshold for starting the code project.
[0005] A multi-language code repository dialogue method, comprising:
[0006] parsing the code project according to a preset format, and parsing the syntax structure of the development language corresponding to the code file through an abstract syntax tree to obtain a parsed tree structure;
[0007] traversing the nodes of the parsed tree structure from bottom to top using a preset language model, performing periodic summaries, and generating an index tree;
[0008] receiving a natural language question from a user, processing the natural language question, and generating a plurality of synonymous questions and a keyword set;
[0009] performing hierarchical traversal retrieval in the index tree from top to bottom, combining keyword matching and large language model scoring, and screening out candidate nodes related to the question;
[0010] reordering and filtering the candidate nodes with low matching degrees, and concatenating the contents of the finally matched nodes with the user question to input the large language model to generate an answer.
[0011] In the preferred technical solution of the present application, the code engineering is parsed according to a preset format, including:
[0012] Parsing according to the formats of code engineering, directory, code file, class, function / other.
[0013] In the preferred technical solution of the present application, the parsed tree structure includes:
[0014] The tree structure of engineering root node, directory node, file node, class node, function node and other code node.
[0015] In the preferred technical solution of the present application, the natural language question of the user is received, the natural language question is processed, and a plurality of synonymous questions and a keyword set are generated, including:
[0016] Receiving the original question input by the user;
[0017] Semantically expanding the original question to generate a plurality of question variants that are semantically the same but have different expression forms;
[0018] Independently extracting keywords from each synonymous question and eliminating invalid words;
[0019] Merging the keywords of all synonymous questions to form a unified keyword set.
[0020] In the preferred technical solution of the present application, the nodes of the parsed tree structure are traversed from bottom to top using a large language model, and a summary is made at each stage to generate an index tree, including:
[0021] Traversing the leaf nodes at the bottom layer of the tree structure, including function nodes and other code nodes;
[0022] After completing the summary of the function nodes and other code nodes, traversing the class nodes at the next layer;
[0023] Continuing to traverse upwards to the file nodes, directory nodes and engineering root nodes, associating the corresponding code original text and natural language summary at each layer, and finally forming an index tree consistent with the original code engineering structure.
[0024] In the preferred technical solution of the present application, the hierarchical traversal and retrieval in the index tree from top to bottom are performed, combined with keyword matching and large language model scoring, to filter out candidate nodes related to the question, including:
[0025] Retrieving the engineering root node starting from the index tree as the initial matching node;
[0026] Setting a matching score threshold for determining whether a node is related to the question;
[0027] From the current level of the to-be-matched node, in the top-down order of the hierarchy, after each layer is processed, the nodes meeting the conditions are screened out as the to-be-matched nodes of the next layer;
[0028] For each to-be-matched node of the current level, the large language model matches the natural language summary of the node with the keyword group;
[0029] For non-leaf nodes in the current level with a score higher than the threshold, the next level nodes contained therein are included in the to-be-matched node list of the next level; for leaf nodes with a score higher than the threshold, they are directly added to the candidate node list and no longer traversed downward; if the node score is lower than the threshold, it is directly skipped and not included in the next level retrieval range;
[0030] When the bottom leaf node of the index tree is reached or all to-be-matched nodes of the current level are lower than the score threshold, the traversal is terminated;
[0031] All nodes with a score higher than the threshold in all levels are summarized to form an initial candidate node list;
[0032] The initial candidate node list is de-duplicated, and the large language model is used again to perform secondary evaluation on the overall relevance of the candidate nodes to the question, and the nodes are sorted in descending order of matching degree according to the node level and score, and the filtered candidate node list is finally output.
[0033] In the preferred technical solution of the present application, the candidate nodes are reordered and filtered, and the content of the finally matched node is spliced with the user question, which includes:
[0034] A secondary filtering threshold is set;
[0035] A node filtering rule is formulated, and the interface node is filtered using the filtering rule;
[0036] The filtered user question and node content are spliced;
[0037] A prompt word is added to the spliced content and a constraint is added;
[0038] The spliced prompt word is input into the large language model to generate a targeted answer.
[0039] In the preferred technical solution of the present application, the node filtering rule includes:
[0040] Nodes with a score lower than the threshold are directly removed;
[0041] If there are multiple child nodes under the same parent node, only 1-2 nodes with the highest score are retained;
[0042] If the filtered candidate node list is empty, return the top 3 nodes in the initial list with the highest scores to ensure at least the base context.
[0043] The second object of the present application is to provide a multi-language code repository conversation system for implementing the multi-language code repository conversation method as described above.
[0044] The present application has the following beneficial effects:
[0045] The present application provides a multi-language code repository conversation method and system, which comprises: parsing a code project according to a preset format, and parsing the syntax structure of the development language corresponding to the code file through an abstract syntax tree to obtain a parsed tree structure; traversing the nodes of the parsed tree structure from bottom to top using a preset language model to generate an index tree; receiving and processing a natural language question of a user to generate a plurality of synonymous questions and a keyword set; performing hierarchical traversal and retrieval in the index tree from top to bottom, combining keyword matching and large language model scoring to filter out candidate nodes related to the question; reordering the candidate nodes, filtering out low matching degree nodes, and concatenating the contents of the finally matched nodes with the user question to input a large language model to generate an answer. The method can quickly understand the main functions, structure and implementation details of the code project through natural language conversation, without spending a lot of time reading and understanding the code. The index tree integrates the semantic association of different language nodes, and the user can cover multiple language logic through a single question, avoiding understanding discontinuity caused by language switching, which can improve the multi-language code understanding efficiency. And through hierarchical retrieval and keyword matching, the target code is directly locked, which can solve the problems of low efficiency and much noise of traditional "global search keyword". BRIEF DESCRIPTION OF DRAWINGS
[0046] Figure 1 is a flowchart of the multi-language code repository conversation method provided by the present application;
[0047] Figure 2 is a logic diagram of the multi-language code repository conversation method provided by the present application;
[0048] Figure 3 is a flowchart of generating an index tree provided by an embodiment of the present application;
[0049] Figure 4 is a flowchart of step S5 provided by an embodiment of the present application;
[0050] Figure 5 is a logic diagram of conversation question matching retrieval provided by an embodiment of the present application. DETAILED DESCRIPTION
[0051] Preferred embodiments of the present application will be described in greater detail below, with reference to the drawings. While the preferred embodiments of the present application are shown in the drawings, it is understood that the present application can be carried out in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the scope of the application to those skilled in the art.
[0052] With the rapid development of artificial intelligence technology, intelligent programming tools based on large language models are increasingly widely used in the field of programming and gradually become an important auxiliary tool for developers. However, existing intelligent programming tools still have certain limitations in practical application. For example, when a developer faces an unfamiliar code project, he usually needs to invest a lot of time in learning the project structure, code logic and implementation principle, which not only increases the development cost, but also raises the threshold for starting the code project. Moreover, for complex code projects with multiple languages, the differences in syntax of different programming languages and the complexity of project architecture further exacerbate the problem, making programmers need to have cross-language knowledge reserves and rich project analysis experience, greatly increasing the time and energy investment in the development preparation stage.
[0053] Based on this, the present application provides a multi-language code repository conversation method.
[0054] Embodiment 1
[0055] As Figures 1-5 shown, the present embodiment provides a multi-language code repository conversation method, comprising:
[0056] S1, parsing the code project according to a preset format, and parsing the syntax structure of the development language corresponding to the code file through an abstract syntax tree to obtain a parsed tree structure; the parsed tree structure comprises a tree structure of project root node, directory node, file node, class node, function node and other code nodes.
[0057] Specifically, the parsing of the code project according to the preset format comprises:
[0058] parsing according to the format of code project, directory, code file, class, function / other.
[0059] S2, traversing the nodes of the parsed tree structure from bottom to top using a preset language model, performing stage summary, and generating an index tree; the preset language model of the present application is can be bag or deep-seek.
[0060] Specifically, this step comprises:
[0061] S21, traversing the leaf nodes at the bottom layer of the tree structure, including function nodes and other code nodes;
[0062] S22, after completing the summary of the function nodes and other code nodes, traversing the class nodes of the previous layer;
[0063] S23, continuing to traverse upwards to the file nodes, directory nodes and project root nodes, associating the corresponding code original text and natural language summary of each layer, and finally forming an index tree consistent with the original code project structure.
[0064] S3, receiving a natural language question of a user, processing the natural language question, and generating a plurality of synonymous questions and a keyword set;
[0065] S4, performing hierarchical traversal retrieval from top to bottom in the index tree, combining keyword matching and large language model scoring, and screening candidate nodes related to the question;
[0066] S5, reordering and filtering the candidate nodes with low matching degree, and concatenating the contents of the finally matched nodes with the user question to input a large language model to generate an answer.
[0067] Specifically, the reordering and filtering of the candidate nodes with low matching degree, and the concatenation of the contents of the finally matched nodes with the user question, include:
[0068] S51, setting a secondary filtering threshold;
[0069] S52, formulating a node filtering rule, and filtering the nodes using the filtering rule;
[0070] S53, concatenating the filtered user question with the node content;
[0071] S54, adding a prompt word and a constraint to the concatenated content;
[0072] S55, inputting the concatenated prompt word into a large language model to generate a targeted answer.
[0073] More specifically, the node filtering rule includes:
[0074] directly removing nodes with scores below the threshold;
[0075] if there are multiple child nodes under the same parent node, only the top 1-2 nodes with the highest scores are retained; this rule is to avoid redundant information, for example, multiple function nodes under the same class, only the most relevant function is retained.
[0076] if the filtered candidate node list is empty, return the top 3 nodes with the highest scores in the initial list to ensure at least a basic context.
[0077] The above-mentioned multilingual code repository dialogue method can enable a newly added developer to quickly understand the main functions, structure and implementation details of the code project through natural language dialogue without spending a lot of time reading and understanding the code. The index tree integrates the semantic association of different language nodes, and the user can cover multilingual logic through a single question, avoiding understanding discontinuity caused by language switching, which can improve the efficiency of multilingual code understanding. And through hierarchical retrieval and keyword matching, the target code can be directly locked, which can solve the problem of low efficiency and much noise of traditional "global search keyword".
[0078] The following takes a game development code project "GameEngine" containing Python and Java as an example to describe the practical application of the multilingual code repository dialogue method claimed in the present application in detail, as follows:
[0079] S1, code project analysis
[0080] According to the tree structure from top to bottom: "code project -> directory -> code file -> class -> function / other":
[0081] The project root node is "GameEngine";
[0082] The root node includes "core" (core logic directory), "utils" (tool class directory), "docs" (document directory) and other subdirectory nodes;
[0083] Each directory node includes code file nodes, such as "render.py" (Python file) and "physics.java" (Java file) under the "core" directory;
[0084] For each code file, its syntax structure is parsed through abstract syntax tree (AST):
[0085] When parsing "render.py", Python AST is generated, and class node "RenderEngine", function nodes "draw_sprite()" and "update_frame()" and global variable node "SCREEN_SIZE" are identified;
[0086] When parsing "physics.java", Java AST is generated, and class node "PhysicsManager" and function node "calculate_collision()" are identified.
[0087] S2, index tree generation
[0088] Based on the parse tree obtained in step 1, use a large language model (such as GPT-4) to summarize the nodes from bottom to top, and generate an index tree:
[0089] S21: Start summarizing from the bottom leaf node, for example, summarize the "draw_sprite()" function node as "This function is used to draw 2D sprites in the specified position of the game window according to the input sprite coordinates and texture parameters, supporting transparency adjustment", and associate the original function code;
[0090] S22: Traverse the class node "RenderEngine", integrate the summaries of the "draw_sprite()" "update_frame()" and other function nodes it contains, and generate the class node summary: "The RenderEngine class is the core class of game rendering, responsible for managing sprite drawing, frame updating and window refreshing logic", and associate the class definition original text;
[0091] S23: Traverse the file node, directory node and project root node in turn:
[0092] The "render.py" file node is summarized as "contains the core logic of game rendering, defines the RenderEngine class and related rendering tool functions";
[0093] The "core" directory node is summarized as "stores the core engine logic of the game, contains code files for key modules such as rendering and physical collision";
[0094] The project root node "GameEngine" is summarized as "a 2D game engine implemented in multiple languages, containing rendering, physical collision, tool class and other modules, supporting the creation and interaction of basic game objects".
[0095] The final generated index tree is consistent with the original code project structure, and each node contains the original code and natural language summary.
[0096] S3, dialogue question processing
[0097] Receive the user natural language question "How to implement the collision detection of sprites in the game?", Process as follows:
[0098] Synonym expansion: generate synonymous questions such as "How is the collision detection of sprites implemented in the game?", "What is the implementation method of sprite collision detection?", "How to write the logic of sprite collision detection in the engine?";
[0099] Refine and extract key phrases: extract key phrases from each synonymous question, merge and remove duplicates to get "sprite" "collision detection" "implementation" "game engine".
[0100] S4, candidate node retrieval
[0101] Based on keyword group, search from top to bottom in index tree:
[0102] From the engineering root node "GameEngine", match the keyword "game engine", score higher than the threshold (such as 0.7), enter the next layer;
[0103] Traverse the directory nodes such as "core" and "utils", and the "core" directory node summarizes the "physical collision" which matches "collision detection" and scores up to standard, enter the file node under "core" directory;
[0104] Traverse the "physics.java" file node, whose summary contains "physical collision" and scores up to standard, enter the class node "PhysicsManager";
[0105] The "PhysicsManager" class node summarizes "collision calculation", and the summary of the function node "calculate_collision()" under it directly matches "collision detection" and "implementation", with the highest score, and is added to the candidate node list;
[0106] The end of the layer sequence traversal, the candidate node list contains the "physics.java" file node, the "PhysicsManager" class node, and the "calculate_collision()" function node.
[0107] S5, intelligent question and answer generation
[0108] S51: Set the secondary filtering threshold (such as 0.8);
[0109] S52: The filtering rule is "node summary matching degree ≥0.8", and the "calculate_collision()" function node (matching degree 0.92) and the "PhysicsManager" class node (matching degree 0.85) are screened out;
[0110] S53-S54: The spliced content is "context information: [calculate_collision() function code original text and summary], [PhysicsManager class code original text and summary]. Please answer the question according to the context: how to implement the collision detection of sprites in the game?", and add the constraint "only based on the provided context, do not use external knowledge";
[0111] S55: input large language model, generate answer: "In the game engine, the collision detection of sprites is implemented through the calculate_collision() function of the PhysicsManager class in the physics.java file under the core directory. This function receives the coordinates and collision box parameters of two sprites, and judges the collision state by calculating the overlapping area of the coordinates. The specific logic is: [quote function code key segment]...".
[0112] Code engineering analysis is based on AST and tree structure, ensuring comprehensive and accurate parsing of syntax and structure of multi-language code;
[0113] Index tree retains the original code and natural language summary, combined with synonym processing and keyword retrieval, reduces the matching error caused by language expression diversity;
[0114] Hierarchical traversal retrieval and secondary filtering ensure that the candidate nodes are highly related to the problem, avoiding invalid information interference.
[0115] The present application can obtain the function and implementation principle of code engineering through natural language dialogue, without the need for programmers to manually read a large amount of code, reducing the learning cost.
[0116] Further, the natural language question of the user is received, and the natural language question is processed to generate a plurality of synonymous questions and a keyword set, comprising:
[0117] Receiving the original question input by the user;
[0118] Semantically expanding the original question to generate a plurality of question variants that are semantically the same but have different expression forms;
[0119] Extracting keywords from each synonymized question independently and eliminating invalid words;
[0120] Merging the keywords of all synonymized questions to form a unified keyword set.
[0121] By semantically expanding the original question to generate a plurality of synonymous question variants, different expressions generated by users due to language habits and expression differences can be covered (such as the same demand may be expressed as "how to implement" "how to do" "what is the implementation method"). This expansion can avoid the mismatch between single expression and index tree node summary text form, ensuring that more potential related nodes are included in the retrieval range and improving the comprehensiveness of retrieval.
[0122] The keywords of all synonymous problems are combined to form a unified set, which can comprehensively include the key information in different synonymous expressions and avoid the one-sidedness of extracting keywords from a single problem. For example, one synonymous problem may focus on "implementation", and another synonymous problem may focus on "specific logic". The combined keyword set can cover these dimensions at the same time, ensuring that the search can fully match the core content summarized in the index tree nodes, and improving the relevance of candidate nodes to the user's real needs.
[0123] Further, the hierarchical traversal retrieval from top to bottom in the index tree, combined with keyword matching and large language model scoring, screens out candidate nodes related to the problem, including:
[0124] The search starts from the engineering root node of the index tree as the initial matching node;
[0125] Set a matching score threshold to determine whether the node is related to the problem;
[0126] Starting from the matching node of the current level, traverse in hierarchical order from top to bottom. After each layer is processed, filter out the nodes that meet the conditions as the matching nodes of the next layer;
[0127] For each matching node of the current level, the large language model matches the natural language summary of the node with the keyword group;
[0128] For non-leaf nodes in the current level with a score higher than the threshold, include the next level nodes contained in them in the matching node list of the next level. For leaf nodes with a score higher than the threshold, directly add them to the candidate node list and do not traverse further. If the node score is lower than the threshold, it is directly skipped and not included in the next level retrieval range;
[0129] When the traversal reaches the bottom leaf nodes of the index tree, or all matching nodes of the current level are lower than the score threshold, the traversal terminates;
[0130] Collect all nodes with a score higher than the threshold in all levels to form an initial candidate node list;
[0131] De-duplicate the initial candidate node list, and again evaluate the overall relevance of the candidate nodes to the problem through the large language model. Combined with the node level and score, sort the matching degree from high to low, and finally output the filtered candidate node list.
[0132] In this application, through the "top-down hierarchical traversal + threshold screening" mechanism, the retrieval process starts from the engineering root node, and only nodes with scores higher than the threshold are included in the next layer of retrieval range, avoiding meaningless traversal of child nodes of low related nodes (such as nodes under the "rendering tool" directory unrelated to "collision detection" are filtered out in advance). This "layer-by-layer shrinking" retrieval logic greatly reduces the number of nodes to be processed, reduces the computational resource consumption of the retrieval process, and improves the overall retrieval efficiency.
[0133] Processing of non-leaf nodes (such as directory, class nodes): non-leaf nodes that meet the score continue to traverse their child nodes, ensuring that the retrieval can go deep into more fine-grained code units (such as functions, specific code snippets), avoiding missing key implementation details due to staying at a macro level (such as directory);
[0134] Processing of leaf nodes (such as function, specific code snippet nodes): leaf nodes that meet the score are directly added to the candidate list without further traversal (as there are no lower level nodes), ensuring accurate capture of specific implementation details and avoiding unnecessary deep traversal.
[0135] This hierarchical processing mechanism covers full-granularity information from macro structure to micro code, and ensures that the retrieval focuses on the path related to the problem, balancing "comprehensiveness" and "targetedness".
[0136] Embodiment 2
[0137] In this embodiment, a multi-language code repository conversation system is provided, which is used to implement the multi-language code repository conversation method as described above.
[0138] Specifically, the multi-language code repository conversation system can include a code engineering parsing module, an index tree generation module, a conversation processing module, a retrieval matching module, and an intelligent question and answer module.
[0139] The code engineering parsing module is responsible for parsing the code engineering and constructing a tree structure according to a preset format (such as "code engineering -> directory -> code file -> class -> function / other").
[0140] An abstract syntax tree (AST) parsing tool is used to parse the syntax structure of the code file corresponding to the development language and extract the syntax information of the code.
[0141] Support for multiple programming languages (such as Java, Python, JavaScript, etc.), and select appropriate parsing tools according to different languages.
[0142] The index tree generation module is configured to load the tree structure generated by the code engineering analysis module. A preset large language model is used to traverse the parsed tree structure nodes from bottom to top and perform periodic summaries. An index tree is generated, and each node contains code original text and a natural language summary. The index tree is optimized, including removing redundant information, extracting keywords, optimizing structure, and the like.
[0143] The dialogue processing module is configured to receive a natural language question input by a user. The user question is preprocessed, including synonym processing and keyword extraction. Multiple synonymous questions and keyword sets are generated to provide diversified inputs for subsequent retrieval matching.
[0144] The retrieval matching module is configured to load the index tree generated by the index tree generation module.
[0145] The index tree is searched hierarchically from top to bottom.
[0146] In combination with keyword matching and large language model scoring, candidate nodes related to the user question are screened out.
[0147] The candidate nodes are reordered and filtered to remove nodes with low matching degrees.
[0148] The intelligent question answering module is configured to splice the content of the candidate nodes screened out by the retrieval matching module with the user question to form a complete prompt word.
[0149] The spliced prompt word is input into a large language model to generate a final answer.
[0150] Embodiment 3
[0151] The embodiment provides an electronic device, which includes a memory and a processor.
[0152] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0153] The memory can include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices.
[0154] Executable code is stored on the memory that, when processed by the processor, can cause the processor to perform some or all of the above-described multilingual codebase conversation method.
[0155] The foregoing and other embodiments of this application are presented by way of example only and are not intended to limit the scope of the application. In this document, the terms "example" and "exemplary" are used as adjectives to indicate a member or members of a group or class of members. Any implementation of the described functionality, regardless of whether such implementation is called or are called an "example" or "exemplary," is intended to serve only as a non-limiting example. Thus, a plurality of examples is contemplated as being a plurality of non-limiting examples. Therefore, the examples are not to be considered as limiting the scope of the application in any way. In the drawings and description above, identical reference numerals have been used to denote the same elements throughout the various figures and the description. It should be noted that the figures are not drawn to scale. Additionally, elements common between figures are not necessarily labeled in every figure.
[0156] It should be understood that spatially relative terms are intended to encompass different orientations of the device in use or operation in addition to the orientations depicted in the figures. For example, if a device is turned over in the opposite orientation, a dependent element described as "above" or "up" another element would then be oriented "below" or "down" the other element. Accordingly, the exemplary term "above" can encompass both an orientation that is above and an orientation that is below. The device can be otherwise oriented (rotated 90 degrees or at other orientations) and the spatially relative descriptors used herein interpreted accordingly.
[0157] In addition, it should be noted that the use of "first", "second", "third", etc. words to describe various components is only intended to distinguish the components from one another, and does not connote any special order or priority, unless otherwise specifically stated. Therefore, the above words are not intended to limit the scope of the present application.
[0158] The preferred embodiments of the application are described above in detail. The application is not limited to the embodiments described above, but can be modified in various ways. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the application should be included in the scope of the application.
Claims
1. A multi-lingual code vault conversation method, characterized by, The method comprises the following steps: parsing the code project according to a preset format, and obtaining a parsed tree structure by parsing the syntax structure of the corresponding development language of the code file through an abstract syntax tree; traversing the nodes of the parsed tree structure from bottom to top using a preset language model, performing periodic summaries, and generating an index tree; receiving a natural language question from a user, processing the natural language question, and generating a plurality of synonymous questions and a keyword set; performing hierarchical traversal retrieval in the index tree from top to bottom, combining keyword matching and large language model scoring, and screening out candidate nodes related to the question; reordering and filtering the candidate nodes with low matching degrees, and concatenating the contents of the finally matched nodes with the user question to input the large language model to generate an answer.
2. The multi-language code repository dialogue method according to claim 1, wherein: the parsing of the code project according to a preset format comprises: parsing according to the formats of code project, directory, code file, class, function / other.
3. The multi-language code repository dialogue method according to claim 2, wherein: the parsed tree structure comprises: a tree structure of project root node, directory node, file node, class node, function node and other code node.
4. The multi-language code repository dialogue method according to any one of claims 1-3, wherein: the receiving of the natural language question from the user, the processing of the natural language question, and the generation of a plurality of synonymous questions and a keyword set comprise: receiving an original question input by the user; performing semantic expansion on the original question to generate a plurality of question variants with the same semantics but different expressions; independently extracting keywords for each synonymous question and eliminating invalid words; merging the keywords of all synonymous questions to form a unified keyword set.
5. The multi-language code repository dialogue method according to any one of claims 1-3, wherein: the traversing of the nodes of the parsed tree structure from bottom to top using a large language model, the periodic summaries, and the generation of an index tree comprise: traversing the leaf nodes at the bottom layer of the tree structure, including function nodes and other code nodes; after completing the summaries of the function nodes and other code nodes, traversing the class nodes at the next layer; continuing to traverse upwards to the file nodes, directory nodes and project root nodes, associating the corresponding code original text and natural language summaries at each layer, and finally forming an index tree consistent with the original code project structure.
6. The multi-language code repository dialogue method according to any one of claims 1-3, wherein: the hierarchical traversal retrieval in the index tree from top to bottom, the combination of keyword matching and large language model scoring, and the screening out of candidate nodes related to the question comprise: starting from the project root node of the index tree as the initial matching node; setting a matching score threshold for determining whether the node is related to the question; starting from the matching node at the current level, traversing in the order of top to bottom, and after completing the processing at each layer, screening out the nodes meeting the conditions as the matching nodes at the next layer; for each matching node at the current level, the large language model matches the natural language summary of the node with the keyword set. For non-leaf nodes in the current level with a score higher than the threshold, the next level nodes included in the next level are included in the list of nodes to be matched in the next level; for leaf nodes with a score higher than the threshold, they are directly added to the candidate node list and no longer traversed downward; if the node score is lower than the threshold, it is directly skipped and not included in the next level search range; When the traversal reaches the bottom leaf nodes of the index tree, or all the nodes to be matched in the current level are lower than the score threshold, the traversal is terminated; All nodes with a score higher than the threshold in all levels are summarized to form an initial candidate node list; The initial candidate node list is de-duplicated, and the overall relevance of the candidate nodes and the question is evaluated again through the large language model, combined with the node level and the score, sorted by matching degree from high to low, and finally output the filtered candidate node list.
7. The multi-language code repository conversation method of claim 6, wherein: the reordering and filtering of the candidate nodes and the concatenation of the final matched node content and the user question include: setting a secondary filtering threshold; developing a node filtering rule to filter the nodes using the filtering rule; concatenating the filtered user question and node content; adding a prompt word and a constraint to the concatenated content; inputting the concatenated prompt word into a large language model to generate a targeted answer.
8. The multi-language code repository conversation method of claim 7, wherein: the node filtering rule includes: directly removing nodes with a score lower than the threshold; if there are multiple child nodes under the same parent node, only the top 1-2 nodes with the highest score are retained; if the filtered candidate node list is empty, return the top 3 nodes with the highest score in the initial list to ensure at least a basic context.
9. A multi-lingual code vault conversational system characterized by: The system is used to implement the multi-language code repository conversation method of any one of claims 1-8.
Citation Information
Cited By
Model question-answering method and device based on code repository abstract and storage medium
CN121303364A