A code requirement verification method and terminal based on a large language model

By transforming unstructured requirement documents into structured representations using a large language model and generating semantic scene representations, the semantic gap between natural language and program code is bridged. This enables automated and semantic code requirement consistency verification, improving the depth and accuracy of verification.

CN122240444APending Publication Date: 2026-06-19FUJIAN TQ DIGITAL

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FUJIAN TQ DIGITAL
Filing Date
2026-01-28
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In existing technologies, the semantic gap between natural language requirements and program code makes it difficult for automated verification to penetrate into the business scenario level, and code modularization leads to fragmented business logic, affecting verification efficiency and accuracy.

Method used

The large language model is used to convert unstructured requirement documents into structured representations, generate semantic scene representations that reflect business scenarios, and perform correlation analysis and alignment verification through the large language model to output a visual verification report.

Benefits of technology

It enables automated extraction of requirements from natural language to machine-processable requirements, improves the consistency judgment between requirements and code at the business intent level, solves the problem of low efficiency in traditional methods, and provides accurate verification depth and closed-loop feedback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240444A_ABST
    Figure CN122240444A_ABST
Patent Text Reader

Abstract

This invention provides a code requirement verification method and terminal based on a large language model. It includes: acquiring the requirement document to be verified and the corresponding source code; converting the requirement document into a structured requirement representation based on the large language model; generating a semantic scenario representation reflecting the business scenario based on the source code; performing correlation analysis and alignment verification on the structured requirement representation and the semantic scenario representation through the large language model, and outputting the analysis results and verification results. This invention automatically parses unstructured requirements through a large language model, achieving automated and accurate verification of code-requirement consistency at the semantic level, thus improving the automation and accuracy of requirement implementation verification in the software development process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing technology, and in particular to a code requirement verification method and terminal based on a large language model. Background Technology

[0002] In software development, ensuring consistency between the program code implementation and the planning documents written in natural language is a core aspect of guaranteeing product quality. However, related technologies have failed to effectively bridge the semantic gap between natural language requirements and program code, as well as the fragmentation of business logic caused by modularization and functionalization of code. This makes it difficult for automated verification to penetrate deeply into the business scenario. Summary of the Invention

[0003] The technical problem to be solved by this invention is to provide a code requirement verification method and terminal based on a large language model, so as to realize the consistency between unstructured planning documents and program source code at the business scenario level.

[0004] A code requirement verification method based on a large language model, the method comprising:

[0005] Obtain the requirements document to be verified and its corresponding source code; The requirement document is converted into a structured requirement representation based on a large language model; Based on the source code, a semantic scene representation reflecting the business scenario is generated; The large language model is used to perform correlation analysis and alignment verification between the structured requirement representation and the semantic scene representation, and the analysis results and verification results are output.

[0006] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is as follows: A code requirement verification terminal based on a large language model includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it performs the following steps: Obtain the requirements document to be verified and its corresponding source code; The requirement document is converted into a structured requirement representation based on a large language model; Based on the source code, a semantic scene representation reflecting the business scenario is generated; The large language model is used to perform correlation analysis and alignment verification between the structured requirement representation and the semantic scene representation, and the analysis results and verification results are output.

[0007] The beneficial effects of this invention are as follows: By parsing requirement documents using a large language model and converting them into structured requirement representations, it achieves automated extraction of requirement points from natural language into machine-processable and traceable ones, solving the problem of low efficiency and reliance on manual intervention in requirement understanding; by utilizing the large language model to perform automated correlation analysis and alignment verification of structured requirements and semantic scenarios at the semantic level, it achieves consistency judgment between requirements and code at the business intent level, improving the depth and accuracy of verification; finally, it outputs a visualized verification report containing implementation status, coverage, and location information, realizing closed-loop feedback and decision support in the verification process. Unlike traditional code analysis methods that rely on manual inspection, script testing, or syntax comparison, this invention integrates static program analysis with the semantic understanding capabilities of a large language model to construct an automated, semantic, and scenario-based code requirement consistency verification method. This effectively overcomes the semantic gap between natural language and programming languages, achieving automatic and accurate verification of consistency between unstructured planning documents and program source code at the business scenario level. Attached Figure Description

