Code compliance detection method based on large model

By establishing a unified compliance detection framework and large model technology, combining user sessions for pre-training to generate code compliance detection knowledge and rules, it solves the problem that existing tools have difficulty understanding complex code structures and adapting to specific rules, and realizes the problem of the problem of existing tools being difficult to understand complex code structures and adapting to specific rules. Higher detection accuracy and scope of application.

CN119415410APending Publication Date: 2025-02-11NO 30 INST OF CHINA ELECTRONIC TECH GRP CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411458103.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-18
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

Existing code compliance detection tools are difficult to fully and accurately understand complex code structures and logic, and are difficult to adapt to unique rules within different industries and companies, resulting in the effectiveness and reliability of false positives, missed reports and detection results.

Method used

By establishing a unified compliance detection framework, using big model technology to learn and integrate various programming standards and specifications, combining user sessions as additional knowledge sources, pre-training the big model, generating code compliance detection knowledge and rules, and realizing Detection of code compliance.

Benefits of technology

It improves the accuracy and scope of application of code compliance detection, reduces false positives and missed reports, enhances development efficiency, and ensures that the code complies with relevant laws, regulations and best practices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415410A_ABST
    Figure CN119415410A_ABST
Patent Text Reader

Abstract

The invention provides a code compliance detection method based on a large model, relates to a software development process in the technical field of computer science, and solves the problems of training of the large model and generation of prompt words of code compliance detection rules by the large model when external knowledge corpora are few. According to the method, user sessions are used as additional and supplementary knowledge for training, and a large model is guided to carry out code compliance detection; the method comprises the following steps: firstly, extracting a corresponding knowledge fragment from a standard specification document, combining the knowledge fragment with a prompt word input by a user session, pre-training a large model, and guiding the large model to generate corresponding code compliance detection knowledge; the code compliance detection knowledge is combined with prompt words input by a user session, the context understanding ability of the large model is enhanced, and a code compliance detection rule is generated through response of the large model; realizing code compliance detection according to the code compliance detection rule; the method has the advantages of being higher in detection accuracy, wider in application range and higher in practicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer science and technology, and is applied to a software development process, and in particular to a code compliance detection method based on a large model. Background Art

[0002] During the software development process, it is crucial to ensure that the submitted code complies with the requirements of relevant laws, regulations, policies, standards and industry best practices. This not only helps to avoid potential legal risks, but also significantly improves software quality and information security. However, due to differences in programming level and experience among developers, the quality of the final output code varies, making it difficult to consistently ensure code compliance.

[0003] To solve the above problems, a series of tools such as SonarQube, PMD, Kritika and Checkstyle have appeared on the market, which can quickly analyze large amounts of code and help enterprises improve the efficiency of code compliance detection. Although these tools have alleviated the challenges faced by enterprises to a certain extent, as different organizations have diversified compliance requirements, existing solutions have also exposed some limitations. Specifically, many tools can only identify common compliance issues, but lack sufficient support for specific rules within a specific industry or company, which limits their scope of application.

[0004] False positives and false negatives are also one of the more prominent problems in the current field of code compliance detection. On the one hand, a high false positive rate will increase the workload of developers, forcing them to spend extra time dealing with problems that do not actually need to be corrected; on the other hand, false negatives may cause some important defects to escape inspection, thereby burying security risks. The existence of these problems is mainly attributed to the fact that existing technologies are difficult to fully and accurately understand complex code structures and logics, and it is difficult to flexibly respond to the ever-changing technical environment. For example, with the emergence of new programming languages ​​and frameworks, traditional methods are often unable to quickly adapt to this rapidly evolving situation, thus affecting the effectiveness and reliability of detection results.

[0005] The emergence of big model technology has brought new research directions to the traditional field of code compliance detection, but the current knowledge-based big model construction process is highly dependent on a large amount of external knowledge corpus to obtain relevant information. This dependence brings significant limitations. On the one hand, these models are limited by the size of the database and the scope of domain coverage, which means that they are difficult to effectively generalize to novel or marginal topics that are not covered by the dataset. On the other hand, retrieving the required information from a huge corpus is a resource-intensive process that requires strong computing power and efficient search algorithm support.

