Intelligent auxiliary learning method and system based on model context protocol and cognitive state modeling

By using an intelligent tutoring system based on model context protocols and cognitive state modeling, the problems of low learning efficiency and lack of context awareness in online assessment systems are solved, achieving efficient, personalized and secure intelligent tutoring, and reducing resource consumption and the risk of answer leakage.

CN121834798APending Publication Date: 2026-04-10FUZHOU UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing online assessment systems have shortcomings in their learning support functions. Students find it difficult to pinpoint specific problems from simple assessment results, leading to low learning efficiency. Large language models lack context awareness, resulting in inaccurate responses or hindering learning progress. Furthermore, holistic AI teaching systems are prone to high resource consumption, obsolescence, and the risk of answer leakage.

Method used

An intelligent learning assistance system based on model context protocol and cognitive state modeling is adopted. Through multi-layer interaction of user terminal, semantic firewall middleware, intelligent learning assistance server and large language model service, it realizes dynamic topology pruning, semantic analysis firewall, hierarchical context compression and cognitive state modeling, dynamically filters tool subsets, monitors output in real time, and provides a secure code sandbox and cognitive state updates.

Benefits of technology

It improves the accuracy and efficiency of large language models in educational scenarios, reduces resource consumption, enhances the relevance of teaching, reduces the risk of answer leakage, enables personalized tutoring and security, and improves learning outcomes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121834798A_ABST
    Figure CN121834798A_ABST
Patent Text Reader

Abstract

According to the intelligent auxiliary learning method and system based on the model context protocol and the cognitive state modeling, decoupling of a model end and a tool end is achieved through the model context protocol, an error type-tool dependency topological graph is constructed through the cognitive state modeling, tool dynamic screening and pruning based on deterministic rule constraints are achieved, and the method and the system have the advantages that the method and the system are easy to implement. The Token consumption is reduced, and the accuracy of model reasoning is improved at the same time. In the aspect of safety control, semantic firewall middleware is introduced into the system, output streams are monitored in real time, illegal behaviors directly giving code answers are intercepted through text semantic analysis and code abstract syntax tree comparison, and a model is forced to turn to a thought guide mode. The system also includes hierarchical context compression to maintain long term memory, adaptive difficulty knowledge retrieval based on user cognitive states, and a mechanism to utilize code sandbox to assist verification of model reasoning logic correctness. According to the method, the behaviors of the large language model can be effectively regulated and controlled, and safe, efficient and personalized intelligent auxiliary learning is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of artificial intelligence and computer science education, and particularly relates to an intelligent tutoring method and system based on model context protocol and cognitive state modeling. BACKGROUND

[0002] Existing online evaluation systems, such as the PTA platform serving college computer courses and the Codeforces platform serving algorithm competition, have become indispensable tools for programming education. However, these systems have significant shortcomings in the function of "tutoring". When the student's submitted code fails to pass the test cases, the system will only return simple, non-heuristic evaluation results, such as "answer error", "run timeout" or "compile error", etc. Students have difficulty locating specific problems from such simple feedback, and the effect of improving student learning efficiency is minimal.

[0003] In recent years, large language models have shown strong capabilities in code understanding and generation, bringing possibilities for the emergence of intelligent tutoring. However, when large language models are directly applied to programming tutoring, a core problem is that the lack of situational awareness of the model leads to inaccurate results, making the answers not only fail to achieve the expected tutoring effect, but may even hinder the student's learning progress.

[0004] For existing education AI assistants based on RAG technology, the usual approach is to use vector databases to retrieve topic-related knowledge, and to mix student error source code, topic description, and related knowledge point information in a fixed and mechanical pattern, and directly input the large model to give the result. In this case, the large model will lack understanding of the "evaluation context". The model cannot perceive where the specific failure point is, where the performance bottleneck is, and which one of the given knowledge points the corresponding topic is trying to examine. The lack of these key information will lead to the model's reply being too broad and highly speculative, and even completely wrong, failing to achieve a "highly personalized and controllable" tutoring effect. At the same time, the excessive context length generated by this input will also affect the model's understanding of the actual task, greatly increasing the probability of the model producing hallucinations in this scenario.

[0005] There are also some overall AI teaching systems on the market. These systems hard-couple the model, business logic, etc., and the over-customization of the model makes it difficult for the underlying model to be updated and replaced in a timely manner, and the knowledge base used in its training often has serious outdated phenomena.

[0006] In view of this, the present application proposes an intelligent tutoring method and system using a large language model, decoupling the system through a model context protocol, and having dynamic tool management and output compliance monitoring. Summary of the Invention

[0007] The purpose of this invention is to propose an intelligent learning aid method and system based on model context protocol and cognitive state modeling. It aims to solve the problems encountered in the practical application of large language models in educational scenarios, such as high resource consumption, lack of context awareness, weak teaching relevance, and risk of answer leakage, through multiple improvements at the protocol layer, middleware layer, and engineering algorithm optimization layer.

[0008] To achieve the above objectives, the technical solution of this invention is: an intelligent learning assistance system based on model context protocol and cognitive state modeling, the system comprising four interaction layers: user terminal, semantic firewall middleware, intelligent learning assistance server, and large language model service, as detailed below:

[0009] The user terminal includes a multimodal input module and a visualization rendering engine; the multimodal input module supports multimodal user input; the visualization rendering engine renders the DSL code blocks returned by the intelligent learning assistance server into visual interactive results locally;