[0008] Figure 1 A flowchart illustrating the steps of a code requirement verification method based on a large language model, provided in this embodiment of the invention; Figure 2 The system architecture diagram of the code requirement verification method based on a large language model provided in the embodiments of the present invention; Figure 3 A flowchart illustrating the application of the code requirement verification method based on a large language model provided in this invention in a real-world scenario; Figure 4 This is a schematic diagram of the structure of a code requirement verification terminal based on a large language model, provided in an embodiment of the present invention. Label Explanation: 1. A code requirement verification terminal based on a large language model; 2. Processor; 3. Memory. Detailed Implementation

[0009] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0010] Please refer to Figure 1 A code requirement verification method based on a large language model includes steps 110 to 140.

[0011] Step 110: Obtain the requirements document to be verified and its corresponding source code. For example, obtain the unstructured natural language requirements document to be verified and its corresponding source code, such as a game design document and its corresponding project source code.

[0012] Step 120: Convert the requirement document into a structured requirement representation based on the large language model. For example, input the requirement document into the large language model for parsing and convert it into a structured requirement representation. This provides a standardized, computable, and traceable input foundation for subsequent semantic scene representation, semantic alignment verification, and automated consistency analysis.

[0013] Step 130: Generate a semantic scene representation reflecting the business scenario based on the source code. For example, the system analyzes the source code and calls a large language model to optimize it into a semantic scene representation that fully describes the business scenario.

[0014] Step 140: Perform correlation analysis and alignment verification on the structured requirement representation and semantic scene representation using a large language model, and output the analysis results and verification results. For example, the system inputs the structured requirements and the generated semantic scene into the large language model for semantic correlation analysis and consistency verification; it then receives the output of the large language model, parses it, and generates the analysis results and verification results.

[0015] As can be seen from the above description, the beneficial effects of this invention are as follows: It automatically extracts unstructured requirements into structured representations using a large language model, solving the problem of low efficiency in manual parsing; it reconstructs fragmented code into complete business scenarios, overcoming the problem of logical fragmentation; and it utilizes a large language model to automatically compare requirements and scenarios at the semantic level, realizing business meaning... Figure 1 Consistency verification improves the accuracy of judgments; the final output is a visual report, forming a closed-loop verification process. Unlike traditional manual inspection, script testing, or code analysis methods based on syntax comparison, this system integrates program analysis and semantic understanding to build an automated, semantic, and scenario-based consistency verification system. It effectively overcomes the semantic gap between natural language and programming language, and achieves automatic and accurate verification of the consistency between unstructured requirements and source code at the business scenario level.

[0016] Further, step 120 includes step 121.

[0017] Step 121: Input the requirements document into the large language model, allowing it to parse the document and output a structured list containing multiple requirements points. For example, input an unstructured natural language requirements document into the planning document parsing module, call the large language model, automatically parse the document content, and extract multiple independent requirements points. Each requirement point is formatted as a structured object containing a unique ID, function name, and natural language description, collectively forming a structured requirements list. The technical principle lies in using the semantic understanding and instruction-following capabilities of the large language model to transform free text into machine-processable and traceable structured data, laying the foundation for accurate semantic comparison with subsequent code scenarios.

[0018] As described above, by leveraging the general natural language understanding capabilities of the large language model, intelligent and automated parsing of unstructured, free-format documents is achieved. It not only transforms scattered text into structured, standardized data formats, enabling subsequent processing, but more importantly, it guides the model to perform purposeful and focused analysis through a pre-defined instruction framework. This overcomes the efficiency bottlenecks, subjective biases, and omission risks associated with traditional methods that rely on manual reading, summarization, and data entry.

[0019] Further, step 130 includes steps 131 to 133.

[0020] Step 131: Segment the source code based on preset code structure rules to obtain multiple code units. For example, use preset code structure rules to parse and segment the project source code to obtain multiple code units as the basic unit for subsequent processing.

[0021] Step 132: Invoke the large language model to convert each code unit into a corresponding initial pseudocode description. For example, taking each segmented code unit as input, the large language model is invoked to convert each code unit into initial pseudocode representing the core logic and function of that code unit. Specifically, the system decomposes and semantically transforms the source code through a code segmentation and transformation module. The module first uses a parser (such as an abstract syntax tree-based parser) to segment the code according to the boundaries of method / function bodies, obtaining multiple method body code units. Subsequently, the large language model is invoked for each code unit to convert it into a corresponding natural language pseudocode description, and the one-to-one correspondence between the source code and the pseudocode is recorded. This transformation is performed using methods as the basic unit, preserving the modularity of the code and providing "atomic" materials for subsequent construction of business scenarios.

