Morphological grading and verification method and system for text-to-CAD generation
By combining the Compiler Judge Module (CJM) and the Review Node Module (CRM), the problems of low efficiency, high cost and poor generation effectiveness in existing text-to-CAD systems are solved, and efficient and low-cost 3D model generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-03-10
AI Technical Summary
Existing text-to-CAD systems are inefficient, costly, and have poor generation effectiveness. Model alignment is costly, and the generated CAD sequences often cannot be compiled into usable 3D models due to syntax or geometric errors.
A two-stage fine-tuning method is adopted, replacing VLM with the Compiler Judge Module (CJM). The Compiler Judge Module (CJM) and Review Node Module (CRM) are used to classify and verify CAD sequences. Combined with quantization and dequantization processing, efficient conversion from natural language instructions to three-dimensional solid models is achieved.
It significantly improves generation efficiency and geometric accuracy, reduces costs, enhances model alignment and generation effectiveness, and is applicable to more industrial design scenarios.
Smart Images

Figure CN121637589A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application is applied to the fields of industrial design, simulation and manufacturing, and is used for efficiently generating editable general-purpose computer-aided design (CAD) models from text descriptions, in particular, a morphological grading and verification method and system for text-to-CAD generation. BACKGROUND
[0002] Existing text-to-CAD systems are mainly based on end-to-end Transformer architecture or integrated pre-trained large language models (LLM), and are trained through text and CAD sequence pairing data sets to generate parameterized CAD command sequences from natural language. In the traditional process, model alignment relies on visual language model (VLM) to construct preference data, which requires multi-perspective rendering and projection of CAD models, and then scores and sorts the VLM (such as GPT-4o), and finally generates CAD sequences that can be compiled into three-dimensional entity models.
[0003] The existing technology has the following problems:
[0004] 1. Low efficiency: the rendering process of the CAD model relied on by the VLM has high computational cost and slow speed, and the construction of the paired preference data requires multiple CAD outputs for each text prompt and sorting, further increasing the time consumption.
[0005] 2. High cost of model alignment: deploying VLM for CAD model review is expensive, and is prone to the problem of "reward cracking", which causes the generated CAD sequence to meet the VLM scoring standard, but deviates from the actual design intent or cannot be normally compiled.
[0006] 3. Poor generation effectiveness: the CAD sequence generated by the LLM often has high inefficiency due to problems such as violation of grammatical rules (such as missing terminators), geometric inconsistency (such as a sketch ring that cannot be closed), etc., and cannot be successfully compiled into a usable three-dimensional model. SUMMARY
[0007] The present application provides a morphological grading and verification method and system for text-to-CAD generation, which can reduce the complexity and use threshold of traditional CAD modeling, and is suitable for rapid prototyping scenarios of professional designers and amateur enthusiasts.
[0008] To this end, the present application adopts the following technical solutions: a morphological grading and verification method for text-to-CAD generation, comprising a training phase and a testing phase, characterized in that the training phase is to input a text instruction x into a two-stage fine-tuning module, the first stage learns the CAD sequence rule through SFT, and the second stage optimizes the model by using the binary preference data output by the compiler judge module to complete LLM fine-tuning; the testing phase is to receive a new text instruction x by the fine-tuned LLM to generate an initial CAD sequence Verify by review node module If unqualified, feedback error information, and regenerate the node; output qualified Compile into a three-dimensional entity model by a CAD compiler to complete text-to-CAD generation.
[0009] As a preferred, the compiler judge module receives the CAD sequence generated by the model and the real CAD sequence y; convert y into a boundary representation (BRep) model through a CAD compiler and generate point clouds by uniform sampling (from ), P (from y); calculate the distance according to the formula:
[0010]
[0011] wherein |P| is the number of point clouds, and ‖·‖2 is the Euclidean distance; if the compilation is successful and the CD is lower than the threshold, mark it as "qualified" (positive sample, (x, true)) with a probability of alpha; if the compilation fails or the CD is higher than the threshold, mark it as "unqualified" (negative sample, (x, false)) with a probability of 1-alpha, and output binary preference data.
[0012] As a preferred, the review node module directly analyzes the CAD sequence generated according to the text prompt and verifies it through a CAD compiler to detect error types, if unqualified, splice the error information with the original x to generate a new input x'.
[0013] As a preferred, when the text instruction x is input into the two-stage fine-tuning module, the original continuous geometric parameters of the real CAD model corresponding to the text instruction x are synchronously called, and the original continuous geometric parameters are subjected to quantization processing to finally convert into an 8-bit fixed-length integer coding sequence, which is a discrete symbolic representation of the CAD parameters and is embedded into the sequence of a large language model (LLM) to participate in model fine-tuning together with the text instruction x.
[0014] Preferably, in the first stage, SFT is used to enable the model to learn the mapping pattern between text instructions and quantized CAD parameter sequences, generating an initial quantized integer encoding sequence. This initial quantized integer encoding sequence Perform dequantization processing: The data is sent to the dequantization module to be restored to continuous geometric parameters, and then the continuous geometric parameters are converted into the corresponding CAD sequences.
[0015] Preferably, the compiler referee module receives the aforementioned CAD sequence. The real CAD sequence y is converted into a boundary representation (BRep) model by its internal CAD sequence reconstruction unit, and then a point cloud is generated by uniform sampling by the point cloud generation unit. Compiler judges calculate point clouds The chamfer distance between the point cloud P and the point cloud P; output binary preference data based on the calculation results and preset rules: if the CAD sequence If compilation is successful and the chamfer distance is below a preset threshold, it is labeled as a positive sample (x, true); if CAD sequence If compilation fails or the bevel distance exceeds a preset threshold, it is labeled as a negative sample (x, false); The model is optimized and trained using the above binary preference data to complete the full-process fine-tuning of the Large Language Model (LLM).
[0016] Preferably, during the testing phase, the large language model, after being fine-tuned during the training phase, receives a new text instruction x and directly outputs the corresponding quantized integer encoding sequence. The quantized integer encoded sequence Perform dequantization to obtain continuous floating-point geometric parameters that can be used for geometry generation; then convert these continuous floating-point geometric parameters into a CAD sequence. And input the review node module.
[0017] Preferably, the types of errors detected include syntax errors, parameter errors, or geometric errors.
[0018] The present invention also discloses a morphological grading and verification system for text-to-CAD generation, which includes a compiler referee module for the training phase and a review node module used in the testing phase.
[0019] Preferably, the compiler referee module (CJM) includes a CAD sequence reconstruction unit, a point cloud generation unit, a chamfer distance calculation unit, and a preference signal output unit.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] 1. Improve efficiency and reduce costs: The Compiler Judge Module (CJM) is used to replace the VLM, eliminating the steps of CAD model rendering and multi-sample sorting. The speed of preference data construction is improved by at least 10 times (compared to CADFusion), while avoiding the high cost of VLM deployment, thus solving the problems of low efficiency and high cost of existing technologies.
[0022] 2. Improved geometric accuracy and alignment: Two-stage fine-tuning and CD optimization reduced the median chamfer distance to 0.62 (compared to Text2CAD's 32.82 and CADFusion's 30.23), and improved the F1 score (sequence accuracy) to 0.89-1.00, solving the problems of low geometric similarity and poor alignment with design intent in existing models.
[0023] 3. Improve generation efficiency: The combination of Agentic generation and CRM reduces inefficiency (IR) to 1.38% (compared to CADFusion's 6.02%), solving the problem of numerous syntax / geometric errors and compilation failures in LLM-generated CAD sequences.
[0024] 4. Enhanced generalization ability: In cross-dataset tests (such as CADPrompt and Fusion360), the chamfer distance metric is more than 40% better than existing models such as CADmium, solving the problem of significant performance drop when existing models generalize across datasets, and making it suitable for more industrial design scenarios. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the CJM module of the present invention.
[0026] Figure 2 This is a schematic diagram of the CRM module of the present invention.
[0027] Figure 3 This is a schematic diagram of the data construction process in the second stage of the training phase of this invention.
[0028] Figure 4 This is for generating CAD sequences during the testing phase of this invention. Detailed Implementation
[0029] The present invention will be further described below with reference to specific embodiments.
[0030] like Figures 1-2 As shown, this invention discloses a morphological grading and verification system for text-to-CAD generation, including a compiler referee module for the training phase and a review node module used in the testing phase.
[0031] I. Compiler Judge Module (CJM) Components: Includes a CAD sequence reconstruction unit, a point cloud generation unit, a chamfer distance (CD) calculation unit, and a preference signal output unit. Working Process: Receives the CAD sequence generated by the model. The actual CAD sequence y (both are sketch-extrude (SE) parametric sequences); the reconstructed units are processed by a CAD compiler (such as Python OCC). y is converted into a boundary representation (BRep) model and then uniformly sampled to generate a point cloud. (from) P (from y); CD calculation unit calculates the distance according to the formula:
[0032]
[0033] in |P| represents the number of points in the point cloud, |||2 represents the Euclidean distance; Preference signal output unit: if If compilation is successful and CD is below the threshold, it is marked as "qualified" (positive sample, (x, If compilation fails or CD exceeds the threshold, it is marked as "unqualified" (negative sample, (x, α) with probability 1-α). false)) outputs binary preference data.
[0034] II. Review Node Module (CRM): Used during the testing phase, it directly parses CAD sequences generated from text prompts. And verify using the CAD compiler to detect error types (such as syntax errors and missing values). <end>Parameter error: abnormal extrusion height, geometry error: sketch loop is not closed); feedback mechanism: if If not, the error information (such as "sketch loop is not closed, and an arc segment needs to be added") is spliced with the original x to generate a new input x'.
[0035] The application also discloses a CAD parameter data quantization and dequantization processing method for a large language model (LLM). The method realizes efficient representation of complex geometric parameters in a discrete symbol space understandable by a language model through discretization and quantization and reconstruction and decoding, significantly reduces the prediction difficulty of a large model, and maintains sufficient geometric accuracy for subsequent CAD structure reconstruction. The method mainly includes a quantization module, a dequantization module, and a data interface module. The quantization module is responsible for mapping continuous floating-point geometric parameter values to fixed-length integer codes; the dequantization module is responsible for restoring the integer codes to continuous values that can be used for geometric generation; and the data interface module is used for interaction with the large language model to realize input and output of the quantized CAD parameter sequence.
[0036] III. The quantization module comprises:
[0037] 1. An input data receiving unit (1) for receiving continuous geometric parameters from a CAD system, such as vertex coordinates, normal vector components, dimension parameters, etc. The input range is generally
[0038] [-1.0, 1.0] [-1.0, 1.0].
[0039] 2. A range setting unit (2) for determining the normalized range rminrmin and rmaxrmax of the data, which are set to -1.0-1.0 and 1.01.0 in this embodiment.
[0040] 3. A quantization mapping unit (3) for discretizing continuous values into integer codes according to a preset bit number bb (8 bits in this embodiment), and the quantization formula is as follows:
[0041] Wherein, the clip function is used to limit the quantization result within the effective range [0, 2b-1][0, 2b-1].
[0042] 4. An integer output unit (4) for outputting the quantized integer value, which is embedded into the token sequence of the LLM as a discretized CAD parameter for training or inference.
[0043] Through the above steps, the original continuous geometric parameters are converted into 8-bit integer representation of uniform scale, ensuring consistent coding across samples and realizing uniform embedding space mapping with natural language tokens.
[0044] Four, the inverse quantization module comprises:
[0045] 1. Input integer receiving unit (5): receiving integer encoding sequence from large language model prediction output;
[0046] 2. Inverse quantization parameter setting unit (6): set the inverse quantization output range rminrmin and rmaxrmax, in this embodiment, take [-0.5, 0.5][-0.5, 0.5];
[0047] 3. Inverse quantization calculation unit (7): convert integer encoding to floating point number according to the following formula:
[0048]
[0049] Wherein, x_d is the decoded continuous numerical value, used to restore CAD geometric parameters;
[0050] 4. Data output unit (8): output the reconstructed floating point data for CAD system or downstream reconstruction module directly. Through this module, the discrete symbols output by the model can be accurately restored to the analyzable geometric parameters, realizing the closed-loop mapping from language model output to CAD geometry.
[0051] The hierarchical and verification method of the application comprises a training stage and a test stage:
[0052] Training stage: the text instruction x is input into the two-stage fine-tuning module, stage 1 learns the CAD sequence rule through SFT; stage 2 optimizes the model using the binary preference data output by CJM, completes LLM fine-tuning, such as Figure 3 .
[0053] Test stage: the fine-tuned LLM (generation node) receives new text instruction x, generates initial CAD sequence CRM (review node) verification If not qualified, feedback error information, and the generation node regenerates; output qualified Through CAD compiler, compile into three-dimensional entity model, complete text to CAD generation.
[0054] The text to CAD whole process of the application takes the above quantization processing and inverse quantization processing as the core data conversion and interaction basis, integrates the preference optimization mechanism of the compiler judge (CJM) and the error feedback mechanism of the review node module (CRM), through the closed-loop design of "text instruction analysis-quantization coding-model fine-tuning / generation-inverse quantization restoration-geometric reconstruction", realizes the accurate and efficient conversion from natural language instruction to three-dimensional entity model, which is specifically divided into training stage and test stage, corresponding to Figure 3 and Figure 4 As shown, detailed as follows:
[0055] Training phase
[0056] 1. Input text instruction x into the two-stage fine-tuning module, and synchronously call the original continuous geometry parameters (including but not limited to vertex coordinates, normal vector components, size parameters, etc.) and the real CAD sequence y (sketch-stretch (SE) parameterization sequence) corresponding to the text instruction x.
[0057] 2. Perform quantization processing on the original continuous geometry parameters: send them into the quantization module, sequentially through the input data receiving unit (1), set the normalized range [-1.0, 1.0] through the range setting unit (2), complete the discretization quantization through the quantization mapping unit (3) according to 8-bit number, and output through the integer output unit (4), finally converted into 8-bit fixed-length integer encoding sequence; the integer encoding sequence is embedded into the token sequence of the large language model (LLM) as the discrete symbolic representation of the CAD parameters, and cooperates with the text instruction x to participate in model fine-tuning.
[0058] 3. Phase 1 learns the mapping rule of text instruction and quantized CAD parameter sequence through supervised fine-tuning (SFT), and generates an initial quantized integer encoding sequence 4. The initial quantized integer encoding sequence is sent into the dequantization module to restore it to continuous geometry parameters, and then the continuous geometry parameters are converted into the corresponding CAD sequence (sketch-stretch (SE) parameterization sequence).
[0059] 4. The compiler judge (CJM) receives the above CAD sequence and the real CAD sequence y, converts them into boundary representation (BRep) models through the internal CAD sequence reconstruction unit of the compiler judge (CJM), and then uniformly samples the point cloud (from the CAD sequence ) and the point cloud P (from the real CAD sequence y).
[0060] 5. The chamfer distance (CD) calculation unit of the compiler judge (CJM) calculates the chamfer distance between the point cloud and the point cloud P according to a preset formula.
[0061] 6. The preference signal output unit of the compiler judge (CJM) outputs binary preference data according to the calculation result and a preset rule: if the CAD sequence is successfully compiled and the chamfer distance is lower than the preset threshold, mark it as a positive sample (x, true) with a probability of α; if the CAD sequence Compiling failure or chamfer distance above the preset threshold is marked as a negative sample (x, false) with probability 1-α.
[0062] 7. Stage 2 optimizes the model using the above binary preference data for training, completes the whole process of fine-tuning of large language model (LLM), and ensures that the model can accurately learn the correspondence between quantization encoding and text instructions.
[0063] Testing phase
[0064] 1. The large language model (generation node) after fine-tuning in the above training stage receives a new text instruction x and directly outputs the corresponding quantization integer encoding sequence (the model has learned the quantization encoding generation ability).
[0065] 2. Perform inverse quantization processing on the quantization integer encoding sequence : input into the inverse quantization module, sequentially receive the input integer receiving unit (5), set the output range [-0.5, 0.5] by the inverse quantization parameter setting unit (6), complete the continuous numerical restoration by the inverse quantization calculation unit (7), and output by the data output unit (8) to obtain continuous floating-point geometric parameters that can be used for geometric generation; further convert the continuous floating-point geometric parameters into CAD sequence (sketch-stretch (SE) parameterized sequence), and input into the review node module (CRM).
[0066] 3. The review node module (CRM) analyzes and verifies the CAD sequence through the CAD compiler, accurately detects possible syntax errors (such as missing identifiers), parameter errors (such as abnormal extrusion height), geometric errors (such as sketch loop not closed), and other problem types.
[0067] 4. If the CAD sequence is not qualified after verification, the review node module (CRM) will splice the specific error information (such as "sketch loop not closed, need to add an arc segment") with the original text instruction x to generate a new input x', and feedback to the generation node; the generation node receives the new input x' and re-outputs the corresponding quantization integer encoding sequence repeat the steps of "inverse quantization processing-sequence conversion-CRM verification" (steps 2-3) until a qualified CAD sequence
[0068] 5. The continuous floating-point geometric parameters (product after dequantization) verified by the review node module (CRM) are compiled into a three-dimensional entity model by a CAD compiler to complete the text-to-CAD full-process generation; the entire process is realized through the bidirectional cooperation of quantization and dequantization, which reduces the difficulty of large model prediction and ensures the geometric reconstruction accuracy.
[0069] The main innovation of the present application is based on the two-stage fine-tuning of the prospect theory: stage 1 adapts to the CAD field through supervised fine-tuning (SFT), and stage 2 optimizes the binary preference data to directly maximize the generated utility without pairing preference annotation, improving the fine-tuning efficiency and model alignment accuracy.
[0070] The compiler judge module (CJM) discards the rendering and pairwise sorting of VLM, generates binary preference data through a CAD compiler and chamfer distance, realizes low-cost and fast model alignment data construction, and avoids reward cracking.
[0071] The review node module (CRM) constructs a "generation-review-feedback" iterative mechanism, CRM detects and feeds back CAD sequence compilation errors in real time, significantly reduces the proportion of invalid sequences in the test stage, and has no additional high computational overhead.
[0072] Multi-dataset adaptability: efficient generation is realized on DeepCAD, CADPrompt, Fusion360 and other datasets, solving the problem of low geometric accuracy and high inefficiency of existing models when generalizing across datasets.
[0073] Those skilled in the art should understand that the present application is not limited to the above embodiments, and the above embodiments and descriptions in the specification are only to illustrate the principles of the present application. Without departing from the spirit and scope of the present application, various changes and improvements can be made to the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims and their equivalents.< / end>
Claims
1. A morphological grading and verification method for text-to-CAD generation, comprising a training phase and a surveying phase, characterized in that The training stage is to input the text instruction x into the two-stage fine-tuning module, the first stage learns the CAD sequence rule through supervised fine-tuning, and the second stage is to optimize the model by using the binary preference data output by the compiler judge module to complete the large language model (LLM) fine-tuning; the test stage is to receive a new text instruction x by the fine-tuned large language model (LLM) to generate an initial CAD sequence Verify by the review node module If unqualified, feedback error information, and generate a new node; output qualified Compile into a three-dimensional solid model by the CAD compiler to complete the text-to-CAD generation.
2. A method for morphological staging and verification for text-to-CAD generation as claimed in claim 1, wherein The compiler adjudication module receives the CAD sequence generated by the model converted into boundary representation models by the CAD compiler and uniformly sampled to generate point clouds y respectively (From ), P (from y); Calculate the distance according to the formula: where |P| is the number of points in the point cloud and ||·||2 is the Euclidean distance; if |P| is the number of points in the point cloud and ||·||2 is the Euclidean distance; if If the compilation succeeds and the CD is below the threshold, mark as "pass" (positive sample, (x, true)) with probability a; if the compilation fails or the CD is above the threshold, mark as "fail" (negative sample, (x, false)) with probability 1 - a, output binary preference data. If the compilation succeeds and the CD is below the threshold, mark as "pass" (positive sample, (x, true)) with probability a; if the compilation fails or the CD is above the threshold, mark as "fail" (negative sample, (x, false)) with probability 1 - a, output binary preference data. If the compilation succeeds and the CD is below the threshold, mark as "pass" (positive sample, (x, true)) with probability a; if 3. A method for morphological staging and verification for text-to-CAD generation as claimed in claim 2, wherein The review node module directly parses the CAD sequence generated according to the text prompt And verifies it through the CAD compiler, detects error types, and if Unqualified, splice the error information with the original x to generate a new input x'.
4. A method for morphological staging and verification for text-to-CAD generation as claimed in claim 1, wherein In the text instruction x input two-stage fine-tuning module, the real CAD model original continuous geometry parameters corresponding to the text instruction x are synchronously called, and the original continuous geometry parameters are quantized to finally convert into 8-bit fixed-length integer encoding sequences, which are discrete symbolic representations of CAD parameters and are embedded into the word sequence of the large model to participate in model fine-tuning together with the text instruction x.
5. A morphological grading and verification method for text-to-CAD generation according to claim 4, in the first stage, the model learns the mapping rule between the text instruction and the quantized CAD parameter sequence by supervised fine-tuning, and generates an initial quantized integer encoding sequence The initial quantized integer encoding sequence Performing dequantization processing: sending into the dequantization module to restore to continuous geometric parameters, and then converting the continuous geometric parameters into the corresponding CAD sequence 6. A method for morphological staging and verification for text-to-CAD generation as claimed in claim 5, wherein The compiler judge module receives the CAD sequence The real CAD sequence y is converted into a boundary representation model by the internal CAD sequence reconstruction unit, and then the point cloud is uniformly sampled by the point cloud generation unit The compiler judge module calculates the point cloud The chamfer distance between the point cloud P; according to the calculation result and the preset rule, output binary preference data: if the CAD sequence Compiling successfully and the chamfer distance is lower than the preset threshold, marked as positive sample (x, true) with probability α; if the CAD sequence Compiling failed or chamfer distance is higher than the preset threshold, marked as negative sample (x, false) with probability 1-α; using the above binary preference data to optimize the training of the model, complete the whole process fine-tuning of the large language model (LLM).
7. A method for morphological staging and verification for text-to-CAD generation as claimed in claim 1, wherein In the testing phase, the large language model (LLM) after fine-tuning in the training phase receives a new text instruction x and directly outputs the corresponding quantized integer encoding sequence The quantized integer encoding sequence is input into the review node module. The inverse quantization process is performed to obtain continuous floating-point geometry parameters that can be used for geometry generation; and the continuous floating-point geometry parameters are further converted into CAD sequences And input the review node module.
8. A method for morphological staging and verification for text-to-CAD generation as claimed in claim 1, wherein The type of error detected includes a syntax error, a parameter error or a geometry error.
9. A morphological staging and verification system for text-to-CAD generation, characterized by The compiler adjudication module for the training phase and the review node module used in the testing phase are included.
10. A system for morphological classification and verification for text-to-CAD generation as claimed in claim 9, wherein The compiler adjudication module includes a CAD sequence reconstruction unit, a point cloud generation unit, a chamfer distance calculation unit and a preference signal output unit.