[0006] In addition, in the field of software development, especially when performing code compliance testing, although clearly defined and strictly enforced testing rules are the key to ensuring software quality and security, in practice developers often encounter problems caused by lack of necessary external knowledge. This not only affects the effectiveness and accuracy of the testing tools, but may also hinder the smooth progress of the project.

[0007] Therefore, developing a more intelligent, efficient and highly adaptable code compliance detection method has become an important issue that needs to be solved urgently. By introducing large model technology and solving its existing problems, it is expected to fundamentally improve the shortcomings of existing solutions and provide a new generation of solutions that can cover a wide range of scenarios and accurately locate problems. Summary of the invention

[0008] Based on the current status of the background technology, the purpose of the present invention is to solve the problem of training a large model when there is less external knowledge corpus and the generation of code compliance detection rule prompt words by the large model, and therefore proposes a code compliance detection method based on a large model. The present invention establishes a unified compliance detection framework, learns and integrates various programming standards and specifications, has a more comprehensive understanding of different code structures and methods, and provides consistent compliance detection results in different business scenarios, thereby bringing about the characteristics of higher detection accuracy, wider scope of application, and stronger practicality.

[0009] The present invention adopts the following technical solutions to achieve the purpose:

[0010] A code compliance detection method based on a big model, the method uses user conversations as additional supplementary knowledge for training, and guides the big model to perform code compliance detection; firstly, corresponding knowledge fragments are extracted from standard specification documents, and the knowledge fragments are combined with prompt words input by user conversations, and the big model is pre-trained to guide the big model to generate corresponding code compliance detection knowledge; the code compliance detection knowledge is combined with the prompt words input by user conversations to enhance the context understanding ability of the big model, and the code compliance detection rules are generated by the big model response; and code compliance detection is implemented according to the code compliance detection rules.

[0011] Preferably, standard specification documents include national standards, enterprise specifications, industry standards and open source specifications; various types of standard specification documents are collected in advance and data preprocessing is performed. After document filtering, document segmentation and knowledge extraction, each type of standard specification document is formed into a data foundation with a consistent structure so as to be used in the pre-training process of the large model.

[0012] Furthermore, in the process of the big model generating code compliance detection knowledge, the big model is pre-trained through the extracted knowledge fragments and the pre-constructed prompt word templates; the historical conversation samples obtained after each pre-training are stored in the database as the basis for the next training to construct new prompt words, and the big model generates new code compliance detection knowledge based on the new prompt words.

[0013] Specifically, the structure of historical conversation samples includes topics, historical conversations and detection knowledge; topics and historical conversations are obtained through pre-constructed prompt word templates, and detection knowledge is generated and obtained by the large model after each training; after each training of the large model, the topic of the most recent conversation in training and the generated code compliance detection knowledge are stored in the database to form corresponding historical conversation samples; in the next training, new prompt words are constructed based on the historical conversations and the code compliance detection knowledge generated by the historical conversations, and new code compliance detection knowledge is generated.

[0014] Furthermore, in the process of the big model generating code compliance detection rules, after the big model constructs corresponding prompt words and responses based on the code compliance detection knowledge and the prompt words input by the user conversation, the prompt words and responses constructed by the big model are stored in the database to form corresponding conversation response samples; the conversation response samples are used as the basis for further training of the big model, and the conversation response samples include topics and historical conversations, as well as corresponding code compliance detection knowledge and response results.

[0015] Preferably, each conversation response sample calculates the contribution of its own code compliance detection knowledge to its own response result through the word overlap rate; in the process of generating code compliance detection rules, the conversation response samples whose word overlap rate is within a preset range are selected as reference inputs for the large model to generate code compliance detection rules.

[0016] Specifically, based on the examples of the selected conversation response samples, the corresponding example prompt words are constructed and input into the big model; for the example prompt words, "system" and "user" are used to connect different rounds in the historical conversation, and "known information" and "system response" are used to introduce code compliance detection knowledge and response results respectively; when the big model responds to the conversation, for the input of the user conversation and the prompts from the example prompt words, the same template as the example prompt words is used, and the "system response" part of the example prompt words is left blank, and the big model generates the code compliance detection rules; the user uses the rule prompt words corresponding to the code compliance detection rules to detect whether the code submitted in the conversation meets the requirements of the standard specification document.