[0022] Step 133: Based on the call relationships between code units, aggregate the initial pseudocode description into a semantic scenario representation that describes the complete business logic. For example, analyze the call relationships between all code units, and aggregate the segmented code units into a fluent and complete final scenario-based pseudocode that describes the execution flow of a specific business scenario—that is, a semantic scenario representation. This fundamentally solves the problem of fragmented business logic in code, providing an indispensable and high-quality intermediate representation for subsequent semantic alignment verification of requirements and code at the business scenario level.

[0023] As described above, through a progressive process from syntactic segmentation to semantic transformation and finally logical optimization, a leap from low-level program code to high-level business scenario description is achieved. This not only preserves the accuracy of the code but also reconstructs a complete business narrative that conforms to human cognitive habits through the semantic understanding and generation capabilities of a large language model. This provides a crucial technical bridge for bridging the semantic gap between code implementation and natural language requirements, enabling automated verification to be performed at the business intent level rather than simply the syntactic level, greatly improving the depth, accuracy, and practicality of verification.

[0024] Further, step 133 includes steps 1331 to 1334.

[0025] Step 1331: Construct a directed call graph based on the calling relationships between code units. For example, using each code unit as a node, if one code unit calls another code unit in the program, a directed edge is established between these two nodes; by traversing the calling relationships between all code units, a complete directed call graph G representing the execution dependencies within the program is constructed. Using each code unit (method) as a node, if one code unit calls another code unit in the program, a directed edge is established between these two nodes; by traversing the calling relationships between all code units, a complete directed call graph G representing the execution dependencies within the program is constructed (nodes represent methods, edges represent calling relationships).

[0026] Step 1332: Perform strong connected component analysis and topological sorting on the directed call graph to determine the business execution order of code units. For example, first, perform strong connected component analysis on the constructed directed call graph G to identify all subsets of nodes with cyclic calls (i.e., the largest strongly connected subgraph), and shrink each such strongly connected component into a single node to construct an acyclic shrinking graph; then, perform topological sorting on this shrinking graph to obtain a linear sequence of nodes. Based on this sequence, call clusters are generated, each containing one or more methods related in the business execution chain. This sequence reflects the expected execution order and dependencies of code units in the business logic.

[0027] Step 1333: Based on the business execution order, concatenate the initial pseudocode descriptions corresponding to the code units. For example, based on the node sequence obtained by topological sorting, extract the initial pseudocode descriptions corresponding to each code unit in sequence; connect and combine these description texts according to their corresponding execution logic order to form a preliminary text draft that reflects the complete business execution process but may contain logical jumps or redundant expressions.

[0028] Step 1334: Call the large language model to perform semantic optimization on the concatenated initial pseudocode and generate contextualized pseudocode. For example, the system calls the large language model to input the obtained text draft; the large language model performs semantic polishing, logical coherence enhancement, redundant information elimination, and expression standardization on the text draft, and outputs contextualized pseudocode.

[0029] As described above, by deeply integrating graph algorithms from the field of program analysis with natural language processing techniques, intelligent reconstruction from fragmented code semantics to coherent business scenario semantics is achieved. The application of strongly connected component analysis and topological sorting ensures that the reconstructed business sequence strictly conforms to the actual execution logic of the code, avoiding potential sequence errors or logical omissions that may arise from aggregation based on text or simple rules. Furthermore, semantic optimization using a large language model further elevates mechanically pieced-together text into high-quality narratives that align with human understanding. This series of operations not only solves the fundamental problem of fragmented code business logic but also lays a solid and irreplaceable technical foundation for subsequent precise alignment of requirements and code at a unified and coherent semantic level.

[0030] Furthermore, step 1334 includes steps 1335 and 1336.

[0031] Step 1335: Based on the preset optimization prompt word template, construct an optimization instruction containing the concatenated initial pseudocode. For example, select a prompt word template suitable for "scenario text optimization" from the system's preset optimization prompt word templates. This optimization prompt word template includes specific requirements for logical coherence, clarity of expression, and consistency of business terminology. Use the concatenated text draft as input and fill it into the specified position of the optimization prompt word template to generate a structured and task-clear complete optimization instruction.

