A data science interactive teaching system and method based on a large language model
Patent Information
- Application Number
- CN202610790044.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-03
- Publication Date
- 2026-10-30
AI Technical Summary
[0011]本发明旨在克服现有机器学习教学中被动学习、缺乏个性化指导、理论与实践脱节、会话管理混乱、学习体验单一等缺陷,提供一种基于大语言模型的智能机器学习教学系统及方法,通过角色反转教学模式,让学习者以“教师”身份指导AI“学生”完成机器学习任务,深化对知识的理解与应用能力;同时通过结构化操作执行、智能可视化、会话持久化、多级学生水平配置、会话隔离管理等功能,提升学习体验与教学效果
[0041]1. 创新的角色反转教学模式:通过让用户扮演教师角色、AI扮演学生角色,激发用户主动学习意识,深化对机器学习概念的理解与应用能力。
Smart Images

Figure CN123015217A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of artificial intelligence and educational technology, specifically involving an interactive teaching system and method for data science based on a large language model. It is particularly suitable for interactive data science teaching scenarios that adopt a role-reversal teaching model, enabling an immersive teaching experience of "users teaching AI" and supporting personalized student level configuration and multi-conversation isolation management. Background Technology
[0002] With the deepening of AI+, AI technology is reshaping various industries with its pervasive growth. As the core underlying logic of this transformation, data science has become not only a branch of computer science but also a universal cornerstone for interdisciplinary innovation. Driven by typical scenarios such as precise risk control in finance, intelligent medical assistance, and smart manufacturing in industry, the demand for compound data science talents with "algorithm models + industry knowledge" is exploding. However, traditional data science teaching models are facing many bottlenecks that urgently need to be addressed, such as the disconnect between theory and practice and the lag in industry standards. Therefore, how to optimize data science teaching paths and improve the efficiency of industry-education integration in machine learning education has become a research focus in the fields of higher education and vocational education.
[0003] 1. Limitations of passive learning: In traditional teaching models, learners are always the recipients of knowledge, lacking opportunities for active output and in-depth thinking. This leads to a superficial understanding of core concepts, making it difficult to form systematic cognition and reliable practical guidance.
[0004] 2. Lack of personalized guidance: Classroom teaching or online courses often adopt a "one-size-fits-all" approach, which fails to develop personalized learning paths based on learners' knowledge reserves, learning progress, and weaknesses, and also makes it difficult to provide timely and targeted feedback and guidance.
[0005] 3. Theory and practice are disconnected: Current teaching focuses more on theoretical explanation, and learners lack practical scenarios to apply algorithm principles and model building logic to the analysis of real datasets, resulting in the common phenomenon of "understanding the theory but not being able to do it in practice".
[0006] 4. Insufficient interactive experience: Mainstream online learning platforms are mainly based on one-way knowledge transmission, lacking guidance, questioning, and error correction in real teacher-student interaction, making the learning process tedious and lacking feedback loops.
[0007] 5. Weak visualization support: The visualization of data analysis results and model training process is limited and not intuitive enough, making it difficult for learners to understand the impact of data characteristics, model performance, and parameter adjustments.
[0008] 6. Disorganized conversation management: In multi-task learning scenarios, conversations on different learning topics are easily confused, there is a lack of effective conversation isolation mechanisms, and responses are prone to misattribution.
[0009] 7. Limited learning experience: Existing systems cannot dynamically adjust the behavior and response of AI students according to the learner's actual level, making it difficult to adapt to the needs of different learning stages.
[0010] While some online programming platforms and data science methodologies exist in the current technology landscape, they all fail to break free from the traditional "teacher-led" model, unable to provide an immersive role-playing learning experience, and failing to address the core pain points such as the disconnect between theory and practice, insufficient personalized guidance, and chaotic session management. Therefore, there is an urgent need for an innovative teaching system and methodology that can stimulate learners' initiative through a novel interactive mode, achieve a deep integration of theory and practice, and simultaneously support personalized configuration and standardized session management, thereby improving the effectiveness and efficiency of machine learning teaching. Summary of the Invention
[0011] This invention aims to overcome the shortcomings of existing machine learning teaching, such as passive learning, lack of personalized guidance, disconnect between theory and practice, chaotic conversation management, and monotonous learning experience. It provides an intelligent machine learning teaching system and method based on a large language model. Through a role-reversal teaching model, learners act as "teachers" to guide AI "students" to complete machine learning tasks, deepening their understanding and application of knowledge. At the same time, through functions such as structured operation execution, intelligent visualization, conversation persistence, multi-level student level configuration, and conversation isolation management, the learning experience and teaching effectiveness are improved.
[0012] The technical solution adopted in this invention is a data science interactive teaching system based on a large language model, characterized by including a front-end interaction module, a back-end processing module, a role-reversal teaching engine, a data visualization rendering engine, a conversation isolation and management mechanism, and a student level customization system; wherein:
[0013] The front-end interaction module is communicatively connected to the back-end processing module. It is used to build an interaction entry point between the user and the system, receive the user's teaching instructions and data file uploads, and send the teaching instructions and data files to the back-end processing module. At the same time, the front-end interaction module receives the response data returned by the back-end processing module and displays the AI student's thinking process, response content, and interactive data visualization charts in real time.
[0014] The student level customization system has its front-end interface integrated into the front-end interaction module, and its back-end logic connected to the large language model interaction submodule in the back-end processing module. The student level customization system is used to provide a visual level selection interface, allowing users to describe the knowledge level and behavioral characteristics of the AI student through natural language, and to pass the characteristics to the large language model interaction submodule.
[0015] The backend processing module includes a session management submodule, a large language model interaction submodule, a data processing submodule, a machine learning execution submodule, and a visualization generation submodule; wherein:
[0016] The session management submodule is connected to the front-end interaction module. It is used to maintain the status information of each teaching session, support the parallel management of multiple sessions, and persist the session data to the browser's local storage.
[0017] The large language model interaction submodule has its input end connected to the conversation management submodule and the student level customization system to obtain the conversation context and student level configuration; its output end is connected to the external large language model API to send requests and receive streaming responses; the large language model interaction submodule also works in collaboration with the role reversal teaching engine to dynamically construct system prompt words containing role settings based on the student level configuration.
[0018] The data processing submodule has its input end connected to the large language model interaction submodule, used to receive and parse structured operation instructions related to data loading and preprocessing; its output end is connected to the session management submodule and the visualization generation submodule respectively, used to update the dataset status in the session and provide data sources;
[0019] The machine learning execution submodule has its input end connected to the large language model interaction submodule, which is used to receive and parse structured operation instructions related to model training and evaluation; its output end is connected to the conversation management submodule and the visualization generation submodule, respectively, which are used to record training progress and provide evaluation result data.
[0020] The visualization generation submodule has its input terminals connected to the data processing submodule and the machine learning execution submodule, respectively, for acquiring the data to be visualized; its output terminal is connected to the front-end interaction module for sending the generated ECharts compatible chart configuration to the front end.
[0021] The role-reversal teaching engine is built into the prompt word construction process of the large language model interaction submodule. Through system prompts, the large language model is configured as a student role, so that it simulates the cognitive process of a beginner and outputs a response containing the thinking process and structured operation instructions.
[0022] The data visualization rendering engine is integrated into the front-end interaction module. Its input end is connected to the visualization generation sub-module to receive chart configurations and convert them into interactive visualization content.
[0023] The session isolation and management mechanism runs through the communication link between the front-end interaction module and the back-end processing module. It assigns a unique identifier to each session, binds the session ID when making API requests, and verifies session matching when the response is returned, so as to ensure that the response content is correctly assigned to the corresponding session.
[0024] Furthermore, the role-reversal teaching engine is further used to: constrain the knowledge output range of AI students and display their thinking logic in a structured manner; the structured operation instructions include at least data loading, plotting, training, and evaluating instructions.
[0025] Furthermore, the front-end interaction module is also used to: display the AI student's thinking process and response content received from the back-end processing module in real time using a streaming text output method, and automatically collapse this part of the content after the thinking process is output, retaining only the response content and the visualization chart generated by the data visualization rendering engine; the visualization chart supports interactive operations such as zooming, panning, and hovering over data points, and the chart data is persisted through the connection with the conversation management submodule and is automatically restored after the page is refreshed.
[0026] Furthermore, the visualization generation submodule is also used to: after receiving the chart drawing instruction, perform intelligent fuzzy matching between the data column names specified by the user and the actual column names of the dataset obtained from the data processing submodule, and generate a chart configuration based on the matching result; the chart configuration is sent to the data visualization rendering engine in the front-end interaction module for processing.
[0027] Furthermore, the session isolation and management mechanism is also used to: when it is detected that the current session ID does not match the session ID bound to the response returned from the backend processing module, save the response content to the original session history maintained by the session management submodule, and display a prompt message on the current interface of the frontend interaction module to inform the user.
[0028] A method for teaching intelligent machine learning includes the following steps:
[0029] Step 1: The front-end interaction module receives the user's instruction to create a new session, triggering the session management submodule in the back-end processing module to generate a unique session ID to initialize the teaching session; the role reversal teaching engine configures the AI student role through the large language model interaction submodule, generates a greeting message, and displays it through the front-end interaction module.
[0030] Step 2: The student level customization system receives the user's selection of the AI student level and the customized feature description, saves the configuration data, and dynamically constructs and updates the system prompt words through the connection with the large language model interaction submodule.
[0031] Step 3: The front-end interaction module receives the teaching instructions input by the user and sends them to the back-end processing module; the session management submodule records the current session ID, and the large language model interaction submodule constructs a complete context including student level characteristics, historical dialogues and current instructions, and sends a request to the external large language model API;
[0032] Step 4: The large language model interaction submodule receives the streaming response returned by the external API. The response is generated based on the student role and includes the thought process, structured operation instructions, instruction parameters and reply content.
[0033] Step 5: The large language model interaction submodule parses the structured response returned by the model and verifies the validity of the operation instructions;
[0034] Step 6: Based on the parsed operation command type, the large language model interaction submodule distributes the command and parameters to the corresponding submodules in the backend processing module: if it is a data loading or preprocessing command, the data processing submodule is called to execute it; if it is a model training or evaluation command, the machine learning execution submodule is called to execute it; if it is a chart drawing command, the visualization generation submodule is called to execute it.
[0035] Step 7: If the operation involves data visualization, the visualization generation submodule obtains data from the data processing submodule or the machine learning execution submodule, generates chart configurations, and sends them to the front-end interaction module, where the data visualization rendering engine renders them into interactive charts; if the operation result only contains text content, the front-end interaction module displays the thought process and response content in a streaming output manner.
[0036] Furthermore, step 5 also includes a session verification step: when the session isolation and management mechanism receives the API response, it verifies whether the session ID of the current front-end interaction module is consistent with the ID when the request was initiated; if they are inconsistent, the response content is not sent to the front-end rendering, but the session data is handed over to the session management submodule to be saved in the history of the original session.
[0037] Furthermore, the method also includes: after the front-end interaction module receives and sends the first user message of the session, the session management submodule automatically extracts keywords from the message, generates the title of the session, and sends it to the front-end for display; and the front-end interaction module receives and responds to the user's double-click manual editing operation on the session title, and sends the updated title to the session management submodule for saving.
[0038] Furthermore, step 7 also includes: the session management submodule persistently saves the user instructions, AI response content, chart configuration data generated by the visualization generation submodule, and student level information of the current round to local storage to support session interruption recovery and historical review.
[0039] Furthermore, in step 6, when the operation instruction is to plot a chart and is executed by the visualization generation submodule, an intelligent column name matching step is also included: the visualization generation submodule obtains the actual column names of the dataset through the connection with the session management submodule and the data processing submodule; if there is a difference between the column name specified by the user and the actual column name, fuzzy matching is automatically performed to locate the correct data column.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] 1. Innovative role-reversal teaching model: By allowing users to play the role of teacher and AI to play the role of student, it stimulates users' initiative in learning and deepens their understanding and application of machine learning concepts.
[0042] 2. Personalized student level system: Supports three levels of student level configuration (beginner / intermediate / proficient) and allows users to customize the behavioral characteristics of each level through natural language, adapting to the needs of different learning stages and achieving truly personalized teaching.
[0043] 3. Robust session isolation and management: Through session ID binding and verification mechanisms, ensure that API responses are correctly assigned to the corresponding sessions; support intelligent title generation, manual editing, and message count statistics to solve the problem of confusion among multiple sessions.
[0044] 4. Transparent thought process display: The AI student displays the complete thought process, supporting automatic folding / manual unfolding, enhancing teaching transparency and helping users understand problem-solving approaches.
[0045] 5. Rich support for structured operations: covering the entire process of data loading, visualization, model training, evaluation, missing value handling, feature encoding, etc., achieving a deep integration of theory and practice.
[0046] 6. Intelligent column name matching and visualization: Supports fuzzy matching of column names to improve system fault tolerance; provides multiple types of interactive charts, and chart data is persisted and automatically restored after page refresh, optimizing the learning experience.
[0047] 7. Smooth, streaming interactive experience: Employs streaming text output at 15ms / character to simulate the rhythm of real conversation, automatically folds the thought process, and keeps the interface clean.
[0048] 8. Low-threshold natural language configuration: Users can describe the behavioral characteristics of AI students through natural language, and complete personalized configuration without professional technology, thus reducing the threshold for use. Attached Figure Description
[0049] Figure 1 System overall architecture diagram;
[0050] Figure 2 : Role Reversal Teaching Sequence Diagram;
[0051] Figure 3 : Internal logic flowchart of the role reversal teaching engine;
[0052] Figure 4 Student level customization configuration flowchart;
[0053] Figure 5 System interface operation diagram;
[0054] Figure 6 Student level settings page. Detailed Implementation
[0055] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0056] An interactive data science teaching system based on a large language model is proposed. This system includes a front-end interaction module, a back-end processing module, a role-reversal teaching engine, an intelligent response processing mechanism, a data visualization rendering engine, a conversation isolation and management mechanism, and a student level customization system. These modules work together to achieve functions such as role-reversal teaching, structured operation execution, intelligent visualization, conversation management, and personalized student configuration, as detailed below:
[0057] (1) Front-end interaction module:
[0058] This is used to build an interaction portal between users and the system, enabling the reception of teaching instructions, display of response content, and visualization of data. Specific functions include:
[0059] a) Provides an intuitive and modern user interface that supports text input of teaching instructions, uploading and drag-and-drop import of CSV data files;
[0060] b) Display the AI student's thought process, response content, and operation execution results in real time, using streaming text output (15ms / character) to simulate a real dialogue experience;
[0061] c) Dynamically render data visualization charts, supporting interactive operations such as chart zooming, panning, and hovering over data points. Chart data is also persistent and automatically restored after page refresh.
[0062] d) Manage multiple teaching sessions, support session creation, switching, saving and history review, realize intelligent generation of session titles (based on keywords of the user's first message) and manual editing by double-clicking, and display message count statistics in the session subtitle;
[0063] (2) Backend processing module
[0064] As the core processing unit of the system, it includes 5 sub-modules, which respectively implement the functions of session management, model interaction, data processing, machine learning execution, and visualization generation:
[0065] a) Session Management Submodule: Maintains the status information of user teaching sessions, including session ID, dialogue history, dataset loading status, model training progress, student level configuration, etc.; supports parallel management of multiple sessions, persists session data to browser localStorage to ensure historical records are traceable; binds session ID when making API requests, and verifies session matching when the response is returned.
[0066] b) Large Language Model Interaction Submodule: Establishes communication with the DeepSeek large language model, converts user teaching instructions and dialogue context into structured requests; parses the streaming response data returned by the model, extracts the thought process, operation instructions and reply content; dynamically constructs system prompt words based on the student's selected level / custom features; ensures efficient collaboration between the model and the system.
[0067] c) Data Processing Submodule: Supports loading built-in datasets of sklearn (Iris, Wine, Breast Cancer, California Housing) and parsing user-uploaded CSV files; performs data preprocessing operations (denoising, missing value imputation, standardization, etc.), dataset splitting (training set, validation set, test set), and also supports extended operations such as missing value checking and categorical variable encoding, providing high-quality data support for machine learning tasks.
[0068] d) Machine Learning Execution Submodule: Supports the training and evaluation of various machine learning models, including logistic regression, decision trees, random forests, etc.; executes the model training process, calculates performance metrics such as accuracy, recall, and F1 score, and outputs model evaluation results.
[0069] e) Visualization Generation Submodule: Generates chart configurations based on the AI student's operation requests, supporting various chart types such as line charts, scatter plots, bar charts, and heatmaps; has an intelligent column name matching function, which can fuzzily match the column names specified by the user with the actual column names in the dataset; generates ECharts-compatible configuration objects to support front-end rendering, and can automatically adjust chart configurations (such as color scheme and axis range) according to data characteristics.
[0070] (3) Role Reversal Teaching Engine
[0071] The core feature lies in constructing a reverse teaching model where "users are teachers and AI is the student":
[0072] a) Configure the large language model as a "humble and eager-to-learn" student through system prompts, with the behavioral characteristics of actively asking questions and requesting guidance;
[0073] b) Constrain the scope of knowledge output of AI students, simulate the cognitive process of beginners, demonstrate thinking logic and operational ideas, and enhance the transparency of teaching;
[0074] c) Supports the parsing and execution of structured operation commands (load, plot, train, evaluate, check_missing, fill_missing, encode, split, etc.) to ensure the accurate implementation of teaching commands;
[0075] (4) Data visualization rendering engine
[0076] The chart configurations generated on the backend are converted into interactive visualizations, adapted to the ECharts visualization library, enabling fast chart rendering and supporting charts that adapt to container sizes to ensure consistent display across different devices. It also supports interactive operations such as chart zooming, panning, and hovering over data points.
[0077] (6) Session isolation and management mechanism
[0078] a) Assign a unique identifier to each session and bind the session ID when making API requests;
[0079] b) When the response is returned, verify whether the current session matches. If the session does not match, save the response to the session history corresponding to the original request and display a prompt message to inform the user.
[0080] c) Supports intelligent generation of conversation titles (extracting keywords from the user's first message) and manual editing via double-click;
[0081] d) The session subtitle displays message count statistics, supporting parallel management of multiple sessions and historical review.
[0082] (7) Student Level Customization System
[0083] a) The front end provides a visual level selector (beginner / intermediate / expert);
[0084] b) The system's modal frame settings support editing the feature descriptions for each level, allowing users to describe students' knowledge levels, learning attitudes, and questioning habits using natural language;
[0085] c) The front end passes the horizontal information and custom description to the back end, and the back end dynamically constructs system prompt words containing custom features;
[0086] A method for teaching intelligent machine learning based on the above system, comprising the following steps:
[0087] Step 1: Initialize the teaching session
[0088] (1) Users create new teaching sessions through the front-end interactive module;
[0089] (2) The system starts the session management submodule, generates a unique session ID, and initializes the session status (including empty dialogue history, unloaded dataset, untrained model, and student level defaulted to advanced level, etc.).
[0090] (3) AI students send greeting messages through the front end (such as “Teacher, I am learning machine learning and would like to ask you to guide me to complete the dataset analysis and model training tasks. Where should I start?”) to express their willingness to learn.
[0091] Step 2: Select / Customize Student Level
[0092] Users select the AI student's level (beginner / intermediate / proficient) through a level selector. Users can optionally customize the behavioral characteristics of each level in natural language through the system settings interface. The system saves the user's level configuration to localStorage, and the backend dynamically constructs system prompts based on the configuration.
[0093] Step 3: Receive teaching instructions
[0094] Users, acting as teachers, input teaching instructions (such as "First load the Iris dataset and view basic data information"), which can be submitted via text input or instruction template selection. The system records the current session ID and the selected student level, adding the user's instruction to the dialogue history. A complete context is constructed, including system prompts, student level characteristics, historical dialogues, and the current instruction.
[0095] Step 4: Large Language Model Inference
[0096] The backend uses the large language model interaction submodule to dynamically construct system prompts based on student level / custom features. It calls the DeepSeek API, passing the complete context to the model. The model generates a response based on the "student" role and specified level. The response content includes the thought process, structured operation instructions, parameters, and reply content, and the response style matches the characteristics of the selected student level.
[0097] Step 5: Session Authentication and Response Processing
[0098] When the system receives an API response, it verifies whether the current session ID matches the one used in the request. If the sessions do not match (the user has switched to another session): the response is not displayed on the current screen, but is saved to the session history corresponding to the original request, and a prompt message is displayed to inform the user. If the sessions match, the system proceeds to the next step of the parsing process.
[0099] Step 6: Analyze the structured response
[0100] (1) The intelligent response processing mechanism parses the JSON format response returned by the model and extracts the thought, action, params, and reply fields;
[0101] (2) Verify the validity of the action field (whether it is a system-supported command such as load, plot, train, evaluate, check_missing, etc.). If the command is invalid, return a prompt message asking the user to provide further guidance.
[0102] Step 7: Execute the operation instructions
[0103] (1) Invoke the corresponding sub-module in the backend to perform the operation based on the action type:
[0104] (2) If it is a load instruction: the data processing submodule loads the specified dataset (built-in dataset or user-uploaded CSV file), performs data preprocessing, and updates the dataset status in the session;
[0105] (3) If it is the plot command: the visualization generation submodule generates an ECharts configuration object based on the params parameters (chart type, data column name, etc.);
[0106] (4) If it is a train instruction: the machine learning execution submodule trains the model according to the params parameters (model type, hyperparameters, etc.) and records the training process;
[0107] (5) If it is the evaluate command: The machine learning execution submodule calculates the model performance metrics and generates an evaluation report;
[0108] (6) If it is a check_missing / fill_missing / encode / split instruction: the data processing submodule performs the corresponding data preprocessing operation.
[0109] Step 8: Generate visualization content (execute as needed)
[0110] (1) When the operation command is plot or the model training / evaluation requires visualization, the visualization generation submodule constructs the chart configuration based on the params parameter and data characteristics;
[0111] (2) Intelligent matching of data column names. If the column name specified by the user differs from the actual column name in the dataset, fuzzy matching will be performed automatically (e.g., "petal length" matches "petal length").
[0112] (3) Generate ECharts-compatible chart configuration objects, supporting line charts, scatter plots, bar charts, heatmaps and other types, and automatically adjust the color scheme and axis range according to data characteristics;
[0113] (4) Return the chart configuration object to the front end and persist the chart data to localStorage.
[0114] Step 9: Render the responsive content
[0115] (1) The front-end interaction module receives the response data returned by the back-end (including thought, reply and chart configuration).
[0116] (2) The thought and reply are displayed in a streaming output mode (15ms / character) to simulate the typing effect of real conversation;
[0117] (3) If a chart configuration exists, initialize an ECharts instance, render an interactive chart and display it. The chart supports adaptive container size and interactive operations.
[0118] Step 10: Automatically Folding the Thinking Process
[0119] After the thought process is streamed, the system automatically collapses the area after a 1-second delay, retaining only the reply content and visual charts to keep the interface clean. Users can also expand the thought process at any time.
[0120] Step 11: Intelligent generation / editing of session titles
[0121] If it's the first user message in a conversation, the system extracts keywords from the message (such as "iris," "classification," and "visualization") and automatically generates a meaningful conversation title. Users can also double-click the title to edit it manually, and the system saves the edited title to localStorage.
[0122] Step 12: Save the session history
[0123] The conversation management submodule saves the user commands, AI responses (including thought, reply, action, and params), chart configuration data, and student level information of the current round to the conversation history. The conversation data is persisted to the browser's localStorage, supporting interrupted conversation recovery and history review.
[0124] Step 13: Wait for the next round of instructions
[0125] AI students send next-step guidance requests based on their skill level (e.g., beginner: "Teacher, I have loaded the Iris dataset. Can you tell me in detail how to analyze the data next?"; experienced user: "Teacher, the Iris dataset has been loaded. I suggest doing feature correlation analysis first, and then training the model. What do you think?").
[0126] Users can continue to enter instructional commands, repeat steps 3-12, or end the current session.
[0127] Example 1: Initialization of Teaching Session and Configuration of Student Level
[0128] 1. When a user opens the system's front-end interface and clicks the "Create New Session" button, the system automatically generates a unique session ID (e.g., "sess-1770001201609-a0e93e8f6468b8") and initializes the session state (empty dialogue history, dataset status "not loaded", model status "not trained", and student level defaults to advanced).
[0129] 2. The role-reversal teaching engine loads the default system prompts and supplements them with advanced learner level characteristics: "You are an advanced machine learning student who understands basic concepts and processes, can independently complete routine operations, occasionally needs reminders for key steps, and has some analytical ability regarding results. Replies must be in JSON format, including the thought, action, params, and reply fields."
[0130] 3. Users can switch the student's level to "Beginner" through the front-end level selector and enter the system settings interface to customize the beginner's characteristics: "Completely zero knowledge of machine learning, requires detailed explanation from the teacher for each step, frequently asks basic questions, and responds in a friendly and innocent tone."
[0131] 4. The system saves custom configurations to localStorage, and the backend reconstructs the system prompts and injects them into the large language model context;
[0132] 5. The AI student sends a greeting message via the front end: "Teacher, I am your student with zero machine learning experience." I have absolutely no idea how to analyze data and train models. Can you teach me step by step? For example, could you teach me how to load a simple dataset first?
[0133] Example 2: Dataset Loading and Intelligent Generation of Session Titles
[0134] 1. The user inputs the teaching instruction: "Hello, please load the Iris dataset from sklearn first, and view the first 5 rows and feature column information of the data";
[0135] 2. The system detects that this is the first user message in the session, extracts the keywords "Iris dataset" and "view", automatically generates the session title "Iris dataset analysis", and displays it in the session list;
[0136] 3. The system adds the instruction to the dialogue history and builds the context (including the customized beginner system prompt, AI student greeting message, and the current instruction).
[0137] 4. The large language model interaction submodule calls the DeepSeek API, passes context information, and the model generates a response (JSON format).
[0138] 5. The intelligent response processing mechanism parses the response, verifies that the action is "load" (a valid instruction), and calls the data processing submodule;
[0139] 6. The data processing submodule loads the Iris dataset built into sklearn, executes the data.head() and data.columns operations, and obtains the first 5 rows of data and the feature column information (sepal length, sepal width, petallength, petal width, target).
[0140] 7. The system returns the operation results to the front end. The AI student's thought process is displayed in a streaming output of 15ms / character, the reply content is displayed synchronously, and the data information is presented in tabular form.
[0141] 8. After the thought process is completed, it will automatically collapse after a 1-second delay;
[0142] 9. The AI student sends the next request: "Teacher, I loaded the Iris dataset as you requested, but I don't understand what these feature columns mean (emoji), for example, what is 'sepal length'? Can you teach me?"
[0143] Example 3: Data Visualization and Session Isolation Verification
[0144] 1. In the "Iris Dataset Analysis" session, the user enters the command: "Draw a scatter plot of petal length and petal width, colored by target category", and clicks send;
[0145] 2. The system binds the current session ID (sess-1770001201609-a0e93e8f6468b8) and initiates an API request. Subsequently, the user switches to another newly created session, "Wine Dataset Analysis".
[0146] 3. After the large language model returns a response, the system verifies that the session ID does not match, saves the response to the session history of "Iris Dataset Analysis", and displays a prompt on the front end: "A new reply has been received in the session 'Iris Dataset Analysis'. Please switch to view it."
[0147] 4. The user switches back to the "Iris Dataset Analysis" session, and the system renders the response content:
[0148] a) Thought process (auto-fold): "The teacher asked me to draw a scatter plot of petal length and petal width, colored by target. First, I performed the plot operation, selected scatter plot as the chart type, with the x-axis as petal length and the y-axis as petal width, and grouped the colors by target. I need to confirm that the column names match because the teacher spoke in Chinese, but the dataset is in English."
[0149] b) Response content: "Teacher, I'm going to draw a scatter plot! I automatically matched the column names ('petal length' corresponds to petal length), and I'll show it to you right away~"
[0150] c) Visual charts: Scatter plots generated by ECharts, with different colors corresponding to different target values, and support for zooming and hovering to view data point details;
[0151] 5. Chart data is automatically saved to localStorage. When the user refreshes the page, the chart is re-rendered and the interactive state remains unchanged.
[0152] Example 4: Model Training and Student Level Adaptation
[0153] 1. The user switches the student's level to "Advanced" and enters the command: "Train a logistic regression model using the Iris dataset, evaluate the accuracy, and provide optimization suggestions."
[0154] 2. The backend constructs system prompts based on the proficiency characteristics of skilled users: "You are a skilled machine learning learner who can independently complete model training and evaluation, can proactively offer optimization suggestions, and provides concise and professional replies."
[0155] 3. The large language model generates responses, with actions in the order of "train" (model training) and "evaluate" (evaluation), and params including model type, test set ratio (0.2), etc.;
[0156] 4. The machine learning execution submodule completes model training and calculates a test set accuracy of 97%.
[0157] 5. The AI student replied: "Teacher, the logistic regression model training is complete, with a test set accuracy of 97%. Performance-wise, the model performs well on the Iris dataset, but the following optimization directions can be tried: 1) Adjust the regularization parameter C; 2) Try a random forest model to compare the results; 3) Standardize the features to further improve stability. Which optimization should I perform?"
[0158] 6. The system saves model training records, evaluation results, and chart configurations (such as model accuracy visualization) to the session history, supporting subsequent review and further optimization.
[0159] Example 5: Core Code Implementation (Key Segments)
[0160] 1. Front-end session isolation logic
[0161] When sending teaching instructions, the frontend does not directly use the current session variable, which may change with interface switching. Instead, it caches the currentSessionId as requestSessionId at the beginning of the sendMessage function. Subsequently, the request body also carries fields such as session_id, message, student_level, and level_prompt, enabling the backend to process the teaching instructions based on clear session identifiers and student level configurations.
[0162] When the frontend receives the backend response, it first compares the currentSessionId with the requestSessionId. If the user switched to another session during the request, the original loading prompt is removed, and the response is not rendered on the current screen. Instead, the target session corresponding to the requestSessionId is located, the AI response content and chart data are written to that session's history, and saveSessions() is called for persistence. Simultaneously, a showToast notification is sent to the user that the original session has received a new response. If the sessions match, displayParsedMessage is called to render the AI student's response and chart, and appendHistory is used to save the current round record. This mechanism corresponds to the sendMessage, appendHistory, saveSessions, and renderHistory logic in the frontend app.js.
[0163] 2. Backend student level prompt word construction
[0164] The backend defines a `student_level` field in the `ChatRequest` data structure, with a default value of `intermediate`, and also defines a `level_prompt` field to receive a custom level description from the frontend. After receiving the request, the `chat_endpoint` passes the above parameters to `agent.process_user_command`, so that each conversation can carry the AI student level selected for the current session.
[0165] In `process_user_command`, the system first calls `_build_context_string(manager)` to organize the current dataset, column names, training / test set, model status, and task type. Then, if `level_prompt` exists, the user-defined description is used directly; otherwise, `_get_default_level_description(student_level)` is called to read the default level description. Default configurations include three levels: beginner, intermediate, and advanced. Beginners need detailed explanations and should actively ask for reasons; intermediate users understand the basic process and can perform routine operations; and experienced users are familiar with the machine learning process and can offer optimization suggestions. Finally, the backend concatenates `STUDENT_SYSTEM_PROMPT`, the current state context, and the student level description into a `system_message`, which is then sent to the DeepSeek API along with historical dialogues and the current user's command. This constrains the AI student to output JSON-formatted thoughts, actions, params, and replies at the specified level.
[0166] 3. Implementation of intelligent column name matching and chart generation
[0167] When the large language model returns "plot" as the action, the backend calls `_create_dynamic_chart(params, manager)`, which distributes the chart to the scatter plot, histogram, line chart, or bar chart constructor based on the `chart_type` in `params`. Each constructor uses `current_data` stored in `ConversationManager` as its data source to generate the chart payload required for frontend ECharts rendering.
[0168] In the current project code, the line chart construction function `_build_line_from_params` contains explicit intelligent column name matching logic: the system first attempts to precisely match the column names in `params.columns`; if no match is found, the user-provided column names and the actual column names in the dataset are converted to lowercase, and a fuzzy match is performed using either "user column name contains actual column name" or "actual column name contains user column name". If no valid column is found, numerical columns are automatically selected, excluding target columns whose names contain "target", and a maximum of the first 6 columns are used to plot the trend chart. Scatter plots and histograms also provide fallback strategies: when the user does not specify valid column names, the scatter plot automatically selects the first two numerical columns, and the histogram automatically selects the first numerical column; the bar chart requires that both `x_column` and `y_column` can be found in the dataset to avoid generating ambiguous charts. The generated chart data is returned by the backend along with ChatResponse. The frontend renderChart function initializes the ECharts instance based on fields such as type, series, xLabel, and yLabel, and automatically adjusts the container height, maximum width, axes, tooltips, and legend configuration according to the chart type.
Claims
1. A data science interactive teaching system based on a large language model, characterized in that, This includes a front-end interaction module, a back-end processing module, a role-reversal teaching engine, a data visualization rendering engine, a session isolation and management mechanism, and a student level customization system; among which: The front-end interaction module is communicatively connected to the back-end processing module. It is used to build an interaction entry point between the user and the system, receive the user's teaching instructions and data file uploads, and send the teaching instructions and data files to the back-end processing module. At the same time, the front-end interaction module receives the response data returned by the back-end processing module and displays the AI student's thinking process, response content, and interactive data visualization charts in real time. The student level customization system has its front-end interface integrated into the front-end interaction module, and its back-end logic connected to the large language model interaction submodule in the back-end processing module. The student level customization system is used to provide a visual level selection interface, allowing users to describe the knowledge level and behavioral characteristics of the AI student through natural language, and to pass the characteristics to the large language model interaction submodule. The backend processing module includes a session management submodule, a large language model interaction submodule, a data processing submodule, a machine learning execution submodule, and a visualization generation submodule; wherein: The session management submodule is connected to the front-end interaction module. It is used to maintain the status information of each teaching session, support the parallel management of multiple sessions, and persist the session data to the browser's local storage. The large language model interaction submodule has its input end connected to the conversation management submodule and the student level customization system to obtain the conversation context and student level configuration; its output end is connected to the external large language model API to send requests and receive streaming responses; the large language model interaction submodule also works in collaboration with the role reversal teaching engine to dynamically construct system prompt words containing role settings based on the student level configuration. The data processing submodule has its input end connected to the large language model interaction submodule, used to receive and parse structured operation instructions related to data loading and preprocessing; its output end is connected to the session management submodule and the visualization generation submodule respectively, used to update the dataset status in the session and provide data sources; The machine learning execution submodule has its input end connected to the large language model interaction submodule, which is used to receive and parse structured operation instructions related to model training and evaluation; its output end is connected to the conversation management submodule and the visualization generation submodule, respectively, which are used to record training progress and provide evaluation result data. The visualization generation submodule has its input terminals connected to the data processing submodule and the machine learning execution submodule, respectively, for acquiring the data to be visualized; its output terminal is connected to the front-end interaction module for sending the generated ECharts compatible chart configuration to the front end. The role-reversal teaching engine is built into the prompt word construction process of the large language model interaction submodule. Through system prompts, the large language model is configured as a student role, so that it simulates the cognitive process of a beginner and outputs a response containing the thinking process and structured operation instructions. The data visualization rendering engine is integrated into the front-end interaction module. Its input end is connected to the visualization generation sub-module to receive chart configurations and convert them into interactive visualization content. The session isolation and management mechanism runs through the communication link between the front-end interaction module and the back-end processing module. It assigns a unique identifier to each session, binds the session ID when making API requests, and verifies session matching when the response is returned, so as to ensure that the response content is correctly assigned to the corresponding session.
2. The system according to claim 1, characterized in that, The role-reversal teaching engine is further used to: constrain the knowledge output range of AI students and display their thinking logic in a structured way; the structured operation instructions include at least data loading, chart drawing, model training and model evaluation instructions.
3. The system according to claim 1, characterized in that, The front-end interaction module is also used to: display the AI student's thinking process and response content received from the back-end processing module in real time using a streaming text output method, and automatically collapse the content after the thinking process is output, retaining only the response content and the visualization chart generated by the data visualization rendering engine; the visualization chart supports interactive operations such as zooming, panning, and hovering over data points, and the chart data is persisted through the connection with the conversation management submodule and is automatically restored after the page is refreshed.
4. The system according to claim 1, characterized in that, The visualization generation submodule is also used to: after receiving the chart drawing instruction, perform intelligent fuzzy matching between the data column names specified by the user and the actual column names of the dataset obtained from the data processing submodule, and generate chart configuration based on the matching results; the chart configuration is sent to the data visualization rendering engine in the front-end interaction module for processing.
5. The system according to claim 1, characterized in that, The session isolation and management mechanism is also used to: when it is detected that the current session ID does not match the session ID bound to the response returned from the backend processing module, save the response content to the original session history maintained by the session management submodule, and display a prompt message on the current interface of the frontend interaction module to inform the user.
6. An intelligent machine learning teaching method based on the system according to any one of claims 1 to 5, characterized in that, Includes the following steps: Step 1: The front-end interaction module receives the user's instruction to create a new session, triggering the session management submodule in the back-end processing module to generate a unique session ID to initialize the teaching session; the role reversal teaching engine configures the AI student role through the large language model interaction submodule, generates a greeting message, and displays it through the front-end interaction module. Step 2: The student level customization system receives the user's selection of the AI student level and the customized feature description, saves the configuration data, and dynamically constructs and updates the system prompt words through the connection with the large language model interaction submodule. Step 3: The front-end interaction module receives the teaching instructions input by the user and sends them to the back-end processing module; the session management submodule records the current session ID, and the large language model interaction submodule constructs a complete context including student level characteristics, historical dialogues and current instructions, and sends a request to the external large language model API; Step 4: The large language model interaction submodule receives the streaming response returned by the external API. The response is generated based on the student role and includes the thought process, structured operation instructions, instruction parameters and reply content. Step 5: The large language model interaction submodule parses the structured response returned by the model and verifies the validity of the operation instructions; Step 6: Based on the parsed operation instruction type, the large language model interaction submodule distributes the instruction and parameters to the corresponding submodule in the backend processing module: if it is a data loading or preprocessing instruction, the data processing submodule is called to execute it; If the instruction is for model training or evaluation, the machine learning execution submodule is invoked; if the instruction is for chart drawing, the visualization generation submodule is invoked. Step 7: If the operation involves data visualization, the visualization generation submodule obtains data from the data processing submodule or the machine learning execution submodule, generates chart configurations, and sends them to the front-end interaction module, where the data visualization rendering engine renders them into interactive charts; if the operation result only contains text content, the front-end interaction module displays the thought process and response content in a streaming output manner.
7. The method according to claim 6, characterized in that, Step 5 also includes a session verification step: when the session isolation and management mechanism receives the API response, it verifies whether the session ID of the current front-end interaction module is consistent with the ID when the request was initiated. If there is a discrepancy, the response content will not be sent to the front-end for rendering. Instead, the session data will be handed over to the session management submodule to be saved in the history of the original session.
8. The method according to claim 6, characterized in that, The method further includes: after the front-end interaction module receives and sends the first user message of the session, the session management submodule automatically extracts keywords from the message, generates the title of the session, and sends it to the front-end for display; and the front-end interaction module receives and responds to the user's double-click manual editing operation on the session title, and sends the updated title to the session management submodule for saving.
9. The method according to claim 6, characterized in that, Step 7 further includes: the session management submodule persistently saves the user instructions, AI response content, chart configuration data generated by the visualization generation submodule, and student level information of the current round to local storage to support session interruption recovery and history review.
10. The method according to claim 6, characterized in that, In step 6, when the operation instruction is chart drawing and is executed by the visualization generation submodule, an intelligent column name matching step is also included: the visualization generation submodule obtains the actual column names of the dataset through the connection with the session management submodule and the data processing submodule; If the column name specified by the user differs from the actual column name, a fuzzy match will be automatically performed to locate the correct data column.