[0017] In summary, due to the adoption of this technical solution, the beneficial effects of the present invention are as follows:

[0018] The present invention aims to automatically identify and parse the coding requirements in national standards, industry standards and internal enterprise specification documents through natural language processing technology. In the case of relatively scarce external knowledge corpus, the present invention can use limited samples for effective learning and significantly enhance the knowledge acquisition ability of the model. This method ensures that even when faced with unknown data, the model can still maintain high accuracy and reliability, thereby improving overall performance and generalization ability.

[0019] In addition, the present invention also solves the problem of how to generate code compliance detection rule prompt words suitable for different programming languages ​​and development environments. By understanding contextual information, the large model can automatically generate prompt words that adapt to multiple programming languages ​​and code compliance detection frameworks. This not only ensures that the generated prompt words are widely applicable, but also enables developers to avoid spending a lot of time manually constructing complex review rules, greatly improving development efficiency. At the same time, this automated process can also provide accurate compliance recommendations, helping developers better understand and follow coding standards, thereby improving the overall quality of the software.

[0020] The present invention not only enhances the accuracy of code compliance detection, reduces false positives and false negatives, but also ensures that the code complies with relevant laws, regulations and best practices while improving development efficiency. In this way, the present invention provides a powerful and flexible tool for software development teams to help build more secure and reliable applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A logical flow diagram of the method of the present invention;

[0022] Figure 2 It is the standard specification document and pre-processing flow chart of the method of the present invention;

[0023] Figure 3 A schematic diagram of the code compliance detection knowledge generation process of the method of the present invention;

[0024] Figure 4 A schematic diagram of context understanding and response generation for code compliance detection of the method of the present invention. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0026] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] Example

[0028] like Figure 1 As shown, a code compliance detection method based on a big model is shown. The method uses user conversations as additional supplementary knowledge for training to guide the big model to perform code compliance detection. First, corresponding knowledge fragments are extracted from standard specification documents, and the knowledge fragments are combined with prompt words input by user conversations to pre-train the big model to guide the big model to generate corresponding code compliance detection knowledge. The code compliance detection knowledge is combined with the prompt words input by user conversations to enhance the context understanding ability of the big model, and the code compliance detection rules are generated by the big model response. Code compliance detection is implemented according to the code compliance detection rules.

[0029] Before introducing the specific content of the method in detail, it is necessary to make some basic explanations in this embodiment. Different from code security defect detection, code compliance detection is mainly to detect whether the code complies with relevant laws and regulations, standards and specifications or other compliance requirements, mainly including regulatory compliance detection, privacy protection detection and coding specification detection.

[0030] Regulatory compliance testing mainly tests whether the code or the license of the introduced third-party components meets the relevant intellectual property protection requirements; privacy protection testing mainly tests whether there is illegal information in the code, involving personal privacy, etc.; coding standard testing mainly tests the code style, such as whether it follows unified naming standards, indentation standards, and comment standards. In addition, there is also code structure testing to test whether its structure is clear and modular, whether it follows object-oriented, functional and other programming paradigms; as well as code readability checking to check whether the code is easy to understand and maintain, whether the variable naming and function comments are clear, and whether there are complex control flows, nested logic and other problems.

[0031] The current knowledge-based large models require a large amount of external knowledge corpus to obtain relevant knowledge, which brings some limitations; large models are limited by the size and domain of the database and cannot be generalized to topics outside the domain that are not covered by the data. Large corpus retrieval also requires a lot of resources. As the core key to code compliance detection, detection rules often face difficulties such as lack of external knowledge during software development.

[0032] The following is a detailed introduction to the method of this embodiment. First, the concept and principle of this embodiment is: when there is less external knowledge corpus, historical conversations are used as an additional source of knowledge, and the external knowledge corpus and conversations are combined and pre-trained in a large language model, and the pre-trained large language model is combined with guidance prompt words to generate. Figure 1 As shown in the figure, the method of this embodiment takes standard specification documents and user conversations as inputs and is roughly divided into four parts, namely preprocessing, knowledge guidance, context understanding and response generation.