[0032] Step 1336: Input the optimization instructions into the large language model to obtain the text processed by the large language model as the contextualized pseudocode corresponding to the initial pseudocode. For example, send the constructed optimization instructions to the large language model; after receiving the instructions, the model, based on its deep understanding and generation capabilities of natural language, performs semantic polishing, logical connection optimization, redundancy elimination, and standardized expression on the input text draft; after processing, it outputs an optimized, fluent, and complete natural language text describing the business execution process, which is then recorded by the system as the contextualized pseudocode corresponding to the initial pseudocode aggregate.

[0033] As described above, by introducing optimized prompt word templates—an engineering control method—the general text optimization capabilities of the large language model are directed towards the specific task of generating business scenario descriptions, ensuring the controllability, consistency, and predictability of the optimization process and the quality of the results. This not only solves the problems of awkwardness, abruptness, or redundancy that may exist in simply splicing text, but also, through deep semantic processing, enables the generated scenario-based pseudocode to maintain the accuracy of business logic while possessing good readability and interpretability. This allows the business scenario description reconstructed from the code to truly become a reliable and efficient semantic bridge connecting program implementation and natural language requirements.

[0034] Furthermore, step 140 involves performing correlation analysis and alignment verification between the structured requirement representation and the semantic scene representation using a large language model, including steps 141 and 142.

[0035] Step 141: Traverse each requirement point in the structured requirement representation. When a target requirement point is encountered, obtain the target scenario-based pseudocode that matches the target requirement point. For example, select a requirement point from the structured requirement list as the target requirement point to be processed; based on the functional keywords, business domain, or preset mapping rules in the requirement point, retrieve and filter the candidate scenario-based pseudocode that is most likely related to the requirement point from the generated scenario-based pseudocode set as the target scenario-based pseudocode.

[0036] Step 142: Perform semantic analysis on the target requirement and the target scenario-based pseudocode based on the large language model. Determine whether the target requirement is implemented in the scenario-based pseudocode based on the analysis results, and generate the corresponding implementation status. For example, combine the natural language description of the target requirement with the target scenario-based pseudocode, along with a preset verification prompt, such as "Please determine whether requirement '[requirement description]' is fully implemented in the following business scenario description," and input them into the large language model; receive and parse the text response output by the model, extract the judgment conclusion regarding implementation; based on the conclusion, generate an implementation status label of "implemented," "not implemented," or "partially implemented" for the requirement, and optionally record the judgment basis or the reference position of relevant scenario fragments.

[0037] As described above, this system elevates traditional code analysis based on keywords or pattern matching to a deep semantic understanding level based on large language models. It is no longer limited to grammatical correspondence but focuses on understanding the semantic consistency between the business intent of the requirements and the operational logic described by the scenario-based pseudocode. By traversing all requirements and combining targeted prompt word engineering, the system can independently and accurately review and judge each requirement, thereby comprehensively evaluating the overall requirement implementation coverage. It identifies scenarios that are implemented at the code level but have semantic deviations, or where the requirement intent is not covered at all. Ultimately, it generates a semantic, scenario-based, and reliable verification report, providing direct data support for accurate defect localization, requirement tracing, and code iteration.

[0038] Furthermore, it also includes steps 143 to 145.

[0039] Step 143: Calculate the implementation status of all requirements and the requirement coverage rate. For example, after completing the semantic analysis of all requirements and generating the implementation status, the system automatically counts the number of requirements in the "implemented", "not implemented", and "partially implemented" states; based on the statistical results, the overall requirement coverage rate is calculated, such as "number of implemented requirements / total number of requirements × 100%", and the percentage distribution of each state can be further calculated to quantify the completeness of requirement implementation.

[0040] Step 144: Associate and mark the unimplemented or partially implemented requirements with the semantic scenario representation of the corresponding scenario-based pseudocode. For example, for each requirement marked as "unimplemented" or "partially implemented", the system records the unique identifier or content fragment of the target scenario-based pseudocode associated with it during the traversal and matching phase; establish an explicit link from the requirement to its corresponding semantic scenario representation, i.e., the scenario-based pseudocode, and attach specific reasons for not implementing, missing functionalities, or contextual comments to the link to form structured association information.

[0041] Step 145: Output the verification results, including associated tags. For example, the system integrates all verification data and automatically generates a structured, visual verification report. This report is output in the form of a visual interface, document, or data interface, providing developers with clear, actionable closed-loop feedback and decision-making basis.