[0010] The semantic firewall middleware is deployed as a traffic gateway between the large language model service and the intelligent learning assistance service, and runs as an independent service. The semantic firewall middleware has the ability to intercept and cache Server-Sent Events streams in real time, and determines whether the output needs to be blocked by analyzing the input and output tokens in a streaming manner.

[0011] The intelligent learning assistance server is used to negotiate tool capabilities and send the final response results to the user terminal; it completes tool filtering and pruning through the stored topology graph; it provides a code sandbox executor to provide a secure reasoning test environment based on Linux container technology; and it has a built-in cognitive state modeling module responsible for updating user profiles and compressing and storing historical dialogues.

[0012] The large language model service acts as an inference engine, receiving prompt words and tool definitions, and completing tool invocations during the inference process through the extended model context protocol.

[0013] An intelligent learning assistance method based on model context protocol and cognitive state modeling, the method being implemented based on the aforementioned intelligent learning assistance system, comprising:

[0014] Handshake phase: when the user initiates a tutoring request, the user terminal initializes the connection as an MCP client, and the intelligent tutoring server responds to the connection as an MCP server: activate the cognitive state modeling module, analyze the current dialogue context and the code submitted by the user, identify the current problem situation, and obtain the current ability profile and historical weaknesses of the student; and use the method of topological graph pruning to filter out the tool subset under the current problem situation from the full tool library, find related knowledge points from the knowledge base based on the cognitive state to inject the context for subsequent reasoning of the large language model, and send the filtered tool subset definition and knowledge content to the user terminal;

[0015] Model inference: the user terminal sends the user's input together with the tool subset definition and knowledge content to the large language model as initial input, and the large language model internally performs detailed logical reasoning through thought chains, and relies on the extended model context protocol to perform corresponding tool calls and receive returns on the MCP server according to the agreement; the whole process of model inference is monitored by the semantic firewall middleware to prevent malicious instruction injection;

[0016] Server security tool execution: after the intelligent tutoring server receives the tool call request of the large language model, it performs permission verification and forwarding execution according to the type, calls the corresponding module in the online evaluation system to complete the response to the call, and the execution result is packaged into the format agreed in the MCP protocol and fed back to the large language model as new context to form a closed loop, and the large language model decides whether to end the reasoning; the online evaluation system includes a domain knowledge and question database and a secure code execution sandbox pool;

[0017] Result integration output and state modeling: after the reasoning ends, the large language model starts to generate explanatory text and returns it to the user terminal; the returned Token stream is subjected to compliance judgment by the semantic firewall middleware, and if it is compliant, the Token stream is directly transmitted to the user terminal, and the user terminal uses the visual rendering engine to render the DSL code block into a visual interactive result, and if it is non-compliant, the fuse strategy is executed to truncate the Token stream and inject instructions to force the large language model to rewrite the answer;

[0018] State update and memory archiving: after this interaction ends, the system extracts the key elements of the dialogue, generates a structured summary for primary compression; the summary data is input into the cognitive state modeling module to update the long-term ability profile of the student, and accumulate data for the next personalized tutoring.

[0019] Preferably, the method of topological graph pruning is used to filter out the tool subset under the current problem situation from the full tool library, which is as follows:

[0020] The system is built-in to the weighted graph ; node set Includes context nodes Error type node and tools Three types of nodes, edge sets Represents the edge weights between nodes ;

[0021] Before each round of dialogue begins, the system analyzes the latest error logs or user questions, locates the current context node, and traverses the topology graph starting from the current context node, calculating the comprehensive activation probability of all reachable tool nodes, based on a dynamically determined threshold. Divide tools into those with high overall activation probability and those with low overall activation probability;

[0022] Introduction Strategy, with The probability selection method is based on the overall activation probability of the tool, while also considering the following: A tool with a low probability of activation through random exploration.

[0023] Preferably, the dependency weights between nodes are adaptively learned as follows:

[0024] Define reward signals for successful coaching If you call the tool Afterwards, the students If the code problem is successfully resolved or the conversation ends within the dialogue round, then ,otherwise ,in It is about The range of values ​​is The function, when The larger the value, the closer it is to ;

[0025] For time t, from the faulty node To tool node edge weight Updated using exponentially weighted moving averages:

[0026]

[0027] in The learning rate controls the smoothness of weight updates. The confidence level for the current situation. This represents the updated edge weights.

[0028] Preferably, the semantic firewall middleware specifically performs the following operations:

[0029] Before sending the user input to the large model, a lightweight BERT model is used for binary classification detection to identify whether there is an induced instruction. If the confidence of the induced instruction is higher than the threshold, it is directly intercepted and a warning is returned, without consuming the large model Token; When constructing the system Prompt, a separator is used to wrap the user's input to distinguish between user input and system instructions, to prevent the user's input from being misinterpreted by the large language model as a system instruction;

[0030] The code similarity between the current question and the passing code and the code segment generated by the large language model ; The semantic similarity between the to-be-detected semantic vector and the reference semantic vector , wherein the to-be-detected semantic vector corresponds to the vector representation of the text generated by the large language model, and the reference semantic vector corresponds to the vector representation of the pre-stored solution text in the background database; Calculate the keyword matching coefficient of the strong guidance prompt word in the large language model output content ;

[0031] The code similarity , semantic similarity , keyword matching coefficient are weighted to obtain the total risk coefficient , if the total risk coefficient exceeds the dynamic fuse threshold, the following automatic process is executed:

[0032] 1) The semantic firewall middleware immediately stops forwarding the current Token stream to the user terminal;