[0033] After collecting documents based on standards and specifications related to code compliance detection, the relevant documents are preprocessed to extract knowledge fragments related to code compliance detection rules. Knowledge guidance combines the prompt words entered by the user in the conversation with the knowledge fragments related to the code compliance detection rules as the knowledge source, guiding the large language model to learn the knowledge to generate more accurate prompt words, where the prompt words entered by the user include the topic of each input and the message of the historical conversation. Context understanding strengthens the large model's understanding of the current conversation scenario to ensure that the generated reply is related to the previous text, and response generation ultimately generates effective code compliance detection rules.

[0034] The knowledge guidance in the method of this embodiment generates relevant knowledge based on the prompt words input by the user, and the response generation generates relevant knowledge based on the context information. Both processes use the same pre-trained large language model. Finally, based on the generated code compliance detection rules, the code compliance can be automatically detected to improve the code quality and maintainability.

[0035] In the software development process, some developers will pursue code writing efficiency rather than code correctness and readability. In order to deal with these problems, a series of programming specifications have been formulated. For example, GJB8114 restricts the programming specifications of C / C++ language. Therefore, in this embodiment, Figure 2 As shown, standard specification documents include national standards, enterprise specifications, industry standards and open source specifications; various types of standard specification documents are collected in advance and data preprocessed. After document filtering, document segmentation and knowledge extraction, each type of standard specification document is formed into a data foundation with a consistent structure so as to be used in the pre-training process of the large model.

[0036] In this embodiment, document filtering of standard specification documents includes unified character encoding, elimination of redundant and repeated content, removal of special characters and HTML tags, processing of spelling errors, and simultaneous word segmentation, identification and removal of stop words, segmentation, sentence segmentation and conversion of text to lowercase; deleting document directories to avoid the large language model from judging the presence of relevant control statements in the document. All these steps ensure that a clean, structured and consistent data foundation is provided for subsequent extraction work.

[0037] The document segmentation process for standard specification documents complies with the maximum context length of the large model, and divides the standard specification documents into multiple blocks of different sizes. The maximum length of each block is determined by the maximum context length of the large model itself. In actual operation, the segmentation of document blocks can be based on the structure of natural language, such as paragraphs, sentences or topics. In order to avoid information loss or context breakage, the semantic integrity should be maintained as much as possible during segmentation. Therefore, the sliding window method is used in the document segmentation process to overlap the content of a preset length between adjacent blocks, that is, the content that has been sorted to a certain extent, to ensure the coherence and integrity of the information.

[0038] The knowledge extraction process for standard specification documents aims to identify content related to code compliance detection rules from the filtered and segmented documents. Specifically, it involves analyzing key information in the document blocks to extract compliance requirements such as laws, regulations, industry standards, and best practices, and organize them into structured knowledge fragments. These knowledge fragments contain detailed compliance descriptions, sample codes, and potential risk response strategies, providing developers with important compliance guidance when writing and reviewing code to ensure that their products comply with relevant standards.

[0039] In the knowledge guidance part, in order to reduce the dependence of the large model on external knowledge, a relatively small data and a pre-trained large language model are used to generate relevant contextual knowledge, namely, code compliance detection knowledge. The relatively small data here refers to the preset content in the first database introduced below, combined with Figure 3 As shown in the process flow, since suitable samples are the key to generating high-quality prompt words, this embodiment uses historical knowledge of similar topics or conversation contexts to help the large language model generate correct detection knowledge that is relevant to the historical conversation context.

[0040] In the process of generating code compliance detection knowledge by the big model in this embodiment, the big model is pre-trained through the extracted knowledge fragments and the pre-constructed prompt word templates; the historical conversation samples obtained after each pre-training are stored in the database, and new prompt words are constructed as the basis for the next training, and the big model generates new code compliance detection knowledge based on the new prompt words. Specifically, the structure of the historical conversation samples includes topics, historical conversations, and detection knowledge; topics and historical conversations are obtained through pre-constructed prompt word templates, and detection knowledge is generated and obtained by the big model after each training; after each training of the big model, the topic of the most recent conversation in the training and the generated code compliance detection knowledge are stored in the database to form the corresponding historical conversation samples; in the next training, based on the historical conversations and the code compliance detection knowledge generated by the historical conversations, new prompt words are constructed to generate new code compliance detection knowledge.