[0042] As described above, the closed-loop aggregation and output phase of the verification process systematically transforms the discrete conclusions obtained from the preceding semantic analysis into measurable, traceable, and actionable engineering insights. Through quantified coverage statistics, the team can grasp the overall progress of project requirement implementation; through precise association markers, abstract missing requirement issues are located to specific business scenario descriptions and even potential code modules, greatly reducing the cognitive and time costs of problem investigation and repair; and the structured verification report further transforms the results of automated analysis into effective inputs that can directly drive development iterations. This entire mechanism not only enhances the completeness and practicality of verification itself but also deeply integrates automated verification into the development workflow, truly achieving end-to-end intelligent support from problem discovery to guiding solutions.

[0043] Furthermore, step 140 outputs the analysis results and verification results, including step 146.

[0044] Step 146: Generate a visual verification report; the visual verification report includes requirement coverage statistics, the implementation status of each requirement point in the structured requirement representation, semantic scene representations associated with the requirement points, and code location prompts for requirement points with an implementation status of "not implemented". For example, based on all the verification data generated in the previous steps, including requirement coverage indicators, status labels of each requirement point, and the relationship between requirement points and their matching scenario-based pseudocode, the system automatically generates a well-structured and content-rich visual report; the report displays requirement coverage and distribution in chart form, and details the unique identifier, functional description, implementation status, and associated scenario-based pseudocode identifier or content summary of each requirement point in table or list form. For all requirement points in the "not implemented" status, based on the original code unit corresponding to its associated scenario-based pseudocode, the system automatically adds location prompts such as source code file path, function name, or line number range, providing developers with a one-stop navigation from requirement issues to code locations.

[0045] As described above, the visual verification report summarizes and outputs the entire verification process, and serves as a bridge to transform automated and semantic analysis capabilities into actual development productivity. The visual statistics in the report provide macro-level decision-making support for project management; detailed requirements and scenario-related information establishes a complete traceability chain from natural language requirements to business scenario descriptions and specific code implementations; and the automatically generated code location hints for unfulfilled requirements directly and accurately map abstract missing requirement issues to the code locations to be modified or developed, greatly shortening the path for problem identification and repair.

[0046] The code requirement verification method and terminal based on a large language model described above are applicable to various software development processes involving requirement and code consistency verification, especially suitable for game software development where requirements change frequently, business logic is complex, and high automation and accuracy requirements are necessary. Please refer to [link / reference]. Figure 2 The following describes specific implementation methods.

[0047] Taking the "purchase items in the store" feature being developed by a game company as an example, its development process involves planning, development, and testing teams, and the specific implementation includes the following steps: S1. The system obtains the requirements document and source code to be verified. The unstructured natural language design document written by the planner describes the complete purchase process, such as the user selecting items, verifying the balance, deducting coins, distributing items, and recording logs; the corresponding project source code submitted by the developers is input into the system. This is equivalent to step 110 above.

[0048] S2. Based on the large language model, the project proposal is parsed into a structured list of requirements. The project proposal parsing module combines the project proposal text with preset decomposition prompts, such as "Please decompose the following project proposal into independent functional requirement points," and inputs this into the large language model. The model output response is then parsed into multiple structured requirement points, for example: (1) Requirement ID: R001, Name: "User selects props", Description: "User selects props to purchase from the product list"; (2) Requirement ID: R002, Name: "Verify Account Balance", Description: "The system checks whether the user has enough gold coins to make a payment"; (3) Request ID: R003, Name: "Deduct corresponding gold coins", Description: "Deduct the required gold coins from the user's account; (4) Request ID: R004, Name: "Distribute items to backpack", Description: "Add the purchased items to the user's backpack"; (5) Requirement ID: R005, Name: "Record Purchase Log", Description: "Record this purchase operation in the log system".

[0049] The system stores these requirements as a structured list. This is equivalent to steps 120 and 121 above.

[0050] S3. Generate a semantic scene representation reflecting the purchase process based on the source code. The code segmentation and conversion module first uses a parser to segment the source code according to method boundaries, obtaining multiple code units, such as CheckBalance(), DeductGold(), AddItemToBag(), etc. For each unit, the large language model is called to generate its initial pseudocode description, such as "This function checks whether the gold coin balance of the account corresponding to the passed user ID is greater than or equal to the required amount". Subsequently, the scene clustering and optimization module analyzes the call relationships between these methods and constructs a directed call graph; through strong connected component analysis and topological sorting, these methods are aggregated into a call cluster reflecting the "purchase execution" process; according to the execution order, the corresponding pseudocode is concatenated into a draft, and the large language model is called again for polishing and optimization, finally generating a scene-based pseudocode describing a natural language, such as "The system first verifies whether the user's balance is sufficient. If it is sufficient, the corresponding gold coins are deducted, then the item is added to the user's backpack, and the transaction log is recorded." This is equivalent to steps 130, 131 to 133, and 1331 to 1334 above.