[0033] 2) The semantic firewall middleware automatically inserts an invisible system-level instruction into the dialogue history of the large language model, guiding the large language model to regenerate heuristic auxiliary learning content; The semantic firewall middleware discards the previous violation buffer content, and streams the compliant heuristic auxiliary learning content regenerated by the large language model according to the injected instruction to the user;

[0034] The fuse threshold is dynamically determined according to the user's ability profile and the understanding level shown in this dialogue. When the user cannot understand continuously, the output restriction is relaxed.

[0035] Preferably, the code similarity , semantic similarity , keyword matching coefficient are calculated as follows:

[0036] The system uses RAG technology in the background to retrieve the passing code of the current question , and real-time intercepts the code segment being generated by the large language model ; respectively and Parse into an abstract syntax tree and Among them, for The process involves streaming parsing; code similarity is achieved by combining tree edit distance and structure hashing. Calculation;

[0037] The semantic firewall middleware performs sliding window buffering on the Server-Sent Events text stream generated by the large language model. The system calls a lightweight text embedding model to convert the current buffered text into a high-dimensional semantic vector. The vector representation of the solution text corresponding to the current question is pre-stored in the background database. Real-time system calculation and Cosine similarity between them as semantic similarity ;

[0038] Using a buffered text stream generated by a large language model as input, the confidence probability of the text containing strongly directional cue words is output by a classification model and used as the keyword matching coefficient. .

[0039] Preferably, the system extracts key elements of the dialogue, generates a structured summary, and performs primary compression. The summary data is input into the cognitive state modeling module to update the student's long-term ability profile, accumulating data for the next personalized tutoring session, as follows:

[0040] When the context content of the dialogue occupies 60% of the total capacity of the context window of the large language model, after each round of dialogue, a lightweight model is triggered to extract the original dialogue in a structured manner, generating a quadruple data containing type, operation, content and notes information, which serves as short-term memory for subsequent dialogues.

[0041] Using cognitive state modeling techniques, the first-level compression results of multi-turn conversations are mapped onto student competency profiles; the student competency profiles constructed by the system are dynamic probability vectors. ,in Indicates the student's opinion on the first The probability of mastering each knowledge point;

[0042] Once a tutoring session ends, based on the structured summary generated by the first-level compression, the system determines the student's understanding of specific knowledge points. Performance on ,in, This indicates that the information has been obtained. This indicates a lack of understanding; the probability of understanding is updated using inference based on Bayesian knowledge tracing: first, the posterior probability is calculated. , wherein is the mastery probability before interaction, is the guessing parameter, i.e. the probability that the student has not mastered the knowledge point but gets it right by chance, is the complement of the error parameter, i.e. the probability that the student has mastered the knowledge point but makes a careless mistake, the final probability wherein is the difficulty decay coefficient of the knowledge point, is the time interval between two interactions.

[0043] Preferably, the extended model context protocol adds the visualization chart corresponding visualization / dsl data type in the CallToolResult and SamplingMessage structure of the standard model context protocol, and injects the syntax definition of the visualization DSL into the large language model.

[0044] Preferably, when retrieving the topic-related knowledge base, the system not only relies on the text semantic similarity, but also introduces a cognitive matching degree filtering mechanism:

[0045] The system pre-labels each knowledge point in the knowledge base with a difficulty level In the retrieval stage, the system reads the current user's mastery ability value of the related field and calculates and the difficulty span between If the difficulty span is greater than the preset value, the knowledge point is determined to be "unintelligible at the current stage", and is automatically de-weighted or shielded in the retrieval result;

[0046] For users with low ability value, the system preferentially retrieves "basic concept definition" type documents; for users with high ability value, the system relaxes the restrictions and allows the retrieval of "high-order optimization skill" type documents.

[0047] Preferably, the secure code execution sandbox pool limits CPU and memory resources based on the cgroup feature of the Linux container technology, and uses namespace to realize the isolation of network and file system, the secure code execution sandbox pool is a hot standby sandbox pool maintained by the system, used for executing the code submitted by the student, the verification code generated by the model and the mathematical symbol derivation verification.

[0048] Compared with the prior art, the present application has the following beneficial effects:

[0049] 1. Tool dynamic pruning and mask mechanism based on topology graph: During the handshake and negotiation phase of the MCP client to the MCP server, the server does not expose the full tool, but according to the actual situation category inferred based on the current dialogue context, it makes probabilistic reasoning based on the topology graph, and only enables the optimal tool subset required for the current step, thereby reducing the context length occupied by the tool definition.

[0050] 2. Output firewall and real-time fuse method based on syntax structure comparison and semantic analysis: Real-time interception of Token stream generated by large language model, screening of answer part, comparison of semantic analysis with existing question explanation content, similarity check of code construction AST, etc. If relevant fuse rules are triggered, the system will automatically truncate the output and inject guiding system instructions to drive the model to reason again.

[0051] 3. Extended model context protocol architecture: Support transmission of visual description blocks and visual description language in specific format through protocol, so that model input and output are not limited to text, but also include interactive charts, flowcharts and other helpful understanding contents.

[0052] 4. Hierarchical context compression and cognitive state modeling: Divide the dialogue history into different levels, extract key teaching nodes using large models, delete redundant language, and update the user's cognitive state model, so as to maintain long-term knowledge problem memory and user state perception within a limited context window.

[0053] 5. Adaptive knowledge retrieval based on cognitive state: Based on user cognitive state, retrieve knowledge points within user's understanding range to improve the applicability of tutoring content.

[0054] 6. Use code sandbox mechanism to assist verification of model reasoning result correctness: Provide a code sandbox based on cgroup technology to provide real-time code testing and verification capability for model reasoning process. BRIEF DESCRIPTION OF DRAWINGS

