Answer verifiable physical formula question generation method for large model training
By extracting formula information from physics texts, performing rationality checks and deduplication, using a code sandbox to execute unit test code to verify the correctness of the calculation code, and combining parameter combinations to generate questions and perform answer distillation verification, the problem of low efficiency and insufficient accuracy in generating scientific calculation questions in existing technologies is solved, achieving efficient and automated data generation and model training.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-10
- Publication Date
- 2026-03-13
Smart Images

Figure CN121660046A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence and natural language processing, and in particular to a method for generating verifiable physical formula-based questions for training large models. Background Technology
[0002] In recent years, large language models (LLMs) have made significant breakthroughs in the field of natural language processing, and their application scenarios have gradually extended to scientific computing reasoning tasks. Related technical research mainly focuses on three major directions: reasoning data synthesis, construction of verifiable reasoning environments, and development of scientific computing evaluation benchmarks.
[0003] In terms of reasoning data synthesis, existing technologies mainly fall into two paradigms: one is query-centric generation methods, which generate reasoning data by iteratively expanding the initial seed question set. Some solutions integrate the reasoning process into the data generation workflow to enhance content diversity or enhance the gradient level differences of the data through specific techniques. The other is document-centric generation methods, which extract information from structured or unstructured data sources to generate questions, ensuring the subject coverage and knowledge base integrity of the data. Some solutions focus on generating highly difficult reasoning questions. However, both of these methods have significant limitations: the former is easily limited by the coverage of the initial seed question set, while the latter faces technical bottlenecks in controlling the difficulty of the questions. Furthermore, neither method has solved the technical challenge of efficiently generating a large number of logically consistent and flexibly expandable calculation problems for a single knowledge point in scientific fields (such as physics).
[0004] Another related technological direction focuses on the construction of verifiable inference environments and automated evaluation mechanisms. Existing technologies achieve the automatic generation of training or test cases with configurable difficulty by building open-source frameworks containing diverse task environments, and integrate verification modules to achieve objective evaluation. Some solutions construct modular generation environments and corresponding evaluation sets, and utilize agent-environment interaction loops and executable code verification techniques to achieve reinforcement learning. However, such verification frameworks still rely heavily on manual intervention for review and correction in the process of generating core computational code or ensuring answer quality, making it difficult to meet the automation needs of large-scale data generation.
[0005] Regarding scientific computing benchmarks, existing technologies have developed scientific problem assessment systems for different educational stages, covering multiple disciplines such as mathematics, chemistry, and physics. Some assessment systems support the evaluation of multiple answer types and reasoning skills, and have constructed corresponding answer correctness evaluation processes. However, evaluation results of several mainstream large-scale language models show that current models still have significant shortcomings in scientific computing reasoning tasks, especially in physics reasoning tasks. The core reasoning skills of the models still need to be improved, and a unified technical solution that can significantly optimize the reasoning performance of the models has not yet been formed.
[0006] While the aforementioned technologies have provided support for the development of scientific computing reasoning, existing methods for generating and training scientific computing problems still suffer from the following key shortcomings: High professional threshold limitation: The creation of scientific computing problems requires professionals with in-depth subject background knowledge, resulting in high human resource costs for problem design and making it difficult to achieve large-scale application; Insufficient scalability: Even if the original questions exist, when expanding and generating similar questions based on the same knowledge points, a lot of manual work is still required for writing and adjusting, resulting in low production efficiency and failing to meet the needs of rapid generation of large-scale training data. Limited domain coverage: Existing single-difficulty calculation datasets or benchmarks usually only cover a single difficulty level (such as only applicable to high school or only applicable to university), and the data types are mostly concentrated in mathematical calculation problems, with insufficient coverage of scientific calculation problems such as physics, making it difficult to meet the model training needs of multiple difficulty levels and multiple disciplines. Answer verification is difficult: The correctness verification of answers to scientific calculation problems relies heavily on manual quality inspection and lacks an efficient automated verification mechanism. As a result, the accuracy of answers to large-scale generated data cannot be reliably guaranteed, which in turn affects the model training effect.
[0007] In summary, existing technologies have not yet solved core technical problems in the field of scientific computing reasoning, such as data generation efficiency, domain coverage completeness, answer verification reliability, and reducing professional barriers. There is an urgent need for a new scientific computing problem generation and training technology solution to break through the above bottlenecks. Summary of the Invention
[0008] To address the aforementioned technical problems, the technical solution adopted by this invention is as follows: This invention provides a method for generating verifiable physics formula-based questions for training large models, the method comprising the following steps: S100 extracts formula information from original textual materials in physics, and performs rationality judgment and deduplication on the extracted formula information to output structured formula data.
[0009] S200: Based on the structured formula data, generate corresponding calculation code and unit test code, and execute the unit test code through a code sandbox to verify the correctness of the calculation code.
[0010] S300: Based on the verified calculation code, generate parameter combinations, run the calculation code to obtain a reference answer, and integrate the calculation code, formula data, parameter combinations and reference answer. Use a large language model to generate a question, and then verify the reasonableness of the question to obtain a verified question.
[0011] S400, the verified question is input into the large language model for multiple responses to obtain distilled answers. By comparing the consistency between the distilled answers and the reference answers, the verified question and answer pair is output.
[0012] This invention fundamentally solves the pain points of high cost, low efficiency, and high error rate of traditional manual physics problem writing by constructing a fully automated pipeline of formula extraction, code verification, parameter generation, and answer distillation. By introducing code sandbox execution and multi-layer verification mechanisms, the technical architecture ensures the accuracy of the generated answers and the physical rationality of the problems. At the same time, the application of parameter perturbation technology allows a single formula to systematically derive problems of varying difficulty, greatly improving the efficiency and diversity of data generation. Its modular design is also easy to extend to other scientific fields, providing high-quality and verifiable data support for large-scale training of language models' scientific reasoning capabilities.
[0013] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 The flowchart illustrates a method for generating verifiable physics formula-based questions for training large models, as provided in this embodiment of the invention. Detailed Implementation
[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0017] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0018] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0019] This invention provides a method for generating verifiable physics formula-based questions for large model training, such as... Figure 1 As shown, the method may include the following steps: S100 extracts formula information from original textual materials in physics, and performs rationality judgment and deduplication on the extracted formula information to output structured formula data.
[0020] In this embodiment of the invention, the original textual materials in physics can be derived from publicly available textbooks, exercise books, academic papers, etc.
[0021] The original text material is input into a large language model (e.g., GPT-4, ChatGLM, Qwen, etc.), and the model is guided to perform an information extraction task using a preset prompt template. The large language model is required to output structured JSON format data, with each formula information unit containing the following fields: name: The name of the theorem or formula; formula: A mathematical formula expression in LaTeX format; Description: A textual description of the physical meaning and application scenarios of a theorem or formula; applicable range The applicable conditions, scope, and physical constraints of the formula.
[0022] To improve data quality, the extracted formula information is input again into the large language model (which may be the same as or different from the previous step) for physical rationality assessment. This step aims to filter out formula entries that clearly do not conform to physical laws (such as incompatible dimensions), contain logical contradictions, or have format errors, thus completing the initial data cleaning.
[0023] For the set of formulas that pass the reasonableness judgment, a two-stage deduplication process is performed to ensure the uniqueness of the formulas: Rapid coarse screening: A locality-sensitive hashing (LSH) method based on MinHash is used to rapidly cluster the name and formula fields of the formulas. Specifically, a MinHash signature is generated for the text of each formula, and the similarity is determined by calculating the Jaccard similarity estimate between the signatures. When the similarity estimate exceeds a first preset threshold (e.g., 0.5 to 0.8, preferably 0.6), the two formulas are considered likely to be similar and are grouped into the same candidate formula set. This stage aims to efficiently narrow down the range of precise comparisons with a high recall rate.
[0024] Precise deduplication: For the candidate formula set obtained after coarse screening, an edit distance algorithm is used to calculate precise similarity. To fairly compare formulas of different lengths, the relative edit distance (i.e., the ratio of the edit distance to the length of the longer formula string) is used as the metric. When the relative edit distance of the name and formula fields of two formulas is lower than a second preset threshold (e.g., 0.1 to 0.3, preferably 0.2), they are determined to be duplicate formulas, and are merged or removed, finally obtaining the deduplicated structured formula data.
[0025] Furthermore, the deduplication process also includes syntax tree similarity deduplication: the LaTeX expression of the formula is parsed into a syntax tree structure, and deduplication is performed by calculating the structural similarity between the syntax trees; if the syntax tree similarity of two formulas exceeds a preset threshold, they are determined to be duplicate formulas.
[0026] The parsing process uses libraries such as pylatexenc or sympy to parse LaTeX formulas into a syntax tree (AST). This tree structure reflects the hierarchical relationship of mathematical operators and operands in the formula. Similarity calculation can use tree edit distance or a traversal-based hash algorithm (tree kernel) to calculate the structural similarity between two syntax trees. A preset threshold can be set based on experimental experience; for example, a tree structure similarity of 0.9 or higher is considered a duplicate. This method can effectively identify formulas that are textually different but mathematically equivalent: In step S200, based on the structured formula data, a large language model is invoked to generate corresponding standardized calculation code and unit test code. The core design of the standardized calculation code is a function. This function takes the parameters on the right side of the formula as input and returns the result value on the left side of the formula through numerical calculation. This standardized interface design (fixed input / output mode) is crucial to this automated pipeline. It provides a unified and reliable calling contract for subsequent steps S300 (parameterized answer calculation) and S400 (answer verification), serving as the technological cornerstone for achieving full-process automation.
[0027] Unit test code is used to verify the correctness of the computation code. Unit test code consists of one or more test cases. Each test case is a structured verification unit designed to systematically verify the correctness and robustness of the computation code from different dimensions. A test case typically includes: Test input: A set of specific parameter values provided to the calculation function.
[0028] Expected output: The correct result that the computation function should return or the behavior it should exhibit given this input.
[0029] Assertion logic: Code used to automatically compare the actual output of a function with its expected output. If they do not match, the test case is considered a failure.
[0030] Taking Newton's second law F=ma as an example, the generated unit test code will contain multiple types of test cases: (1) Normal test cases Objective: To verify whether the computational logic is correct under typical and reasonable inputs.
[0031] Example: Input mass = 2 (kg), acceleration = 3 (m / s) 2 The Assert function returns a force equal to 6 (N).
[0032] (2) Boundary condition test cases Objective: To test the stability and accuracy of the code under extreme or critical parameter values.
[0033] Example: Input mass=0 (kg), assert output should be 0 (N) (zero mass inspection).
[0034] Input mass as an extremely large value (e.g., 1e30kg) and check whether the calculation will overflow or return an unreasonable result.
[0035] (3) Exception handling test cases Objective: To verify the code's ability to handle illegal or unexpected input and ensure its robustness.
[0036] Example: Input mass=-1(kg) (negative mass), the assertion function can throw a predefined Value Error exception.
[0037] If you input acceleration="fast" (string type), the assertion function can correctly handle type errors.
[0038] Furthermore, the unit test code is pre-configured to cover three test scenarios: normal conditions, boundary conditions, and exception handling. This multi-scenario coverage aims to systematically build trust in the correctness and robustness of the computation code within an automated environment, ensuring its ability to handle various input conditions and guaranteeing the production of high-quality data. Specifically: Normal procedure: Use a set of typical parameter values that conform to the physical meaning and applicable range of the formula to verify whether the calculation results are consistent with manual calculations or generally accepted results.
[0039] Boundary conditions: Test the stability and correctness of the calculation of parameters under extreme values (such as maximum, minimum, and zero values) to ensure the robustness of the code on the calculation boundaries.
[0040] Exception handling: Verify that when illegal input data (such as negative mass or non-numeric types) is input, the code can throw an exception or return an error message as expected, rather than crashing or outputting meaningless results.
[0041] Furthermore, the correctness of the computation code is verified by executing the unit test code through a code sandbox, specifically including: Verification process: The calculation code is concatenated with the unit test code to form a complete, independently runnable executable program, which is then submitted to an isolated code sandbox for execution. The execution results of all test cases are automatically checked. The calculation code is deemed to have passed verification and can be adopted for subsequent steps only if all test cases pass.
[0042] Retry Mechanism: If verification fails (i.e., there are test cases that fail), a closed-loop retry process is triggered: the calculation code and unit test code are regenerated, and the complete steps from code generation to code verification are repeated. The number of times this retry process is repeated is limited by a preset retry limit (e.g., 3 times). If verification still fails after reaching this limit, all generated content corresponding to the formula is automatically discarded to ensure the high quality and high reliability of the final dataset.
[0043] In this embodiment of the invention, the code sandbox environment is a resource-constrained, secure execution environment isolated from the host operating system and network. The core functions and characteristics of this environment are: Isolation: Sandboxes ensure that code executed inside cannot access or corrupt the host system's files, network, and other critical resources through process isolation, containerization technologies (such as Docker), or virtual machine technologies.
[0044] Security: This environment disables all dangerous system calls and module imports (such as file read / write and network requests), fundamentally preventing security risks that may be caused by malicious or flawed code.
[0045] Resource control: Strict limits are set on the running time (CPU time) and memory usage of programs within the sandbox to ensure that errors or infinite loops in a single program will not exhaust system resources, thereby ensuring the stable operation of the entire automated pipeline.
[0046] Self-destruction: After each execution, the sandbox instance is destroyed and all temporary states are cleared, ensuring that each verification is carried out in a brand new, clean environment and avoiding cross-contamination.
[0047] This design ensures the feasibility of large-scale, automated verification of code generated automatically from untrusted sources (large language models), and is the key technical infrastructure for the implementation of this invention.
[0048] S300: Based on the verified calculation code, generate parameter combinations, run the calculation code to obtain a reference answer, and integrate the calculation code, formula data, parameter combinations, and reference answer. Use a large language model to generate a question, and then verify the reasonableness of the question to obtain a verified question.
[0049] This step aims to automatically generate a question cluster (i.e., a group of questions with a related difficulty gradient) using the validated calculation code in S200, ensuring its physical plausibility and professional format. The specific implementation is as follows: S301, Generation of parameter combination clusters The core of this step is to generate a set of pedagogically meaningful parameters, laying the foundation for constructing a question family, including: Generate a baseline parameter combination: Input the formula information and the verified calculation code into the large language model, and guide the model to generate a baseline parameter combination that conforms to the physical meaning, applicable boundaries and dimensional requirements of the formula through preset prompts. This combination defines a baseline physical scenario (such as "an object sliding on a smooth 30° inclined plane").
[0050] Perform a systematic parameter shift: To derive problems with associated difficulty gradients from a single formula, a teaching-oriented systematic shift of the baseline parameters is required, where: Offset object: This refers to key physical quantities, that is, core parameters whose changes will directly and significantly alter the system state or calculation path (such as slope angle and friction coefficient).
[0051] Offset Logic: Offset is not a random perturbation, but a directional and step-by-step adjustment based on the physical context and according to the preset physical evolution or teaching progression rules. For example, systematically increasing the slope angle (30°→45°→60°) or the coefficient of friction (0→0.2→0.4) to construct different physical scenarios.
[0052] Output: This process generates a parameter combination cluster, which consists of multiple sets of parameters that are intrinsically related.
[0053] To more clearly illustrate the concepts of "systematic parameter shift" and "critical physical quantities," two non-limiting examples are provided below: Example 1 (Force Analysis of an Inclined Plane) Baseline scenario: An object is at rest on a smooth inclined plane with an angle of 30° (coefficient of friction μ=0).
[0054] Key physical quantities: slope angle and friction coefficient.
[0055] Systematic drift strategy 1 (changing the tilt angle): Keep the slope smooth (μ=0), and systematically increase the inclination angle to 45° and 60°.
[0056] Effect: By changing the component of gravity along the inclined plane, problems are generated from "uniformly accelerated linear motion" to "uniformly accelerated linear motion with greater acceleration", which increases the difficulty of dynamic analysis.
[0057] Systematic offset strategy 2 (introducing and changing friction): With a fixed tilt angle of 30°, the coefficient of friction is systematically increased from 0 to 0.2 and 0.4.
[0058] Effects: The introduction of friction calculations has completely changed the force analysis model, generating problems with different equilibrium states, from "about to slide" to "stationary on the inclined plane," significantly increasing the complexity of the problems and the depth of physical thinking.
[0059] Example 2 (Free Fall and Kinetic Energy Calculation) Baseline scenario: A 2kg object falls freely from a height of 10m.
[0060] Key physical quantities: initial height, object mass.
[0061] Systematic offset strategy: The initial height was systematically increased from 10m to 50m and 100m.
[0062] At the same time, the mass of the object was systematically increased from 2kg to 5kg and 10kg.
[0063] Effect: Although the physical model (free fall) remains unchanged, the calculation values and scale of physical quantities such as final velocity and kinetic energy have been increased, which has increased the computational complexity and can be used to examine derivative problems such as energy and momentum.
[0064] S302, Calculation of Reference Answer Each set of parameters in the parameter combination cluster generated by S301 is sequentially input into the calculation code. The code is executed in an isolated code sandbox to obtain the numerical result corresponding to each set of parameters. These numerical results serve as the standard reference answer, forming the answer benchmark for subsequent question clusters.
[0065] S303, Question Cluster Generation and Reasonableness Verification Question generation: Integrate the aforementioned calculation code, structured formula data, parameter combinations, and reference answers, input them into the large language model, and generate a complete initial question set, i.e., the initial question cluster, which includes the question stem, solution analysis, and answer unit.
[0066] Reasonableness Verification: To prevent parameter perturbations or model illusions from causing questions to violate common sense, a lightweight large language model is used to independently review each question in the generated initial question cluster. This review judges each dimension from various aspects, including physical laws (whether the scenario conforms to the laws), numerical reasonableness (whether the calculation results are consistent with common sense), and scenario realism (whether the scenario is likely to exist in reality), filtering out unreasonable questions to obtain a verified question cluster. For example, a question like "Using a force of 1 Newton to push an aircraft carrier to produce an acceleration of 10 m / s²" is generated and filtered out by the model as "numerically unreasonable".
[0067] S304, Standardized Format To ensure the professionalism and consistency of the verified question set, its format was converted: The large language model is used to convert the problem content into standard LaTeX format, specifically the formulas, values, and units in the problem.
[0068] Calculate the ROUGE-L F1 similarity score of the text before and after conversion, and compare it with a preset threshold (e.g., 0.6).
[0069] If the score is greater than or equal to the threshold, the converted LaTeX version is adopted; if it is lower than the threshold, the original version is retained. This mechanism ensures professional formatting while strictly preventing semantic deviations.
[0070] S400, the verified question is input into the large language model for multiple responses to obtain distilled answers. By comparing the consistency between the distilled answers and the reference answers, the verified question and answer pair is output.
[0071] This step aims to leverage the reasoning capabilities of large language models to generate high-quality thought-chain answers for the questions. Through an innovative double-verification mechanism, it automatically filters out error-free, high-quality data, thus effectively replacing traditional manual quality checks. The specific implementation is as follows: S401, Distillation Answer Generation The validated question obtained from S300 is input into a high-performance large language model (such as GPT-4, DeepSeek, etc.), which then makes multiple (e.g., 5) independent responses. Each time, the model needs to generate a thought chain containing detailed reasoning steps and extract the final numerical answer from each response as the distilled answer.
[0072] S402, Consistency Verification To ensure the correctness of the proof distillation answer lies not only in the result but also in the process, the following double verification procedure is performed: Final answer verification: Determine whether the final value of the distillation answer is consistent with the value of the reference answer within a preset first tolerance range (such as absolute tolerance 1e-6 or relative tolerance 1%).
[0073] Intermediate process verification: Analyze the thought process chain in the distilled answer and extract the value of at least one key intermediate result. Determine whether this value is consistent with the corresponding intermediate variable value recorded when the code sandbox executes the calculation code, and whether it falls within a preset second tolerance range.
[0074] The key intermediate results refer to the calculation results of intermediate variables that have clear physical meaning and are necessary for calculating the final answer in the calculation path of solving the final answer according to a specific physical formula (e.g., the acceleration value calculated before solving the final velocity).
[0075] The second tolerance range is typically the same as or similar to the first tolerance range. In an illustrative embodiment, it is set to a small absolute tolerance (e.g., 1e-5) or a relative tolerance (e.g., 1%). An absolute tolerance is suitable when the magnitude of the intermediate result is relatively well-defined and stable. For example, when the intermediate result is acceleration, force, or energy, its value is usually within a predictable range, and using a fixed tolerance (e.g., 1e-5) is simple and effective. A relative tolerance is suitable when the magnitude of the intermediate result varies considerably. A relative tolerance can more fairly assess the consistency of values at different scales. For example, if one intermediate result is 1.0 and another is 1000.0, using a 1% relative tolerance is more reasonable than a fixed absolute tolerance.
[0076] Those skilled in the art will understand that the specific value of the second tolerance range can be adaptively adjusted according to the stringency of data quality requirements. For example, it can be reduced to 1e-8 when pursuing extremely high precision, and relaxed to 5% when more tolerance for calculation errors is required. All these adjustments fall within the protection scope of this invention. For example, when verifying the thought process of a slope motion problem, it is necessary to extract the acceleration 'a' as a key intermediate result. If the acceleration calculated by the code is 2.450000 m / s², ... 2 The acceleration calculated in the large model's thought chain is 2.450015 m / s².2 The absolute tolerance 1e-4 is used for judgment: if abs(2.450000-2.450015)=0.000015<0.0001, then the key intermediate result is determined to be consistent.
[0077] S403, Data Item Decision and Output A distillation answer passes consistency verification only if both the final answer verification and the intermediate process verification are determined to be consistent. The verified question, thought process, and distillation answer are integrated to output a high-quality question-answer pair. For multiple answers to the same question, a data item is retained as long as at least one of them passes verification.
[0078] And determine whether the value of the key intermediate result is consistent with the value of the corresponding intermediate variable recorded when the code sandbox executes the calculation code within the preset second tolerance range; the key intermediate result refers to the calculation result of those intermediate variables that have clear physical meaning and are necessary for calculating the final answer in the calculation path of solving the final answer according to a specific physical formula.
[0079] Specifically, the distillation answer passes the consistency verification only if both the final answer verification and the intermediate process verification are determined to be consistent.
[0080] This distillation process replaces manual quality control by comparing the answers calculated by the code with those given by a large model, thus greatly saving costs.
[0081] Furthermore, the method also includes: S500 trains a language model using validated question-answer pairs and employs at least one of supervised fine-tuning and reinforcement learning.
[0082] This step aims to use the high-quality, verifiable question-answer pairs produced in the preceding steps to train and optimize the language model, with the goal of significantly improving the model's reasoning accuracy, logical rigor, and answer reliability in physics problem-solving tasks.
[0083] The reinforcement learning training employs the advanced Group Relative Policy Optimization (GRPO) algorithm. This algorithm's advantage lies in its ability to more effectively guide the model's learning direction by having the model generate multiple responses to the same question, forming groups, and then calculating rewards through relative comparisons within each group. This significantly improves training efficiency and model performance.
[0084] Based on different training objectives and data utilization methods, this invention provides a variety of training strategies to maximize the conversion efficiency of the generated data value. These strategies include, but are not limited to: Strategy 1 (Purely Supervised Fine-Tuning - SFT) This strategy aims to enable the model to quickly and stably learn the solution paradigm for physics problems using high-quality labeled data.
[0085] Data composition: A large-scale training dataset is constructed using high-quality question-answer pairs generated by the method of this invention. This dataset is configured with mixed difficulty levels, typically containing a large batch of basic questions and a small batch of advanced questions, to ensure that the model has a certain generalization ability while mastering core knowledge.
[0086] Training process: Supervised fine-tuning of a pedestal language model is performed using the hybrid dataset.
[0087] Purpose and effect: This strategy aims to enable the model to efficiently learn the standard solution patterns, normative formats, and application of fundamental laws of physics problems, resulting in a model that performs stably and reliably in solving physics problems.
[0088] Strategy 2 (Pure Reinforcement Learning - RL) This strategy focuses on inference strategies that optimize the model directly from trial and error through reinforcement learning.
[0089] Data generation: Have a base model or a pre-trained model answer a set of questions (e.g., the training set used in Strategy 1) multiple times to collect the inference trajectories of the base model or the pre-trained model.
[0090] Data filtering: From the model's multiple responses, filter out the data that can effectively expose the model's capabilities and shortcomings (e.g., data where the model's answer accuracy is between 0 and 1) to form a targeted reinforcement learning training set.
[0091] Training process: The GRPO algorithm is used to train the model on the selected reinforcement learning training set.
[0092] Purpose and effect: This strategy aims to shape and improve the autonomous reasoning ability and logical rigor of the model directly through strategy optimization without relying on a large amount of labeled data.
[0093] Strategy 3 (Hybrid Progressive Training - SFT+RL) This strategy is a phased, progressive training method that aims to combine the advantages of the previous two strategies to achieve a step-by-step improvement in model capabilities.
[0094] Phase 1 (Knowledge Foundation): First, following Strategy 1, a base model is supervised and fine-tuned using a first dataset (which can be a mix of basic and advanced questions) to obtain an intermediate model with solid foundational knowledge.
[0095] Phase 2 (Capability Enhancement): Subsequently, based on this intermediate model, GRPO reinforcement learning training is performed using a second, more challenging dataset (e.g., consisting entirely or mostly of highly difficult problems generated by systematic parameter shifts).
[0096] Purpose and effect: This strategy aims to allow the model to take on more challenging tasks based on its existing knowledge, thereby stimulating its deep and complex reasoning ability and potential to solve difficult problems, ultimately resulting in a more powerful expert model.
[0097] The following are specific, non-limiting embodiments: In its specific implementation, this invention adopts the above-mentioned strategy one, using approximately 20,000 mixed difficulty data points to perform supervised fine-tuning of the Qwen3-8B pedestal model, resulting in the Qwen3-8B-SFT model.
[0098] Based on strategy two, the Qwen-8B model was used to answer questions, and approximately 4,000 data points were selected for GRPO training, resulting in the Qwen3-8B-GRPO model.
[0099] Based on strategy three, the Qwen3-8B-SFT-GRPO model was trained using approximately 20,000 challenging data points with high-difficulty parameters.
[0100] S500 is the key closed loop for realizing the value of this invention. Its core function is to transform the high-quality, verifiable question-answer pairs produced in the data synthesis stage (S100-S400) into the language model's inherent, generalizable physical problem-solving capabilities. This training process achieves the following four key objectives: Knowledge internalization and ability generalization: Through supervised fine-tuning (SFT), the model learns physical formulas, laws, applicable scenarios, and standard problem-solving formats from precise structured data, internalizing external knowledge as its own parameter weights. This transforms the model from a passive information retrieval tool into an intelligent agent capable of actively applying physical knowledge for numerical calculations and logical reasoning, thus gaining the ability to generalize to solve unseen problems.
[0101] Optimizing Reasoning Strategy and Stability: By employing reinforcement learning algorithms such as GRPO, the training process directly optimizes the model's reasoning strategy. The model is guided to pursue the correctness of the final answer while ensuring the logical rigor of the thought process, the completeness of the steps, and the accuracy of intermediate results. This significantly improves the stability and reliability of the model's output, effectively reducing "illusions" and logical fallacies.
[0102] Verifying Data Validity and Methodological Closed Loop: This stage is the final and objective step in verifying the effectiveness of the aforementioned data synthesis method. The significant performance improvement of the trained model on standard evaluation sets such as SciBench and UGPhysics strongly demonstrates the extremely high value and quality of the data generated by this invention, thus forming a complete technical closed loop from raw materials → high-quality data → high-performance model, proving the feasibility and superiority of the entire chain solution of this invention.
[0103] Creating downstream application value: The domain expert model ultimately trained (such as Qwen3-8B-SFT) itself becomes a high-value commercial product. It can be directly applied to scenarios such as intelligent education tutoring, adaptive test question generation, and scientific research-assisted computing, realizing the transformation from methodological innovation to practical productivity tools.
[0104] Input and output definitions of the trained language model After being trained using the method of this invention, the language model completes the transformation from "student" to "expert," and its functional definition is as follows: Input: A brand new, unanswered physics problem, presented in natural language text format.
[0105] Example input: "A 5kg object slides down an inclined plane with an angle of 37° from rest. If the coefficient of kinetic friction between the object and the inclined plane is 0.3, and the length of the inclined plane is 2m, find the speed of the object when it reaches the bottom of the inclined plane. (Take g = 10m / s²)" Output: A structured solution containing a complete reasoning process, including the following core elements: a. Thinking chain: The model gradually demonstrates its solution process, including formula selection (such as listing Newton's second law), intermediate reasoning (such as force analysis and acceleration calculation), numerical substitution, etc.
[0106] b. Final answer: The final numerical result obtained after calculation.
[0107] c. Units: Clearly indicate the units in the final answer.
[0108] d. Standard format: Formulas and values in the output are often presented in standard formats such as LaTeX.
[0109] Example output: "First, perform a force analysis on the object... The net force F acting on the object..." 合 =mgsinθ-μmgcosθ. According to Newton's second law, the acceleration a=F 合 / m=g(sinθ-μcosθ)=10×(sin37°-0.3×cos37°)≈10×(0.6-0.3×0.8)=3.6m / s 2According to the kinematic formula v 2 =2as, so v=(2×3.6×2) 1 / 2 ≈3.79 m / s. Therefore, the speed of the object when it reaches the bottom of the inclined plane is approximately 3.79 m / s.
[0110] To objectively verify the effectiveness of the data generation method and training strategy proposed in this invention, rigorous experiments were conducted on internationally recognized benchmark evaluation sets.
[0111] Evaluation setup: The trained model was compared and evaluated with the base model (Qwen3-8B) on the SciBench physics subset and the UGPhysics English subset.
[0112] Evaluation results: As shown in Table 1 below, all models trained based on the data generated by this invention show significant performance improvements compared to the base model, fully demonstrating the effectiveness of the whole-chain solution of this invention.
[0113] Table 1: Results analysis: Effectiveness of Supervised Fine-Tuning (SFT): The model using only supervised fine-tuning (Strategy 1) (Qwen3-8B-SFT) achieved an average accuracy improvement of 4.37% compared to the base model. This demonstrates that the data generated by the method of this invention is inherently high-quality and can effectively inject physical knowledge into the model.
[0114] Significant gains from reinforcement learning (GRPO): Directly training the base model with GRPO reinforcement learning (strategy 2) resulted in a considerable performance improvement, demonstrating the effectiveness of policy optimization based on the model's own responses.
[0115] Superiority of the hybrid training strategy: The most significant performance improvement is seen in the model employing the hybrid progressive training strategy (Strategy 3) (Qwen3-8B-SFT-GRPO), which achieves an average improvement of 6.3% compared to the base model. This result strongly suggests that the path of "supervised fine-tuning lays the knowledge foundation, followed by reinforcement learning using high-difficulty data to stimulate deep reasoning ability" is the preferred approach of this invention.
[0116] Conclusion: The above evaluation results empirically verify that the end-to-end method of data synthesis and model training of this invention can systematically and significantly improve the ability of language models to solve physics problems. This not only confirms the extremely high value of the generated data, but also clarifies the applicable scenarios and effects of different training strategies, providing a solid basis for the practical application and promotion of this invention.
[0117] In summary, compared with the prior art, the present invention has the following significant advantages and beneficial effects: 1. End-to-end automation, revolutionary efficiency improvement: This method achieves end-to-end automated generation from raw text to high-quality training data, completely overcoming the bottlenecks of high cost and long cycle caused by the reliance on physics experts to manually write questions in traditional methods. Practical verification shows that this method can reduce human input by more than 95%, achieving a leapfrog improvement in efficiency.
[0118] 2. Verifiable answers, fundamentally guaranteeing data quality: An innovative dual mechanism of "code sandbox execution" and "answer distillation verification" is introduced, ensuring the accuracy of generated answers from the outset. By using the calculation results of executable code as an objective benchmark and employing a large model for automated answer consistency comparison, it completely replaces error-prone manual calculations and quality checks, constructing the technological cornerstone of data reliability.
[0119] 3. Systematic Data Generation with Excellent Scalability and Generalization: The core technology, "Systematic Parameter Offset," can derive "question clusters" with related difficulty gradients from a single formula, achieving an exponential increase in data expansion efficiency. This invention has successfully generated over 40,000 high-quality data points, and its modular pipeline architecture can be seamlessly extended to scientific fields such as chemistry and mathematics that require complex formula reasoning.
[0120] 4. Multiple quality control lines, scientific and rigorous: A four-layer quality control system has been constructed, consisting of "formula rationality judgment", "code boundary testing", "question scenario review" and "answer consistency verification". It cross-verifies from multiple dimensions such as physical laws, numerical stability and scenario authenticity to ensure the scientific rigor and logical authenticity of the generated data.
[0121] 5. Broad and deep coverage, comprehensive knowledge system: The generated data covers physics calculation problems from undergraduate to graduate levels, with a particular emphasis on examining physical principles and contexts, rather than simple mathematical calculations. It currently systematically covers nearly 4,000 physical formulas and their variations, providing comprehensive, in-depth, and highly challenging scientific computing knowledge support for training models.
[0122] 6. Empirical Demonstration of Training Effectiveness and Significant Performance Improvement: Empirical results on authoritative benchmark tests such as SciBench-Physics and UGPhysics-EN demonstrate that the model trained using the data generated in this invention achieves a significant performance improvement of 4.37% to 6.3% compared to the baseline model. This fully verifies the high effectiveness of the generated data under the two mainstream training paradigms of Supervised Fine-tuning (SFT) and Group Relative Policy Optimization (GRPO), providing a crucial data foundation for breakthroughs in the scientific reasoning capabilities of large language models.
[0123] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in this invention.
[0124] This invention also provides a computer-readable storage medium storing computer-executable instructions for performing the methods described in this invention.
[0125] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this invention can be achieved, and this is not limited herein.
[0126] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for generating verifiable physics formula-based questions for large model training, characterized in that, The method includes the following steps: S100 extracts formula information from original textual materials in physics, and performs rationality judgment and deduplication on the extracted formula information to output structured formula data. S200, Based on the structured formula data, generate corresponding calculation code and unit test code, and execute the unit test code through a code sandbox to verify the correctness of the calculation code; S300: Based on the verified calculation code, generate parameter combinations, run the calculation code to obtain a reference answer, and integrate the calculation code, formula data, parameter combinations and reference answer. Use a large language model to generate a question, and then verify the reasonableness of the question to obtain a verified question. S400, the verified question is input into the large language model for multiple responses to obtain distilled answers. By comparing the consistency between the distilled answers and the reference answers, the verified question and answer pair is output.
2. The method according to claim 1, characterized in that, In S100, the deduplication process includes: The local sensitive hashing method based on minimum hashing is used to quickly screen the formula information that has passed the rationality judgment and obtain a set of candidate formulas. The candidate formula set is precisely deduplicated using an edit distance algorithm to obtain the structured formula data.
3. The method according to claim 1, characterized in that, In S200, the unit test code is configured to cover three test scenarios: normal conditions, boundary conditions, and exception handling.
4. The method according to claim 2, characterized in that, In S200, the unit test code is executed through a code sandbox to verify the correctness of the computation code, specifically including: Verification process: The calculation code and the unit test code are concatenated to form an executable program, which is then submitted to an isolated code sandbox for execution, and the test case results are checked; the calculation code is deemed to have passed verification if and only if all test cases pass. Retry mechanism: If the verification fails, a retry process is triggered, the calculation code and unit test code are regenerated, and the verification process is repeated; if the verification still fails after the number of retry attempts reaches the preset maximum number of retry attempts, the corresponding formula is discarded.
5. The method according to claim 1, characterized in that, In S300, after generating the parameter combination, the key physical quantities are adjusted in a directional manner according to the physical context of the formula and the preset physical rules or teaching difficulty rules, so as to generate a cluster of questions with a related difficulty gradient based on the same calculation code.
6. The method according to claim 5, characterized in that, The directional numerical adjustment is achieved by sequentially and stepwise changing the values of one or more key physical quantities.
7. The method according to claim 1, characterized in that, In S300, the rationality of the questions is verified, including using a large language model to judge from three dimensions: physical laws, numerical rationality, and situational authenticity.
8. The method according to claim 1, characterized in that, After generating a question in S300, a format standardization step is also included: converting the question content into standard LaTeX format and determining whether to adopt the converted version through a similarity metric.
9. The method according to claim 1, characterized in that, It also includes the following steps: S500 trains a language model using validated question-answer pairs and at least one of supervised fine-tuning and reinforcement learning.
10. The method according to claim 1, characterized in that, In S400, comparing the consistency between the distillation answer and the reference answer specifically includes: Final answer verification: Determine whether the final value of the distillation answer is consistent with the value of the reference answer within a preset first tolerance range; Intermediate process verification: Analyze the thought chain in the distilled answer, extract the value of at least one key intermediate result, and determine whether the value of the key intermediate result is consistent with the corresponding intermediate variable value recorded when the code sandbox executes the calculation code within a preset second tolerance range; Specifically, the distillation answer passes the consistency verification only if both the final answer verification and the intermediate process verification are determined to be consistent.