[0051] S4. Perform semantic alignment verification between requirements and scenarios using a large language model. The consistency comparison analysis module traverses each requirement point in the structured requirement list and matches it with the generated scenario-based pseudocode. For example, for requirement point R005 "Record purchase log", its description and scenario pseudocode are input into the large language model, and verification prompts, such as "Determine whether the requirement 'Record purchase log' is implemented in the following scenario description," are used for analysis. The model outputs a judgment result based on semantic understanding, and the system generates an "Implemented" status for R005 accordingly. After traversing all requirement points, the system finds that requirement point R004 "Distribute items to backpack" is not mentioned in the scenario pseudocode, so it is marked as "Not Implemented". This is equivalent to steps 140 and 141 to 142 above.

[0052] S5. Generate a visual verification report and establish a closed-loop feedback loop. The report generation module summarizes all verification results, automatically generates a report, and displays the requirement coverage rate. For example, if 4 out of 5 requirements have been implemented, the coverage rate is 80%, and the implementation status of each requirement is listed in detail. For unimplemented R004, the report associates it with its corresponding business scenario ("Purchase Execution" process) and provides possible source code location hints based on code unit mapping relationships, such as suggesting checking whether the AddItemToBag() method is correctly called or implemented. This report can be directly pushed to the development task management system to guide developers in checking and fixing the issues. This is equivalent to steps 143 to 146 above.

[0053] Through the above application examples, this invention realizes a fully automated process from unstructured requirement parsing, semantic code reconstruction, semantic alignment verification to closed-loop report generation. This method effectively solves the pain points in game development, such as low efficiency, numerous omissions, and reliance on human experience in requirement verification caused by frequent changes in design documents and fragmented business logic in code. It has significant engineering practice value in improving the degree of verification automation, ensuring the completeness of requirement implementation, and accelerating the development iteration cycle.

[0054] Please refer to Figure 3 The following section, with reference to the accompanying diagram, details the application of the code requirement verification method based on a large language model in a real-world scenario. Taking a game company's "social friend system" feature as an example, the development process involves social planning, client-side and server-side development teams. The specific implementation includes the following steps: S21: Input Project Plan and Source Code: The system simultaneously obtains the unstructured natural language project plan (describing complete social functions such as friend addition, friend list management, message interaction, and intimacy system) written by the social planner and the corresponding project source code. The project plan includes business descriptions such as "users can search and add friends," "friend list needs to support group management," "friends can send real-time messages," and "intimacy level is calculated based on interaction frequency."

[0055] The planning document parsing module combines the aforementioned planning document text with preset requirement extraction prompts, such as "Please break down the following social system description into independent functional requirement points," and inputs them into the large language model. The model's output response is parsed and formatted into a structured requirement list, for example: (1) Requirement ID: S001, Name: "Friend Search and Add", Description: "Supports searching for users by ID or nickname and sending friend requests"; (2) Requirement ID: S002, Name: "Friend List Group Management", Description: "Allow users to group their friends (such as family members, comrades-in-arms) and customize the group names"; (3) Requirement ID: S003, Name: "Real-time Message Communication", Description: "Friends can send text, emoticons and other messages and display them in real time"; (4) Requirement ID: S004, Name: "Intimacy Calculation and Display", Description: "Automatically calculate the intimacy value based on the interaction frequency and display the level in the UI".

[0056] This is equivalent to steps 110 and 120 above.

[0057] S22: Code Segmentation and Method-Level Pseudocode Generation: The code segmentation and transformation module performs syntactic parsing on the social system's source code, dividing it into multiple independent code units according to method boundaries, such as SearchUser(), SendFriendRequest(), CreateFriendGroup(), SendInstantMessage(), CalculateIntimacy(), etc. For each code unit, a large language model is called to generate a corresponding initial pseudocode description, such as "This function queries the database based on the input user ID and returns the user's basic information and current online status." This is equivalent to steps 131 and 132 above.

