Method and device for processing program conversion of equipment agent based on large model and small model cooperation
By employing a device intelligence approach that combines large and small models, the problem of reusing CNC machining programs across different systems and machine tools is solved. This approach enables efficient and reliable cross-system program conversion, reducing costs and error risks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
- Filing Date
- 2026-01-26
- Publication Date
- 2026-04-10
AI Technical Summary
Existing CNC machining programs are difficult to reuse across different CNC systems and machine tools, making program migration difficult. Manual conversion is time-consuming, labor-intensive, and prone to errors, while automatic programming software is expensive.
We adopt a device agent approach based on the collaboration of large and small models. By constructing device agents, we collect and clean data, abstract it into multi-dimensional semantic functions, and combine supervised learning of small models and scoring mechanisms of large models to achieve cross-system processing procedure transformation.
It achieves high-fidelity, automated program conversion between different CNC systems, reduces cross-system setup costs, improves machining preparation efficiency and reliability, and avoids errors in traditional manual conversion.
Smart Images

Figure CN121578774B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of numerical control system program conversion in intelligent manufacturing technology, and particularly relates to a device intelligent agent machining program conversion method and device based on large model and small model cooperation. BACKGROUND
[0002] In numerical control machining production, historical machining programs often lack traceability, and two typical problems often occur: first, some machining tasks only retain the final generated numerical control code, and the three-dimensional model file used to compile the code cannot be found; second, even if the model exists, the original CAM system may lack process data for generating tool path trajectories, resulting in the inability to regenerate the corresponding machining program through traditional programming software. When it is necessary to migrate existing machining programs to another machine tool with different structures, the lack of model and tool path information makes it impossible for the program to rely on CAM software for regeneration, causing difficulties in machining program transplantation. To address this problem, manual analysis of the differences between different machine tool structures and numerical control systems is usually required, and manual rewriting and adaptation of cross-system code are completed. However, different numerical control systems (such as FANUC, Siemens, Heidenhain, and Huazhong) have significant differences in G / M instruction systems, motion control modes, macro program syntax, and coordinate system setting methods. Manual rewriting not only consumes time and effort, but also is prone to errors and may pose risks to machining quality and equipment safety.
[0003] One of the existing solutions is to purchase corresponding automatic programming software for each numerical control system to generate machining programs executable by the target system through a post-processor. However, automatic programming software is expensive, and each system usually requires an investment of hundreds of thousands of yuan. As the scale of equipment expands, newly purchased machine tools may be equipped with new numerical control systems, and to maintain compatibility, more post-processing software needs to be continuously purchased, resulting in increasing costs of software and hardware investment. In addition, due to significant structural differences between different devices, simply relying on a post-processor still cannot solve actual machining problems such as tool compensation methods, path safety, and machine tool limitations.
[0004] Therefore, there is an urgent need for a technical solution that can intelligently analyze, semantically understand, and convert existing numerical control machining programs in the absence of model and tool path trajectories. By studying the mapping rules of machining programs between different structural machine tools, automatic extraction of machining intent and intelligent generation of cross-system instructions can help solve the bottleneck problems of high cost, low efficiency, and poor adaptability of traditional programming methods, and lay a foundation for building unified and expandable machining program conversion capabilities. SUMMARY
[0005] To solve the above technical problems, the present application aims to provide a device agent processing program conversion method and device based on large model and small model cooperation, which can effectively solve the problem that traditional numerical control processing program is difficult to reuse between different numerical control systems and different structure machine tools, and ensure that the processing program is converted without manual code conversion in a multi-type machine tool and cross-system processing environment.
[0006] To achieve the above purpose, the embodiments of the present application adopt the following technical solutions:
[0007] The device agent processing program conversion method based on large model and small model cooperation comprises:
[0008] Step 1: based on the control system type, kinematic structure parameters and process constraint information of the target machine tool and the source machine tool, a device agent containing system parameter set, kinematic parameter set and process constraint parameter set is constructed;
[0009] Step 2: the device agent performs data collection and cleaning, abstracts the control system operation instructions of the machine tool system composed of the target machine tool and the source machine tool into a multi-dimensional semantic function composed of motion semantics, function semantics, tool semantics, path semantics, feed semantics, spindle semantics and process semantics, and executes a unified semantic mapping function combined with machine tool system parameters to obtain a system-independent unified semantic representation;
[0010] Step 3: the source program of the source machine tool control system to be converted is executed for line-level analysis, context dependency analysis, and the source program to be converted is constructed into an abstract syntax tree to identify processing steps, coordinate system settings, tool calls, trajectory paths and macro program logic, combined with the syntax rules, kinematic constraints and process restrictions of the target machine tool control system, to generate a conversion task prompt information template Prompt containing processing intent, parameter dependency, path structure and target system constraints;
[0011] Step 4: a small model is selected, the original instruction line is taken as input, and the unified semantics are taken as supervision labels for supervised learning training, so that the small model masters the syntax structure of numerical control instructions, tool compensation semantics, path expression and macro structure relationship, and has unified semantic analysis and initial conversion capability;
[0012] Step 5: the small model generates a plurality of candidate patches based on the Prompt, and the large model scores the patches from the four dimensions of consistency, process rationality, safety and kinematic executability, constructs a differential reward according to the scoring results, and updates the small model parameters using an improved proximal policy optimization algorithm, realizing the knowledge migration of the large model to the small model; Figure One
[0013] Step 6: Calculate the average entropy value of the conditional probability distribution of the candidate patches' terms or tokens, sort them according to the entropy value, and select the high-confidence patches as the final patches;
[0014] Step 7: Call the cross-system code generation module to map the unified semantics corresponding to the final patch into G / M instructions, fixed cycles, macro variable structures and multi-axis trajectories that can be executed by the target machine tool, obtain the target program, write the target program into the program storage area of the target machine tool through the communication layer and execute simulation or machining.
[0015] Furthermore, the device intelligent agent includes a communication layer, an intelligent decision-making layer, and an adaptation layer, which are used to realize program reading and writing, semantic parsing, unified semantic generation, program transformation, and executability verification.
[0016] Furthermore, the specific steps of constructing differential rewards based on the scoring results and updating the small model parameters using an improved proximal policy optimization algorithm are as follows:
[0017] Introducing adaptive modulation coefficients The adaptive modulation coefficient Gradually decrease as training progresses:
[0018] ;
[0019] in, This represents the current number of training steps. Total training steps The initial modulation factor, For the terminal modulation factor, It is a natural exponential function. It is the natural logarithm function;
[0020] A priority sampling mechanism is introduced, based on the cumulative reward amount for each patch. Assign sampling probabilities, let the first... patch The sampling probability is:
[0021] ;
[0022] in, Total number of patches For the first The sampling probability of each patch being selected. and The first The and the first The cumulative rewards from each patch, For patch index, This is the patch index for the currently calculated sampling probability;
[0023] In combination with the differential reward, the adaptive modulation factor and the priority sampling distribution, the small model parameters are updated as:
[0024]
[0025]
[0026]
[0027] wherein, is the learning rate, is the small model parameter before the last policy update, is a priority sampling probability vector constructed based on the reward accumulation, is a discrete categorical distribution defined by the probability vector represents that the patch index is randomly sampled according to the priority sampling distribution is the policy ratio, is the clipping threshold, is the policy gradient used to calculate the policy update direction, is the expectation of the priority sampling distribution over the patch index is the policy output value given by the small model with the current parameter to the patch is the policy output value given by the small model with the old parameter to the patch is the advantage estimate corresponding to the patch is the minimum function.
[0028] Further, in the step 2, the unified semantic mapping function is used to eliminate the syntax differences of different control systems, and converts the motion type, tool compensation mode, interpolation plane, path point, circle center, normal vector, macro variable and fixed cycle parameter of the G / M instruction into a standardized semantic expression independent of the system.
[0029] Further, the device agent analyzes the historical machining programs, process planning documents, control system instruction sets, macro instruction syntax rules and machining trajectory data generated by the digital twin simulation system of the source machine tool and the target machine tool, and after data processing such as semantic extraction, instruction standardization and semantic alignment, a semantic corpus is constructed. Based on the corpus, instructions from different numerical control systems but semantically equivalent or highly similar are clustered across systems, and a cross-system mapping matrix is constructed.
[0030] The device agent will encode each piece of unified semantics into a high-dimensional feature vector, where is the i-th piece of unified semantics instruction, is the i-th piece of unified semantics instruction, is the structured semantic set obtained after parsing the semantics instruction , is the semantic instruction index, and the i-th motion semantic type , the i-th functional semantic type , and the i-th tool compensation type are discretely numbered, and each type is assigned a trainable or preset embedding vector, which is mapped to the corresponding embedding subspace to obtain the motion semantic embedding vector , the functional semantic embedding vector , and the tool semantic embedding vector ; for the i-th path semantic , the geometry and pose parameters are normalized, and for different types of interpolation, a uniform dimension parameter bit is used to fill in to form a numerical feature vector , represents the i-th semantic instruction corresponding to the motion path semantic information, represents the i-th semantic instruction corresponding to the feed parameter semantic information, which is used to describe the feed amount or feed method in the motion or machining process, and for the i-th spindle speed or motion speed related semantic and the i-th other process or control parameter semantic , etc. are discretely encoded and mapped into embedding vectors to form process and macro-logic features ; the unified high-dimensional feature representation vector of the i-th unified semantics instruction is obtained by vector splicing : . Further, the hybrid semantic distance is defined as:
[0031] .
[0032] Further, the hybrid semantic distance is defined as:
[0033]
[0034] where is used to measure the category difference between discrete semantics; is used to measure the difference between continuous geometry features and process parameters, is the i-th piece of unified semantics instruction, a uniform high-dimensional feature representation vector of the uniform semantic instruction, indexing the semantic instructions, and weighting coefficients;
[0035] collecting all instruction samples selecting Kmeans clustering under the distance constraint to obtain C semantic clusters, forming several semantic clusters where each cluster represents a type of numerical control instruction pattern that is semantically equivalent or highly similar between different control systems, is the total number of instruction samples, is the number of semantic clusters, and represent the first and semantic clusters, and represent the index.
[0036] Further, based on the semantic cluster results, a cross-system mapping matrix is constructed, and the set of control systems participating in the conversion is set as where and represent the first and semantic clusters, and represent the index, and each instruction sample is labeled with the source control system and the corresponding original instruction form;
[0037] For each semantic cluster and each control system , the sample subset belonging to the control system is counted, and the original G / M code, fixed loop format, parameter arrangement, and macro statement style of all instruction samples in the subset are parsed and structured to extract the most representative instruction expression structure of the semantic cluster in the control system .
[0038] Based on the syntax elements, parameter fields, and their arrangement order, the standard template of the semantic cluster in the control system is formed, denoted as :
[0039] .
[0040] wherein The template generation function is used to generate a template including an instruction keyword structure, a macro structure mapping mode, a fixed cycle mapping rule, and a compatibility correction rule;
[0041] After all semantic cluster template extraction is completed, a control system index is constructed The row is numbered as a semantic cluster The column is numbered as a semantic cluster, and a cross-system mapping matrix is constructed :
[0042] .
[0043] The application also provides a device agent processing program conversion device based on large model and small model cooperation, the conversion device comprising:
[0044] A device agent construction module is configured to collect a machine tool system and kinematic parameters and construct a device agent;
[0045] A corpus construction module is configured to generate a unified semantic mapping rule;
[0046] A requirement analysis and prompt generation module is configured to perform analysis on a source program and generate a conversion task prompt;
[0047] A small model training and deployment module is configured to perform supervised learning fine-tuning;
[0048] A large model evaluation module is configured to jointly score candidate patches;
[0049] A patch entropy value sorting and verification module is configured to filter high-confidence patches;
[0050] A cross-system code generation and delivery module is configured to map the patches into target machine tool executable programs and write them into a machine tool control system.
[0051] Beneficial effects:
[0052] The application realizes automatic and high-fidelity bidirectional conversion of processing programs between different numerical control systems through construction of a device agent, unified semantic expression, small model patch generation driven by a prompt word, and a large model multi-dimensional verification mechanism. The method can realize equivalent rewriting between Siemens, Huazhong and other systems while keeping the machining geometry, tool compensation, fixed cycle parameters and process logic completely unchanged, avoiding problems such as tool compensation errors, cycle parameter mismatches and trajectory distortion that are prone to occur in traditional manual conversion. At the same time, the patch filtering and safety verification mechanism ensures the executability and process safety of the generated program, greatly reduces the cross-system machine adjustment cost, improves the machining preparation efficiency and the reliability of the machining process, and has significant engineering application value. BRIEF DESCRIPTION OF DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art without creative work based on the drawings are within the protection scope of the present application.
[0054] Figure 1 A device agent graph is constructed for the device agent of the present application.
[0055] Figure 2 A processing code conversion method flowchart is provided for the present application.
[0056] Figure 3 An improved near-end policy optimization algorithm network graph is provided for the present application.
[0057] Figure 4 A case implementation flowchart based on conversion task prompt information is provided for the present application.
[0058] Figure 5 A processing code conversion device graph is provided for the present application. DETAILED DESCRIPTION
[0059] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work are within the protection scope of the present application.
[0060] The present application provides a device agent processing program conversion method based on cooperation of a large model and a small model, such as Figure 1As shown, this embodiment constructs a corresponding intelligent device for each CNC machine tool in the workshop to achieve control and information interaction. The intelligent device consists of three basic parameter libraries: a system parameter set, a kinematic parameter set, and a process constraint parameter set, as well as a three-layer functional structure: a communication layer, an intelligent decision-making layer, and an adaptation layer. The system parameter set records the CNC system brand and model, supported G / M instruction dictionaries, macro instruction styles, and subroutine calling methods. The kinematic parameter set describes the machine tool's axis structure and degrees of freedom, positive axis direction and zero point position, rotation center, travel range, and the spatial transformation relationship between the machine tool coordinate system and the workpiece coordinate system. The process constraint parameter set stores the machine tool's executable feed rate range, spindle speed range, depth of cut, cutting depth, safety plane height, restricted areas, and various machining process restrictions. Based on this, the communication layer of the intelligent device is responsible for establishing a real-time data exchange channel with the machine tool control system, enabling the reading and writing of machining programs, system variables, alarm information, and operating status. The intelligent decision-making layer integrates a semantic parsing module, a unified semantic generation module, a corpus interface, and a program conversion module, used to decompose instructions, abstract semantics, identify machining structures, and construct unified semantics from the source program uploaded from the machine tool side. The adaptation layer, based on the kinematic characteristics and safety constraints of the target machine tool, maps the unified semantics output by the intelligent decision-making layer into a sequence of G / M instructions executable by the machine tool control system, and performs syntax, security, and executability checks on the generated instructions before output. Figure 1 As shown in the structure, this application uses a unified approach to model parameters and encapsulate semantics for CNC machine tools of different brands and structures, enabling the intelligent agent of the equipment to work collaboratively with the cross-system program conversion platform in subsequent steps. This supports source program parsing, semantic abstraction, patch generation, code mapping, and secure program distribution, thereby realizing the conversion of automated machining programs in multi-system and multi-machine tool environments.
[0061] After the device's intelligent agent is constructed, the flowchart of the processing code conversion method is as follows: Figure 2 As shown, the main steps include: Constructing a CNC domain corpus covering multiple systems, structures, and process scenarios, and forming unified semantic mapping rules. Specifically, this involves: centrally collecting and preprocessing historical machining programs, standard process templates, and simulation generation programs from enterprises; unifying file encoding formats; removing comments, blank lines, and invalid characters; and processing each CNC instruction at the line-level granularity. Label the code and abstract it into a multidimensional function:
[0062]
[0063] in Indicates motion path type commands, used to describe the type of tool movement in space, such as linear interpolation, circular interpolation, helical interpolation, multi-axis linkage interpolation, etc. Machine tool function class instruction, used to reflect machine tool execution state and auxiliary functions, such as spindle start-stop, coolant switch, tool change, pause and program end, etc. Tool number and tool compensation index, used to indicate the tool used in current machining and the corresponding length compensation or radius compensation; Feed speed parameter, used to reflect the linear speed of the tool relative to the workpiece, which is an important process feature of tool cutting conditions; Spindle speed or spindle-related control parameter, used to describe the cutting speed or spindle power characteristics; Additional parameter set related to machining process, including depth, tool retraction, tool engagement, delay, tool path offset, coolant state, macro variable reference, etc. in fixed cycle.
[0064] After the above instruction element abstraction is completed, record the control system label to which each instruction belongs , combined with the system parameter set of the corresponding machine tool , kinematics parameter set and process constraint parameter set , through the unified semantic mapping function , where is the original machining instruction or numerical control instruction text, is the unified semantic mapping operator, which converts system-related and syntax-related instruction expressions into system-independent unified semantic descriptions , resulting in:
[0065]
[0066] where, represents the motion semantics of the instruction (such as LinearMove, ArcMove, RapidMove, etc.), represents the standardized function semantics (such as SpindleOn, CoolantOff, etc.), represents the tool geometry attribute and tool compensation type, represents the geometric information such as path endpoint, circle center, direction, normal vector, and respectively represent the normalized feed and spindle semantics and the abstracted process parameter set.
[0067] On the basis of this corpus, instructions from different numerical control systems but with equivalent or highly similar semantics are clustered across systems, and on this basis, a cross-system mapping matrix is constructed, as follows: each unified semantic is encoded as a high-dimensional feature vector, is the structured semantic set obtained after parsing the semantic instruction , To index the semantic instructions, the first movement semantic type , the first function semantic type , the first tool compensation type are discretely numbered, and each type is assigned a trainable or preset embedding vector, which is mapped to a corresponding embedding subspace, to obtain the first movement semantic embedding vector , the first function semantic embedding vector and the first tool semantic embedding vector ; for the first path semantic , the path end coordinates, the arc center, the normal vector, the interpolation direction, the feed mode (absolute / incremental), the interpolation plane (G17 / G18 / G19), the attitude angle (A / B / C) and other geometric and attitude parameters are normalized, and for different types of interpolation, a unified dimension parameter bit is filled (invalid dimension is set to 0) to form the first numerical feature vector , represents the movement path semantic information corresponding to the first semantic instruction, represents the corresponding feed parameter semantic information in the first semantic instruction, which is used to describe the feed amount or feed mode in the movement or machining process, and the first spindle speed or movement speed related semantic and the first other process or control parameter semantic logical features are discretely encoded and mapped into embedding vectors to form the first process and macro logical features , and finally, the unified high-dimensional feature representation vector of the first uniform semantic instruction is obtained by vector splicing:
[0068]
[0069] In order to comprehensively measure the difference between two uniform semantics in category semantics and numerical geometric / process features, the application designs a hybrid semantic distance:
[0070]
[0071] wherein Hamming distance, cosine distance or KL divergence can be used to measure the difference between discrete semantics (e.g. motion type, function type, tool compensation type, etc.); Euclidean distance, Mahalanobis distance or weighted normalized distance can be used to measure the difference between continuous geometric features and process parameters, a unified high-dimensional feature representation vector of the unified semantic instruction, and and is a weight coefficient, used to balance the contribution of categorical features and numerical features.
[0072] The total instruction sample set is divided into C semantic clusters under the distance constraint, and a plurality of semantic clusters are formed Kmeans clustering is performed under the distance constraint to obtain C semantic clusters, and a plurality of semantic clusters are formed wherein is the total number of instruction samples, is the number of semantic clusters, and represent the first and semantic clusters, and represent the index. Each cluster represents a type of numerical control instruction mode that is semantically equivalent or highly similar between different control systems, for example: ordinary straight line interpolation, clockwise circular arc interpolation, light load drilling cycle, deep hole segmented drilling cycle, tool calling, spindle start / stop, etc. The cluster number c in the present application is regarded as a unified semantic type number.
[0073] Further, the present application constructs a cross-system mapping matrix based on the semantic cluster results. Let the set of control systems participating in the conversion be Each instruction sample is labeled with the source control system and the corresponding original instruction form. For each semantic cluster and each control system , the sample subset belonging to the system is counted, and the original G / M code, fixed cycle format, parameter arrangement mode and macro statement style of all instruction samples in the subset are parsed and structured, and the most representative instruction expression structure of the semantic cluster in the control system is extracted.
[0074] Based on the syntax elements (such as G code, M code, tool compensation instruction, cycle header / tail, variable reference mode), parameter fields (such as X / Y / Z endpoint coordinates, I / J / K center offset, F / S parameters, depth / step / retreat amount, etc.) and their arrangement order, the standard template of the semantic cluster in the system is formed, denoted as:
[0075]
[0076] in The template generates functions, including instruction keyword structures such as G01 / G1, G02 / G02 / G3, G81 / G83, M03 / M5, etc.; macro structure mapping patterns (if present): including IF / WHILE, GOTO, LBL / CALL, and macro variable forms (such as #i, Ri, #). <name>Fixed cyclic mapping rules: such as G81 / G82 / G83 corresponding to CYCLE81 / 82 / 83 or Siemens CYCLE 95 / 97 parameter format; compatibility correction rules: such as attitude angle default completion, radius compensation number mapping, coordinate system switching supplement, etc.
[0077] After completing the extraction of all semantic cluster templates, control the system index. For row and semantic cluster numbering For each column, construct a cross-system mapping matrix. :
[0078]
[0079] The source program to be converted undergoes requirement semantic parsing, and conversion task prompts are constructed. When there is a source program... When it is necessary to migrate from one CNC system to another, the equipment intelligence agent of the source machine tool will handle the migration. The program performs syntax parsing and structural analysis. Through a built-in semantic parsing module, it decomposes the program at the line level, identifies instruction patterns, and analyzes contextual dependencies. Various G-instructions, M-instructions, tool call instructions, macro parameter instructions, and fixed loop instructions are extracted into structured syntactic units according to preset semantic rules, and further constructed into an abstract syntax tree. This abstract syntax tree includes machining step sequences (e.g., roughing, semi-finishing, finishing, drilling, tapping cycles, etc.), workpiece coordinate system and machine tool coordinate system setting instructions (e.g., G54, G55, G92, etc.), tool call and tool change sequences (e.g., ... This includes the set of trajectory points formed by linear interpolation, circular interpolation, or multi-axis linkage, as well as information such as conditional branches, loop logic, and variable dependencies corresponding to the macro structures in the source program. Based on this, the structural and semantic information in the abstract syntax tree is integrated with the system parameter set in the target machine tool's intelligent agent. and the set of process constraint parameters The source program is parsed according to the syntax rules, instruction format, parameter style of the target control system, and the kinematic structure, posture reachable range, axis stroke limit, tool compensation mechanism and safety plane of the target machine tool, and the machining depth, feed interval, spindle speed, tool retract distance, safety height, tool load, posture change range and spatial trajectory reachability in the source program are constrained and modeled, and the instruction segments that need to be adjusted, rewritten or re-planned are identified. Finally, based on the above analysis, abstraction and constraint modeling results, the model-oriented conversion task prompt information Prompt is constructed, the machining intention, parameter dependency, path structure, macro program logic in the abstract syntax tree, and the syntax rules, kinematic constraints and process safety requirements of the target machine tool are uniformly coded, so that the Prompt simultaneously expresses the "machining operation performed by the source program", "the reachable ability and syntax characteristics of the target machine tool", and "the process and safety constraints that must be met after conversion" three key semantics, providing unified and standardized input description for subsequent small model patch generation, large model patch evaluation and cross-system code reconstruction.
[0080] The small model is supervised learning fine-tuned to have basic numerical control semantic understanding and conversion capability. A small model with moderate parameter scale and suitable for deployment on an industrial PC or edge server is selected , and the aforementioned corpus is used as training data to perform supervised learning fine-tuning on the small model. In this process, the original instruction line is used as input, and its unified semantics is used as a supervised label to minimize the objective function:
[0081]
[0082] wherein, represents a small model for numerical control semantic understanding and conversion, is the parameter of the small model, is the parameter of the small model , and is the unified semantic prediction result generated by the small model for the input original instruction , and represents the cumulative sum of all instruction samples in the training data set, represents that the overall supervised learning loss function is minimized by optimizing the model parameters For cross-entropy loss or semantic alignment loss, it is used to constrain the model to output consistent with the true label in the multi-dimensional semantic space (motion semantics, function semantics, tool semantics, path semantics, process semantics, etc.). During the training process, the small model gradually learns to extract the essential semantic structure from the heterogeneous instruction format of different numerical control systems, masters the basic syntax rules of numerical control instructions, the abstract expression method of motion path, the semantic relationship of tool and compensation, the dependency relationship of macro structure and the encoding method of process parameters, and has the basic ability to map the input code to the system-independent unified semantic representation.
[0083] After completing the supervised learning fine-tuning, in order to further improve the small model's understanding of the complex numerical control program structure and the quality of cross-system conversion, a large model is introduced as a patch evaluator to build a knowledge transfer mechanism from large model evaluation to small model reinforcement learning adjustment. Under the condition of the third step generated Prompt, the small model According to the current parameters of the source program unified semantic representation , it predicts and generates a plurality of candidate conversion patch sets:
[0084]
[0085] Among them, and are the first and the first patch, is the patch index, is the total number of patches. Each patch represents a scheme for modifying the local or overall structure of the source program, including but not limited to: fixed loop structure replacement, automatic adjustment of process parameters such as feed rate, spindle speed, and cutting amount, IF / WHILE semantic reconstruction or variable dependency repair in macro programs, unified mapping of tool compensation instructions and target system tool compensation strategies, coordinate system conversion, rotation angle compensation and pose reparameterization of multi-axis linkage trajectory, automatic disassembly, parameter rewriting or processing flow reordering of incompatible instruction segments. Subsequently, the large model scores each patch from the following four dimensions according to the Prompt and patch content :
[0086]
[0087]
[0088] Among them, respectively represent the weight coefficients of semantic consistency, process rules, safety and kinematics dimensions, Measures used to measure whether a patch retains the original processing intent include: semantic consistency (e.g., whether the coarse processing intent has been changed), macro program logical equivalence (semantic preservation of IF conditions and loop structures), and trajectory direction, interpolation type, and path intent. Figure One To the point of being responsive. Used to evaluate whether the patch meets the machining process rules, such as whether the depth, depth of cut, stepover are within the allowable range, spindle speed, feed rate conforms to the tool parameter manual, fixed cycle input parameters conform to the system specifications, and whether the process flow is reasonable (roughing before finishing, surface before hole, etc.). This is used to determine whether a patch has potential hazards, such as whether it crosses the safety plane, whether it may cause the tool to penetrate into the workpiece, whether it did not exit to a safe height during tool change, and whether the switching of coolant, spindle, feed, and other states complies with safety logic. The criteria for evaluating whether the trajectory generated by the patch can be executed by the target machine tool include: whether the spatial attitude is reachable, whether the travel exceeds the limit after coordinate transformation, whether the multi-axis attitude angle exceeds the limit, and whether the rationality of forward kinematics / inverse kinematics is satisfied.
[0089] After obtaining the joint score of each candidate patch from the large model, to effectively transfer the knowledge of the large model to the capabilities of the small model, a reinforcement learning reward signal is constructed based on the patch quality differences. An improved proximal strategy is then used to iteratively update the parameters of the small model, gradually converging it to a generation strategy that better aligns with the evaluation preferences of the large model. The candidate patches are then... With unmodified baseline patch Perform quality comparisons and construct differential rewards. :
[0090]
[0091] like This indicates the patch quality is better than the baseline, and a positive reward is given; if This indicates a patch degradation and warrants a negative reward.
[0092] To avoid policy oscillations caused by fluctuations in patch quality during the early stages of training, this application introduces adaptive modulation coefficients. It gradually decreases as training progresses:
[0093]
[0094] in, This represents the current number of training steps. Total training steps The initial modulation factor, For the terminal modulation factor, It is a natural exponential function. It is the natural logarithm function;
[0095] Different patches contain significantly different amounts of information. To encourage smaller models to focus on patches highly regarded by larger models, this application introduces a priority sampling mechanism, based on the cumulative reward of each patch. Assign sampling probabilities, let the first... patch sampling probability for:
[0096]
[0097] in, Total number of patches For the first The sampling probability of each patch being selected. and The first The and the first The cumulative rewards from each patch, For patch index, This is the patch index for the currently calculated sampling probability;
[0098] Combining differential reward, adaptive modulation factor, and priority sampling distribution, small model parameters Updated to:
[0099]
[0100]
[0101]
[0102] in, For learning rate, These are the parameters of the small model before the previous policy update. It is a priority sampling probability vector constructed based on the accumulated reward. From probability vector Defined discrete categorical distribution, Indicates according to priority sampling distribution Randomly select patch index , The strategy ratio, The shearing threshold, The policy gradient is used to calculate the policy update direction. Preferred sampling distribution Patch Index Expectations For the current parameter Small model for patch The given strategy output value, old parameters Small model for patch the strategy output value, for the patch the corresponding advantage estimator, is a minimum function.
[0103] After the large model scoring and improved PPO update, the small model may still generate multiple feasible patch schemes. To improve the real-time performance of the workshop site, an entropy-based confidence evaluation and sorting mechanism is introduced. The small model outputs the conditional probability distribution of each token in the patch when generating the patch :
[0104]
[0105] wherein is the patch length, is the token in the patch, is the conditional probability distribution predicted by the small model when generating the token , and traverses all possible tokens in the model vocabulary. The system sorts the patches according to the entropy values from small to large, and only selects the patches with entropy values less than the threshold to enter the next verification process, improving the response speed.
[0106] After completing the patch screening, the optimal patch corresponding to the source program uniform semantic representation is denoted as , which is combined with the system parameter set , kinematics parameter set and process constraint parameter set pre-solidified in the target machine tool equipment agent by the cross-system code generation module, and the cross-system mapping function in step 2 is called to map the motion semantics, function semantics, tool semantics, path semantics and process semantics independent of the specific control system into the G / M instructions, fixed loop calling statements, macro variables and subprogram statements and tool compensation instruction expression forms supported by the target CNC system. For patches containing macro program structures, the present application rewrites the conditional judgment, loop control, variable assignment and subprogram call relationship in the uniform semantics into the IF / WHILE, LBL / CALL or GOTO structure of the target system based on the macro syntax style recorded in , ensuring the semantic equivalence of macro logic between different control systems. Subsequently, for trajectory segments involving multi-axis linkage, the code generation module utilizes The axis configuration, rotation center, workpiece coordinate system, and machine tool coordinate system transformation relationship stored in the memory are used to perform coordinate and posture transformation on the path geometry parameters in the unified semantics, map the abstract path points to the axis position instructions executable by the target machine tool, and check whether the entire trajectory sequence meets the stroke constraint and posture angle constraint conditions. If it is found that the local point position exceeds the reachable range of the target machine tool, automatic segmentation, interpolation step adjustment, or posture reparameterization is performed on the segment path according to the redrawing rules in the patch until the kinematic feasibility is met. After generating a complete target program After that, the system further combines the rule verification of the process parameters such as feed F, spindle speed S, cutting depth ap, cutting amount ae, tool retract amount, cutting-in / cutting-out mode, etc. to ensure that various fixed cycle parameters are within the range allowed by the target machine tool manual and process specification. At the same time, consistency checks are performed on the state switching between segments in the program, such as ensuring that the tool is retracted to a safe plane before tool change, the sequence of spindle start / stop and coolant switch is legal, and there is a safe movement before the first interpolation after coordinate system switching. Finally, after completing multiple verifications such as syntax legality, process rationality, kinematic feasibility, and collision safety, the communication layer of the target machine tool device agent writes the program into the program storage area (such as a specified program number or file name) of the machine tool control system through DNC, FTP, Ethernet, or special bus protocols, and can perform empty running simulation, single-segment trial cutting, or direct formal processing according to user settings, realizing the full-automatic closed-loop conversion process from unified semantics to target code and actual execution of the NC machining program across system and machine tool structure.
[0107] As shown in Figure 4 The present application realizes cross-system program conversion based on device agent and large / small model cooperation through the three-stage process of "source machining program analysis-cross-system machining program generation-code debugging and deployment", which includes the specific implementation process of two typical implementation cases of "Siemens->HNC" and "HNC->Siemens".
[0108] Case 1:
[0109] This embodiment illustrates the specific application process of the method of the present application in the cross-system conversion scene of "Siemens->HNC (HNC-8)". Combined with the Siemens source program %_N_OXMZ01_MPF and the target HNC program O OHZ01, the whole process of device agent, small model, and large model cooperation to realize automatic conversion of complex machining program is demonstrated.
[0110] In the workshop, the source machine tool is a machining center of Siemens numerical control system, and the target machine tool is a vertical machining center of HNC-8 series of Huazhong. First, according to the types of control systems, axis structures (X / Y / Z three axes), stroke ranges, zero points and coordinate system settings, tool magazine configurations, and the unique tool compensation rules (Txx and Hxx / Dxx one-to-one, M code zero padding, G81 / G83 fixed cycle format, etc.) of Huazhong system, the device agent is constructed respectively, and the rules such as "tool length compensation must use G43 Z… Hxx, radius compensation must use G41 / G42 Dxx and H, D number consistent with T number" are written into the target machine tool's process constraint parameter set and syntax rule library for solidification.
[0111] When the Siemens program %_N_OXMZ01_MPF is input into the system, the intelligent decision layer of the Siemens device agent performs line-level analysis on the source program, abstracts the tool and tool changing instructions T5 / M6, T7 / M6, T8 / M6, spindle and cooling control instructions S3500 M3, M8, M9, contour interpolation (a large number of G1 / G2 / G3 straight lines and circular arc segments), fixed cycle call MCALLCYCLE81(...), MCALLCYCLE83(...), and the spiral interpolation segment containing TURN=33 into system-independent unified semantic representation, extracts the corresponding motion semantics, tool semantics, path geometric features, process parameters, and macro / loop semantics, and generates a unified semantic sequence.
[0112] On this basis, the system combines the unified semantic analysis results with the system parameter set, kinematics parameter set and process constraint parameter set of the target Huazhong machine tool to construct a large model-oriented conversion task Prompt. The Prompt explicitly embeds the core rules set by the user: the first G00 after tool changing at the safety height must be supplemented with G43 Hxx, and xx is the current tool number; radius compensation G41 / G42 must be explicitly with Dxx, and consistent with the tool number; all M codes are uniformly padded to two-bit format (M03, M05, M08, M09, M30); CYCLE81 is converted to G98 G81, CYCLE83 is converted to G98 G83, and RTP / RFP / SDIS / DP / FDEP parameters are parsed according to the rules and mapped to Z, R, Q, etc.; when TURN= parameter is detected in an abnormally complex trajectory, it is prohibited to simplify it to a single-turn circular arc, and a Python trajectory generation script must be called to generate a point column in the XY plane in a counterclockwise spiral manner, with a Z-axis adjacent point spacing of 0.05. The Prompt also embeds safety constraint information such as "line-by-line, no omission conversion" and "prohibit any form of deletion or simplification of G43 Hxx, prohibit tool compensation number error".
[0113] Under the above Prompt constraints, the small model reasons on the unified semantic sequence and generates multiple candidate "conversion patch" schemes. Typical patches include: automatically adding G00 G43 Z100. H05M08 in the rapid positioning segment after T5 / M6 tool change; deleting the Siemens-specific G641 and retaining only the general G64 continuous cutting mode; unifying S3500 M3, M5, M8, M9 to zero as S3500 M03, M05, M08, M09; converting MCALL CYCLE81(50.,0.,3.,,1.) to the Huazhong format G98 G81 X… Y… Z-1. R3. F110.; converting MCALL CYCLE83(50.,0.,3.,,21.562,,1.,0.,0,0,1,1) to G98 G83 X… Y… Z-21.562 R3. Q-1, and automatically deriving the signs and values of Z, R, and Q according to the reference point and safety distance; for the spiral interpolation segment containing TURN=33, call the pre-set Python trajectory generation script to generate a high-density point column by walking the tool center path in the XY plane and reducing Z axis by 0.05, rewrite the original three-line G3 spiral interpolation segment with TURN to hundreds of lines of G01 / G03 interpolation instructions with X / Y / Z, strictly maintaining the original machining intent and geometric path.
[0114] The large model jointly scores each candidate patch from four dimensions:
[0115] (1) Semantic consistency: check if the contour is closed, if the final depth of spiral machining is maintained to Z-30, and if the drilling depth and pecking step distance are completely consistent with the original CYCLE83;
[0116] (2) Process rationality: check if the feed parameters F=1500, F=500, F=110 fall within the recommended process range of the equipment, and if the pecking step distance 1.0 is reasonable;
[0117] (3) Safety: check if the tool change and tool compensation are completed above Z100, and if there is dangerous motion that crosses the safety plane;
[0118] (4) Kinematic executability: check if the spiral reconstruction trajectory exceeds the machine tool stroke, and if the continuous interpolation meets the machine tool acceleration and deceleration capabilities, etc.
[0119] According to the joint scoring results, the large model automatically selects the patch scheme that is optimal in terms of semantic fidelity, process rationality, and safety, making it consistent or equivalent to the example Hua Zhong program OOHZ01 in terms of tool compensation calling, fixed loop unrolling, spiral trajectory splitting, M code zero padding, and comment retention, etc. Finally, the cross-system code generation module generates a complete Hua Zhong numerical control machining program based on the unified semantics corresponding to the optimal patch, combined with the G / M instruction format and macro syntax style solidified in the target Hua Zhong machine tool device agent: the first tool T05 processing section is automatically organized as G17 G90 G54 G64→ change tool T05 M06→ S3500 M03→ G00 G43 Z100. H05 M08, etc.; the spiral processing section containing TURN is expanded into a large number of continuous G03 / G01 coordinate points, and the Z axis is lowered from 3 to -30 in steps of 0.05; the drilling and deep hole processing section is automatically converted into G98 G81 and G98 G83, and G80 is added at the end to cancel the fixed cycle; all M codes are unified into two-bit format, and the (END OF PATH) and other comment information are retained as they are.
[0120] After the program is generated, the system performs multiple checks on its syntax, process, and safety. After passing the checks, the communication layer of the target machine tool device agent writes the program into the Hua Zhong numerical control system through the network interface, and can first perform an empty running simulation, and then perform a formal machining verification. This embodiment shows that the present application can realize high-fidelity automatic conversion from the Siemens system to the Hua Zhong system on a real production program that contains complex trajectories and fixed cycles.
[0121] Implementation Case 2:
[0122] This embodiment illustrates the application process of the method of the present application in the "Hua Zhong (HNC-8)→Siemens" direction, that is, taking the Hua Zhong source program OOHZ01 as input, the %_N_OXMZ01_MPF program that can be directly run on the Siemens system is automatically generated by the device of the present application, realizing equivalent conversion and automatic reconstruction between the two numerical control systems.
[0123] In this scenario, the source machine tool is a Huazhong HNC-8 CNC system, and the target machine tool is a Siemens CNC system. First, the Huazhong device agent performs sentence-level analysis on the OOHZ01 program, identifies and extracts key structures, including: tool changing and tool compensation segments (such as T05, M06, G00 G43 Z100. H05 M08, G41 X… Y… D05, etc.), fixed loop calls (G98 G81, G98 G83 and their X / Y / Z / R / Q / F parameters), regular contour machining segments, drilling point lists, and program annotations (END OF PATH), etc. After unified semantic processing, the above instructions are mapped to system-independent unified semantic representations, recording tool geometry information, compensation mode, path point sequence, and corresponding process parameters, providing standardized input for subsequent cross-system conversion.
[0124] Based on the above, the requirement analysis and prompt generation unit constructs a conversion prompt for large and small models in combination with the syntax and functional characteristics of the target Siemens system. The prompt specifies that: the round bracket annotations "()" in the Huazhong program are uniformly converted to the semicolon annotations ";…" commonly used by Siemens; G17 plane selection is supplemented or maintained at the beginning of the program; G40 / G641 compensation mode; map the tool length compensation of Huazhong G43 Hxx to the corresponding tool compensation mode of Siemens, and use G41 Dxx equivalent representation when radius compensation; map the continuous cutting mode G64 to Siemens G641; if there is G52 local coordinate bias in the source program, convert it to TRANS X… Y… Z…, and explicitly insert TRANS to cancel the bias at the end of the program; convert Huazhong G81 to MCALL CYCLE81(…), G83 to MCALL CYCLE83(…), and according to the parameter order of Siemens CYCLE81 / CYCLE83, recombine and map the parameters RTP, RFP, SDIS, DP, FDEP, etc.; At the same time, strictly restrict: do not change any machining geometry parameters, feed speed and machining depth, only allow equivalent rewriting at the syntax and structure level, prohibit any simplification or modification of the machining path and process itself.
[0125] Under the above Prompt constraints, the small model reasons on the unified semantic sequence and generates multiple candidate "conversion patch" schemes. Typical patches include: mapping the starting segment N10 G17 G90 G54 G64 to the Siemens style N10 G17 G90 G40 G54 G64 1 D1, inserting G40 / G64 and tool offset register D1 while keeping the plane selection and coordinate system unchanged; combining T05 M06, T07 M06, T08 M06 with the corresponding G43 Z100. H05 / H07 / H08 to generate the Siemens standard tool change and length compensation call sequence according to the target strategy; converting G98 G81 X-37.801 Y38.902 Z-1. R3. F110. and subsequent hole site into Siemens fixed cycle form, such as generating N820 MCALL CYCLE81(50.,0.,3.,,1.) in the specified program segment, and completing each hole processing through subsequent X… Y… linear movement, and ending the cycle at the appropriate position using MCALL; converting G98 G83 X-37.801 Y38.902 Z-21.562 R3. Q-1. and the corresponding hole site to N1010 MCALL CYCLE83(50.,0.,3.,,21.562,,1.,0.,0,0,1,1), and ensuring that the key parameters DP, FDEP, etc. are consistent with the Z, Q in the original G83; retaining the comment lines such as (TOOL NAME: …), (END OF PATH) completely, and annotating before and after the corresponding program segment in the Siemens style with a semicolon prefix.
[0126] The large model comprehensively evaluates the above candidate patches from the following aspects:
[0127] (1) Semantic consistency: check whether all hole coordinates, machining depths, and pecking drill step distances are completely consistent with the Hua Zhongyuan program, and ensure that the geometric semantics such as hole machining and contour machining are not deviated;
[0128] (2) Process rationality: check whether the parameters RTP / RFP / SDIS / DP / FDEP in CYCLE81 and CYCLE83 are correctly related to the corresponding R, Z, Q in the source G81 / G83 instructions, and whether there are sign direction errors or depth interpretation deviations;
[0129] (3) Safety: confirm that the tool change and tool offset are still executed at a safe height, and that the conversion of G81 / G83 to CYCLE81 / 83 does not introduce potential risks such as insufficient tool retract travel and fast tool down;
[0130] (4) Executability: Verify whether the generated CYCLE call format and MCALL syntax conform to the Siemens system specification, and whether the overall program can successfully pass through the Siemens simulation environment and has the feasibility of online processing.
[0131] The system scores and filters the candidate patches according to the above evaluation results, eliminates schemes with excessively high entropy values and insufficient confidence, and only retains high-confidence patches with highly consistent semantics and processes, optimal scores. The cross-system code generation and delivery unit then translates the unified semantics corresponding to the finally selected patch into Siemens G code to generate a complete %_N_OXMZ01_MPF program: automatically adds path declarations and comments such as %_N_OXMZ01_MPF, ; $PATH=...; to the program header, unifies the tool changing and compensation segments into Siemens standard formats (such as T5, M6, S3500 M3, G0 Z100. D1 M8 or equivalent structures), converts the G81 / G83 segments on the Huazhong side into MCALL CYCLE81(...), MCALL CYCLE83(...) calls, and adds MCALL to cancel the fixed loop at the end of the loop; standardizes and retains annotations such as (TOOL NAME: …), (END OF PATH), etc., and uniformly uses semicolon prefixes; and standardizes the program end to M5, M9, M30, etc. standard end statements.
[0132] The finally generated Siemens program can be directly verified on the target machine tool through simulation and trial cutting, realizing lossless automatic conversion from the Huazhong HNC-8 system to the Siemens system. This embodiment shows that the present application not only can realize high-fidelity program migration from "Siemens -> Huazhong", but also can complete automatic reconstruction and equivalent conversion from "Huazhong -> Siemens" under the premise that the geometry and process parameters remain unchanged, verifying the universality and reliability of the present application in the scenario of bidirectional cross-system program conversion.
[0133] As shown in Figure 5 The present application also proposes a numerical control system device agent program conversion device based on a large model, which is composed of a device agent construction module, a corpus construction module, a demand analysis and prompt generation module, a small model training and deployment module, a patch screening and verification module, and a cross-system code generation and delivery module, which are connected in turn, for unified semantic extraction, prompt word construction, candidate patch generation and screening, and automatic generation and deployment of target numerical control system executable code.
[0134] The various embodiments described in this specification are presented as examples of the application. Each embodiment is presented in a way that emphasizes the differences between the embodiments and the other embodiments. In particular, the device embodiments are described in less detail than the method embodiments because they are substantially similar to the method embodiments. The above description is presented in terms of preferred embodiments of the application, but the scope of the application is not limited to the preferred embodiments. Any person skilled in the art who understands the technology described in this specification can easily make changes or replacements within the scope of the technology disclosed in this specification, without departing from the principles of the application. Therefore, the scope of the application should be determined by the scope of the claims.< / name>
Claims
1. A method for processing program conversion of a device agent based on cooperation of a large model and a small model, characterized in that, The method comprises the following steps: Step 1: Based on the control system type, kinematic structure parameters and process constraint information of the target machine tool and the source machine tool, an equipment agent containing a system parameter set, a kinematic parameter set and a process constraint parameter set is constructed; Step 2: The equipment agent performs data acquisition and cleaning, abstracts the control system operation instructions of the machine tool system composed of the target machine tool and the source machine tool into a multi-dimensional semantic function, and combines the machine tool system parameters to execute a unified semantic mapping function to obtain a system-independent unified semantic representation; Step 3: The source program of the source machine tool control system to be converted is executed for line-level analysis, context dependency analysis, and an abstract syntax tree is constructed for the source program to be converted, the machining steps, coordinate system setting, tool calling, trajectory path and macro program logic are identified, and the conversion task prompt information template Prompt containing the machining intention, parameter dependency, path structure and target system constraint is generated according to the syntax rules, kinematic constraints and process restrictions of the target machine tool control system; Step 4: A small model is selected, the original instruction line is taken as input, and the unified semantic is taken as a supervision label for supervised learning training, so that the small model masters the syntax structure, tool compensation semantics, path expression and macro structure relationship of numerical control instructions, and has unified semantic analysis and initial conversion capability; Step 5: The small model generates a plurality of candidate patches based on the Prompt, the large model scores the patches from four dimensions of machining intention consistency, process rationality, safety and kinematic executability, constructs a differential reward according to the scoring results, and updates the parameters of the small model by using an improved proximal policy optimization algorithm, so as to realize the knowledge migration of the large model to the small model; Step 6: The average entropy value of the token conditional probability distribution of the candidate patch is calculated, and the high-confidence patch is selected as the final patch according to the entropy value size; Step 7: The cross-system code generation module is called to map the unified semantic corresponding to the final patch to the G / M instructions, fixed cycles, macro variable structure and multi-axis trajectory executable by the target machine tool to obtain the target program, and the target program is written into the program storage area of the target machine tool through the communication layer and executed for simulation or machining.
2. The device agent processing program conversion method based on large model and small model cooperation of claim 1, characterized in that, The equipment agent comprises a communication layer, an intelligent decision-making layer and an adaptation layer, and is used for realizing program reading and writing, semantic analysis, unified semantic generation, program conversion and executability verification.
3. The device agent processing program conversion method based on large model and small model cooperation of claim 2, characterized in that, According to the scoring results, the differential reward is constructed, and the improved proximal policy optimization algorithm is used to update the parameters of the small model. Introducing adaptive modulation coefficients , the adaptive modulation coefficients decrease gradually with training progress: ; wherein, is the current training step, is the total training steps, is the initial modulation factor, is the final modulation factor, is the natural exponential function, is the natural logarithm function; Introduce a priority sampling mechanism, according to the reward accumulation of each patch Assign a sampling probability, let the sampling probability of the i-th patch be: ; wherein, is the total number of patches, is the sampling probability of the th patch being selected, and are the reward accumulations of the th and the th patch, respectively, is the patch index, is the patch index for which the sampling probability is currently being calculated. In combination with the differential reward, the adaptive modulation factor and the priority sampling distribution, the small model parameters are updated as: ; ; ; where, is the learning rate, is the small model parameters before the last policy update, is the priority sampling probability vector constructed based on the reward accumulations, is the discrete categorical distribution defined by the probability vector , represents the random sampling of patch indices according to the priority sampling distribution , is the policy ratio, is the clipping threshold, is the policy gradient used to compute the policy update direction, is the expectation of the priority sampling distribution over the patch indices , is the policy output value given by the current parameters small model for the patch , is the policy output value given by the old parameters small model for the patch , is the advantage estimate for the patch , is the minimum function.
4. The device agent processing program conversion method based on large model and small model cooperation of claim 2, characterized in that, In step 2, the unified semantic mapping function is used to eliminate the syntax differences of different control systems, and the motion type, tool compensation mode, interpolation plane, path point, center of circle, normal vector, macro variable and fixed cycle parameter of the G / M instruction are converted into a system-independent standardized semantic expression.
5. The device agent processing program conversion method based on large model and small model cooperation of claim 4, characterized in that, The device agent parses historical machining programs, process planning documents, control system instruction sets, macro instruction syntax rules of the source machine tool and the target machine tool, and machining trajectory data generated by a digital twin simulation system, constructs a semantic corpus after data processing such as semantic extraction, instruction standardization and semantic alignment, and performs cross-system clustering on instructions from different numerical control systems but with semantic equivalence or high similarity based on the corpus, and constructs a cross-system mapping matrix; The device agent will use each unified semantic... Encoded as a high-dimensional feature vector, where For the first A unified semantic instruction, To make semantic instructions The structured semantic set obtained after parsing For semantic instruction index, for the first Motion semantic types , No. Functional semantic types , No. Tool compensation type Discretely number the vectors and assign a trainable or pre-defined embedding vector to each class, mapping them to the corresponding embedding subspaces to obtain motion semantic embedding vectors. Functional semantic embedding vector and tool semantic embedding vector For the first Path semantics The geometric and attitude parameters are normalized, and for different types of interpolation, parameter bits of a uniform dimension are filled to form numerical feature vectors. , Indicates the first The semantic information of the motion path corresponding to each semantic instruction. Indicates the first The semantic information of the feed parameters corresponding to each semantic instruction describes the feed amount or feed method during the motion or machining process. For the first... semantics related to spindle speed or motion speed and the Other process or control parameter semantics The logical features are discretely encoded, then mapped into embedding vectors, and combined to form process and macro-logical features. The first vector is obtained by concatenating vectors. A unified high-dimensional feature representation vector for a unified semantic instruction : 。 6. The device agent processing program conversion method based on large model and small model cooperation of claim 5, characterized in that, Defining mixed semantic distance : ; wherein for measuring the class difference between discrete semantics; for measuring the difference between continuous geometric features and process parameters, for the first a uniform high-dimensional feature representation vector of the uniform semantic instruction, for the semantic instruction index, and for the weight coefficient; The complete set of instruction samples Under the above distance constraints, K-means clustering is selected to obtain C semantic clusters, forming several semantic clusters. each of the clusters This represents a class of numerical control instruction patterns that are semantically equivalent or highly similar across different control systems. The total number of instruction samples. The number of semantic clusters, and They represent the first and A semantic cluster, and Represents an index.
7. The device agent processing program conversion method based on large model and small model cooperation of claim 6, characterized in that, A cross-system mapping matrix is constructed based on the semantic cluster results, and a set of control systems participating in the conversion is set as wherein and represent the first and the second semantic clusters, and represent indexes, and each instruction sample is provided with a source control system label and a corresponding original instruction form; For each semantic cluster and each control system , the sample subset belonging to the control system is counted and the original G / M code, fixed loop format, parameter arrangement and macro statement style of all instruction samples within the subset are parsed and structured to extract the most representative instruction expression structure of the semantic cluster under the control system . Based on the syntax elements, parameter fields and their arrangement order, the semantic cluster is formed In a standard template under the control system , denoted as : ; wherein, The template generating function generates a template including an instruction keyword structure, a macro structure mapping pattern, a fixed loop mapping rule, and a compatibility correction rule. After all semantic cluster templates are completed, index the control system by row, semantic cluster number by column, build cross-system mapping matrix : 。 8. A device agent processing program conversion apparatus based on large model and small model cooperation, characterized in that, The conversion device is used to realize the conversion method according to claim 1, and the conversion device comprises: A device agent construction module is configured to collect machine tool systems and kinematic parameters and construct a device agent. A corpus construction module is configured to generate unified semantic mapping rules. A requirement analysis and prompt generation module is configured to analyze source programs and generate conversion tasks Prompt. A small model training and deployment module is configured to perform supervised learning fine-tuning. A large model evaluation module is configured to jointly score candidate patches. A patch entropy value sorting and verification module is configured to filter high-confidence patches. A cross-system code generation and delivery module is configured to map patches to executable programs of the target machine tool and write them into the machine tool control system.
Citation Information
Patent Citations
Industrial robot process package generation system and method of large language model
CN116679909A
General electromyographic signal processing method and system based on large self-supervised model
CN121337377A