Large model thinking chain evaluation method and system for formal theorem proof
By constructing and evaluating the large model thinking chain evaluation method for formal theorem proof, we determine the data types that the model relies on during reasoning, optimize training data and strategies, solve the problem of poor interpretability of large models, and improve the efficiency of formal theorem proof. and accuracy, ensuring security checks on computer systems.
Patent Information
- Application Number
- CN202410836289.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-06-26
AI Technical Summary
The large models used for formal theorem proof in the existing technology lack interpretability, making it difficult to understand its internal reasoning process and decision-making mechanism, resulting in the inability to determine whether the model truly understands the rules and logic of the proof, and the lack of a complete thinking chain evaluation method. Influence training data and policy improvements.
A large model thinking chain evaluation method is proposed. By constructing the original data set, including the proof steps of the formal theorem formed by the transformation of computer system security attributes, state change tree data and premise library, the model is trained and the performance of different data sets is compared to determine The model depends on the data type during inference, and then corrects the training set and strategy to optimize model performance.
By evaluating the thinking chain of large models, we find key points, optimize training data and strategies, improve the interpretability and performance of the model, and ensure the security check of the computer system.
Smart Images

Figure CN118709791A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a large-model thinking chain evaluation method and system for formalized theorem proof. Background Art
[0002] Formal theorem proving technology is a technology that uses mathematical and logical methods to verify the correctness of mathematical theorems. This technology expresses mathematical theorems and proof processes in a rigorous, formal language, and then uses computer programs to check the correctness of these proofs. Formal theorem proving technology provides a rigorous and systematic method to verify mathematical theorems, and it plays a key role in ensuring the correctness and security of the fields of mathematics and computer science. At present, the manual proof of formal theorem proofs faces the challenges of high entry barriers and high costs. Writing formal theorem proofs requires deep mathematical and logical knowledge, a steep learning curve, and the need to master complex proof tools. In addition, the proof is labor-intensive and usually takes weeks or even months to complete, and the time spent on proofs often exceeds the time required for development. High entry barriers and high costs currently hinder the application of formal theorem proving technology.
[0003] Large language model technology has been applied in the field of formal theorem proving. Large language model technology is a natural language processing technology based on deep learning. It trains large-scale neural network models to enable them to understand and generate natural language. This technology has been widely used in various fields such as intelligent customer service, machine translation, and sentiment analysis. In the field of formal theorem proving, large language models can replace manual proof writing by learning from the theorem proof database, significantly reducing the manpower and time costs of formal verification work.
[0004] There are many works on training large models for formal theorem proving, and the training data construction methods and training strategies of these works are different. For example, models such as LeanDojo focus on the changes in the proof status during training, and add the changes in the proof status under each proof step to the data, thereby training the model's logical reasoning ability for the proof steps. Models such as Baldur delete a large number of proof state trees in the data, and the output of the model can simplify the proof. Models such as LEGO-PROVER try to build a growing skill library, focus on searching the theorem premise library, and try to let the model learn more useful rules and use them. The large models trained by these works have certain reasoning capabilities and can complete formal theorem proving work in specific data sets.
[0005] Prior art Theorem proving method, device, electronic device and storage medium based on machine learning (publication number CN110443369A) discloses a theorem proving method, device, electronic device and storage medium based on machine learning. The theorem proving method based on machine learning includes obtaining the intermediate reasoning steps of the target proposition according to the target proposition; using a pre-trained recognition model to determine the target reasoning steps that can be used to prove the target proposition from the intermediate reasoning steps; and using the target reasoning steps to prove the target proposition through a formalized theorem proving method. This technical solution simplifies the proof process of the target proposition, compresses the search space of the intermediate reasoning steps, and improves the efficiency and automation of proposition proof.
[0006] Prior art A method for generating content based on large language model reasoning based on implicit thinking chain (publication number CN117892818A) discloses a method for generating content based on large language model reasoning based on implicit thinking chain, which mainly includes: using the question-answering ability of the pre-trained large language model to prompt the model to generate a textual thinking process by asking questions; inputting its thinking process into the text embedding model to extract the high-dimensional implicit embedding of the thinking process; using the high-dimensional implicit embedding as the input of the large language model, replacing the original thinking chain process, and guiding the large language model to output the correct reasoning result. This invention makes full use of the small sample imitation ability of the large language model, and at the same time uses its ability to obtain the correct answer with the help of the reasoning process, which improves the performance of the large language model on reasoning-related problems, and has better accuracy than the existing methods, and has strong versatility, and is suitable for any large language model to generate any reasoning-related problems.
[0007] Although large models for formal theorem proving have shown some potential in automatically generating proofs, they have poor interpretability and lack a complete thought chain evaluation method. This means that it is unclear whether the large model has learned the rules or logic of the proof, which makes the construction of training data and training strategies lack theoretical guidance. In formal theorem proving, the rules and logic of the proof are crucial. The rules of proof refer to the axioms and theorems used to derive the proof, while logic refers to the reasoning process used to organize the proof. However, large models have poor interpretability and it is difficult to understand their internal reasoning process and decision-making mechanism. This makes it impossible to determine whether the large model truly understands the rules and logic of the proof, or just generates the proof through pattern matching. In addition, due to the lack of a complete thought chain evaluation method, it is impossible to further improve the training data and training strategy.
[0008] Therefore, although large models have made some progress in formal theorem proving, the lack of a complete thought chain evaluation method is still a problem that needs to be solved. In view of the above problems, the present invention aims to study a large model thought chain evaluation method in the field of formal theorem proving, which can evaluate the thought chain of large models in the field of formal theorem proving, find the key points of the large model to complete theorem proving, and provide a theoretical basis for the construction of training data and training strategies of the theorem proving model. Summary of the invention
[0009] The present invention provides a large-model thinking chain evaluation method and system for formalized theorem proving, which are used to solve the technical problems that the large models in the prior art have poor interpretability and are difficult to understand their internal reasoning processes and decision-making mechanisms.
[0010] In a first aspect, a large model thinking chain evaluation method for formalized theorem proving is disclosed, the method comprising the following steps:
[0011] Step S1: constructing an original data set, wherein the data in the original data set includes proof steps of a formalized theorem formed by the conversion of computer system security attributes, state change tree data for characterizing the state change of the computer system after each proof step of the formalized theorem formed by the conversion is executed, and a premise library, wherein: the premise library is composed of premise data, and the premise data is the premise that needs to be satisfied for the formalized theorem formed by the conversion to be formalized.
[0012] Among the proof steps, some of the proof steps include references to the state change tree data and / or premise data required by them;
[0013] The original data set is used to train the large model, and the trained large model is obtained as the benchmark model; wherein the state change tree is a data structure composed of the state changes of the proof target and the computer system in the process of formal theorem proof, and the premise is the axiom, hypothesis or definition that needs to be relied on or based on in the formal theorem proof;
[0014] Step S2: Based on the original data set, construct a first data set including only state data tree data and a second data set including only premise data; use the first data set to train the large model to obtain a trained first large model; use the second data set to train the large model to obtain a trained second large model;
[0015] The proof success rate, the accuracy of the proof steps, and the completeness of the proof of the benchmark model are used as benchmark intermediate data, the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the first large model are used as first intermediate data, and the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the second large model are used as second intermediate data; based on the comparison results of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined;
[0016] Step S3: Selecting a number of state change tree data and a number of premise data from the original data set to form a third data set;
[0017] The baseline model includes a calculation layer for calculating attention, the calculation layer calculates attention weights for data in the original data set, and uses the average value of the calculated attention weights as the baseline attention data; the calculation layer calculates attention weights for data in the third data set, and uses the calculated attention weights as the third attention data; based on the comparison result of the baseline attention data and the third attention data, determining the second performance of the baseline model;
[0018] Step S4: sampling a number of proof steps containing citations from the original data set as a fourth data set;
[0019] The output of the benchmark model under the prompt of the proof step of the original data set is used as the benchmark thinking chain prompt data; the proof step of the reference containing only the state change tree data and the proof step containing only the premise data in the fourth data set are respectively input into the benchmark model, and the output of the benchmark model under the prompt of the proof step of the fourth data set is used as the fourth benchmark thinking chain prompt data; based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, the third performance of the benchmark model is determined; wherein, the thinking chain refers to the reasoning steps inside the benchmark model;
[0020] Step S5: Based on the first performance, the second performance, and the third performance, the original data set is corrected to obtain a corrected training set; a correction method for the training method is determined; and the trained large model is trained again with the corrected training set to obtain a new trained large model.
[0021] Preferably, in step S2, based on the comparison result of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined, wherein:
[0022] If the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data, it indicates that the benchmark model is more dependent on the state change tree data during reasoning; if the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data, it indicates that the benchmark model is more dependent on the premise data during reasoning; if the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data, it indicates that the benchmark model needs both state change tree data and premise data during reasoning; wherein:
[0023]
[0024] Preferably, the step S3, based on the comparison result between the baseline attention data and the third attention data, determines the second performance of the baseline model, including:
[0025] If the comparison result is that the attention weight on the state change tree data in the third attention data is higher than the attention weight on the premise data in the third attention data and the baseline attention data, then it indicates that the baseline model is more dependent on the state change tree data during reasoning; if the comparison result is that the attention weight on the premise library data in the third attention data is higher than the attention weight on the state change tree data in the third attention data and the baseline attention data, then it indicates that the baseline model is more dependent on the premise library data during reasoning; if the comparison result is that the baseline attention data is higher than the attention weight on the state change tree data in the third attention data and the attention weight on the premise library data in the third attention data, then it indicates that the baseline model needs both the state change tree data and the premise library data during reasoning.
[0026] Preferably, the step S4, based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, determines the third performance of the benchmark model, including:
[0027] If the comparison result is that in the fourth benchmark thinking chain prompt data, the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the premise data, and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data in the benchmark thinking chain, then it indicates that the benchmark model relies more on the state change tree data during reasoning; the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data. , and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the proof steps in the benchmark thinking chain, which indicates that the benchmark model relies more on the premise data during reasoning; the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data, and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing state change tree data, which indicates that the benchmark model needs both state change tree data and premise library data during reasoning.
[0028] Preferably, the step S5: based on the first performance, the second performance, and the third performance, the original data set is corrected to obtain a corrected training set; a correction method of the training method is determined; and the trained large model is trained again with the corrected training set to obtain a new trained large model, specifically:
[0029] If the first performance, the second performance, and the third performance all indicate that the benchmark model is more dependent on the state change tree during reasoning, then the original data set is corrected by adding a number of state change tree data to the original data set to form a corrected training set; the training method is corrected by randomly masking the proof steps in the corrected training set during the training process, and retraining the trained large model based on the random mask;
[0030] If the first performance, the second performance, and the third performance all indicate that the benchmark model is more dependent on the premise library data during reasoning, then the original data set is modified by adding premise data to the premise library of the original data set, and injecting the newly added premise data into the trained large model; the training method is modified by using data containing the proof axiom corpus to pre-train the trained large model, and then using the original data set to train the pre-trained large model;
[0031] If the first performance, the second performance, and the third performance all indicate that the benchmark model needs both state change tree data and premise library data during reasoning, there is no need to modify the original data set and the training method.
[0032] In a second aspect, a large-model thinking chain evaluation system for formalized theorem proving is disclosed, the system comprising:
[0033] Training module: configured to construct an original data set, wherein the data in the original data set includes proof steps of a formalized theorem formed by the conversion of computer system security attributes, state change tree data for characterizing the state change of the computer system after each proof step of the formalized theorem formed by the conversion is executed, and a premise library, wherein: the premise library is composed of premise data, and the premise data is the premise that needs to be satisfied for the formalized theorem formed by the conversion to be formalized.
[0034] Among the proof steps, some of the proof steps include references to the state change tree data and / or premise data required by them;
[0035] The original data set is used to train the large model, and the trained large model is obtained as the benchmark model; wherein the state change tree is a data structure composed of the state changes of the proof target and the computer system in the process of formal theorem proof, and the premise is the axiom, hypothesis or definition that needs to be relied on or based on in the formal theorem proof;
[0036] The first performance module is configured to construct a first data set including only state data tree data and a second data set including only premise data based on the original data set; train the large model using the first data set to obtain a trained first large model; and train the large model using the second data set to obtain a trained second large model;
[0037] The proof success rate, the accuracy of the proof steps, and the completeness of the proof of the benchmark model are used as benchmark intermediate data, the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the first large model are used as first intermediate data, and the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the second large model are used as second intermediate data; based on the comparison results of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined;
[0038] A second performance module: configured to select a number of state change tree data and a number of premise data from the original data set to form a third data set;
[0039] The baseline model includes a calculation layer for calculating attention, the calculation layer calculates attention weights for data in the original data set, and uses the average value of the calculated attention weights as the baseline attention data; the calculation layer calculates attention weights for data in the third data set, and uses the calculated attention weights as the third attention data; based on the comparison result of the baseline attention data and the third attention data, determining the second performance of the baseline model;
[0040] A third performance module: configured to sample a number of proof steps including references from the original data set as a fourth data set;
[0041] The output of the benchmark model under the prompt of the proof step of the original data set is used as the benchmark thinking chain prompt data; the proof step of the reference containing only the state change tree data and the proof step containing only the premise data in the fourth data set are respectively input into the benchmark model, and the output of the benchmark model under the prompt of the proof step of the fourth data set is used as the fourth benchmark thinking chain prompt data; based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, the third performance of the benchmark model is determined; wherein, the thinking chain refers to the reasoning steps inside the benchmark model;
[0042] Adjustment module: configured to modify the original data set based on the first performance, the second performance, and the third performance to obtain a modified training set; determine a modification method for the training method; and re-train the trained large model with the modified training set to obtain a new trained large model.
[0043] In a third aspect, an electronic device is disclosed, the electronic device comprising:
[0044] at least one processor; and
[0045] a memory communicatively connected to the at least one processor; wherein,
[0046] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described above.
[0047] In a fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is disclosed, wherein the computer instructions are used to cause the computer to execute the method as described above.
[0048] The present invention proposes a method for evaluating the thinking chain of a large model in the field of formal theorem proof, applies the thinking chain evaluation method to the large model in the field of formal theorem proof, and designs an evaluation method based on the characteristics of formal theorem proof data, and uses data structures unique to the fields of proof status tree, premise library, etc. to evaluate the thinking chain.
[0049] The present invention provides theoretical support for the construction of large-model training data and strategy selection in the field of formalized theorem proving. Through the method proposed in the present invention, the key points in the large-model thinking chain can be found, and then the training data and training strategy can be optimized, and computing resources can be used efficiently. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A flowchart of the large model thinking chain evaluation method for formal theorem proving;
[0051] Figure 2 A schematic diagram of the architecture of the large model thinking chain evaluation method for formal theorem proving;
[0052] Figure 3 This is a schematic diagram of the ablation experiment data comparison process;
[0053] Figure 4 Schematic diagram of the attention visualization analysis process for large models;
[0054] Figure 5 Provide a flowchart for the thought chain prompt;
[0055] Figure 6 Schematic diagram of the structure of the large model thinking chain evaluation system for formal theorem proving. DETAILED DESCRIPTION
[0056] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0057] like Figure 1-Figure 2 As shown, the present invention provides a large model thinking chain evaluation method for formal theorem proving, the method comprising the following steps:
[0058] Step S1: constructing an original data set, wherein the data in the original data set includes proof steps of a formalized theorem formed by the conversion of computer system security attributes, state change tree data for characterizing the state change of the computer system after each proof step of the formalized theorem formed by the conversion is executed, and a premise library, wherein: the premise library is composed of premise data, and the premise data is the premise that needs to be satisfied for the formalized theorem formed by the conversion to be formalized.
[0059] Among the proof steps, some of the proof steps include references to the state change tree data and / or premise data required by them;
[0060] The original data set is used to train the large model, and the trained large model is obtained as the benchmark model; wherein the state change tree is a data structure composed of the state changes of the proof target and the computer system in the process of formal theorem proof, and the premise is the axiom, hypothesis or definition that needs to be relied on or based on in the formal theorem proof;
[0061] Step S2: Based on the original data set, construct a first data set including only state data tree data and a second data set including only premise data; use the first data set to train the large model to obtain a trained first large model; use the second data set to train the large model to obtain a trained second large model;
[0062] The proof success rate, the accuracy of the proof steps, and the completeness of the proof of the benchmark model are used as benchmark intermediate data, the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the first large model are used as first intermediate data, and the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the second large model are used as second intermediate data; based on the comparison results of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined;
[0063] Step S3: Selecting a number of state change tree data and a number of premise data from the original data set to form a third data set;
[0064] The baseline model includes a calculation layer for calculating attention, the calculation layer calculates attention weights for data in the original data set, and uses the average value of the calculated attention weights as the baseline attention data; the calculation layer calculates attention weights for data in the third data set, and uses the calculated attention weights as the third attention data; based on the comparison result of the baseline attention data and the third attention data, determining the second performance of the baseline model;
[0065] Step S4: sampling a number of proof steps containing citations from the original data set as a fourth data set;
[0066] The output of the benchmark model under the prompt of the proof step of the original data set is used as the benchmark thinking chain prompt data; the proof step of the reference containing only the state change tree data and the proof step containing only the premise data in the fourth data set are respectively input into the benchmark model, and the output of the benchmark model under the prompt of the proof step of the fourth data set is used as the fourth benchmark thinking chain prompt data; based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, the third performance of the benchmark model is determined; wherein, the thinking chain refers to the reasoning steps inside the benchmark model;
[0067] Step S5: Based on the first performance, the second performance, and the third performance, the original data set is corrected to obtain a corrected training set; a correction method for the training method is determined; and the trained large model is trained again with the corrected training set to obtain a new trained large model.
[0068] The present invention can be applied to the inspection of guaranteeing the security of computer systems, and the security attributes of computer systems are used as formalized theorems for the steps of theorem proof to be generated.
[0069] The following are the conversion steps required to transform the security properties of a computer system into a formal theorem: (1) Select a security property of the computer system, such as "the system does not allow unauthorized access", or a functional property, such as "the system always responds to every input." (2) Define a formal language: Next, you need to select or define a formal language that can describe the state and behavior of the computer system. This language usually contains logical symbols and axioms to facilitate expression and reasoning. (3) Convert to a formal theorem: Convert the selected characteristics of the computer system into a formal proposition. For example, "the system does not allow unauthorized access" is formalized as "for all users u and actions a, if u is not authorized to perform a, then the system will not perform a."
[0070] The inspection methods for ensuring the security of computer systems can be applied to aerospace control software, operating system kernels, compilers, hardware design, network protocols and other fields.
[0071] The present invention aims to evaluate the thinking chain of a large model used for formal theorem proving through methods such as ablation experiments, attention visualization, and thinking chain prompts, combined with the characteristics of the theorem proving dataset, so as to conduct targeted and focused training on the large model and obtain a large model with better performance.
[0072] The step S2, the step S2, determines the first performance of the benchmark model based on the comparison result of the first intermediate data, the second intermediate data and the benchmark intermediate data, wherein:
[0073] If the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data, it indicates that the benchmark model is more dependent on the state change tree data during reasoning; if the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data, it indicates that the benchmark model is more dependent on the premise data during reasoning; if the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data, it indicates that the benchmark model needs both state change tree data and premise data during reasoning; wherein:
[0074]
[0075] The step S3, determining the second performance of the baseline model based on the comparison result between the baseline attention data and the third attention data, comprises:
[0076] If the comparison result is that the attention weight on the state change tree data in the third attention data is higher than the attention weight on the premise data in the third attention data and the baseline attention data, then it indicates that the baseline model is more dependent on the state change tree data during reasoning; if the comparison result is that the attention weight on the premise library data in the third attention data is higher than the attention weight on the state change tree data in the third attention data and the baseline attention data, then it indicates that the baseline model is more dependent on the premise library data during reasoning; if the comparison result is that the baseline attention data is higher than the attention weight on the state change tree data in the third attention data and the attention weight on the premise library data in the third attention data, then it indicates that the baseline model needs both the state change tree data and the premise library data during reasoning.
[0077] In the present invention, based on existing visualization tools or technologies (such as TensorBoard, Pytorch, etc.), the attention weights in the self-attention layer of the benchmark model when processing specific data samples can be calculated and compared.
[0078] The step S4, based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, determines the third performance of the benchmark model, including:
[0079] If the comparison result is that in the fourth benchmark thinking chain prompt data, the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the premise data, and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data in the benchmark thinking chain, then it indicates that the benchmark model relies more on the state change tree data during reasoning; the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data. , and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the proof steps in the benchmark thinking chain, which indicates that the benchmark model relies more on the premise data during reasoning; the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data, and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing state change tree data, which indicates that the benchmark model needs both state change tree data and premise library data during reasoning.
[0080] The step S5: based on the first performance, the second performance, and the third performance, the original data set is corrected to obtain a corrected training set; a correction method of the training method is determined; and the trained large model is trained again with the corrected training set to obtain a new trained large model, specifically:
[0081] If the first performance, the second performance, and the third performance all indicate that the benchmark model is more dependent on the state change tree during reasoning, then the original data set is corrected by adding a number of state change tree data to the original data set to form a corrected training set; the training method is corrected by randomly masking the proof steps in the corrected training set during the training process, and retraining the trained large model based on the random mask;
[0082] If the first performance, the second performance, and the third performance all indicate that the benchmark model is more dependent on the premise library data during reasoning, then the original data set is modified by adding premise data to the premise library of the original data set, and injecting the newly added premise data into the trained large model; the training method is modified by using data containing the proof axiom corpus to pre-train the trained large model, and then using the original data set to train the pre-trained large model;
[0083] If the first performance, the second performance, and the third performance all indicate that the benchmark model needs both state change tree data and premise library data during reasoning, there is no need to modify the original data set and the training method.
[0084] like Figure 3 As shown in Figure 1, ablation experiments are a common method for evaluating large models, especially deep learning models. The main purpose of this method is to understand the contribution of each component in the model to the performance of the model. By systematically removing or disabling certain parts of the model, it is possible to observe how these changes affect the final performance of the model, thereby better understanding how the model works.
[0085] (1) Preparation of reference data set
[0086] Prepare the original dataset, make sure it contains the state change tree and the premise library, and create two modified datasets: one dataset that only contains the state change tree but not the premise library, and the other dataset that only contains the premise library but not the state change tree.
[0087] (2) Control model training
[0088] First, the baseline model is trained using the original dataset, and then two new models are trained using the modified dataset: one using only the state change tree data and the other using only the premise database data.
[0089] (3) Performance evaluation
[0090] All three models (baseline model and two modified models) are evaluated on the same test set. Evaluation metrics can include the success rate of theorem proof, the accuracy of proof steps, the completeness of proof, etc.
[0091] (4) Ablation analysis
[0092] Compare the performance of the baseline model and the two modified models. Analyze the performance differences of the models on different datasets to determine which part the model relies more on when reasoning. If the performance of the model using only the state change tree drops significantly, while the performance of the model using only the premise library remains good, it means that the model relies more on the state change tree for reasoning. Conversely, if the performance of the model using only the premise library drops significantly, while the performance of the model using only the state change tree remains good, it means that the model relies more on the premise library for reasoning.
[0093] (5) Improvement of training sets and training methods
[0094] Adjust the way the training set is constructed based on the experimental results and strengthen the model's reliance on key parts. If the model is more dependent on the state change tree, consider increasing the diversity and complexity of the state change tree. If the model is more dependent on the premise library, consider increasing the coverage and depth of the premise library. During the training process, you can try different training strategies, such as data enhancement and adversarial training, to improve the robustness and generalization ability of the model.
[0095] (6) Iterative Optimization
[0096] Retrain the model using the improved training set and training method. Repeat the performance evaluation and result analysis steps to verify the effectiveness of the improvement measures. Further adjust the training set and training method based on the evaluation results until satisfactory proof accuracy and completeness are achieved.
[0097] like Figure 4 As shown in Figure 1, attention visualization is an important method for evaluating large language models, especially when using attention mechanisms. It can help understand how the model allocates attention when processing input data, that is, which parts of the input data the model focuses on when making decisions. This method is very important for improving the interpretability and trust of the model.
[0098] (1) Dataset preparation
[0099] Prepare the original dataset, making sure it contains the state change tree and the premise library. Select some representative samples from the dataset (such as some samples with important premise libraries) for subsequent attention visualization analysis.
[0100] (2) Model training
[0101] Train the model using the original dataset.
[0102] (3) Attention weight collection
[0103] Collect the attention weights of the self-attention layer in the model as it processes representative examples. Make sure the collected attention weights reflect the degree of attention the model pays when processing the state change tree and the premise library.
[0104] (4) Attention Visualization:
[0105] Use visualization tools or techniques (such as charts, heat maps, etc.) to display the attention weights in a visual form, and visualize the attention weights of the state change tree and the premise library respectively.
[0106] (5)Attention analysis
[0107] Analyze the attention visualization results to determine the degree of attention paid by the model when processing the state change tree and the premise library. If the model shows a higher attention weight when processing the state change tree, it means that the model relies more on the state change tree for reasoning. Conversely, if the model shows a higher attention weight when processing the premise library, it means that the model relies more on the premise library for reasoning.
[0108] (6) Improvement of training sets and training methods:
[0109] Adjust the way the training set is constructed based on the attention visualization results, and strengthen the model's reliance on key parts. If the model is more dependent on the state change tree, consider increasing the diversity and complexity of the state change tree. If the model is more dependent on the premise library, consider increasing the coverage and depth of the premise library.
[0110] (7) Iterative optimization:
[0111] Retrain the model using the improved training set and training method, repeat the steps of attention weight collection, visualization, result analysis, and training set and training method improvement to verify the effectiveness of the improvement measures. Further adjust the training set and training method based on the evaluation results until satisfactory proof accuracy and completeness are achieved.
[0112] like Figure 5 As shown in the figure, the thinking chain prompt guides the model to think more deeply by providing a series of intermediate reasoning steps, thereby analyzing the reasoning basis of the model and improving the reasoning ability and performance of the model.
[0113] (1) Tips for building a thinking chain
[0114] Construct two different thought chain prompts for the model: one focuses on the state change tree and the other focuses on the premise library. The thought chain prompt should include a series of intermediate reasoning steps to guide the model to focus on the key information of the state change tree or premise library.
[0115] (2) Dataset preparation
[0116] Prepare the original dataset, make sure it contains the state change tree and premise library, and select some representative samples from the dataset for subsequent experiments.
[0117] (3) Model training
[0118] Train the model using the original dataset.
[0119] (4) Apply the thinking chain prompts
[0120] When the model processes representative examples, apply two different chain of thought prompts. Record the model's output when different chain of thought prompts are applied.
[0121] (5) Thinking chain analysis
[0122] Analyze the model's output when applying different thought chain prompts to determine the model's reliance on the state change tree and premise library when reasoning. If the model shows higher proof accuracy and completeness when applying thought chain prompts that focus on the state change tree, it means that the model relies more on the state change tree for reasoning. Conversely, if the model shows higher proof accuracy and completeness when applying thought chain prompts that focus on the premise library, it means that the model relies more on the premise library for reasoning.
[0123] (6) Improvement of training sets and training methods
[0124] Adjust the way the training set is constructed according to the results of the thought chain prompt experiment, and strengthen the model's reliance on key parts. If the model is more dependent on the state change tree, consider increasing the diversity and complexity of the state change tree. If the model is more dependent on the premise library, consider increasing the coverage and depth of the premise library.
[0125] (7) Iterative Optimization
[0126] Retrain the model using the improved training set and training method. Repeat the steps of applying the thinking chain prompts, result analysis, and training set and training method improvement to verify the effectiveness of the improvement measures. Further adjust the training set and training method based on the evaluation results until satisfactory proof accuracy and completeness are achieved.
[0127] like Figure 6 As shown, the present invention provides a large model thinking chain evaluation system for formal theorem proving, the system comprising:
[0128] Training module: configured to construct an original data set, wherein the data in the original data set includes proof steps of a formalized theorem formed by the conversion of computer system security attributes, state change tree data for characterizing the state change of the computer system after each proof step of the formalized theorem formed by the conversion is executed, and a premise library, wherein: the premise library is composed of premise data, and the premise data is the premise that needs to be satisfied for the formalized theorem formed by the conversion to be formalized.
[0129] Among the proof steps, some of the proof steps include references to the state change tree data and / or premise data required by them;
[0130] The original data set is used to train the large model, and the trained large model is obtained as the benchmark model; wherein the state change tree is a data structure composed of the state changes of the proof target and the computer system in the process of formal theorem proof, and the premise is the axiom, hypothesis or definition that needs to be relied on or based on in the formal theorem proof;
[0131] The first performance module is configured to construct a first data set including only state data tree data and a second data set including only premise data based on the original data set; train the large model using the first data set to obtain a trained first large model; and train the large model using the second data set to obtain a trained second large model;
[0132] The proof success rate, the accuracy of the proof steps, and the completeness of the proof of the benchmark model are used as benchmark intermediate data, the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the first large model are used as first intermediate data, and the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the second large model are used as second intermediate data; based on the comparison results of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined;
[0133] A second performance module: configured to select a number of state change tree data and a number of premise data from the original data set to form a third data set;
[0134] The baseline model includes a calculation layer for calculating attention, the calculation layer calculates attention weights for data in the original data set, and uses the average value of the calculated attention weights as the baseline attention data; the calculation layer calculates attention weights for data in the third data set, and uses the calculated attention weights as the third attention data; based on the comparison result of the baseline attention data and the third attention data, determining the second performance of the baseline model;
[0135] A third performance module: configured to sample a number of proof steps including references from the original data set as a fourth data set;
[0136] The output of the benchmark model under the prompt of the proof step of the original data set is used as the benchmark thinking chain prompt data; the proof step of the reference containing only the state change tree data and the proof step containing only the premise data in the fourth data set are respectively input into the benchmark model, and the output of the benchmark model under the prompt of the proof step of the fourth data set is used as the fourth benchmark thinking chain prompt data; based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, the third performance of the benchmark model is determined; wherein, the thinking chain refers to the reasoning steps inside the benchmark model;
[0137] Adjustment module: configured to modify the original data set based on the first performance, the second performance, and the third performance to obtain a modified training set; determine a modification method for the training method; and re-train the trained large model with the modified training set to obtain a new trained large model.
[0138] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, it should be understood by those skilled in the art that the technical solutions described in the above embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents, and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A large model thinking chain evaluation method for formal theorem proving, characterized in that: The method comprises the following steps: Step S1: constructing an original data set, wherein the data in the original data set includes proof steps of a formalized theorem formed by the conversion of computer system security attributes, state change tree data for characterizing the state change of the computer system after each proof step of the formalized theorem formed by the conversion is executed, and a premise library, wherein: the premise library is composed of premise data, and the premise data is the premise that needs to be satisfied for the formalized theorem formed by the conversion to be formalized. Among the proof steps, some of the proof steps include references to the state change tree data and / or premise data required by them; The original data set is used to train the large model, and the trained large model is obtained as the benchmark model; wherein the state change tree is a data structure composed of the state changes of the proof target and the computer system in the process of formal theorem proof, and the premise is the axiom, hypothesis or definition that needs to be relied on or based on in the formal theorem proof; Step S2: Based on the original data set, construct a first data set including only state data tree data and a second data set including only premise data; use the first data set to train the large model to obtain a trained first large model; use the second data set to train the large model to obtain a trained second large model; The proof success rate, the accuracy of the proof steps, and the completeness of the proof of the benchmark model are used as benchmark intermediate data, the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the first large model are used as first intermediate data, and the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the second large model are used as second intermediate data; based on the comparison results of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined; Step S3: Selecting a number of state change tree data and a number of premise data from the original data set to form a third data set; The baseline model includes a calculation layer for calculating attention, the calculation layer calculates attention weights for data in the original data set, and uses the average value of the calculated attention weights as the baseline attention data; the calculation layer calculates attention weights for data in the third data set, and uses the calculated attention weights as the third attention data; based on the comparison result of the baseline attention data and the third attention data, determining the second performance of the baseline model; Step S4: sampling a number of proof steps containing citations from the original data set as a fourth data set; The output of the benchmark model under the prompt of the proof step of the original data set is used as the benchmark thinking chain prompt data; the proof step of the reference containing only the state change tree data and the proof step containing only the premise data in the fourth data set are respectively input into the benchmark model, and the output of the benchmark model under the prompt of the proof step of the fourth data set is used as the fourth benchmark thinking chain prompt data; based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, the third performance of the benchmark model is determined; wherein, the thinking chain refers to the reasoning steps inside the benchmark model; Step S5: Based on the first performance, the second performance, and the third performance, the original data set is corrected to obtain a corrected training set; a correction method for the training method is determined; and the trained large model is trained again with the corrected training set to obtain a new trained large model.
2. The method according to claim 1, characterized in that The step S2 is to determine the first performance of the benchmark model based on the comparison result of the first intermediate data, the second intermediate data and the benchmark intermediate data, wherein: If the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data, it indicates that the benchmark model is more dependent on the state change tree data during reasoning; if the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data, it indicates that the benchmark model is more dependent on the premise data during reasoning; if the comparison result is that the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the benchmark intermediate data are respectively higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the first intermediate data, and are also higher than the proof success rate, the accuracy of the proof steps, and the completeness of the proof in the second intermediate data, it indicates that the benchmark model needs both state change tree data and premise data during reasoning; wherein:
3. The method according to claim 2, characterized in that The step S3, determining the second performance of the baseline model based on the comparison result between the baseline attention data and the third attention data, includes: If the comparison result is that the attention weight on the state change tree data in the third attention data is higher than the attention weight on the premise data in the third attention data and the baseline attention data, then it indicates that the baseline model is more dependent on the state change tree data during reasoning; if the comparison result is that the attention weight on the premise library data in the third attention data is higher than the attention weight on the state change tree data in the third attention data and the baseline attention data, then it indicates that the baseline model is more dependent on the premise library data during reasoning; if the comparison result is that the baseline attention data is higher than the attention weight on the state change tree data in the third attention data and the attention weight on the premise library data in the third attention data, then it indicates that the baseline model needs both the state change tree data and the premise library data during reasoning.
4. The method according to claim 3, characterized in that The step S4, based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, determines the third performance of the benchmark model, including: If the comparison result is that in the fourth benchmark thinking chain prompt data, the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the premise data, and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data in the benchmark thinking chain, then it indicates that the benchmark model relies more on the state change tree data during reasoning; the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof step containing the state change tree data. , and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the proof steps in the benchmark thinking chain, which indicates that the benchmark model relies more on the premise data during reasoning; the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing premise data, and the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing state change tree data are respectively higher than the average value of the proof success rate and the average value of the accuracy of the proof steps under the prompt of the referenced proof steps containing state change tree data, which indicates that the benchmark model needs both state change tree data and premise library data during reasoning.
5. The method according to claim 4, characterized in that The step S5: based on the first performance, the second performance, and the third performance, the original data set is corrected to obtain a corrected training set; Determine how to modify your training approach; The trained large model is trained again with the revised training set to obtain a new trained large model, specifically: If the first performance, the second performance, and the third performance all indicate that the benchmark model relies more on the state change tree during reasoning, then the original data set is corrected by adding a number of state change tree data to the original data set to form a corrected training set; The training method is modified as follows: during the training process, the proof steps in the modified training set are randomly masked, and the trained large model is trained again based on the random mask; If the first performance, the second performance, and the third performance all indicate that the benchmark model is more dependent on the premise library data during reasoning, then the original data set is corrected by adding premise data to the premise library of the original data set, and injecting the newly added premise data into the trained large model; The training method is modified as follows: pre-training the trained large model using data containing the proof axiom corpus, and then training the pre-trained large model using the original data set; If the first performance, the second performance, and the third performance all indicate that the benchmark model needs both state change tree data and premise library data during reasoning, there is no need to modify the original data set and the training method.
6. A large-model thinking chain evaluation system for formal theorem proving, characterized in that: The system comprises: Training module: configured to construct an original data set, wherein the data in the original data set includes proof steps of a formalized theorem formed by the conversion of computer system security attributes, state change tree data for characterizing the state change of the computer system after each proof step of the formalized theorem formed by the conversion is executed, and a premise library, wherein: the premise library is composed of premise data, and the premise data is the premise that needs to be satisfied for the formalized theorem formed by the conversion to be formalized. Among the proof steps, some of the proof steps include references to the state change tree data and / or premise data required by them; The original data set is used to train the large model, and the trained large model is obtained as the benchmark model; wherein the state change tree is a data structure composed of the state changes of the proof target and the computer system in the process of formal theorem proof, and the premise is the axiom, hypothesis or definition that needs to be relied on or based on in the formal theorem proof; The first performance module is configured to construct a first data set including only state data tree data and a second data set including only premise data based on the original data set; train the large model using the first data set to obtain a trained first large model; and train the large model using the second data set to obtain a trained second large model; The proof success rate, the accuracy of the proof steps, and the completeness of the proof of the benchmark model are used as benchmark intermediate data, the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the first large model are used as first intermediate data, and the proof success rate, the accuracy of the proof steps, and the completeness of the proof of the second large model are used as second intermediate data; based on the comparison results of the first intermediate data, the second intermediate data and the benchmark intermediate data, the first performance of the benchmark model is determined; A second performance module: configured to select a number of state change tree data and a number of premise data from the original data set to form a third data set; The baseline model includes a calculation layer for calculating attention, the calculation layer calculates attention weights for data in the original data set, and uses the average value of the calculated attention weights as the baseline attention data; the calculation layer calculates attention weights for data in the third data set, and uses the calculated attention weights as the third attention data; based on the comparison result of the baseline attention data and the third attention data, determining the second performance of the baseline model; A third performance module: configured to sample a number of proof steps including references from the original data set as a fourth data set; The output of the benchmark model under the prompt of the proof step of the original data set is used as the benchmark thinking chain prompt data; the proof step of the reference containing only the state change tree data and the proof step containing only the premise data in the fourth data set are respectively input into the benchmark model, and the output of the benchmark model under the prompt of the proof step of the fourth data set is used as the fourth benchmark thinking chain prompt data; based on the comparison result of the benchmark thinking chain prompt data and the fourth benchmark thinking chain prompt data, the third performance of the benchmark model is determined; wherein, the thinking chain refers to the reasoning steps inside the benchmark model; Adjustment module: configured to modify the original data set based on the first performance, the second performance, and the third performance to obtain a modified training set; determine a modification method for the training method; and re-train the trained large model with the modified training set to obtain a new trained large model.
7. An electronic device, characterized in that: The device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method for continuously integrating combined formal verification
CN116756000A
SysML state machine diagram formalized demand verification method based on large model
CN117608525A
Alignment evaluation method for Chinese large language model
CN117633225A
Cited By
Scratch virtual teaching demonstration method based on large language model
CN120124664A