[0058] S23: Construct a call graph and analyze strongly connected components: The scenario clustering and optimization module analyzes the call dependencies between the methods mentioned above and constructs a directed call graph. Through strongly connected component analysis, it identifies logical groups with cyclical calls (such as mutual calls between message sending and status updates) and performs topological sorting to determine the business execution sequence. Then, methods with strong dependencies are aggregated into business scenario call clusters, such as the "friend addition process cluster" and the "message interaction cluster." This is equivalent to step 133 above.

[0059] S24: Automated Comparison of Requirement Points and Contextualized Pseudocode: The consistency comparison and analysis module processes each requirement point in the structured requirement list sequentially. Taking requirement S002 "Friend List Group Management" as an example, its description and the generated contextualized pseudocode (such as text describing the complete friend management process) are input into the large language model, along with verification prompts (such as "determine whether the 'Friend List Group Management' function is fully implemented in the following business scenario description") for semantic analysis. The model outputs a judgment result based on deep understanding, and the system marks the requirement point as "implemented" or "not implemented" accordingly. After traversing all requirement points, the system may find that "Intimacy Level Display" in requirement S004 is not explicitly reflected in the scenario description, and marks it as "partially implemented." Steps 141 and 142.

[0060] S25: Generate Implementation Completeness Report: The report generation module summarizes all verification results and automatically generates a structured, visual verification report. The report includes: overall requirement coverage statistics (e.g., 3 out of 4 requirements are fully implemented, and 1 is partially implemented, resulting in a coverage rate of 87.5%), detailed implementation status of each requirement, a summary of the associated business scenario description, and code location suggestions for unimplemented or partially implemented requirements, such as indicating that the `UpdateIntimacyUI()` method may be missing or not correctly integrated. This report can be directly pushed to the project management platform or version control system, providing the development team with clear repair guidance and iteration basis. This is equivalent to steps 143 and 146 above.

[0061] As can be seen from the above embodiments, the present invention realizes an end-to-end automated process from natural language requirement input, semantic code parsing, intelligent business scenario reconstruction, semantic alignment verification to result visualization feedback. This method is particularly suitable for development scenarios such as game social systems, multiplayer collaborative gameplay, and community functions, where business logic is intertwined, interaction states are complex, and requirement descriptions are prone to ambiguity. It can reduce communication costs, improve the traceability and verification efficiency of requirement implementation, and has high engineering practical value.

[0062] Please refer to Figure 4 : A code requirement verification terminal 1 based on a large language model includes a memory 3, a processor 2, and a computer program stored on the memory 3 and running on the processor 2. When the processor 2 executes the computer program, it implements each step of the code requirement verification method based on a large language model described above.

[0063] In summary, this invention provides a code requirement verification method and terminal based on a large language model. By integrating unstructured natural language requirements with structured program code, an automated consistency verification system with semantic understanding as its core and program analysis as its support is constructed, realizing intelligent management of the entire process from requirement parsing, semantic code refactoring, semantic alignment verification to closed-loop feedback.

[0064] The system can automatically trigger a structured requirements extraction and code scenario refactoring process based on the input requirements document and source code, enabling controllable orchestration and status tracking of the verification process. For different business scenarios and verification objectives, the system can output differentiated semantic intermediate representations and perform multi-level semantic matching analysis, ultimately generating a concrete verification report.

[0065] Meanwhile, based on preset prompt word templates and program analysis algorithms (such as strongly connected component analysis and topological sorting), the system constructs a structured semantic transformation and optimization mechanism at each stage of requirement parsing, scenario reconstruction, and semantic alignment. This serves as a core technological bridge connecting natural language and program code, thereby achieving an automated verification-driven mechanism highly compatible with the software development process. In terms of data processing, the system performs standardized storage and association mapping on multimodal intermediate products generated during parsing, such as structured requirements, initial pseudocode, call graphs, and scenario-based pseudocode. It also performs targeted semantic analysis and consistency judgment based on the verification objectives, ensuring that the data at each stage is technically interpretable, traceable, and operable.

[0066] Leveraging the deep semantic understanding capabilities of large language models and the precise dependency identification capabilities of static program analysis, the system performs cross-level correlation and quantitative evaluation of requirement points, code units, business scenarios, and verification results, achieving global intelligent monitoring and integrity assessment of requirement implementation status. This method differs from traditional verification approaches that rely on manual inspection, script testing, or syntax comparison. Through semantic-driven, scenario-driven, and data-driven approaches, it constructs an efficient, accurate, and reproducible automated verification workflow, improving the breadth of verification coverage, the depth of problem discovery, and the credibility of conclusions.