[0041] In this embodiment, the generation process of code compliance detection knowledge adopts a query-based sample selection method to select historical conversation samples from the database; based on the input query q, a query is performed in the similarity sample library D (containing multiple pre-constructed samples, which are used to generate relevant prompts and knowledge) in the database; in order to ensure that the selected samples are relevant to the query, a pre-trained encoder SE is used to obtain the data sample d corresponding to each historical conversation sample of the query i The data sample d is queried by the following formula i The similarity of each sentence in Sim weight :

[0042] Sim weight (q,d i )=w1·SE(t+h)+w2·SE(t i +h i )

[0043] Where q represents the input query, i.e., the context of the question asked by the user or the knowledge required; d i represents the i-th data sample in the similarity sample library D, which contains information related to a specific topic or session; w1 and w2 represent the corresponding weights, that is, the importance of the topic and historical information; t represents the topic, which refers to the topic or subject involved in the query, and t i represents the specific topic of the i-th data sample, which is usually closely related to the sample content; h represents the historical conversation, which contains the previous communication content between the user and the big model, and h i Represents the specific historical conversation of the i-th data sample; after the query, select the n historical conversation samples with the highest similarity scores.

[0044] The i-th data sample d i The build hint is in represents the historical conversation information of the i-th data sample, which is usually the context related to the sample, k i represents the knowledge output of the i-th data sample, which is the final knowledge content generated by the large model based on the constructed prompts; when the user inputs the conversation, the current conversation context prompt word h * Indicates historical conversation information, symbol Represents guiding the pre-trained model to generate knowledge. When generating knowledge, only the last dialogue turn is used to construct prompts, because the previous dialogue turns are usually irrelevant to knowledge generation, and adding redundant information may have a negative impact on the generation results.

[0045] In the constructed prompt, since the knowledge output k of the i-th data sample i Usually related to the specific topic t of the i-th data sample iThe relationship is greater than the historical conversation information Closer, so the knowledge output k i Place near a specific topic i Finally, the separator seq is used to connect the constructed prompt words as the input knowledge P of the pre-training model. final , as follows:

[0046] P final =prompt1+seq+prompt2+seq+…+prompt n +seq+prompt cuur

[0047] The separator seq represents the symbol "\n". Since it is used to separate prompt words, the large model will use "\n" as a separator during the generation process and randomly generate another example after completing the knowledge generation. Therefore, the generated sentence before the "\n" symbol is regarded as the code compliance detection knowledge k′.

[0048] Finally, the code compliance detection knowledge k′=LLM(P final ), where LLM represents the pre-trained large language model as a large model, which is responsible for generating relevant knowledge content based on the input prompts. Through the above content, the relevance and accuracy of the generated content are ensured during the sample selection and knowledge generation process.

[0049] Regarding the context understanding part, this embodiment is introduced as follows: When the preset data set is small, it may cause the data of the large model to overfit; therefore, by prompting the pre-trained model, the response is generated to avoid fine-tuning. In order to generate more accurate prompt words, more attention should be paid to the selection of samples and the response information when selecting samples, see Figure 4 The key to the process diagram given is to effectively utilize the code compliance detection knowledge generated in the previous article so that the response generated here is knowledge-rich and can be used as the final code compliance detection rule. The large model used in this part is the same as the large model used in the knowledge guidance part, both of which are large language models.

[0050] In the process of generating code compliance detection rules by the big model in this embodiment, after the big model constructs corresponding prompt words and responses based on the code compliance detection knowledge and the prompt words input by the user conversation, the prompt words and responses constructed by the big model are stored in the database to form corresponding conversation response samples; the conversation response samples are used as the basis for further training of the big model, and the conversation response samples include topics and historical conversations, as well as corresponding code compliance detection knowledge and response results.