[0055] Figure 1 The timing diagram of the intelligent tutoring method interaction link of the present application. DETAILED DESCRIPTION

[0056] The technical solutions of the present application will be specifically described below in combination with the drawings.

[0057] The present application proposes an intelligent tutoring system based on model context protocol and cognitive state modeling. The core of the present application aims to solve the problems encountered in the practical landing of large models in education scenarios such as "large resource consumption", "weak teaching targeting" and "answer leakage risk" through multiple improvements of protocol layer, middleware layer and engineering algorithm optimization layer.

[0058] The system realizes the decoupling of the model end and the tool end through the model context protocol. During the interaction process, the system analyzes the weaknesses of students using cognitive state modeling and constructs a topology graph of "error type-tool dependency". When negotiating available tools with the model, the system does not directly provide a full list, but uses probabilistic reasoning under deterministic rule constraints to dynamically filter the optimal tool subset for the large model to call, thereby achieving the expected effect of reducing Token consumption and improving accuracy.

[0059] During reasoning, the model can perform efficient and accurate logical verification by executing code in the code sandbox provided by the system, significantly improving the accuracy and speed of reasoning. The code sandbox has sufficient security mechanisms to effectively avoid security risks caused by attempts to execute harmful code by the model due to injection attacks, etc.

[0060] During the conversation process, the system models the cognitive state and compresses the context at different levels. After each conversation, the "error point", "used tool" and "correction result" are extracted to generate a structured summary, replacing redundant information in the original context as short-term memory. The summaries of multiple conversations are organized and summarized through cognitive state modeling, etc. Finally, they are archived in the student's ability profile for subsequent use in question answering, question recommendation, etc.

[0061] In addition, the system also introduces a semantic firewall middleware to monitor the Token stream generated by the model in real time. The semantic analysis of the text content is compared with the existing question explanations, and the abstract syntax tree of the code content is constructed and compared with the code that has passed. The system can accurately identify and intercept the "direct code" behavior and force the model to switch to the thinking guidance mode.

[0062] Using the above technologies, the behavior of the large language model can be effectively regulated and controlled through engineering means, so that it can quickly and accurately achieve safe, efficient and personalized intelligent tutoring.

[0063] The system mainly includes four core interaction levels: user terminal, semantic firewall middleware, intelligent tutoring service server and large language model service.

[0064] 1. User terminal

[0065] Integrated in IDE plug-ins or web front-ends, directly providing services to users. It has a multi-modal input module that supports user input of code text, natural language questions, and uploading of error screenshot, handwritten thought draft, or topic description picture. It also has a visualization rendering engine that has built-in parsers for specific visualization description languages (DSL). When receiving the returned DSL code block (such as Mermaid, Graphviz, or custom JSON format) from the server, it renders it locally into an interactive flowchart, data structure diagram, or algorithm demonstration animation instead of the traditional static picture transmission.

[0066] 2. Semantic Firewall Middleware

[0067] Deployed between large language model services and intelligent tutoring service servers as a standalone service. It has the ability to intercept and cache Server-Sent Events streams in real time, and can determine whether the output needs to be blocked by analyzing input and output tokens in a streaming manner.

[0068] 3. Intelligent Tutoring Service Server

[0069] The business logic core of the system, responsible for tool capability negotiation and sending final response results to user terminals. It stores "error type-tool dependency topology graph" that can be used for tool selection and pruning. The server provides a code sandbox executor based on Linux container technology to provide a safe reasoning thought test environment. In addition, it also has a cognitive state modeling module that is responsible for user profile updating and historical dialogue compression storage.

[0070] 4. Large Language Model Service

[0071] As a pure reasoning engine, it does not store any state and has high replaceability. It receives prompt words and tool definitions and completes tool calls through model context protocols during reasoning

[0072] The invention realizes the above functions through the following specific subsystems and algorithm processes:

[0073] 1. Tool dynamic pruning and mask mechanism based on topology graph

[0074] To solve the problem of large model selection difficulty and excessive Token consumption when facing a large number of tools, the system proposes a "probabilistic reasoning under deterministic rule constraints" method.

[0075] a) Topology graph construction

[0076] The system has a directed and weighted graph .

[0077] Node set Three kinds of nodes (Calling context / stage, such as "thought check", "code debug", etc.), (error type, such as "answer error", "array out of bounds", "infinite loop"), and (tool set, such as "memory inspector", "test case result", "knowledge base search", etc.).

[0078] Edge set representing the dependency weight probability between nodes . For example, the weight of edge is set to , while the weight to is only .

[0079] b) Adaptive learning of topology graph weights

[0080] Define the reward signal for tutoring success . If the student successfully solves the code problem or ends the conversation within rounds of conversation after calling the tool , then , otherwise , where is a function of with a value range of , and the value tends to as becomes larger.

[0081] For the edge weight from the error node to the tool node , an exponentially weighted moving average (EWMA) is used for updating: , where is the learning rate, controlling the smoothness of weight updates, is the confidence of the current context determination, evaluated by user profiling and problem state.

[0082] c) Dynamic masking algorithm steps

[0083] Before the start of each round of conversation, the system analyzes the latest error log or user's question to locate the current context node . Starting from , traverse the topology graph to calculate the comprehensive activation probability of all reachable tool nodes . Then, according to the dynamically determined threshold , retain tools that meet the threshold, and generate a pruned tool list. Then, in the tool list response part of the MCP protocol, only return the pruned tool list, completing the dynamic pruning of tools.

