Code flow method based on large model
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-11
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]为了解决算力网络的计算资源调度效率低下的问题,本发明提供了一种基于大模型的代码流转方法,能够实现跨平台、跨硬件和跨编程框架的代码自动化适配,从而实现异构计算资源的智能调度和优化
本发明提供的一种基于大模型的代码流转方法,首先通过预先构建结构化提示词模板,该结构化提示词模板包括系统提示词和功能提示词,其中,系统提示词用于定义大模型扮演代码适配专家的角色并规定输出格式规范,以统一模型输出格式;功能提示词用于描述与目标配置参数一一对应的具体的适配任务;然后在后端服务器接收到携带原始代码和目标配置参数的代码适配请求之后,通过检索结构化提示词模板库,将目标配置参数与其中的结构化提示词模板进行逐一匹配,检索出对应的结构化提示词模板;最后将代码适配请求中的原始代码与该对应的结构化提示词模板拼接后,输入大模型,就可以输出目标代码,即与目标配置参数适配的代码,从而能够实现跨平台、跨硬件和跨编程框架的代码自动化适配,并进一步地能够实现异构计算资源的智能调度和优化。
Smart Images

Figure CN122569953A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a code flow method based on a large model. Background Technology
[0002] Computing networks have become a core infrastructure supporting computing tasks across multiple industries. Their computing resources originate from various cloud service providers and encompass diverse heterogeneous hardware devices, forming a resource landscape that is "cross-regional, cross-platform, and multi-architecture." The hardware devices within computing networks include various types such as graphics processing units (GPUs) (e.g., NVIDIA A100), neural network processing units (NPUs) (e.g., Huawei Ascend 910), and deep learning units (DCUs). The instruction sets and acceleration libraries of these different hardware components differ fundamentally. For example, GPU tasks rely on the CUDA library, while NPU tasks require calling the Ascend acceleration interface based on the MindSpore framework. When migrating GPU tasks to NPUs, users need to modify the hardware calling logic, replace the acceleration library, and resolve data precision compatibility issues. Furthermore, there are significant differences in the interface specifications (including task input / output formats, data storage and retrieval methods) of programming frameworks (e.g., PyTorch, TensorFlow) and different platforms (e.g., OpenI, Supercomputing Internet).
[0003] To address the challenges of code adaptation, when users request cross-platform computing resources, engineers often need to manually analyze the differences between the source code and the target platform, and make extensive manual modifications to the original task code. This process is not only labor-intensive and error-prone, but also severely restricts the efficient scheduling of computing resources and the efficiency of task migration. Achieving automatic adaptation of source code in heterogeneous computing environments has become a key bottleneck in improving the overall performance of computing networks. Summary of the Invention
[0004] To address the problem of low efficiency in scheduling computing resources in computing networks, this invention provides a code flow method based on a large model, which can achieve automated code adaptation across platforms, hardware, and programming frameworks, thereby enabling intelligent scheduling and optimization of heterogeneous computing resources.
[0005] To achieve the above objectives, according to a first aspect of the present invention, a code flow method based on a large model is provided, which is executed by a backend server and includes: Receive code adaptation requests. Code adaptation requests are obtained by encapsulating the original code and target configuration parameters. Target configuration parameters include target platform type, target hardware architecture, and target programming framework. Based on the target configuration parameters in the code adaptation request, the structured prompt word template library is retrieved. Each structured prompt word template contains system prompt words and function prompt words. System prompt words are used to define the role of the large model as a code adaptation expert and specify the output format specifications. Function prompt words are used to describe the specific adaptation tasks that correspond one-to-one with the target configuration parameters. The original code in the code adaptation request is concatenated with the retrieved structured prompt word template, then input into the large model, and the target code is output.
[0006] Furthermore, the original code from the code adaptation request is concatenated with the retrieved corresponding structured prompt word template, then input into the large model, and the target code is output. This includes concatenating the original code from the code adaptation request with the retrieved corresponding structured prompt word template, inputting it into the large model, and outputting analysis results. The analysis results include the locations in the code that need to be modified and modification suggestions. Based on the analysis results, the segment to be modified in the original code is obtained. The segment to be modified, the analysis results, and the target configuration parameters are used as input to the large model, and the large model is called again to generate the adapted code segment. The adapted code segment and the unmodified part of the original code are merged to form the target code.
[0007] Furthermore, the above-mentioned code flow method based on a large model also includes returning the target code to the front end; the front end displays the original code and the target code simultaneously in the code editing area, which is also used for users to manually modify the target code and receive user confirmation information.
[0008] Furthermore, the aforementioned code flow method based on a large model also includes the following steps: after receiving confirmation from the user, the front end sends a task submission request to the task scheduling module of the computing power network operation and control platform. The task submission request includes the final code confirmed by the user and the target configuration parameters. Both the task scheduling module and the backend server are deployed on the computing power network operation and control platform. The task scheduling module calls the API of the computing power network operation and control platform corresponding to the target platform type to package the final code confirmed by the user and the user task configuration into a new computing task. The new computing task is submitted to the computing power network operation and control platform corresponding to the target platform type and allocated the corresponding hardware resources for execution.
[0009] Furthermore, the original code in the code adaptation request is concatenated with the retrieved corresponding structured prompt word template and then input into the large model. The analysis results are output, including: concatenating the original code in the code adaptation request with the retrieved corresponding structured prompt word template and inputting it into the large model; performing semantic analysis through the large model to identify at least one key element, which includes hardware call logic, framework dependencies, or platform interface specifications; and outputting analysis results based on at least one key element.
[0010] Furthermore, based on the analysis results, the code snippet to be modified in the original code is obtained. The snippet to be modified, the analysis results, and the target configuration parameters are used as input to the large model, which is then invoked again to generate an adapted code snippet. This includes obtaining the code adaptation scenario type and the code snippet to be modified in the original code based on the analysis results. The code adaptation scenario types include simple API replacement scenarios and scenarios with complex logic. For simple API replacement scenarios, the rule engine processes the code snippet to be modified based on the analysis results and the target configuration parameters. For scenarios with complex logic, the large model is invoked again to process the code snippet to be modified based on the analysis results and the target configuration parameters to generate an adapted code snippet.
[0011] Furthermore, the adapted code snippet and the unmodified parts of the original code are merged to form the target code. This includes merging the adapted code snippet and the unmodified parts of the original code to form the target code; verifying the target code to ensure that the code is executable; and outputting the target code that passes the verification.
[0012] Furthermore, the large model is a locally deployed, lightweight large model.
[0013] Furthermore, the above-mentioned code flow method based on large models also includes setting the large model to a context-free mode.
[0014] Furthermore, the function prompts include features of the original code, features of the target code, transformation templates, and sample code, with the transformation templates and sample code derived from expert knowledge.
[0015] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects: This invention provides a code flow method based on a large model. First, a structured prompt word template is pre-constructed. This template includes system prompt words and function prompt words. The system prompt words define the large model's role as a code adaptation expert and specify the output format to unify the model's output format. The function prompt words describe the specific adaptation tasks that correspond one-to-one with the target configuration parameters. Then, after the backend server receives a code adaptation request carrying the original code and target configuration parameters, it searches the structured prompt word template library, matching the target configuration parameters with the corresponding structured prompt word templates one by one to retrieve the appropriate template. Finally, the original code in the code adaptation request is concatenated with the corresponding structured prompt word template and input into the large model. This outputs the target code, i.e., the code adapted to the target configuration parameters. This enables automated code adaptation across platforms, hardware, and programming frameworks, and further allows for intelligent scheduling and optimization of heterogeneous computing resources. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart illustrating a code flow method based on a large model, provided as an embodiment of this application; Figure 2 A schematic diagram of a code flow method based on a large model is provided for another embodiment of this application; Figure 3 Example diagrams of system prompts provided in embodiments of this application; Figure 4 Example diagram of function prompts provided in the embodiments of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0019] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.
[0020] like Figure 1 As shown, a code flow method based on a large model is provided, which is executed collaboratively by a front-end and a back-end server. The front-end can be, but is not limited to, various personal computers, laptops, and smartphones. The back-end server can be a standalone server or a server cluster consisting of multiple servers. In this embodiment, the back-end server is the main execution entity, and the method includes the following steps: Step 101: Receive code adaptation request. The code adaptation request is obtained by encapsulating the original code and target configuration parameters. The target configuration parameters include the target platform type, target hardware architecture and target programming framework.
[0021] For example, the frontend obtains the original code and target configuration parameters, encapsulates the original code and target configuration parameters into a code adaptation request in a specified format (e.g., an HTTP request in JSON format), and then sends it to the backend server. The backend server receives the code adaptation request.
[0022] Step 102: Based on the target configuration parameters in the code adaptation request, retrieve the structured prompt word template library. Each structured prompt word template contains system prompt words and function prompt words. System prompt words are used to define the role of the large model as a code adaptation expert and specify the output format specifications. Function prompt words are used to describe the specific adaptation tasks that correspond one-to-one with the target configuration parameters.
[0023] Each structured prompt word template corresponds to a set of target configuration parameters, namely a combination of target platform type, target hardware architecture, and target programming framework.
[0024] Step 103: After concatenating the original code in the code adaptation request with the retrieved corresponding structured prompt word template, input the result into the large model and output the target code.
[0025] The target code is derived from the original code and adapted to the target configuration parameters.
[0026] The aforementioned code flow method based on a large model first pre-constructs structured prompt word templates. These templates include system prompt words and function prompt words. System prompt words define the large model's role as a code adaptation expert and specify output format standards to unify model output formats. Function prompt words describe specific adaptation tasks that correspond one-to-one with target configuration parameters. Then, after the backend server receives a code adaptation request carrying the original code and target configuration parameters, it searches the structured prompt word template library, matching the target configuration parameters with the corresponding structured prompt word templates one by one to retrieve the appropriate template. Finally, the original code in the code adaptation request is concatenated with the corresponding structured prompt word template and input into the large model to output the target code, i.e., the code adapted to the target configuration parameters. This enables automated code adaptation across platforms, hardware, and programming frameworks, and further allows for intelligent scheduling and optimization of heterogeneous computing resources.
[0027] In one embodiment, step 103 includes the following steps: the backend server concatenates the code adaptation request with the retrieved corresponding structured prompt word template, inputs it into the large model, and outputs the analysis results, which include the locations in the code that need to be modified and modification suggestions; based on the analysis results, the segment to be modified in the original code is obtained; the segment to be modified, the analysis results, and the target configuration parameters are used as input to the large model, and the large model is called again to generate the adapted code segment; the adapted code segment and the original code are merged to form the target code.
[0028] In this embodiment, by first generating the analysis results to clarify the code modification location and modification suggestions, and then generating the target code to adapt to the target platform type, target hardware architecture and target programming framework corresponding to the target configuration parameters, this two-stage "analysis first, generation later" strategy can avoid the situation where a large model processes too many tasks in one call, resulting in incorrect results.
[0029] In one embodiment, a system (i.e., the backend server in the above embodiment) is provided. This system, as an independent service module, can be directly deployed within a cross-regional, cross-architecture computing center or multi-computing center operation and control platform (such as a computing network operation and control platform). It is deeply integrated with the task scheduling module, resource management module, user authentication module, and other modules of the operation and control platform, serving as a core auxiliary service provided by the operation and control platform. The system deploys lightweight large models locally on the operation and control platform based on the Dify framework (an open-source large model application development platform that supports visual AI workflow construction). It executes code flow methods based on lightweight large models, achieving full-process automation from user submission of original code to generation of adapted code.
[0030] Typical application scenarios for this method include: AI training scripts have been migrated from the GPU environment to the NPU environment; Convert PyTorch framework code to TensorFlow framework code; Tasks from the Qizhi OpenI platform have been migrated to the supercomputing internet platform. Hot migration adaptation of running tasks.
[0031] like Figure 2 As shown, the method specifically includes the following steps: Step 1: Encapsulate User Input and Requests (Data Entry Point) Input data: Users submit two parts of the data through the front-end web interface: (1) Original code: You can enter it directly in the code editing area or submit it through the file upload function (supports common formats such as .py and .ipynb).
[0032] (2) Target configuration parameters: Select the target platform type (such as Qizhi OpenI, supercomputing Internet), target hardware architecture (such as GPU, NPU, DCU), and target programming framework (such as PyTorch, TensorFlow) through the drop-down menu or form.
[0033] Data flow: The front end encapsulates the original code text and target configuration parameters into a JSON-formatted HTTP request and sends it to the system through the API gateway.
[0034] In this step, the target parameter configuration is submitted by providing a graphical configuration interface, which eliminates the need for users to manually write any adaptation rules or prompts, thus greatly reducing the barrier to entry for this code flow method based on a large model.
[0035] Step Two: Intelligent Semantic Analysis (Code Understanding) Input data: raw code text, target configuration parameters.
[0036] Processing procedure: The backend service retrieves the corresponding structured prompt word template from a pre-built structured prompt word template library (also known as an adaptation strategy library) based on the target configuration parameters.
[0037] The structured prompt template library is deployed in the form of a structured database (such as PostgreSQL), storing the solidified structured prompt templates for all platforms, hardware, and frameworks.
[0038] The structured prompt template consists of two parts: (1) System prompts: These define the Large Language Model (LLM) as playing the role of a "code adaptation expert" and specify the output format (see reference). Figure 3 ).
[0039] (2) Function prompts: used to describe specific adaptation tasks, such as "Please modify the following PyTorch training script to be compatible with Huawei Ascend NPU, use the torch_npu plugin, replace all .cuda() with .npu(), and adjust the pin_memory parameter of the data loader to False" (see reference). Figure 4 ).
[0040] Functional prompts include characteristics of the original code, characteristics of the target code, conversion templates (including documentation describing common sense or existing technologies related to code adaptation), and sample code, wherein the conversion templates and sample code are based on expert knowledge.
[0041] The function prompts correspond one-to-one with the target configuration parameters. The function prompts use a multi-level index, preferably a three-level index of "target platform type - target hardware architecture - target programming framework" to facilitate fast retrieval.
[0042] The backend service concatenates the encapsulated raw code text with the corresponding structured prompt word template to form a complete large model input.
[0043] Invoke a locally deployed lightweight / lightweight large model (a large model with relatively small parameter size, such as DeepSeek-Coder-33B), and force the large model to be set to a context-free mode (i.e., each inference is an independent session, without carrying any historical session information). Each call initializes a new model session, without carrying any historical session information.
[0044] Regarding the selection of large models, domestic open-source large models covering Kimi-K2, DeepSeek R1 / V3.1, Qwen3, DeepSeek-Coder, and Qwen3-Coder-Plus-30B were selected for testing. After multiple rounds of testing for different functions (cross-platform, heterogeneous hardware adaptation, and modification of programming framework), it was confirmed that under the premise of fixed prompt words, a large model of 30B can meet the requirements without relying on ultra-large-scale general models, thus balancing performance and deployment costs.
[0045] Regarding context control, actual testing revealed that enabling context association mode in large models can easily lead to code style or variable naming conventions from previous tasks being carried over to the current modification, resulting in logical errors. Therefore, this embodiment chooses to disable context association mode in large models to make the generated results more stable and reliable.
[0046] The large model performed deep semantic analysis on the code and identified the following key elements: (1) Hardware calling logic: such as torch.cuda, npu-related APIs, CUDA kernel functions, etc.
[0047] (2) Framework dependencies: such as import statements for modules like torch and tf.keras.
[0048] (3) Platform interface specifications: such as data reading path ( / data / vs s3: / / bucket / ), environment variable settings, task submission format, etc.
[0049] Large model output analysis results are usually returned in a structured form (such as JSON), including the locations in the code that need to be modified and modification suggestions. For example, modify a certain element in the first row (such as hardware call point, framework API, path variable, etc.) to an element adapted to the Qizhi OpenI platform.
[0050] Data flow: The backend service transmits the analysis results to the code conversion module (as a functional module in the backend service).
[0051] This step combines expert knowledge (i.e., the transformation templates and sample code in the structured prompt templates) with the capabilities of the large model. First, by solidifying the prompts using templates (i.e., defining structured prompt templates including system prompts and function prompts), the standardization of the large model's output is ensured, avoiding the uncontrollability caused by the large model's "free rein" and the uncertainty brought by user-designed prompts. Solidifying prompts using templates also guides the large model to focus on specific adaptation tasks, significantly improving the accuracy and efficiency of the analysis. Then, a lightweight, locally deployed large model is selected. On the one hand, the 30B dedicated code model, with its solidified prompts, achieves a near 100% modification success rate, saving computing resources and controlling deployment costs. On the other hand, it ensures code security, avoiding data privacy risks associated with transferring code to an online large model platform. Furthermore, setting the large model to a context-free mode avoids interference from previous tasks, ensuring that each analysis is performed independently of the current task, improving the stability of each generated result.
[0052] Step 3: Code Generation and Adaptation (Code Conversion Module) Input data: original code, analysis results, target configuration parameters.
[0053] Processing procedure: (1) The code conversion module, based on the modification suggestions in the analysis results and the target configuration, calls the large model again to generate specific adapted code snippets.
[0054] (2) Among them, for conversions with strong determinism (such as API name replacement, .cuda()→.npu()), the rule engine can be used to process them quickly first, and then the large model can handle the complex logic (such as data loader parameter adjustment, multi-card training logic modification).
[0055] (3) The adapted code snippets generated by the large model are merged with the unmodified parts of the original code to form the complete target code.
[0056] (4) The system performs basic verification on the generated target code (such as syntax checking and dependency import checking) to ensure that the code is runnable.
[0057] Data flow: The generated target code is returned to the front end in JSON format.
[0058] This step first employs a two-stage "analysis + generation" invocation strategy, analyzing first and then generating to avoid processing too many tasks in a single call, which could lead to incorrect results. Secondly, during the large model generation process, sample code from the adaptation strategy library is referenced in real-time to ensure that the code style and specifications meet the target platform's requirements. Furthermore, a hybrid mechanism of "rule engine + large model" is used, ensuring both rapid processing of common transformations and maintaining intelligence in handling complex scenarios, while reducing excessive reliance on the large model and lowering latency and cost.
[0059] Step 4: Results Display and User Interaction (Before Data Export) Input data: original code, generated target code, and modification difference comparison information.
[0060] Processing procedure: (1) After the front end receives the target code, it displays the original code and the target code in the code editing area at the same time, and highlights the modified lines.
[0061] (2) Provide a comparison view (left-right comparison or in-line difference) to visualize the comparison information of the modification difference, so that users can quickly understand the modification content.
[0062] (3) Users can manually fine-tune the target code directly in the code editing area.
[0063] (4) After confirming that everything is correct, click the "Submit" button.
[0064] Data flow: The final code after user confirmation is encapsulated into a task submission request and sent to the task scheduling module of the computing power network operation and control platform.
[0065] In this step, a visual code editing area is provided, enabling visual code comparison and fine-tuning functions, which ensures both automation efficiency and the flexibility of manual intervention.
[0066] Step 5: Task Submission and Execution (Data Export) Input data: final code after user confirmation, user task configuration (such as resource requirements, run commands).
[0067] Processing procedure: (1) The task scheduling module calls the API of the computing power network operation and control platform (hereinafter referred to as the target computing power platform) corresponding to the target platform type, and packages the final code confirmed by the user and the user task configuration into a new computing task.
[0068] (2) The task is submitted to the target computing platform (such as Qizhi OpenI, supercomputing Internet) and the corresponding hardware resources are allocated for execution.
[0069] Data flow: The code is eventually deployed to run in a heterogeneous computing environment.
[0070] This step achieves a closed-loop process from code adaptation to task execution, allowing users to complete cross-platform task migration simply by clicking the "One-Click Submit" button once.
[0071] Step Six: Error Feedback and Knowledge Base Update (Closed-Loop Optimization) Input data: Error logs when the task fails, and user feedback.
[0072] Processing procedure: (1) The system automatically collects error information of failed tasks and calls the big model to analyze the error logs and extract the reasons for failure (such as missing dependencies, API usage errors, precision mismatch, etc.).
[0073] (2) Summarize the reasons for failure and the corresponding solutions, and store them as new knowledge items in the external knowledge base of the large model.
[0074] (3) Regularly optimize and update the structured prompt word template using the content of the plug-in knowledge base, such as adding prompts for common errors or adjusting the sample code.
[0075] Data flow: After the plug-in knowledge base is updated, subsequent code adaptation tasks (i.e., step two above: intelligent semantic analysis (code understanding) and step three: code generation and adaptation) will benefit from the optimized structured prompt word template, improving the success rate.
[0076] In this step, an error feedback and continuous optimization mechanism is established. By collecting failure cases, the knowledge base of plug-ins is continuously enriched, and a closed-loop mechanism for continuous learning is built, enabling the system to continuously optimize itself and adapt to new platform versions and hardware types.
[0077] This embodiment provides a code flow method based on a large model, which has the following beneficial effects: (1) Automating code adaptation: By leveraging the code understanding and generation capabilities of large models, the method automatically identifies hardware call logic, programming framework dependencies, and platform interface specifications in the original code, and automatically generates adapted target code. This significantly improves code adaptation efficiency, enhances user experience, and increases task deployment efficiency. Experimental results show that this method achieved a 97% success rate in 288 cross-platform, cross-hardware, and cross-framework code adaptation tests (excluding 7 local deployment failures). Compared to manual modification, this method reduces the workload of code adaptation by 92.3%, and the modified code can completely complete the training task, while manual modification suffers from the problem of missing key modification points.
[0078] (2) Lowering the barrier to entry for users: Users do not need to delve into the underlying technical details of the target platform (such as the differences between NVIDIA’s parallel computing platform and programming model CUDA and Huawei Ascend AI processor’s heterogeneous computing architecture CANN, and the API mapping relationship between the open-source machine learning framework PyTorch and TensorFlow). They can simply select the target configuration parameters, including the target platform type, target hardware architecture and target programming framework, through a simple interface operation to complete the complex code adaptation work with one click, transforming the code adaptation work from “user actively and manually modifying” to “platform assistance”.
[0079] (3) Improve the success rate and stability of adaptation: Through technical means such as structured prompt word templates, lightweight large model selection, and setting large model no context association mode, ensure the accuracy and stability of the generated results.
[0080] (4) Building a sustainable optimization capability: By establishing an error feedback and continuous optimization mechanism, it is possible to collect failure cases to continuously enrich the plug-in knowledge base, continuously optimize the structured prompt word template, and achieve the intelligent adaptation effect of "the more you use it, the more accurate it becomes".
[0081] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0082] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0083] The above description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of embodiments of this disclosure upon considering the specification and practicing the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described herein. The specification and embodiments are to be considered exemplary only, and the scope and spirit of this disclosure are defined by the claims.
[0084] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0085] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A code flow method based on a large model, characterized in that, Executed by the backend server, including: Receive code adaptation request, which is obtained by encapsulating the original code and target configuration parameters, including target platform type, target hardware architecture and target programming framework; Based on the target configuration parameters in the code adaptation request, a structured prompt word template library is retrieved. Each structured prompt word template contains system prompt words and function prompt words. The system prompt words are used to define the role of the large model as a code adaptation expert and specify the output format specifications. The function prompt words are used to describe the specific adaptation tasks that correspond one-to-one with the target configuration parameters. The original code in the code adaptation request is concatenated with the retrieved corresponding structured prompt word template, then input into the large model, and the target code is output.
2. The method as described in claim 1, characterized in that, The process of concatenating the original code in the code adaptation request with the retrieved corresponding structured prompt word template, inputting it into the large model, and outputting the target code includes: The original code in the code adaptation request is concatenated with the retrieved corresponding structured prompt word template, then input into the large model, and the analysis results are output. The analysis results include the parts of the code that need to be modified and modification suggestions. Based on the analysis results, the segment to be modified in the original code is obtained; the segment to be modified, the analysis results, and the target configuration parameters are used as input to the large model, and the large model is called again to generate the adapted code segment; The adapted code snippet and the unmodified portion of the original code are merged to form the target code.
3. The method as described in claim 1, characterized in that, Also includes: Return the target code to the front end; The front end displays both the original code and the target code in the code editing area. The code editing area is also used for users to manually modify the target code and receive confirmation from the user that the code is correct.
4. The method as described in claim 3, characterized in that, The process also includes the front-end sending a task submission request to the task scheduling module after receiving confirmation from the user. The task submission request includes the final code and target configuration parameters confirmed by the user. Both the task scheduling module and the back-end server are deployed on the computing power network operation and control platform. The task scheduling module calls the API of the computing power network operation and control platform corresponding to the target platform type to package the final code confirmed by the user and the user task configuration into a new computing task. The new computing task is submitted to the computing power network operation and control platform corresponding to the target platform type and allocated corresponding hardware resources for execution.
5. The method as described in claim 2, characterized in that, The process involves concatenating the original code from the code adaptation request with the retrieved corresponding structured prompt word template, inputting it into a large model, and outputting analysis results, including: The original code in the code adaptation request is concatenated with the retrieved corresponding structured prompt word template and then input into the large model; Semantic analysis of a large model identifies at least one key element, which includes hardware calling logic, framework dependencies, or platform interface specifications. Based on at least one of the key elements, output the analysis results.
6. The method as described in claim 2, characterized in that, Based on the analysis results, the step involves obtaining the segment to be modified from the original code; using the segment to be modified, the analysis results, and the target configuration parameters as input to the large model, and then calling the large model again to generate an adapted code segment, including: Based on the analysis results, the code adaptation scenario types and the segments to be modified in the original code are obtained. The code adaptation scenario types include simple API replacement scenarios and complex logic scenarios. For the simple API replacement scenario, the rule engine processes the fragment to be modified based on the analysis results and the target configuration parameters; For scenarios with complex logic, based on the analysis results and the target configuration parameters, the large model is invoked again to process the segment to be modified, generating an adapted code segment.
7. The method as described in claim 2, characterized in that, The step of merging the adapted code fragment and the unmodified portion of the original code to form the target code includes: The adapted code snippet and the unmodified portion of the original code are merged to form the target code; The target code is verified to ensure that it is executable; Output the target code that passes the verification.
8. The method as described in claim 1, characterized in that, The large model is a locally deployed, lightweight large model.
9. The method as described in claim 1 or 2, characterized in that, Also includes: The large model is set to a context-free mode.
10. The method as described in claim 1, characterized in that, The functional prompts include features of the original code, features of the target code, a conversion template, and sample code, wherein the conversion template and sample code are derived based on expert knowledge.