[0051] This embodiment considers that only a small number of dialogue samples can be provided to the large model. Unless the dialogue response has a strong connection with the knowledge in the provided sample, it is difficult for it to learn how to generate responses based on knowledge. Therefore, it is necessary to focus on selecting samples whose responses are rich in knowledge and highly dependent on the corresponding real knowledge. Specifically, each conversation response sample in the database calculates the contribution of its own code compliance detection knowledge to its own response result through the word overlap rate; in the process of generating code compliance detection rules, the conversation response samples with word overlap rates within the preset range are selected as reference inputs for the large model to generate code compliance detection rules.

[0052] Specifically, the word overlap rate of conversation response samples ranges from 0 to 1. The lower limit of the word overlap rate of conversation response samples within the preset range is 0.6. This is to eliminate irrelevant information during actual training. Therefore, it is necessary to filter out example samples with a ratio lower than 0.6; the upper limit is 0.9. This is because responding to overly specialized knowledge may also reduce its effectiveness. Since we hope that the response contains information other than professional knowledge, it is also necessary to filter out example samples with a ratio higher than 0.9.

[0053] After all the conversation response samples within the preset range are selected, in order to ensure that the method does not depend on the conversation context, some conversation response samples can be further screened out in a random manner as reference input. Conversation response samples that are not within the preset range are all filtered out in the process of generating prompt words related to the user conversation.

[0054] The final response generation process can also be seen Figure 4 The process diagram shows that in order to increase the contextual understanding ability of the big model, we focus on building intuitive prompts for the selected examples. Based on the examples of the selected conversation response samples, we construct the corresponding example prompt words and input them into the big model. For the example prompt words, "system" and "user" are used to connect different rounds in the historical conversation, and "known information" and "system response" are used to introduce code compliance detection knowledge and response results respectively; when the big model responds to the conversation, for the input of the user conversation and the prompts from the example prompt words, the same template as the example prompt words is used, and the "system response" part of the example prompt words is left blank, and the code compliance detection rules are generated by the big model. Users use the rule prompt words corresponding to the code compliance detection rules to detect whether the code submitted in the conversation meets the requirements of the standard specification document.

[0055] In summary, this embodiment realizes the use of rule prompt words generated by a large language model to support different programming languages ​​and code compliance detection frameworks to detect whether the code complies with relevant national / industry / enterprise standards or specifications.

Claims

1. A code compliance detection method based on a large model, characterized in that: The method uses user conversations as additional supplementary knowledge for training, and guides the big model to perform code compliance detection. First, corresponding knowledge fragments are extracted from standard specification documents, and the knowledge fragments are combined with prompt words input by user conversations to pre-train the big model, and guide the big model to generate corresponding code compliance detection knowledge. Combine code compliance detection knowledge with prompt words input by user conversations to strengthen the contextual understanding ability of the big model, generate code compliance detection rules based on the big model response, and implement code compliance detection based on the code compliance detection rules.

2. The code compliance detection method based on a large model according to claim 1 is characterized in that: Standard specification documents include national standards, enterprise specifications, industry standards and open source specifications. Various types of standard specification documents are collected in advance and data preprocessing is performed. After document filtering, document segmentation and knowledge extraction, each type of standard specification document is formed into a data foundation with a consistent structure so as to be used in the pre-training process of the large model.

3. The code compliance detection method based on a large model according to claim 2 is characterized in that: Document filtering for standard specification documents includes unified character encoding, elimination of redundant and repeated content, removal of special characters and HTML tags, processing of spelling errors, word segmentation, identification and removal of stop words, segmentation, sentence segmentation and conversion of text to lowercase, and deletion of document directories; The document segmentation process for standard specification documents complies with the maximum context length of the large model, and divides the standard specification documents into multiple blocks of different sizes. The maximum length of each block is determined by the maximum context length of the large model itself. The document segmentation process adopts a sliding window method to overlap the content of the preset length between adjacent blocks. The knowledge extraction process for standard specification documents is as follows: after identifying the content related to the code compliance detection rules from the standard specification documents that have been segmented, they are organized into structured knowledge fragments; the knowledge fragments include compliance descriptions, sample codes, and potential risk response strategies.

4. The code compliance detection method based on a large model according to claim 1 is characterized in that: In the process of the big model generating code compliance detection knowledge, the big model is pre-trained through the extracted knowledge fragments and the pre-constructed prompt word templates; the historical conversation samples obtained after each pre-training are stored in the database as the basis for the next training to construct new prompt words, and the big model generates new code compliance detection knowledge based on the new prompt words.