[0084] To prevent the system from entering a local optimum after running for a period of time (only commonly used tools are recommended), a method is introduced during the tool selection phase. Strategy, with The probability of selecting tools with higher activation probabilities is considered, while also... The algorithm randomly explores low-weight tools with a probability. If the exploration reveals that a low-weight tool performs exceptionally well in a specific new question type, the above weight update formula will automatically increase its priority.

[0085] By introducing "topology pruning" during the tool definition phase, the system effectively controls the model's "action space." The model will not attempt to call complex algorithm analysis tools due to simple syntax errors, which not only saves computational resources but also avoids logical confusion caused by too many tool selections.

[0086] 2. Output firewall and real-time circuit breaker method based on syntax structure comparison and semantic analysis

[0087] To prevent the model from directly outputting code answers, the system implements deep semantic monitoring in the middleware layer.

[0088] a) Input risk assessment

[0089] Before sending user input to the main model, a lightweight BERT model is used for binary classification detection. This identifies whether there are misleading instructions, such as "ignore previous instructions," "act as my code-writing assistant," or "provide complete code directly without further explanation." If the confidence level is higher than a threshold, the input is intercepted and a warning is returned without consuming tokens from the main model.

[0090] When building the system prompt, special delimiters are used to "wrap" the user input to prevent the user input from being misinterpreted as system commands by the model.

[0091] b) Code similarity calculation

[0092] The system uses RAG technology in the background to retrieve the passing code for the current question. Extracting code snippets generated by the large language model in real time. . respectively and Parse into an abstract syntax tree and Among them, for The process involves streaming parsing. Similarity is calculated using methods such as tree-edit-distance and structural hashing. algorithm. This algorithm ignores the differences in variable naming, comments, and white spaces, and focuses on the comparison of the logical structure of the code.

[0093] c) Semantic Similarity Detection

[0094] To make up for the possible omissions of code similarity comparison alone (for example, the model directly describes the specific problem-solving steps in natural language instead of code), the system introduces a vector space-based text semantic detection mechanism in the semantic firewall middleware. The middleware buffers the Server-Sent Events text stream generated by the large language model in a sliding window (for example, 50 tokens are generated as a detection window). The system calls a lightweight text embedding model to convert the current buffered text into a high-dimensional semantic vector . In the background database, the vector representation of the "standard problem-solving approach", "reference answer analysis" and other text content corresponding to the current problem is pre-stored . The system calculates the cosine similarity (Cosine Similarity) between in real time .

[0095] d) Keyword Matching

[0096] In addition to comparing with the standard answer, the system also detects whether the output contains strong guiding prompt words such as "directly copy", "the answer is", "the code is as follows" and the like through keyword matching, and calculates the keyword matching coefficient .

[0097] The calculation of the keyword matching coefficient is realized by using a threat detection model based on BERT model fine-tuning and distillation. The system integrates a pre-trained sequence classification model in the semantic firewall, takes the buffered text stream generated by the large language model as input, processes it through the model encoding layer and classification head, and outputs the confidence probability that the text belongs to the "answer directly leaks" category. The confidence probability is normalized to a value between 0 and 100%. The actual logic of this step is similar to the logic of the induced instruction detection of user input in the firewall.

[0098] e) Fuse Strategy

[0099] When the above three scores are weighted to obtain the total risk coefficient After that, if it exceeds the dynamic threshold value evaluated according to the request, the following automation process is performed: 1) the middleware immediately stops forwarding the current Token stream to the user terminal, and the user sees the reply will temporarily stop at the last compliant character; 2) the middleware automatically inserts an invisible system-level instruction into the dialogue history of the large language model, such as: "Detecting that the current output contains direct answers or highly similar code, which violates the heuristic teaching principles of the tutoring system. Please stop the current output immediately and switch to guiding students to think through questions or only explain the core algorithm logic, without giving specific code implementation." After receiving the injection instruction, the model will regenerate the reply based on the new constraint conditions. The middleware discards the previous illegal buffer content and streams the model's regenerated compliant guiding content to the user, completing the mode switch from "directly giving answers" to "inducing" in a user-unaware state. The fuse threshold can be dynamically determined according to the user's ability profile and the understanding level reflected in this dialogue, and the output restriction can be appropriately relaxed when the user continues to fail to understand.

[0100] 3. Hierarchical Context Compression and Cognitive State Modeling

[0101] For historical dialogue content, the system adopts a double-layer compression mechanism to maximize the utilization of the context window.

[0102] a) Primary compression (session-level short-term memory)

[0103] When the context reaches 60% of the context window size of the main model, after each dialogue ends, a lightweight model is triggered to structure the original dialogue, using a four-tuple of (type, operation, content, note) as short-term memory for subsequent dialogue.

[0104] b) Secondary compression (user-level long-term memory)

[0105] Using cognitive state modeling technology, the primary compression results of multiple sessions are mapped into the "student ability profile". The student ability profile constructed by the system is a dynamic probability vector , where represents the student's mastery probability of the th knowledge point (such as "pointer" "recursion", etc.).

[0106] When a tutoring interaction ends, according to the structured summary generated by the primary compression, the system determines the student's performance on a specific knowledge point ( as correct / understanding, For errors / misses). The mastery probability is updated using inference based on Bayesian Knowledge Tracing (BKT). First, the mastery probability is updated by the posterior probability is calculated, where is the mastery probability before the interaction, is the guessing parameter, i.e., the probability that the student has not mastered but got it right by guessing. is the complement of the error parameter, i.e., the probability that the student has mastered but made a careless mistake. Considering memory decay, the time interval between two interactions will cause the mastery rate to decay, with the final probability where is the difficulty decay coefficient for this knowledge point.