[0067] Furthermore, during the verification execution and report generation process, the system has established an iterative optimization mechanism for prompt words and rules based on implementation status feedback. When unimplemented or partially implemented requirements are identified, the system can provide developers with clear repair guidance by combining related business scenarios and code location information. It can also adaptively optimize the prompt word templates and matching rules based on historical verification data to ensure continuous improvement and effectiveness of the verification process, thereby improving verification efficiency while ensuring the completeness and accuracy of requirement implementation.

[0068] This system is suitable for verification scenarios in development and other software projects where requirements change frequently, business logic is complex, and code modularity is high. By building an intelligent, automatic, and continuously optimized requirement consistency assurance system, it effectively reduces the cost of manual verification and communication losses, and improves the standardization level and delivery quality of the development process.

[0069] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention's specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A code requirement verification method based on a large language model, characterized in that, include: Obtain the requirements document to be verified and the corresponding source code; The requirement document is converted into a structured requirement representation based on a large language model; Based on the source code, a semantic scene representation reflecting the business scenario is generated; The large language model is used to perform correlation analysis and alignment verification between the structured requirement representation and the semantic scene representation, and the analysis results and verification results are output.

2. The code requirement verification method based on a large language model according to claim 1, characterized in that, The process of converting the requirement document into a structured requirement representation based on a large language model includes: The requirement document is input into the large language model, so that the large language model parses the requirement document and outputs a structured list containing multiple requirement points.

3. The code requirement verification method based on a large language model according to claim 1, characterized in that, The generation of a semantic scene representation reflecting the business scenario based on the source code includes: The source code is segmented based on preset code structure rules to obtain multiple code units; The large language model is invoked to convert each code unit into a corresponding initial pseudocode description; Based on the calling relationships between the code units, the initial pseudocode description is aggregated into a semantic scenario representation that describes the complete business logic.

4. The code requirement verification method based on a large language model according to claim 3, characterized in that, The aggregation of the initial pseudocode description into a semantic scenario representation describing complete business logic based on the calling relationships between the code units includes: Based on the calling relationships between the code units, a directed call graph is constructed; Perform strong connectivity component analysis and topology sorting on the directed call graph to determine the business execution order of the code unit; Based on the business execution order, the initial pseudocode descriptions corresponding to the code units are concatenated; The large language model is invoked to perform semantic optimization on the concatenated initial pseudocode, generating contextualized pseudocode.

5. The code requirement verification method based on a large language model according to claim 4, characterized in that, The step of calling the large language model to perform semantic optimization and polishing on the concatenated initial pseudocode to generate the contextualized pseudocode includes: Based on the preset optimized prompt word template, an optimized instruction containing the concatenated initial pseudocode is constructed; The optimization instructions are input into the large language model, and the text processed by the large language model is obtained as the contextualized pseudocode corresponding to the initial pseudocode.

6. The code requirement verification method based on a large language model according to claim 1, characterized in that, The step of performing correlation analysis and alignment verification between the structured requirement representation and the semantic scene representation using the large language model includes: Iterate through each requirement point in the structured requirement representation. When a target requirement point is reached, obtain the target scenario-based pseudocode that matches the target requirement point. Based on the large language model, semantic analysis is performed on the target requirement and the target scenario pseudocode. Based on the analysis results of the semantic analysis, it is determined whether the target requirement is implemented in the scenario pseudocode, and the corresponding implementation status is generated.

7. The code requirement verification method based on a large language model according to claim 6, characterized in that, Also includes: Statistically analyze the implementation status of all the aforementioned requirements and calculate the requirement coverage rate; Associate and mark the unrealized or partially realized requirements with the semantic scene representation of the corresponding scenario-based pseudocode; The output includes the verification results of the associated tags.

8. The code requirement verification method based on a large language model according to claim 6, characterized in that, Also includes: Based on the correspondence between the implementation state and the semantic scene representation, the requirement decomposition prompt words, optimized prompt word templates, and matching rules are iteratively adjusted.

9. The code requirement verification method based on a large language model according to claim 1, characterized in that, The output analysis results and verification results include: Generate a visual verification report; the visual verification report includes requirement coverage statistics, the implementation status of each requirement point in the structured requirement representation, the semantic scene representation associated with the requirement point, and code location prompts for the requirement points whose implementation status is not implemented.

10. A code requirement verification terminal based on a large language model, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement each step of the code requirement verification method based on a large language model as described in any one of claims 1 to 9.