5. The code compliance detection method based on a large model according to claim 4 is characterized in that: The structure of historical conversation samples includes topics, historical conversations, and detection knowledge. Topics and historical conversations are obtained through pre-constructed prompt word templates, and detection knowledge is generated and obtained by the large model after each training. After each training of the large model, the topics of the most recent conversations in the training and the generated code compliance detection knowledge are stored in the database to form the corresponding historical conversation samples; During the next training, new prompt words are constructed based on the historical dialogue and the code compliance detection knowledge generated by the historical dialogue to generate new code compliance detection knowledge.

6. The code compliance detection method based on a large model according to claim 5 is characterized in that: The generation process of code compliance detection knowledge adopts a query-based sample selection method to select historical conversation samples from the database; based on the input query q, a query is performed in the similarity sample library D in the database, and a pre-trained encoder SE is used to obtain the data sample d corresponding to each historical conversation sample queried i The data sample d is queried by the following formula i The similarity of each sentence in Sim weight : Sim weight (q,d i )=w1·SE(t+h)+w2·SE(t i +h i ) Where q represents the input query; d i represents the i-th data sample in the similarity sample library D; w1 and w2 represent the corresponding weights; t indicates the topic, t i Represents the specific topic of the i-th data sample; h indicates historical dialogue, h i represents the specific historical conversation of the i-th data sample; after querying, select the n historical conversation samples with the highest similarity scores; The i-th data sample d i The build hint is in represents the historical conversation information of the i-th data sample, k i Represents the knowledge output of the i-th data sample; when the user inputs a conversation, the current conversation context prompt word h * Indicates historical conversation information, symbol Indicates guiding the pre-trained model to generate knowledge; when generating knowledge, only the last dialogue round is used to construct prompts; in the constructed prompts, the knowledge output of the i-th data sample is k i Placed near the specific topic t of the i-th data sample i Finally, the separator seq is used to connect the constructed prompt words as the input knowledge p of the pre-training model. final , as follows: P final =prompt1+seq+prompt2+seq+…+prompt n +seq+prompt cuur Finally, the code compliance detection knowledge k′=LLM(P final ), where LLM represents the pre-trained large language model as a large model.

7. The code compliance detection method based on a large model according to claim 1 is characterized in that: In the process of the big model generating code compliance detection rules, after the big model constructs corresponding prompt words and responses based on the code compliance detection knowledge and the prompt words input by the user conversation, the prompt words and responses constructed by the big model are stored in the database to form corresponding conversation response samples; the conversation response samples are used as the basis for further training of the big model. The conversation response samples include topics and historical conversations, as well as corresponding code compliance detection knowledge and response results.

8. The code compliance detection method based on a large model according to claim 7 is characterized in that: Each conversation response sample calculates the contribution of its own code compliance detection knowledge to its own response result through the word overlap rate; in the process of generating code compliance detection rules, the conversation response samples with word overlap rates within the preset range are selected as reference inputs for the large model to generate code compliance detection rules.

9. The code compliance detection method based on a large model according to claim 8 is characterized in that: The word overlap rate of the conversation response samples ranges from 0 to 1, and the lower limit of the word overlap rate of the conversation response samples within the preset range is 0.6, and the upper limit is 0.9; after all the conversation response samples within the preset range are selected, some conversation response samples are further screened out by random method as reference input; Session response samples that are not within the preset range are all filtered out during the process of generating code compliance detection rules.

10. The code compliance detection method based on a large model according to claim 8, characterized in that: Based on the selected examples of conversation response samples, the corresponding sample prompt words are constructed and input into the big model. For the sample prompt words, "system" and "user" are used to connect different rounds in the historical conversation, and "known information" and "system response" are used to introduce code compliance detection knowledge and response results respectively. When the big model performs conversation response, for the input of the user conversation and the prompt from the sample prompt words, the same template as the sample prompt words is used, and the "system response" part of the sample prompt words is left blank, and the big model generates the code compliance detection rules. The user uses the rule prompt words corresponding to the code compliance detection rules to detect whether the code submitted in the conversation meets the requirements of the standard specification document.