[0107] At the beginning of a new tutoring session, the system generates a personalized system prompt based on the profile (e.g., "The student often makes mistakes on the recursive termination condition, please focus on this area. The current student level is weak, please avoid using high-level algorithms for solving, and focus on basic concept explanation rather than complex problem-solving skills") to achieve personalized tutoring.

[0108] 4. Extended Model Context Protocol Architecture

[0109] The standard model context protocol is extended to support rich media interaction. The visualization / dsl data type corresponding to the visualization chart is added to the structures such as CallToolResult and SamplingMessage in the model context protocol, and the strict syntax definition of the visualization DSL is injected into the model. When the model needs to explain complex data structures (such as the process of flipping a binary tree), a piece of DSL code can be generated and then transferred between the model and the user terminal. Compared to directly generating pictures for transmission, this method consumes fewer Tokens, network resources, and is more conducive to large language models focusing on generating logically related content rather than pictures and other miscellaneous items, improving the stability of the response. For the user terminal, using a specific DSL to render visual charts is also better in terms of interactive experience, allowing users to observe the details of data structures through scaling, sequencing, and other operations.

[0110] 5. Adaptive Knowledge Retrieval Based on Cognitive State

[0111] When retrieving the knowledge base related to the question, the system not only relies on the text semantic similarity, but also introduces a cognitive matching degree filtering mechanism.

[0112] The system pre-labels each knowledge point in the knowledge base with a difficulty level . During the retrieval phase, the system reads the mastery ability value of the current user in the relevant field and calculate the difficulty span between and If the difficulty span is too large, the knowledge point is determined as "un-understandable in the current stage" and is automatically de-weighted or shielded in the search results.

[0113] For users with lower ability values, the system prioritizes searching for "basic concept definition" type documents; for users with higher ability values, the system relaxes the restrictions and allows the search of "high-level optimization technique" type documents.

[0114] This mechanism ensures that the tutoring content generated by the model is always within the student's ability and cognitive range, avoiding teaching failures caused by retrieving too deep or too shallow knowledge.

[0115] 6. Online sandbox with security isolation

[0116] The system can use the sandbox mechanism to assist the model in logical verification.

[0117] The sandbox limits CPU and memory resources based on the cgroup feature of Linux, and uses namespace to achieve network and file system isolation. Before giving modification suggestions, the model can independently call the code execution tool code_executor to inject code into the sandbox for execution, capture stdout, stderr, and resource usage, and if the execution result is problematic, the model will modify the approach based on the error information, just like a human programmer, until the approach is correct and can pass self-checking before outputting to the student.

[0118] To ensure the real-time performance of model reasoning, the system maintains a hot standby sandbox pool. The system pre-starts a group of stateless base container images in a suspended or low-power standby state. When the model initiates a code execution request, the system directly takes an already warmed-up instance from the pool and only needs to mount the current session's code volume to put it into use within milliseconds. After execution, the sandbox is not immediately destroyed, but is reset and returned to the pool, or destroyed after a timeout.

[0119] The verification environment is not limited to executing computer code. By connecting to symbolic computation engines such as NumPy and SymPy, it can also be used to verify the correctness of mathematical formulas and derivations, further expanding the scope of disciplines that can be used with this strategy. This generalization design allows this method to be applied to a wide range of STEM (Science, Technology, Engineering, Mathematics) education fields, rather than just computer programming.

[0120] The system completes the mutual connection of main functional modules through the following interactive links:

[0121] 1. Handshake phase

[0122] When a user initiates a tutoring request, the user terminal as an MCP client first initializes the connection. The MCP server activates the cognitive state modeling module, analyzes the current dialogue context and the code submitted by the user, identifies the current problem situation, and obtains the current ability profile and historical weaknesses of the student. Then: 1) use the method of pruning the topological graph to filter out irrelevant tools from the full tool library; 2) find related knowledge points from the knowledge base and inject them into the context. Then send the filtered tool subset definition and knowledge content to the user terminal.

[0123] 2. Model inference

[0124] The user terminal sends the user's input together with the tool description to the large language model as the initial input. The large model internally performs detailed logical reasoning through the thought chain, and in the reasoning process, it relies on the model context protocol to perform corresponding tool calls and receive returns on the MCP server according to the agreement. This process is completely under the monitoring of the semantic firewall to prevent the injection of malicious instructions through various means to attempt to complete illegal tasks.

[0125] 3. Server security tool execution (dependent on the reasoning process)

[0126] The MCP service part of the intelligent tutoring server receives the tool call request, performs permission verification and forwarding execution according to the type, calls different modules in the online evaluation system to complete the response to the call. The execution result is packaged into the format agreed in the MCP protocol and fed back to the model as a new context to form a closed loop, and the model decides whether to end the reasoning.

[0127] The online evaluation system is the infrastructure layer of the entire architecture, which manages hardware resources and data assets downward, and provides atomic capability support for the intelligent tutoring server through internal APIs upward, and is also a place for users to submit and evaluate problems from a traditional perspective; This application mainly uses two sub-modules of the system: 1) domain knowledge and problem database, which stores problem descriptions, test cases, standard solution codes, and associated structured knowledge points (including difficulty level, knowledge point label, and problem reference answer), and can also obtain the student's historical submission answers; 2) secure code execution sandbox pool, an isolated environment based on Linux container technology (cgroup and namespace), which maintains a hot standby sandbox pool for executing student-submitted code, model-generated verification code, and mathematical symbol derivation verification.

