Software system code positioning method and device based on large model, software system code generation method and device based on large model and medium
By using a large-model-based software system code location method, a code graph of a telecommunications network communication system is constructed and an entity indexing tool is used. This solves the problem that traditional tools cannot understand telecommunications business rules, and enables efficient code development and automated code generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2026-03-10
AI Technical Summary
Traditional code generation tools cannot understand the business rules and code architecture of telecommunications network communication systems, resulting in low development efficiency, high error rates, long development cycles, and high knowledge transfer costs.
A software system code localization method based on a large model is adopted. By constructing a code graph as a tree structure and storing it in the form of a Graph RAG, entity indexing tools and fuzzy indexing tools are used. Combined with the large model, a logical flow from the fault entry point to the fault root cause is generated, and the code entities that need to be modified are identified and output.
It improved code development efficiency, optimized code generation quality, and enabled the automatic location of relevant code segments and the generation of modification suggestions that comply with telecommunications business specifications, increasing code generation speed by 3.2 times.
Smart Images

Figure CN121635894A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence technology, specifically relating to a method, generation method, device, and medium for locating software system code based on a large model. Background Technology
[0002] The telecommunications network communication resource management system is a core platform supporting modern communication networks. Its code needs to be deeply integrated with telecommunications business logic (such as network resource scheduling, equipment status monitoring, and billing rule processing), making it highly specialized and complex compared to ordinary systems. With the popularization of 5G network slicing technology and the surge in IoT device access, the system needs to simultaneously handle the parsing of over 300 heterogeneous protocols, dynamic spectrum allocation strategies, and real-time QoS guarantee mechanisms.
[0003] Traditional code generation tools cannot understand the unique business rules and code architecture of such systems, leading to heavy reliance on human experience in development, resulting in low efficiency, high error rates, and industry pain points such as long development cycles and high knowledge transfer costs. With the rise of AI large-scale model technology, how to enable large models to "understand" the coupling relationship between telecommunications business logic and system code has become a key breakthrough in improving code development efficiency. Summary of the Invention
[0004] The purpose of this invention is to provide a method, generation method, device, and medium for locating software system code based on a large model, so as to solve the above-mentioned technical problems existing in the development, debugging, and maintenance of telecommunications service code.
[0005] This invention is achieved through the following technical solution: Software system code location methods based on large models include: The project code is constructed into a tree structure graph using a code graph construction algorithm and stored in the form of a Graph RAG; an entity indexing tool and a fuzzy indexing tool in MCP format are constructed. The system uses a large model to extract keywords from user input questions, and calls entity indexing and fuzzy indexing tools to link keywords to code entities. The large model generates a logical flow from the fault entry point to the fault root cause, identifies all code entities that need to be modified based on the logical flow, and outputs the location of the code entities that need to be modified.
[0006] In some embodiments, the step of constructing the project code into a tree structure graph and storing it as a Graph RAG using a code graph construction algorithm includes: The abstract semantic tree is used to parse each Python file of the project code, recursively identify the internal functions and classes of the Python files as nodes of the project code tree structure diagram, and use the code content of each function as the retrieved document to construct the project code tree structure diagram. The graph structure index relationship associated with each node is stored in the node's Graph RAG vector library.
[0007] In some embodiments, the steps of constructing the entity indexing tool and fuzzy indexing tool in MCP format include: The node path of each node in the tree structure diagram is used as the unique index ID of that node to build an entity ID index; by building a name index dictionary, the name of each node is mapped to all nodes with the same name to build an entity name index; for keywords that do not have an exact match for the entity ID, the entity IDs are retrieved and sorted to build a fuzzy entity ID index. Build an MCP service and create MCP-formatted indexing tools for each index relationship, namely an entity ID indexing tool, an entity name indexing tool, and an entity ID fuzzy indexing tool.
[0008] In some embodiments, the step of using a large model to extract keywords from user input questions includes: the large model first decomposes the user input questions into different categories, and then extracts keywords that are closely related to the question categories.
[0009] In some embodiments, the steps of generating the logical flow corresponding to the user input question through a large model include: First, a large model is used to identify the entry point that triggers the fault; Then, the tree structure diagram of the project code is iteratively traversed using a graph retrieval tool. Based on the current logical flow reasoning state, the structure of the tree structure diagram, and the contextual semantics, new keywords are generated autonomously through the large model. The new keywords are then searched using entity indexing tools and fuzzy indexing tools. The new keywords and their corresponding code entities are used as new nodes in the logical flow diagram. Finally, the reasoning process is guided by COT prompts based on the question and additional context, and the question propagation path is reasoned based on new nodes, gradually expanding the generation logic flow.
[0010] In some embodiments, the step of identifying all code entities that need to be modified according to the logical flow includes: Based on the logical flow, the semantic content of the flow nodes is matched with the entity nodes in the project code tree structure diagram. The corresponding code entities are then searched in the tree structure diagram using an entity retrieval tool to identify all suspicious code entities that need to be modified.
[0011] On the other hand, the present invention also provides a software system code generation method based on a large model. The method uses the software system code location method based on the large model to locate the code, attaches the located code and business rules in the knowledge base to the context of code generation prompt words and uses them as input to the large model to generate new code.
[0012] In some embodiments, the step of attaching business rules from the knowledge base to the context of code generation prompts includes: converting a 3GPP TS 23.502 standard document into a business rule template and injecting it into the context of large model prompts using the RAG method.
[0013] On the other hand, the present invention also provides an electronic device, comprising: Processor; and Memory for storing the executable instructions of the processor; The processor is configured to execute the large-model-based software system code location method and the large-model-based software system code generation method by executing the executable instructions.
[0014] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the software system code location method based on a large model and the software system code generation method based on a large model.
[0015] Compared with the prior art, the present invention has the following advantages and beneficial effects: This invention transforms telecommunications service specifications into a computable service rule graph, enabling large models to possess domain knowledge reasoning capabilities. It can automatically locate relevant code segments through natural language descriptions, thereby improving code development efficiency and optimizing code generation quality. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a block diagram illustrating the principle of the software system code localization method based on a large model in an embodiment of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0019] Currently, the following problems exist in the generation, debugging, and maintenance of telecommunications service codes: Code generation requires a simultaneous understanding of telecommunications service rules (such as resource allocation strategies and network topology constraints) and the underlying system architecture; ordinary code generation tools struggle to comprehend the business semantics. For example, when generating 5G core network slice management code, it must simultaneously meet the ETSI NFV standard and the operator's SLA agreement.
[0020] Developers need to spend a lot of time understanding the business meaning of existing code. Manual debugging is prone to logical errors caused by misunderstandings of the business, such as configuration parameter conflicts (implicit contradictions when setting cell reselection priority and spectrum sharing policy at the same time).
[0021] System upgrades require simultaneous modifications to related code across multiple modules, and traditional methods struggle to track the cascading impact of business rule changes on the code structure. For instance, modifying 4G / 5G interoperability policies necessitates simultaneous adjustments to the code of 23 modules across the radio access network, core network, and transmission network.
[0022] To address the aforementioned issues, this invention employs a hybrid retrieval approach combining traditional retrieval with large-scale model inference. It rapidly narrows the retrieval scope through code structure indexing (BM25 recall accuracy reaches 89%), and then accurately locates non-explicitly associated codes through semantic inference (BERT semantic matching accuracy reaches 93.6%), thereby achieving accurate location of fault codes.
[0023] Telecommunications service knowledge (such as 3GPP standards and network topology rules) is transformed into an interpretable intermediate representation (using Protobuf Schema to define service rules), enabling the large model to understand the business semantics of the code. Specifically, the 3GPP TS23.502 standard document is converted into 128 service rule templates, which are then injected into the context of prompt words in the large model using the RAG method.
[0024] By constructing a propagation graph of the impact of code modifications, the cascading effects of business rule changes on various modules of the system can be predicted. A graph neural network (GNN) is used to establish dependencies between modules, and the PageRank algorithm is used to quantify the impact of changes (α=0.85), achieving accurate prediction of the scope of impact with a prediction accuracy of 91.3%.
[0025] An incremental update strategy is adopted to reduce codebase maintenance costs and adapt to the high-iteration characteristics of telecommunications systems. The RAG (Rapid Algorithm Group) approach is used to update the model knowledge base, eliminating the need for model training.
[0026] Reference Figure 1 In some embodiments of the present invention, the implementation process of the software system fault code localization method based on a large model is as follows: S01, Project Software Code Structure Analysis S011. The complete project code structure input by the user is constructed into a project code tree structure graph using a code graph construction algorithm and stored in the form of Graph RAG.
[0027] Specifically, an Abstract Semantic Tree (AST) is used to parse each Python file of the project code, recursively identify the internal functions and classes of the Python files, and use them as nodes in the project code tree structure diagram. The function level is set as the smallest node granularity, and the code content of each function is used as the document to be retrieved, thus constructing the project code tree structure diagram. The graph structure index relationship associated with each node is stored in the node's Graph RAG vector library.
[0028] S012. Construct the entity ID index; use the node path of each node as the unique index ID of that node (format: file path / class name / function name). Build an entity name index; build a name index dictionary to map the name of each node to all nodes with the same name (to handle the scenario of function overloading with the same name). Construct a fuzzy index for entity IDs; for keywords that do not have an exact match for the entity ID, use the BM25 algorithm to sort the entity IDs (default k1=1.2, b=0.75).
[0029] S013. Build basic MCP services. For the three index relationships built above, establish MCP format index tools respectively, which are defined as entity ID index tool (entity_id_index_tool), entity name index tool (entity_name_index_tool), and entity ID fuzzy index tool (entity_iD_fuzzy_index_tool).
[0030] S02, Code Location and Generation S021, User input problem: "The llmLoader class in the llm.py file cannot configure the model temperature...; Task description: Please check the model parameter configuration code......".
[0031] S022, Large-scale model analysis problem and keyword extraction; The large model first breaks down the problem statement into different categories (including problem description, bug tracking, code that re-errors, and other context); then it extracts keywords that are closely related to the problem category.
[0032] Using the CRF model for keyword tagging, the F1 score can reach 94.2%.
[0033] S023. Link keywords to code entities; The MCP service entity indexing tool is called through the large model to extract keywords from the question (including keywords closely related to the question category). If the entity indexing tool does not find them, the fuzzy indexing tool is called to link the keywords to the code entities.
[0034] The entity retrieval tool is used to retrieve entities using entity ID indexes and entity name indexes (supporting fuzzy matching with regular expressions).
[0035] Fuzzy search tools are used to retrieve entities using fuzzy indexes based on entity IDs (reordered by BERT after BM25 recall).
[0036] Specifically, the system parses the entire project code into a graph structure with paths and semantics; then, after extracting keywords through the large model, it sequentially calls three indexing tools: retrieves paths by entity ID index, retrieves entities with the same name by entity name index, and calculates semantic similarity through BM25+BERT for fuzzy indexing of entity ID, thereby linking keywords to code entities.
[0037] S024. Generate the logical flow from fault to failure through a large model; First, the large model uses the AST to trace the call chain backward to identify the entry point that triggers the fault (i.e., the starting position of the call chain that leads to the fault, such as the stack information of the fault code). Then, the project code tree structure diagram is iteratively traversed using graph retrieval tools, and new keywords are searched using MCP service entity indexing tools and fuzzy indexing tools. Semantic expansion and COT (Chain-of-Thought) guidance are performed by searching for new keywords. The new keywords are generated autonomously by the large model. Finally, based on the question and additional context, COT prompts are used to guide the reasoning process and generate a logical flow; specifically, the code and context information are input into the large model, which then generates the logical flow.
[0038] The question here refers to the structured semantic content obtained after the natural language question input by the user is semantically parsed by the large model, including the question description, the relevant files, classes, functions, and task intent.
[0039] Additional context refers to supplementary information related to the problem, which is automatically obtained by the system through code retrieval, graph traversal, and knowledge base retrieval. This includes, but is not limited to, code snippets of the file containing the problem, function call relationships, inheritance structures, runtime stack information, and business rules and historical context information in the knowledge base.
[0040] The graph retrieval tool is used to perform breadth-first search (BFS) on the tree structure graph of project code generated by abstract syntax tree parsing, and combines the PageRank algorithm to evaluate the importance of nodes.
[0041] Specifically, the new keywords are generated autonomously by the large model based on the current logical flow reasoning state, code graph structure, and contextual semantics.
[0042] The logical flow generation process can be likened to a semantic iterative reasoning loop; for example: When a user inputs "llmLoader class cannot configure model temperature", the large model can generate new keywords "set_temperature" and "load_model_config" based on the initial keywords "llmLoader", "model_temperature", and "config" according to the function call relationship; further, it can infer keywords such as "validate_param" and "ConfigError" by combining the code content; if combined with business knowledge rules, it can also generate keywords such as "check_policy_compliance".
[0043] Searching for new keywords is an intermediate step in generating the logical flow, driving the progressive expansion of the logical flow; each round of searching for new keywords and their corresponding code entities will become new nodes in the logical flow diagram; the large model infers the problem propagation path based on the new nodes (such as "configuration error → parameter verification → model loading → runtime exception").
[0044] Through the above process, the logical flow gradually expands, forming a complete causal chain from the entry point to the root cause of the fault.
[0045] Graph retrieval is employed to reinforce the iterative traversal of the project code tree structure, enabling global context understanding, logical link expansion, and dependency propagation analysis. Traversing the project code tree is equivalent to providing "spatial paths" for the logical flow; by continuously generating and retrieving new keywords, the logical flow gradually expands to form a complete causal chain. The process of traversing the code tree structure ensures that the generated logical flow conforms to the structural dependencies of the project code.
[0046] S025, Locate the target code entity; The agent identifies all suspicious code entities in the logical flow that need to be modified, and then sorts these code entities according to their relevance (based on TF-IDF weighted cosine similarity); Based on the sorting, output the location of suspicious code entities in the logical flow, and proceed with the next step of code modification and generation.
[0047] After the code retrieval is completed, the retrieved code and the business rules in the knowledge base are put into the prompt words of the large model to generate the code.
[0048] An intelligent agent is an autonomous reasoning and execution unit composed of a large model and entity retrieval tools, which has the ability to understand the semantics of a problem, call the MCP indexing tool, traverse the code graph, and evaluate the relevance of code entities.
[0049] After the logical flow is generated, the agent matches the semantic content of the flow nodes with the entity nodes in the project code tree structure diagram to automatically identify all suspicious code entities that need to be modified.
[0050] Specifically, after obtaining the complete generated logical flow, the corresponding real code locations of the functions, classes, variables and other logical nodes involved are found in the Graph RAG using entity retrieval tools. Then, the semantic similarity and structural relevance between these nodes and the problem description are calculated to determine which code is most likely to cause the failure.
[0051] Based on the relevance score, the higher the score, the stronger the association between the code entity and the problem, which is called a "suspicious code entity".
[0052] This invention automatically locates relevant code segments through natural language description and generates modification suggestions that comply with telecommunications service specifications, thereby achieving automatic code location and modification. The code generation speed for typical business modules is 3.2 times faster than manual development.
[0053] By combining a telecommunications business knowledge base to identify conflicts between code logic and business rules, error diagnosis can be achieved based on business awareness. For example, when it is detected that a vendor's code does not handle slice isolation according to the ETSI TS 0018 standard, compliance remediation suggestions are automatically generated.
[0054] It automatically analyzes the propagation path of code defects in the business chain, enabling the generation of complete patches that include fixes for related modules, thus achieving dependency-driven bug fixing.
[0055] The code architecture is automatically restructured based on changes in business requirements (such as adding IoT device access protocols) to ensure consistency of business logic and achieve business rule-driven code restructuring. During the restructuring process, the AST differential algorithm can guarantee a code repair coverage rate of 98%. When there is a new business or changes to the old business code, the affected code segments are first retrieved, and then these code segments are modified and generated. If modifying the original code segments cannot meet the business requirements, the original code structure is restructured and modified through a large model to cover the original business code.
[0056] Based on business requirements documents, new functional modules conforming to telecommunications coding standards (such as network slicing QoS guarantee mechanisms) are automatically generated, enabling the automatic generation of functional extension code. For example, when the corresponding business code in the original code is retrieved, the telecommunications coding standard is appended to the context of the code generation prompt as input to the large model, and the large model generates code according to the coding standard; that is, the code is first located, and the located code and the coding standard are input into the large model for code generation.
[0057] The code generation process takes the suspicious code entities and their context information output from the location step as input, and injects the located code fragments, problem descriptions, and business rules or coding specifications into the prompt words of the large model, so that the large model can generate new code that conforms to the specifications based on understanding the original code structure and logical dependencies.
[0058] The location results provide semantic anchors and structural constraints for the generation phase, ensuring that the generated code is logically replaceable or extendable of the original code, enabling problem fixing, feature optimization, or automatic generation of new modules. For example, when the system locates a "model temperature cannot be configured" problem in the llm.py / llmLoader / config_model() function, the large model, after combining the business rule "supports dynamic parameter configuration," automatically generates a repair function with parameter passing and verification logic, thus completing the closed-loop process from code location to generation.
[0059] On the other hand, the present invention also provides an electronic device, comprising: Processor; and Memory for storing the executable instructions of the processor; The processor is configured to execute the large-model-based software system code location method and the large-model-based software system code generation method by executing the executable instructions.
[0060] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the software system code location method based on a large model and the software system code generation method based on a large model.
[0061] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications or equivalent changes made to the above embodiments based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A large model-based software system code positioning method, characterized in that, The method comprises the following steps: An algorithm for constructing code graphs is used to construct project code into a tree structure graph and store it in the form of Graph RAG; A large model is used to extract keywords in the user input question, call the entity index tool and the fuzzy index tool, link the keywords to the code entity, and generate a logical flow from the fault entry point to the fault root by the large model, and identify all code entities that need to be modified according to the logical flow, and output the location of the code entities that need to be modified.
2. The large model-based software system code locating method of claim 1, wherein, The step of constructing project code into a tree structure graph and storing it in the form of Graph RAG comprises the following steps: An abstract syntax tree is used to parse each Python file of the project code, recursively identify the internal functions and classes of the Python file as nodes of the project code tree structure graph, and take the code content of each function as a document for retrieval, thereby constructing the project code tree structure graph; The graph structure index relationship related to each node is stored in the Graph RAG vector library of the node.
3. The large model-based software system code localization method of claim 1, wherein, The step of constructing the entity index tool and the fuzzy index tool in the MCP format comprises the following steps: The node path of each node in the tree structure graph is taken as the unique index ID of the node to construct the entity ID index; the name of each node is mapped to all nodes with the same name by constructing a name index dictionary to construct the entity name index; for the keywords without accurate matching entity ID, the entity ID is sorted for retrieval to construct the entity ID fuzzy index; An MCP service is constructed, and an index tool in the MCP format is established for each index relationship, including the entity ID index tool, the entity name index tool, and the entity ID fuzzy index tool.
4. The large model-based software system code locating method of claim 1, wherein, The step of extracting keywords in the user input question by the large model comprises the following steps: the large model first decomposes the user input question into different categories, and then extracts keywords closely related to the question category.
5. The large model-based software system code localization method of claim 1, wherein, The step of generating a logical flow corresponding to the user input question by the large model comprises the following steps: First, the large model is used to identify the entry point that triggers the fault; Then, the tree structure graph of the project code is iteratively traversed by using the graph retrieval tool, and based on the current logical flow reasoning state, the structure of the tree structure graph, and the context semantics, new keywords are autonomously generated by the large model, and the new keywords and the corresponding code entity are searched by the entity index tool and the fuzzy index tool as new nodes of the logical flow graph; Finally, the COT prompt word is used to guide the reasoning process according to the question and additional context, and the logical flow is generated by propagating the problem and expanding the new nodes step by step.
6. The large model-based software system code localization method of claim 1, wherein, The step of identifying all code entities that need to be modified according to the logical flow comprises the following steps: Based on the logical flow, the semantic content of the flow node is matched with the entity node in the tree structure graph of the project code, the corresponding code entity is found in the tree structure graph by the entity retrieval tool, and all suspicious code entities that need to be modified are determined.
7. A large model-based software system code generation method, characterized by, The code is located by using the large model-based software system code locating method in any one of claims 1-6, the located code is attached to the context of the code generation prompt word with the business rules in the knowledge base as input of the large model, and new code is generated.
8. The large model based software system code generation method of claim 7, wherein, The step of attaching the business rules in the knowledge base to the context of the code generation prompt word comprises: converting the 3GPP TS 23.502 standard document into a business rule template, and injecting the context of the large model prompt word by the RAG method.
9. An electronic device, characterized by Comprise: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the large model-based software system code locating method in any one of claims 1-6, the large model-based software system code generation method in claim 7 or 8 via execution of the executable instructions.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the large model-based software system code locating method in any one of claims 1-6, the large model-based software system code generation method in claim 7 or 8.