Algorithm Visualization Methods Based on Large Models
By performing semantic analysis and instrumentation point localization on a large model, calling code is automatically generated, solving the problems of universality and automation in algorithm visualization technology. This achieves efficient and accurate algorithm visualization and reduces development difficulty.
Patent Information
- Application Number
- CN202511269887.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-09-08
AI Technical Summary
Existing algorithm visualization technologies lack versatility, have high development barriers, low automation levels, and cannot effectively support the visualization needs of custom or complex algorithms.
By using large models for semantic analysis, instrumentation points in the algorithm are automatically identified and calling code is generated. Operation code templates are matched with a preset code library to generate an operation queue for visualization, thereby automating and improving the accuracy of the instrumentation process.
It improves the processing efficiency and accuracy of algorithm visualization, lowers the development threshold, supports universal visualization conversion of any algorithm, and enhances applicability and robustness.
Smart Images

Figure CN120743256B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to an algorithm visualization method based on large models. Background Technology
[0002] With the continuous development of computer technology, algorithm visualization technology has gradually become an important tool in research and teaching. It helps users understand the execution process and logic of algorithms more intuitively, thereby improving learning efficiency and development quality. Related algorithm visualization technologies mainly include the following implementation methods: The first category is visualization tools based on predefined templates, such as VisuAlgo (an algorithm visualization platform that supports Chinese) and Algorithm Visualizer (an online platform for visualizing code algorithms). The second category is visualization frameworks based on code annotations, such as Manim (Mathematical Animation Engine) and Algomation (an algorithm visualization tool). The third category is dedicated visualization development environments, such as Processing (an open-source graphics design language) and p5.js (a graphical programming library).
[0003] However, the above methods have the following main drawbacks: Most related tools are designed for specific algorithm types, lacking versatility. Predefined template tools only support a limited number of classic algorithms and cannot handle user-defined or emerging algorithms; annotation-based frameworks, while offering better flexibility, require writing specialized visualization logic for different algorithm types, failing to achieve true generalization. When faced with complex custom or cross-domain algorithms, these tools often fail to provide effective visualization support, lacking applicability and versatility. Traditional visualization tools require users to have strong programming skills and visualization development experience. Annotation-based methods require users to have a deep understanding of visualization APIs (Application Programming Interfaces) and animation control logic; dedicated development environments require users to master graphical programming skills; even with relatively simple predefined tools, users need to learn specific operation interfaces and parameter configuration methods, resulting in high development costs and technical barriers. Related technologies generally rely on manual analysis and configuration, lacking intelligent processing capabilities. Users need to manually identify key execution points in the algorithm, manually add visualization markers, and manually adjust animation parameters and display effects. When the algorithm logic changes, the corresponding visualization code also needs to be manually modified synchronously, resulting in high maintenance costs, low automation, and significant demand for manual intervention.
[0004] Given the aforementioned shortcomings of existing algorithm visualization technologies, there is an urgent need for a new algorithm visualization technology that can address issues such as insufficient applicability, high development barriers, and low automation levels, in order to meet the growing demand for algorithm visualization. Summary of the Invention
[0005] To address or partially address the problems existing in related technologies, this application provides an algorithm visualization method based on a large model. This method can leverage the code understanding capabilities of the large model to automatically perform semantic analysis, instrumentation point localization, and instrumentation code generation during the visualization process. This not only improves processing efficiency but also ensures the accuracy and consistency of the instrumentation code in the visualization operation, enhances the applicability of visualization technology, and lowers the development threshold.
[0006] The first aspect of this application provides an algorithm visualization method based on a large model, including:
[0007] The original code is obtained by transforming the target data to be visualized using a large model, and the original code is analyzed to obtain the analysis results.
[0008] Identify the analysis results to obtain at least one instrumentation point in the original code, as well as the location and type of the instrumentation point;
[0009] The target operation code template is matched sequentially from a preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations;
[0010] Instructions are generated sequentially based on the position of each insertion point and the corresponding target operation code template, and the instructions are inserted into the position of the insertion point.
[0011] The calling code is converted into operation objects, and the operation objects are arranged in execution order to generate an operation queue;
[0012] The target data is visualized based on the operation queue.
[0013] In one embodiment, the step of sequentially matching target operation code templates from a preset code library according to the type of each of the instrumentation points includes:
[0014] For any of the aforementioned instrumentation points, the large model determines the type of visualization operation based on the type of the instrumentation point and the context code;
[0015] Match the target operation code template from the preset code library according to the determined type of visualization operation.
[0016] In one embodiment, the step of generating calling code sequentially based on the position of each of the insertion points and the corresponding target operation code template includes:
[0017] Identify the position variable representing the location of the insertion point;
[0018] The position variable is filled into the target operation code template to generate the calling code.
[0019] In one embodiment, the step of converting the calling code into operation objects and arranging the operation objects in execution order to form an operation queue includes:
[0020] Identify the key steps in the calling code;
[0021] The key steps are transformed into operation objects, which include operation type, operation data, and metadata description.
[0022] The operation objects are organized into the operation queue according to the execution order.
[0023] In one embodiment, visualizing the target data based on the operation queue includes:
[0024] The data structure of the operation data of each operation object in the operation queue is determined sequentially, and a visualization scheme is determined based on the data structure of the operation data;
[0025] The visualization script code is generated based on the visualization scheme; the script code is used to respond to the operation commands sent by the user on the interactive interface and to perform visualization display.
[0026] In one embodiment, the process of transforming the target data to be visualized using a large model to obtain the original code includes:
[0027] Determine the data type of the target data; the target data type includes at least natural language and algorithm code.
[0028] If the target data is natural language, then the target data is converted into the original code of the target language type;
[0029] If the target data is algorithm code, and the algorithm code is not in the target language type, the target data will be converted into the original code of the target type.
[0030] In one embodiment, the original code is analyzed to obtain the following analysis results:
[0031] The original code is combined with a preset structure list to generate structured instructions;
[0032] The large model performs semantic analysis on the original code based on the structured instructions, and generates the analysis results.
[0033] In one embodiment, the process further includes the following after generating the operation queue:
[0034] Check the operation queue for syntax errors, and if syntax errors are found, perform syntax repair on the operation queue.
[0035] If there are no syntax errors, execute the operation queue and determine whether the operation queue passes the runtime check;
[0036] If the operation check fails, the operation queue will be repaired.
[0037] A second aspect of this application provides an algorithm visualization device based on a large model, comprising:
[0038] The analysis module is used to transform the target data to be visualized using a large model to obtain the original code; and to analyze the original code to obtain the analysis results.
[0039] The identification module is used to identify at least one instrumentation point in the original code obtained from the analysis results, as well as the position and type of the instrumentation point;
[0040] The matching module is used to match target operation code templates from a preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations;
[0041] An instrumentation module is used to generate calling code sequentially based on the position of each instrumentation point and the corresponding target operation code template, and to insert the calling code into the position of the instrumentation point;
[0042] The operation queue module is used to convert the calling code into operation objects and arrange the operation objects in the execution order to generate an operation queue.
[0043] A visualization module is used to visualize the target data based on the operation queue.
[0044] A third aspect of this application provides an electronic device, comprising:
[0045] Processor; and
[0046] A memory that stores executable code, which, when executed by the processor, causes the processor to perform the method described above.
[0047] The technical solution provided in this application may include the following beneficial results:
[0048] This application provides an algorithm visualization method based on a large model. The method includes transforming the target data to be visualized using the large model to obtain original code, analyzing the original code to obtain analysis results, identifying at least one instrumentation point in the original code, and the position and type of the instrumentation point. Then, based on the type of each instrumentation point, a target operation code template is matched from a preset code library. The preset code library includes operation code templates corresponding to different types of visualization operations. Call code is generated sequentially based on the position of each instrumentation point and the corresponding target operation code template, and the call code is inserted into the position of the instrumentation point. The call code is then transformed into an operation object, and the operation objects are arranged in execution order to generate an operation queue. The target data is visualized based on the operation queue. This method leverages the code understanding capabilities of the large model to automatically perform semantic analysis, instrumentation point location, and instrumentation code generation during the visualization process. This not only improves processing efficiency but also ensures the accuracy and consistency of the instrumentation of visualization operation instrumentation code, enhances the applicability of visualization technology, and lowers the development threshold.
[0049] The technical solution of this application precisely inserts the calling code into the corresponding position of the original code to obtain the operation queue, thus completing the automated integration of the code. The instrumentation process strictly follows the principle of keeping the original algorithm logic unchanged, inserting the calling code only synchronously in key steps such as data structure creation, modification, and access. The entire instrumentation process is fully automated, requiring no manual intervention, and the instrumented code maintains the integrity and correctness of the original algorithm. It achieves decoupling between algorithm logic and visualization representation. The algorithm execution layer focuses on generating a standardized operation queue, while the visualization rendering layer performs corresponding graphic rendering based on the operation type and data in the queue, thereby supporting general visualization conversion of any algorithm. The adaptive fault tolerance mechanism dynamically adjusts the repair strategy according to the error type and frequency, thereby improving the repair success rate and enhancing the overall robustness of the solution.
[0050] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0051] The above and other objects, features and advantages of this application will become more apparent from the more detailed description of exemplary embodiments thereof in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments thereof.
[0052] Figure 1 This is a flowchart illustrating the algorithm visualization method based on a large model, as shown in the embodiments of this application;
[0053] Figure 2 This is another flowchart illustrating the algorithm visualization method based on a large model as shown in the embodiments of this application;
[0054] Figure 3 This is a flowchart illustrating the automatic fault-tolerance mechanism in an embodiment of this application;
[0055] Figure 4 This is a schematic diagram of the process for analyzing target data as shown in an embodiment of this application;
[0056] Figure 5 This is a schematic diagram of the process for generating an operation queue, as shown in an embodiment of this application;
[0057] Figure 6 This is a flowchart illustrating an algorithm visualization based on a large model, as shown in an embodiment of this application;
[0058] Figure 7a This is a schematic diagram of the original array order in the bubble sort algorithm shown in the embodiments of this application;
[0059] Figure 7b This is a schematic diagram illustrating the array element comparison process in the bubble algorithm as shown in the embodiments of this application;
[0060] Figure 7c This is another schematic diagram illustrating the array element comparison process in the bubble algorithm shown in the embodiments of this application;
[0061] Figure 7d This is a schematic diagram illustrating the completion of array element comparison in the bubble algorithm as shown in the embodiments of this application;
[0062] Figure 8 This is a schematic diagram of the structure of an algorithm visualization device based on a large model, as shown in an embodiment of this application;
[0063] Figure 9 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application. Detailed Implementation
[0064] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.
[0065] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0066] It should be understood that although the terms "first," "second," "third," etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0067] Given the shortcomings of existing algorithm visualization technologies, there is an urgent need for a new algorithm visualization technology that can address issues such as insufficient applicability, high development barriers, and low automation levels, in order to meet the growing demand for algorithm visualization and promote the application and development of algorithms in a wider range of fields.
[0068] To address the aforementioned issues, this application provides an algorithm visualization method based on a large model. This method leverages the code understanding capabilities of the large model to automatically perform semantic analysis, instrumentation point localization, and instrumentation code generation during the visualization process. This not only improves processing efficiency but also ensures the accuracy and consistency of the instrumentation code in the visualization operation, enhancing the applicability of visualization technology and lowering the development threshold.
[0069] The technical solutions of the embodiments of this application are described in detail below with reference to the accompanying drawings.
[0070] Figure 1 This is a flowchart illustrating an algorithm visualization method based on a large model, as shown in an embodiment of this application.
[0071] See Figure 1 The method includes:
[0072] Step 110: Transform the target data to be visualized using a large model to obtain the original code; and analyze the original code to obtain the analysis results.
[0073] Visualization is the theory, method, and technology of using computer graphics and image processing techniques to convert data into graphics or images for display on a screen, followed by interactive processing. To enhance the applicability of visualization technology and lower the development threshold, this application provides an algorithm visualization method based on a large model. This method can be applied to fields such as education, software development, and content creation. In education, it can serve as an algorithm visualization generation module to assist algorithm learning websites; in software development, it can be used as a visualization plugin for IDEs (Integrated Development Environments); and in content creation, it can be embedded as an algorithm visualization in technical blogs or documents.
[0074] The large model can be a large language model (LLM), which refers to a deep learning model trained on a large amount of text data, enabling it to generate natural language text or understand the meaning of language text. In this embodiment, the large model can receive user-input target data to be visualized, transform the target data to obtain raw code, ensure the consistency of the subsequent execution environment, and perform semantic analysis on the raw code to obtain analysis results, providing standardized data for subsequent processing.
[0075] Step 120: Identify and analyze the results to obtain at least one instrumentation point in the original code, as well as the location and type of the instrumentation point.
[0076] Based on a predefined instrumentation rule set, the analysis results can be traversed and identified to obtain at least one instrumentation point in the original code, along with its location and type. In one example, the predefined instrumentation rule set could be "insert a queue operation recording data changes after each structure of type 'variable assignment'", or "insert a queue operation highlighting the loop control variable before each structure of type 'loop body entry'". In one example, the types of instrumentation points include: data structure initialization points, loop iteration key points, conditional branch points, and data operation execution points.
[0077] Step 130: Match the target operation code template from the preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations.
[0078] The pre-built code library includes operation code templates for different types of visualization operations. It's actually a core, well-designed `OperationQueue` utility class, which encapsulates methods for adding standardized operations to the operation queue. Each method corresponds to a specific operation. For example, the `create_array2d` method (create a two-dimensional array):
[0079] def create_array2d(self, array: List[List[int]], array_id: Optional[str]= None,
[0080] metadata: str = "Creating a two-dimensional array", row_position: Optional[int] = None) ->str:
[0081] """Creating a two-dimensional array"""
[0082] if array_id is None:
[0083] array_id = self.get_next_array2d_id()
[0084] self.add_operation(
[0085] operation="create_array2d",
[0086] data={"array": [row.copy() for row in array], "id": array_id},
[0087] metadata=metadata,
[0088] row_position=row_position )
[0090] return array_id
[0091] The `create_array2d` method is specifically responsible for the event of "creating a two-dimensional array," adding it to the operation queue in standard JSON (a lightweight data interchange format). The default codebase also includes other methods such as `highlight(...)`, `swap(...)`, and `update_element(...)`, which together constitute a stable and standardized API (Application Programming Interface) for interacting with the large model.
[0092] For each instrumentation point, the target operation code template that best matches the type of the instrumentation point can be determined from the preset code library based on the type of the instrumentation point.
[0093] Step 140: Generate calling code according to the position of each instrumentation point and the corresponding target operation code template, and insert the calling code into the position of the instrumentation point.
[0094] The operation code template contains the name, parameters, and comments of the public method. Based on the location of each instrumentation point, the large model sequentially fills the position information of the instrumentation point into the matching target operation code template, thereby generating the calling code corresponding to the instrumentation point. This calling code is then precisely inserted into the corresponding position in the original code, completing automated code integration. The instrumentation process strictly adheres to the principle of maintaining the original algorithm logic unchanged, inserting calling code only synchronously during key steps such as data structure creation, modification, and access. The entire instrumentation process is fully automated, requiring no manual intervention, and the instrumented code maintains the integrity and correctness of the original algorithm.
[0095] Step 150: Transform the calling code into operation objects, and arrange the operation objects in the execution order to generate an operation queue.
[0096] This application introduces a general operation queue mechanism, which establishes a standardized operation abstraction system. It uniformly represents the execution process of any algorithm as an ordered sequence of operations. The operation queue is stored in JSON format, and each operation element includes fields such as operation type identifier, target data structure identifier, operation parameter set, and operation comments. A rich vocabulary of predefined operation types is provided, covering: data access operations (e.g., highlight, unhighlight), data modification operations (e.g., assign, swap, insert, delete), and structure transformation operations (e.g., split, merge, rotate). Through standardized abstraction, the specific operations of different algorithms, such as element swapping in bubble sort, node access in binary tree traversal, and state transitions in dynamic programming, can be uniformly represented as operation records in the same format, thereby realizing an algorithm-independent general visualization processing framework. After generating the calling code, the calling code corresponding to each instrumentation point can be converted into an operation object, and the operation objects can be arranged according to the execution order to generate the operation queue.
[0097] Step 160: Visualize the target data based on the operation queue.
[0098] When performing visualization, the execution steps, data changes, and algorithm state transition information recorded in the operation queue are analyzed. An appropriate visualization scheme is selected based on the algorithm type and data structure characteristics, and the target data is visualized based on the selected visualization method.
[0099] This application provides an algorithm visualization method based on a large model. The method includes transforming the target data to be visualized using the large model to obtain original code, analyzing the original code to obtain analysis results, identifying at least one instrumentation point in the original code, and the position and type of the instrumentation point. Then, based on the type of each instrumentation point, a target operation code template is matched from a preset code library. The preset code library includes operation code templates corresponding to different types of visualization operations. Call code is generated sequentially based on the position of each instrumentation point and the corresponding target operation code template, and the call code is inserted into the position of the instrumentation point. The call code is then transformed into an operation object, and the operation objects are arranged in execution order to generate an operation queue. The target data is visualized based on the operation queue. This method leverages the code understanding capabilities of the large model to automatically perform semantic analysis, instrumentation point location, and instrumentation code generation during the visualization process. This not only improves processing efficiency but also ensures the accuracy and consistency of the instrumentation of visualization operation instrumentation code, enhances the applicability of visualization technology, and lowers the development threshold.
[0100] Figure 2 This is another flowchart illustrating an algorithm visualization method based on a large model, as shown in an embodiment of this application.
[0101] See Figure 2 The method includes:
[0102] Step 210: Transform the target data to be visualized using a large model to obtain the original code, and analyze the original code to obtain the analysis results.
[0103] In this embodiment of the application, the large model can receive target data to be visualized by user input, transform the target data to obtain the original code, ensure the consistency of the subsequent execution environment, and perform semantic analysis on the original code to obtain analysis results, providing standardized data for subsequent processing.
[0104] Step 220: Identify and analyze the results to obtain at least one instrumentation point in the original code, as well as the location and type of the instrumentation point.
[0105] Based on the preset instrumentation rule set, the analysis results can be traversed and identified to obtain at least one instrumentation point in the original code, as well as the position and type of the instrumentation point.
[0106] Step 230: Match the target operation code template from the preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations.
[0107] The pre-built code library includes operation code templates corresponding to different types of visual operations. It is actually a core, well-designed `OperationQueue` utility class, which encapsulates methods for adding standardized operations to the operation queue. Each method corresponds to a specific operation. For each located instrumentation point, the target operation code template that best matches the instrumentation point type can be determined from the pre-built code library based on the instrumentation point's type.
[0108] Step 240: Generate calling code according to the position of each instrumentation point and the corresponding target operation code template, and insert the calling code into the position of the instrumentation point.
[0109] The operation code template contains the name, parameters, and comments of the public method. Based on the location of each instrumentation point, the large model sequentially fills the position information of the instrumentation point into the matching target operation code template, thereby generating the calling code corresponding to the instrumentation point. This calling code is then precisely inserted into the corresponding position in the original code, completing automated code integration. The instrumentation process strictly adheres to the principle of maintaining the original algorithm logic unchanged, inserting calling code only synchronously during key steps such as data structure creation, modification, and access. The entire instrumentation process is fully automated, requiring no manual intervention, and the instrumented code maintains the integrity and correctness of the original algorithm.
[0110] Step 250: Identify the key steps in the calling code.
[0111] After inserting the calling code at the instrumentation point, the key steps in the execution process of the calling code can be identified, such as inserting, deleting, and highlighting elements, and creating, modifying, and accessing data structures.
[0112] Step 260: Transform the key steps into operation objects, which include operation type, operation data, and metadata description.
[0113] The key steps are transformed into operation objects, each of which contains three core fields: operation (operation type), data (operation data), and metadata (metadata description).
[0114] For example, array creation operations are represented as:
[0115] {"operation": "create_array",
[0116] "data": {"array": [4, 2, 1, 3], "id": "arr1"},
[0117] "metadata": "one-dimensional array"}.
[0118] Step 270: Organize the operation objects into an operation queue according to the execution order.
[0119] By organizing multiple operation objects into an operation queue according to their execution order, a complete intermediate representation of the algorithm execution process is formed, and the operation queue fully records each step of the algorithm execution.
[0120] Step 280: Determine the data structure of the operation data for each operation object in the operation queue in sequence, and determine the visualization scheme based on the data structure of the operation data.
[0121] Based on the data structure of the operation data for each operation object in the operation queue, a visualization scheme corresponding to the data structure can be determined. In one example, the visualization scheme specifically includes: graphical representation, how to display the data structure graphically; animation effects design, dynamic changes during the operation process; layout and style, the arrangement and visual style of elements in the image. When the data structure is an array type, the visualization scheme to choose from is: horizontally or vertically arranged rectangles; animation effects: element highlighting, swapping animation, comparison pointer movement. When the data structure is a linked list type, the visualization scheme to choose from is: a node + arrow connection structure; animation effects: pointer redirection, node movement, connection line changes. When the data structure is a tree structure, the visualization scheme to choose from is: a hierarchical node tree layout; animation effects: node path highlighting, subtree rotation, balance adjustment. When the data structure is a graph structure, the visualization scheme to choose from is: a node + edge network graph layout; animation effects: path highlighting, weight changes.
[0122] Step 290: Generate visualization script code based on the visualization scheme; the script code is used to respond to the operation commands sent by the user in the interactive interface and to perform visualization display.
[0123] Based on the determined visualization scheme, visualization script code is dynamically generated using the D3.js (a data-driven documentation library) technology stack. This enables the visualization of various data structures such as arrays, linked lists, trees, and graphs, and supports animated demonstrations of different algorithm types, including sorting, searching, and dynamic programming. A component-based design is adopted, providing an extensible visualization component library that supports the flexible addition of new visualization types and the customization of existing components.
[0124] Furthermore, the embodiments of this application can also realize the interactive function between users and the visualized content. After the user sends an operation command on the interactive interface, the system responds to the operation command by visualizing the algorithm through script code, presenting a dynamic visualization effect of the algorithm execution in the user interface. The user interface also provides complete playback control functions, including play, pause, single-step execution, fast forward, rewind, and other operations, supporting precise playback control such as forward, backward, and jump. Users can control the playback speed and progress of the visualization process as needed, providing an effective technical means for algorithm teaching and debugging. In addition, the user interface also supports interactive parameter adjustment. Users can modify algorithm input data or adjust algorithm parameters, and the system can respond in real time and regenerate the corresponding visualization display, realizing dynamic debugging and exploratory learning.
[0125] In an optional embodiment of this application, step 270 is followed by:
[0126] Check the operation queue for syntax errors, and if syntax errors are found, perform syntax repair on the operation queue;
[0127] If no syntax errors are found, execute the operation queue and determine whether the operation queue passes the runtime check.
[0128] If the operation check fails, perform an operation repair on the operation queue.
[0129] Reference Figure 3 The diagram below illustrates the automatic fault-tolerance mechanism in an embodiment of this application. To ensure stability and reliability in the face of complex and ever-changing input scenarios, this embodiment designs an adaptive fault-tolerance mechanism. This mechanism adopts a layered and progressive fault-tolerance strategy, establishing a complete error detection, diagnosis, and repair system.
[0130] After generating the operation queue, a static syntax check can be performed to examine it for syntax errors. To prevent infinite repair loops, a maximum number of repair attempts is set. Upon confirming a syntax error, it's determined whether the repair attempts have exceeded the threshold. If the threshold is exceeded, automatic repair stops, and a detailed syntax error report and manual intervention suggestions are returned to the user. If the threshold is not exceeded, the code repair capabilities of the large-scale model are utilized to analyze the error type and location, automatically generating a syntactically correct version of the code to repair the operation queue.
[0131] If no syntax errors are found, the operation queue is executed, and it is checked whether the operation queue passes the runtime check. If it passes the runtime check, the execution is successful. To prevent infinite repair loops, a maximum number of repair attempts is set. If the runtime check fails and an exception occurs (such as undefined variable, index out of bounds, type mismatch, etc.), it is checked whether the number of repair attempts exceeds the threshold. If the number of repair attempts exceeds the threshold, automatic repair stops, and a detailed runtime error report and manual intervention suggestions are returned to the user. If the number of repair attempts does not exceed the threshold, the code repair capabilities of the large language model are used to analyze the exception stack information, analyze the error type and location, and feed the feedback to the large model to automatically generate a repair plan for runtime repair. If the number of repair attempts exceeds the threshold, automatic repair stops, and a detailed error report and manual intervention suggestions are returned to the user. By using an adaptive fault tolerance mechanism to handle the operation queue, the final operation queue can be obtained. The adaptive fault tolerance mechanism dynamically adjusts the repair strategy according to the error type and frequency, thereby improving the repair success rate and enhancing the overall robustness of the solution.
[0132] This application's embodiments precisely insert the calling code into the corresponding positions of the original code, thereby obtaining an operation queue and completing automated code integration. The instrumentation process strictly adheres to the principle of maintaining the original algorithm logic unchanged, inserting the calling code only synchronously in key steps such as data structure creation, modification, and access. The entire instrumentation process is fully automated, requiring no manual intervention, and the instrumented code maintains the integrity and correctness of the original algorithm. It achieves decoupling between algorithm logic and visualization representation; the algorithm execution layer focuses on generating a standardized operation queue, while the visualization rendering layer performs corresponding graphical rendering based on the operation type and data in the queue, thus supporting general visualization conversion for any algorithm. An adaptive fault-tolerance mechanism dynamically adjusts the repair strategy based on error type and frequency, thereby improving the repair success rate and enhancing the overall robustness of the solution.
[0133] like Figure 4 The diagram shown is a flowchart illustrating the analysis of target data according to an embodiment of this application, including:
[0134] Step 410: Determine the data type of the target data; the data type should include at least natural language and algorithm code.
[0135] In this embodiment, user input of different types of target data is supported, such as natural language and algorithm code. After obtaining the target data, it is first determined whether the target data input by the user is natural language or algorithm code.
[0136] Step 420: If the target data is natural language, then convert the target data into the original code of the target language type.
[0137] If the target data is in natural language, it can be converted into raw code in the target language type. In one example, the target language type is Python.
[0138] Step 430: If the target data is algorithm code, and the algorithm code is not in the target language type, convert the target data into the original code of the target type.
[0139] If the target data is algorithm code, and the target data is not in the target language type, the target data will be converted into the original code of the target language. In one example, if the target language type is not Python, the target data will be converted into the original Python language code.
[0140] Step 440: Combine the original code with the preset structure list to generate structured instructions.
[0141] A predefined list of preset structures related to key programs can be established. This list should include at least: variable assignment statements, data structure initialization statements, loop entry and exit points, conditional branches, function calls and returns, and modification operations (such as insertion, deletion, and swapping) for specific data structures (e.g., arrays, linked lists). Combining the original code with this list of preset structures can generate a structured instruction.
[0142] In one example, a structured instruction could be:
[0143] ROLE is a high-precision static code analysis engine. Your goal is to break down source code into a series of basic operation sequences for general algorithm visualization systems.
[0144] The TASK analysis provides a code snippet. Identify and extract all occurrences of the following "basic program structure".
[0145] TARGET STRUCTURES
[0146] Variable assignment: Any assignment to a new variable or an existing variable.
[0147] Loop start (loop_start): The start of any for or while loop, including the loop condition.
[0148] Conditional branch: an if statement including its condition.
[0149] Function call: Any call to a function or method. Pay special attention to recursive calls.
[0150] Return statement: The return statement, including the returned value (if any).
[0151] Data modification (data_mutation): Any operation that directly modifies a data structure (such as a list, array, or dictionary). This includes, but is not limited to:
[0152] Update the element at the specified index (e.g., arr[i] = value)
[0153] Adding elements (e.g., list.append(value))
[0154] Deleting elements (e.g., list.pop())
[0155] Swap two elements
[0156] OUTPUT FORMAT must return the output as a single, minimal JSON array. Do not include any explanation. Each object in the array must have the following key:
[0157] "line_number": (integer) The line number in the code where this structure was found.
[0158] "type": (String) Structure type, which must be one of the six types defined above.
[0159] "details": (string) A concise description of the operation, including the variables, expressions, or values involved.
[0160] CODE TO ANALYZE [Enter the algorithm code to be processed here]
[0161] START OF OUTPUT
[0162] Step 450: The large model performs semantic analysis on the original code based on the structured instructions and generates analysis results.
[0163] The large model performs semantic analysis on the original code based on structured instructions. During this process, it first analyzes the core logical structure of the algorithm: for example, which loops and conditional branches are included. Then, it identifies the data flow: describing how data (such as variables and arrays) is created, read, modified, and passed within the program. Finally, it understands the algorithmic semantics of the original code. After semantic recognition, it returns an analysis result in a specific format (e.g., JSON), which can be a semantic analysis graph. The analysis result includes the location information (such as line number and column number) and type of each key program structure in the original code.
[0164] The embodiments of this application can not only process algorithm code, but also natural language, which improves applicability and lowers the development threshold; by using precise structured instructions to leverage the code understanding capabilities of large language models, the model is guided to complete automated information extraction tasks with clear inputs and outputs.
[0165] like Figure 5 The diagram shown is a flowchart illustrating the generation of an operation queue according to an embodiment of this application, including:
[0166] Step 510: Identify and analyze the results to obtain at least one instrumentation point in the original code, as well as the location and type of the instrumentation point.
[0167] Based on a predefined instrumentation rule set, the analysis results can be traversed, identified, and key execution paths can be determined, thereby obtaining at least one instrumentation point in the original code, along with its location and type. In one example, the predefined instrumentation rule set could be "insert a queue operation recording data changes after each structure of type 'variable assignment'", or "insert a queue operation highlighting the loop control variable before each structure of type 'loop body entry'". In one example, the types of instrumentation points include: data structure initialization points, key loop iteration points, conditional branch points, and data operation execution points.
[0168] Step 520: For any instrumentation point, the large model determines the type of visualization operation based on the type of the instrumentation point and the context code.
[0169] To ensure an accurate match between the operation code template and the instrumentation point, the instrumentation point type and context code can be provided to the large model. After receiving the instrumentation point type and context code, the large model can understand the intent based on the instrumentation point's code and type. For example, if it understands that a "data exchange" event has occurred at this instrumentation point, it can determine that the type of the visualization operation is data exchange.
[0170] Step 530: Match the target operation code template from the preset code library according to the determined type of visualization operation.
[0171] Based on the determined type of visualization operation, the target operation code template corresponding to the instrumentation point type is searched from the preset code library. In one example, the large model searches the provided OperationQueue API interface definition and finds the function that best matches "data exchange", such as: swap(self, array_id, index1, index2).
[0172] Step 540: Identify the position variable representing the insertion point location.
[0173] The large model analyzes the context code and identifies positional variables that represent the location of the insertion point (such as array ID being arr, with two indices being j and j+1).
[0174] Step 550: Fill the position variable into the target operation code template to generate the calling code.
[0175] The positional variables are populated into the target operation code template, and the large model generates complete and syntactically correct calling code, such as: `operation_queue.swap(array_id='arr', index1=j, index2=j+1)`. Visual operation record code is automatically inserted at key execution locations in the original code. This instrumented code is responsible for adding each key operation during algorithm execution to the visual operation queue, such as insertion, deletion, and element highlighting. The instrumentation process strictly adheres to the principle of maintaining the original algorithm logic unchanged, only synchronously inserting queue record operations during critical steps such as data structure creation, modification, and access.
[0176] The embodiments of this application perform intelligent code insertion on the input algorithm code, that is, automatically embeds the recorded code at key execution points without manual intervention.
[0177] To better understand the technical solutions of the embodiments of this application, Figure 6 A flowchart illustrating algorithm visualization based on a large model is provided, comprising the following steps: receiving target data to be visualized from user input; determining the data type of the target data; if the target data is natural language, performing natural language processing to convert the target data into raw code of the target language type; if the target data is algorithm code, performing code processing; if the algorithm code is not of the target language type, converting the target data into raw code of the target type; combining the raw code with a preset structure list to generate structured instructions; the large model performing semantic analysis on the raw code based on the structured instructions, analyzing the core logical structure of the algorithm in the raw code, identifying the data flow, understanding the algorithmic semantics of the raw code, and obtaining the analysis results; identifying the analysis results... The key execution path is identified by locating the instrumentation point, along with its position and type. Instrumentation point types include: data structure initialization points, loop iteration key points, conditional branch points, and data operation execution points. The large model interprets the intent based on the instrumentation point type. Based on the interpreted intent, it matches the target operation code template from a pre-defined code library. It identifies the positional variable representing the instrumentation point's location, fills the positional variable into the target operation code template, and generates the calling code. The calling code is then inserted into the instrumentation point's position. An automatic fault tolerance mechanism is enabled to determine the success of fault tolerance processing. If unsuccessful, error handling is performed; if successful, the final operation queue is generated. A visualization scheme is determined, visualization script code is generated, and visualization is implemented. User interaction control is then provided.
[0178] The following example uses the visualization of the bubble sort algorithm.
[0179] (a) User input: The user inputs the target data to be visualized in natural language.
[0180] Input example: Please use the bubble sort algorithm to sort the array [3, 1, 4, 2] in ascending order and visualize the process.
[0181] (b) Original code: The original code that the large model determines that the target data input by the user is of natural language and converts the target data into a standard target language type (such as Python).
[0182] Generated Python code:
[0183] def bubble_sort(arr):
[0184] n = len(arr)
[0185] for i in range(n):
[0186] # Last i elements are already in place
[0187] for j in range(0, n - i - 1):
[0188] if arr[j] > arr[j + 1]:
[0189] arr[j], arr[j + 1]= arr[j + 1], arr[j]
[0190] return arr
[0191] my_array = [3, 1, 4, 2]
[0192] sorted_array = bubble_sort(my_array)
[0193] print(sorted_array)
[0194] (c) Instrumentation code: Analyze the original code, identify key locations as instrumentation points, and automatically insert calling code for generating visual operations.
[0195] The code below demonstrates method calls to insert operation_queue objects at critical locations (such as array creation, element comparison, and element swapping).
[0196] Python code with added calling code:
[0197] def bubble_sort_visualized(arr):
[0198] n = len(arr)
[0199] # Instrumentation Point 1: Creating a visual representation of the array before the algorithm begins
[0200] arr_id = operation_queue.create_array(arr, metadata="initialize array")
[0201] for i in range(n):
[0202] for j in range(0, n - i - 1):
[0203] # Intercalation Point 2: Before comparison, highlight the two elements being compared.
[0204] operation_queue.highlight(arr_id, [j, j + 1], metadata=f"Compare arr[{j}] and arr[{j+1}]")
[0205] if arr[j] > arr[j + 1]:
[0206] # Instrumentation point 3: When an exchange occurs, record the exchange operation.
[0207] operation_queue.swap(arr_id, j, j + 1, metadata=f"Swap arr[{j}] and arr[{j+1}]")
[0208] arr[j], arr[j + 1]= arr[j + 1], arr[j]
[0209] # Instrumentation point 4: After the comparison, remove highlighting.
[0210] operation_queue.unhighlight(arr_id, [j, j + 1])
[0211] return arr
[0212] (d) Operation Queue: When the instrumented code above is executed, the operation_queue object records a series of standardized operation objects in sequence, forming a JSON-formatted operation queue. The visualization frontend only needs to parse and render this queue in sequence.
[0213] The following is an example of an operation queue fragment generated when performing the first few steps of bubble sort on the array [3, 1, 4, 2]:
[0214] Generated JSON operation queue fragment: [
[0216] {
[0217] "operation": "create_array",
[0218] "data": {
[0219] "array": [3, 1, 4, 2],
[0220] "id": "arr_1
[0221] },
[0222] "metadata": "Initialize the array"
[0223] },
[0224] {
[0225] "operation": "highlight",
[0226] "data": {
[0227] "id": "arr_1",
[0228] "indices": [0, 1]
[0229] },
[0230] "metadata": "Compare arr[0] and arr[1]"
[0231] },
[0232] {
[0233] "operation": "swap",
[0234] "data": {
[0235] "id": "arr_1",
[0236] "indices": [0, 1]
[0237] },
[0238] "metadata": "Swap arr[0] and arr[1]"
[0239] },
[0240] {
[0241] "operation": "unhighlight",
[0242] "data": {
[0243] "id": "arr_1",
[0244] "indices": [0, 1]
[0245] },
[0246] "metadata": ""
[0247] },
[0248] {
[0249] "operation": "highlight",
[0250] "data": {
[0251] "id": "arr_1",
[0252] "indices": [1, 2]
[0253] },
[0254] "metadata": "Compare arr[1] and arr[2]"
[0255] },
[0256] {
[0257] "operation": "unhighlight",
[0258] "data": {
[0259] "id": "arr_1",
[0260] "indices": [1, 2]
[0261] },
[0262] "metadata": ""
[0263] }
[0265] Taking the array [3, 1, 4, 2] as an example, after generating the corresponding operation queue, executing and rendering the operation queue will visualize it. (Refer to...) Figures 7a-7d This is a partial state diagram of the visualization process. Figure 7a This is a diagram illustrating the original array order in the bubble sort algorithm. Figure 7b This is a schematic diagram of the array element comparison process in the bubble sort algorithm. The elements being compared in the diagram are arr[1] and arr[2]. Figure 7c This is another schematic diagram of the array element comparison process in the bubble sort algorithm. The elements being compared in the diagram are arr[0] and arr[1]. Figure 7d This is a diagram illustrating the completion of array element comparison in the bubble sort algorithm, resulting in the array [1,2,3,4].
[0266] This embodiment implements a fully automated processing flow from user input (natural language or algorithm code) to the generation of interactive dynamic visualizations. The first step leverages the code understanding capabilities of a large language model to intelligently instrument the input algorithm code, automatically calling and recording code at key execution points without manual intervention. During the execution of the instrumented code, a standardized, universal operation queue is dynamically generated. This queue, in JSON format, unifies the execution process of different algorithms into a series of standard operations (such as creation, highlighting, and swapping), thereby decoupling the algorithm logic from the visualization presentation and achieving universal processing for any algorithm. Furthermore, an adaptive fault-tolerance mechanism is integrated to automatically repair potential errors during instrumentation and execution, ensuring the stability and reliability of the entire process.
[0267] Corresponding to the aforementioned application function implementation method embodiments, this application also provides an algorithm visualization device, electronic device, and corresponding embodiments based on a large model.
[0268] Figure 8 This is a schematic diagram of the structure of an algorithm visualization device based on a large model, as shown in an embodiment of this application.
[0269] See Figure 8 The device includes:
[0270] Analysis module 710 is used to transform the target data to be visualized using a large model to obtain the original code; and to analyze the original code to obtain the analysis results.
[0271] The identification module 720 is used to identify at least one instrumentation point in the original code obtained from the analysis results, as well as the location and type of the instrumentation point;
[0272] The matching module 730 is used to match the target operation code template from the preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations;
[0273] The instrumentation module 740 is used to generate calling code sequentially based on the position of each instrumentation point and the corresponding target operation code template, and insert the calling code into the position of the instrumentation point;
[0274] The operation queue module 750 is used to convert the calling code into operation objects and arrange the operation objects in the execution order to generate an operation queue.
[0275] The visualization module 760 is used to visualize target data based on the operation queue.
[0276] In an optional embodiment of this application, the matching module 730 includes:
[0277] The first determination submodule is used to determine the type of visualization operation for any instrumentation point, based on the type of the instrumentation point and the context code;
[0278] The matching submodule is used to match the target operation code template from the preset code library based on the determined type of visual operation.
[0279] The insert module 740 includes:
[0280] The identification submodule is used to identify the position variables representing the location of the insertion point;
[0281] The fill submodule is used to fill the position variables into the target operation code template and generate the calling code;
[0282] The operation queue module 750 includes:
[0283] Insert a submodule to identify key steps in the calling code;
[0284] The Operation Object submodule is used to transform key steps into operation objects, which include operation type, operation data, and metadata description.
[0285] The organization submodule is used to organize operation objects into an operation queue according to the execution order.
[0286] Visualization module 760 includes:
[0287] The second determination submodule is used to determine the data structure of the operation data of each operation object in the operation queue in turn, and to determine the visualization scheme based on the data structure of the operation data.
[0288] The code submodule is used to generate visualization script code based on the visualization scheme; the script code is used to respond to the operation commands sent by the user in the interactive interface and perform visualization display.
[0289] Analysis module 710 includes:
[0290] The judgment submodule is used to determine the data type of the target data; the data type of the target data includes at least natural language and algorithm code.
[0291] The first conversion submodule is used to convert the target data into the original code of the target language type if the target data is natural language.
[0292] The second conversion submodule is used to convert the target data into the original code of the target type if the target data is algorithm code and the algorithm code is not in the target language type.
[0293] Combined with submodules, it is used to combine the original code with a list of preset structures to generate structured instructions;
[0294] The analysis results submodule is used by the large model to perform semantic analysis on the original code based on structured instructions and generate analysis results.
[0295] In an optional embodiment of this application, the device further includes:
[0296] The first inspection module is used to check whether there are syntax errors in the operation queue. If there are syntax errors, the operation queue is repaired.
[0297] The second checking module is used to execute the operation queue and determine whether the operation queue passes the runtime check when there are no syntax errors.
[0298] The run repair module is used to perform run repairs on the operation queue if the run check fails.
[0299] This application provides an algorithm visualization device based on a large model. The large model transforms the target data to be visualized into original code, analyzes the original code to obtain analysis results, identifies at least one instrumentation point in the original code, and identifies the position and type of the instrumentation point. Target operation code templates are matched from a preset code library according to the type of each instrumentation point. The preset code library includes operation code templates corresponding to different types of visualization operations. Calling code is generated according to the position of each instrumentation point and the corresponding target operation code template, and the calling code is inserted into the position of the instrumentation point. The calling code is transformed into operation objects, and the operation objects are arranged in execution order to generate an operation queue. The target data is visualized based on the operation queue. This device leverages the code understanding capabilities of the large model, automatically performing semantic analysis, instrumentation point location, and instrumentation code generation during the visualization process. This not only improves processing efficiency but also ensures the accuracy and consistency of the instrumentation of visualization operation instrumentation code, enhances the applicability of visualization technology, and lowers the development threshold.
[0300] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated further here.
[0301] Figure 9 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application.
[0302] See Figure 9 The electronic device 800 includes a memory 810 and a processor 820.
[0303] The processor 820 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0304] Memory 810 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. ROM may store static data or instructions required by the processor 820 or other modules of the computer. Permanent storage devices may be read-write storage devices. Permanent storage devices may be non-volatile storage devices that retain stored instructions and data even when the computer is powered off. In some embodiments, permanent storage devices use mass storage devices (e.g., magnetic or optical disks, flash memory) as permanent storage devices. In other embodiments, permanent storage devices may be removable storage devices (e.g., floppy disks, optical drives). System memory may be a read-write storage device or a volatile read-write storage device, such as dynamic random access memory. System memory may store some or all of the instructions and data required by the processor during operation. Furthermore, memory 810 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (e.g., DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, memory 810 may include a removable storage device that is readable and / or writable, such as a laser disc (CD), a read-only digital multifunction optical disc (e.g., DVD-ROM, dual-layer DVD-ROM), a read-only Blu-ray disc, an ultra-high density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not contain carrier waves or transient electronic signals transmitted wirelessly or via wired connections.
[0305] The memory 810 stores executable code, which, when processed by the processor 820, can cause the processor 820 to execute part or all of the methods described above.
[0306] Furthermore, the method according to this application can also be implemented as a computer program or computer program product, which includes computer program code instructions for performing some or all of the steps in the method described above.
[0307] Alternatively, this application may be implemented as a computer-readable storage medium (or a non-transitory machine-readable storage medium or a machine-readable storage medium) storing executable code (or computer program or computer instruction code) that, when executed by a processor of an electronic device (or server, etc.), causes the processor to perform part or all of the steps of the methods described above according to this application.
[0308] This application also provides a computer program product, which includes computer instructions that, when executed by a processor, implement the method described above.
[0309] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. An algorithm visualization method based on a large model, characterized in that, The method includes: The original code is obtained by transforming the target data to be visualized using a large model, and the original code is analyzed to obtain the analysis results. Identify the analysis results to obtain at least one instrumentation point in the original code, as well as the location and type of the instrumentation point; The target operation code template is matched sequentially from a preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations; Instructions are generated sequentially based on the position of each insertion point and the corresponding target operation code template, and the instructions are inserted into the position of the insertion point. The calling code is converted into operation objects, and the operation objects are arranged in execution order to generate an operation queue; The target data is visualized based on the operation queue; The step of sequentially matching the target operation code template from the preset code library according to the type of each instrumentation point includes: for any instrumentation point, the large model determines the type of visualization operation based on the type of the instrumentation point and the context code; and matches the target operation code template from the preset code library according to the determined type of visualization operation. The step of generating call code sequentially based on the position of each insertion point and the corresponding target operation code template includes: identifying a position variable representing the position of the insertion point; filling the position variable into the target operation code template; and generating the call code. The step of converting the calling code into operation objects and arranging the operation objects in execution order to generate an operation queue includes: identifying key steps in the calling code; converting the key steps into operation objects, wherein the operation objects include operation type, operation data, and metadata description; and organizing the operation objects into the operation queue in execution order. The visualization of the target data based on the operation queue includes: sequentially determining the data structure of the operation data of each operation object in the operation queue, and determining a visualization scheme based on the data structure of the operation data; generating visualization script code based on the visualization scheme; the script code is used to respond to the operation instructions sent by the user on the interactive interface and perform visualization display.
2. The method according to claim 1, characterized in that, The process of transforming the target data to be visualized using a large model to obtain the original code includes: Determine the data type of the target data; the target data type includes at least natural language and algorithm code. If the target data is natural language, then the target data is converted into the original code of the target language type; If the target data is algorithm code, and the algorithm code is not in the target language type, the target data will be converted into the original code of the target type.
3. The method according to claim 1, characterized in that, The analysis of the original code yielded the following results: The original code is combined with a preset structure list to generate structured instructions; The large model performs semantic analysis on the original code based on the structured instructions, and generates the analysis results.
4. The method according to claim 1, characterized in that, Following the generation operation queue, the following also includes: Check the operation queue for syntax errors, and if syntax errors are found, perform syntax repair on the operation queue. If there are no syntax errors, execute the operation queue and determine whether the operation queue passes the runtime check; If the operation check fails, the operation queue will be repaired.
5. An algorithm visualization device based on a large model, characterized in that, The device includes: The analysis module is used to transform the target data to be visualized using a large model to obtain the original code; and to analyze the original code to obtain the analysis results. The identification module is used to identify at least one instrumentation point in the original code obtained from the analysis results, as well as the position and type of the instrumentation point; The matching module is used to match target operation code templates from a preset code library according to the type of each instrumentation point; the preset code library includes operation code templates corresponding to different types of visual operations; An instrumentation module is used to generate calling code sequentially based on the position of each instrumentation point and the corresponding target operation code template, and to insert the calling code into the position of the instrumentation point; The operation queue module is used to convert the calling code into operation objects and arrange the operation objects in the execution order to generate an operation queue. A visualization module is used to visualize the target data based on the operation queue; The matching module includes: The first determination submodule is used to determine the type of visualization operation for any instrumentation point, based on the type of the instrumentation point and the context code; The matching submodule is used to match the target operation code template from the preset code library based on the determined type of visual operation; The plug-in modules include: The identification submodule is used to identify the position variables representing the location of the insertion point; The fill submodule is used to fill the position variables into the target operation code template and generate the calling code; The operation queue module includes: Insert a submodule to identify key steps in the calling code; The Operation Object submodule is used to transform key steps into operation objects, which include operation type, operation data, and metadata description. The organization submodule is used to organize operation objects into an operation queue according to the execution order; The visualization module includes: The second determination submodule is used to determine the data structure of the operation data of each operation object in the operation queue in turn, and to determine the visualization scheme based on the data structure of the operation data. The code submodule is used to generate visualization script code based on the visualization scheme; the script code is used to respond to the operation commands sent by the user in the interactive interface and perform visualization display.
6. An electronic device, characterized in that, include: processor; as well as A memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Algorithm visual development method and device, electronic equipment and storage medium
CN116069306A
Food cold chain data visualization automatic generation method based on large language model
CN120144106A