[0128] 4. Result integration output and state modeling

[0129] After the inference ends, the model begins to generate explanatory text and returns it to the user terminal. This Token stream must pass through the semantic firewall middleware. If compliant, the Token stream is directly transmitted to the user terminal, which uses the rendering engine to render the DSL into an interactive chart. If non-compliant (triggering the fuse), the above-mentioned "fuse strategy" is executed, the stream is truncated and an instruction is injected, forcing the model to rewrite the answer.

[0130] 5. State update and memory archiving

[0131] After this interaction, the system extracts the key elements of the dialogue (error points, correction schemes) and generates a structured summary for primary compression. The summary data is input into the cognitive state model to update the student's long-term ability profile (secondary compression), accumulating data for the next personalized tutoring.

[0132] The above is the preferred embodiment of the present application. Any changes made in accordance with the technical solutions of the present application, as long as the resulting functional effects do not exceed the scope of the technical solutions of the present application, are within the scope of protection of the present application.

Claims

1. An intelligent learning assistance system based on model context protocol and cognitive state modeling, characterized in that, The system comprises four interactive layers: user terminal, semantic firewall middleware, intelligent learning assistance server, and large language model service, as detailed below: The user terminal includes a multimodal input module and a visualization rendering engine; the multimodal input module supports multimodal user input; the visualization rendering engine renders the DSL code blocks returned by the intelligent learning assistance server into visual interactive results locally; The semantic firewall middleware is deployed as a traffic gateway between the large language model service and the intelligent learning assistance service, and runs as an independent service. The semantic firewall middleware has the ability to intercept and cache Server-Sent Events streams in real time, and determines whether the output needs to be blocked by analyzing the input and output tokens in a streaming manner. The intelligent learning assistance server is used to negotiate tool capabilities and send the final response result to the user terminal; The tools are selected and pruned using the stored topology graph; Provides a code sandbox executor to offer a secure testing environment for inference ideas based on Linux container technology; It also has a built-in cognitive state modeling module, which is responsible for updating user profiles and compressing and storing historical conversations; The large language model service acts as an inference engine, receiving prompt words and tool definitions, and completing tool invocations during the inference process through the extended model context protocol.

2. An intelligent learning aid method based on model context protocol and cognitive state modeling, characterized in that, The method is implemented based on the intelligent learning assistance system described in claim 1, and includes: Handshake Phase: When a user initiates a tutoring request, the user terminal initializes the connection as an MCP client, and the intelligent tutoring server responds to the connection as an MCP server: activating the cognitive state modeling module, analyzing the current dialogue context and the code submitted by the user, identifying the current problem situation, and obtaining the student's current ability profile and historical weaknesses; and using the topology graph pruning method to filter out a subset of tools in the current problem situation from the full tool library, searching for relevant knowledge points from the knowledge base based on the cognitive state to inject into the context of subsequent reasoning in the large language model, and sending the definition of the filtered tool subset and knowledge content to the user terminal; Model inference: The user terminal sends the user's input along with the tool subset definition and knowledge content to the large language model as initial input. The large language model performs detailed logical reasoning through the thought chain. During the inference process, the corresponding tool calls are executed on the MCP server according to the convention based on the extended model context protocol and the return is received. The entire model inference process is monitored by the semantic firewall middleware to prevent malicious command injection. Server-side security tool execution: After receiving a tool call request from the large language model, the intelligent learning server performs permission verification and forwards the execution according to the type. It calls the corresponding module in the online evaluation system to complete the response to the call. The execution result is encapsulated back into the format agreed in the MCP protocol and fed back to the large language model as a new context to form a closed loop. The large language model decides whether to end the inference. The online evaluation system includes a domain knowledge and question database as well as a secure code execution sandbox pool. Results integration and state modeling: After inference, the large language model starts generating explanatory text and returns it to the user terminal; the returned token stream is judged for compliance by the semantic firewall middleware. If it is compliant, the token stream is directly passed to the user terminal, and the user terminal uses the visualization rendering engine to render the DSL code block into a visual interactive result. If it is non-compliant, the circuit breaker strategy is executed, the token stream is cut off and the instruction is injected to force the large language model to rewrite the answer. Status Update and Memory Archiving: After this interaction, the system extracts the key elements of the dialogue, generates a structured summary, and performs primary compression. The summary data is input into the cognitive state modeling module to update the student's long-term ability profile and accumulate data for the next personalized tutoring session.

3. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 2, characterized in that, The method of using topology graph pruning to filter out a subset of tools for the current problem context from the full tool library is as follows: The system has a built-in directed weighted graph. Node set Includes context nodes Error type node and tools Three types of nodes, edge sets Represents the edge weights between nodes ; Before each round of dialogue begins, the system analyzes the latest error logs or user questions, locates the current context node, and traverses the topology graph starting from the current context node, calculating the comprehensive activation probability of all reachable tool nodes, based on a dynamically determined threshold. Divide tools into those with high overall activation probability and those with low overall activation probability; Introduction Strategy, with The probability selection method is based on the overall activation probability of the tool, while also considering the following: A tool with a low probability of activation through random exploration.

4. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 3, characterized in that, The dependency weights between nodes are adaptively learned as follows: Define reward signals for successful coaching If you call the tool Afterwards, the students If the code problem is successfully resolved or the conversation ends within the dialogue round, then ,otherwise ,in It is about The range of values ​​is The function, when The larger the value, the closer it is to ; for From the error node To tool node edge weight Updated using exponentially weighted moving averages: in The learning rate controls the smoothness of weight updates. The confidence level for the current situation. This represents the updated edge weights.

5. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 2, characterized in that, The semantic firewall middleware specifically performs the following operations: Before sending user input to the large model, a lightweight BERT model is used to perform binary classification detection to identify whether there are misleading instructions. If the confidence of a misleading instruction is higher than the threshold, it is directly intercepted and a warning is returned without consuming the large model's token. When building the system prompt, a separator is used to wrap the user input to distinguish between user input and system instructions, preventing the user input from being misinterpreted as system instructions by the large language model. Calculate the code for the current problem Code snippets generated by large language models Code similarity between ; Calculate the semantic similarity between the semantic vector to be detected and the benchmark semantic vector. The semantic vector to be detected corresponds to the vector representation of the text generated by the large language model, and the benchmark semantic vector corresponds to the vector representation of the solution text pre-stored in the background database; the keyword matching coefficient of strongly guiding prompts in the output content of the large language model is calculated. ; Code similarity semantic similarity Keyword matching coefficient The total risk factor is obtained by weighting. If the total risk factor If the dynamic circuit breaker threshold is exceeded, the following automated process will be executed: 1) The semantic firewall middleware immediately stops forwarding the current token stream to the user terminal; 2) The semantic firewall middleware automatically inserts an invisible system-level instruction into the dialogue history of the large language model, guiding the large language model to regenerate heuristic supplementary learning content; the semantic firewall middleware discards the previous illegal buffer content and streams the compliant heuristic supplementary learning content regenerated by the large language model according to the injected instruction to the user. The circuit breaker threshold is dynamically determined based on the user's ability profile and the level of understanding demonstrated in the current conversation. When the user continues to be unable to understand, the output restrictions are relaxed.

6. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 5, characterized in that, The code similarity semantic similarity Keyword matching coefficient The calculation is as follows: The system uses RAG technology in the background to retrieve the passing code for the current question. Extracting code snippets generated by the large language model in real time. ; respectively and Parse into an abstract syntax tree and Among them, for The process involves streaming parsing; code similarity is achieved by combining tree edit distance and structure hashing. Calculation; The semantic firewall middleware performs sliding window buffering on the Server-Sent Events text stream generated by the large language model. The system calls a lightweight text embedding model to convert the current buffered text into a high-dimensional semantic vector. The vector representation of the solution text corresponding to the current question is pre-stored in the background database. Real-time system calculation and Cosine similarity between them as semantic similarity ; Using a buffered text stream generated by a large language model as input, the confidence probability of the text containing strongly directional cue words is output by a classification model and used as the keyword matching coefficient. .

7. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 2, characterized in that, The system extracts key elements from the dialogue, generates a structured summary, and performs primary compression. The summary data is then input into the cognitive state modeling module to update the student's long-term ability profile, accumulating data for the next personalized tutoring session, as detailed below: When the context content of the dialogue occupies 60% of the total capacity of the context window of the large language model, after each round of dialogue, a lightweight model is triggered to extract the original dialogue in a structured manner, generating a quadruple data containing type, operation, content and notes information, which serves as short-term memory for subsequent dialogues. Using cognitive state modeling techniques, the first-level compression results of multi-turn conversations are mapped onto student competency profiles; The student competency profile constructed by the system is a dynamic probability vector. ,in Indicates the student's opinion on the first The probability of mastering each knowledge point; Once a tutoring session ends, based on the structured summary generated by the first-level compression, the system determines the student's understanding of specific knowledge points. On performance ,in, This indicates that the information has been obtained. This indicates a lack of understanding; the probability of understanding is updated using inference based on Bayesian knowledge tracing: first calculate the posterior probability. , ,in It is the probability of knowing before interaction. It's a guessing parameter, specifically the probability that a student guesses correctly even if they haven't mastered the knowledge. It is the complement of the error parameter, that is, the probability that a student has mastered the knowledge but makes a careless mistake, the final probability. ,in This is the difficulty reduction coefficient for this knowledge point. It is the time interval between two interactions.

8. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 2, characterized in that, The extended model context protocol adds the visualization / DSL data type corresponding to the visualization chart to the CallToolResult and SamplingMessage structures of the standard model context protocol, and injects the syntax definition of the visualization DSL into the large language model.

9. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 2, characterized in that, When searching the knowledge base related to the question, the system not only relies on textual semantic similarity, but also introduces a cognitive matching filtering mechanism: The system will store each knowledge point in the knowledge base. Difficulty levels are pre-marked. During the search phase, the system reads the current user's level of expertise in the relevant field. and calculate and The range of difficulty between them; if the range of difficulty exceeds the preset value, then the knowledge points... It was determined to be "incomprehensible at the current stage" and was automatically downgraded or blocked in the search results; For users with low ability scores, the system prioritizes searching documents in the "basic concept definition" category; for users with high ability scores, the system relaxes the restrictions and allows searching documents in the "advanced optimization techniques" category.

10. The intelligent learning aid method based on model context protocol and cognitive state modeling according to claim 2, characterized in that, The secure code execution sandbox pool uses the cgroup feature of Linux container technology to limit CPU and memory resources, and uses namespaces to achieve network and file system isolation. The secure code execution sandbox pool is a hot standby sandbox pool maintained by the system, used to execute code submitted by students, verification code generated by models, and mathematical symbol derivation verification.

Citation Information

Cited By

  • Human-computer collaborative adaptive regulation method, system and electronic device

    CN122241694A