Education ethics deviation prediction method, system and device for large language model and medium

By constructing a traceable structured knowledge graph and training with a sparse autoencoder, a value-based intelligent agent is generated for adversarial testing. A dynamic early warning mechanism is established, which solves the problems of ethical bias and privacy leakage in educational scenarios of large language models, and achieves accurate prediction and traceable monitoring of ethical risks.

CN122334589APending Publication Date: 2026-07-03GUANGZHOU UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGZHOU UNIVERSITY
Filing Date
2026-04-03
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing large language models in educational settings suffer from ethical biases, privacy leaks, ambiguity of intellectual property rights, and insufficient algorithmic transparency. Traditional ethical constraints are ill-suited to the dynamic updates of educational ethical guidelines, and the lack of a comprehensive, systematic ethical framework makes it difficult to trace ethical risks and results in low accuracy in early warning.

Method used

We construct a structured knowledge graph with traceable digital fingerprints, train an ethical knowledge enhancement model through a sparse autoencoder, generate multiple value-based intelligent agents for adversarial testing, establish an ethical behavior risk matrix and set dynamic early warning thresholds, and monitor the internal activation state of the model in real time to trigger ethical deviation warnings.

Benefits of technology

It enables forward-looking prediction and traceable monitoring of ethical deviation risks in large language models, improves the accuracy and comprehensiveness of ethical deviation prediction, and enhances the interpretability and auditability of model ethical compliance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122334589A_ABST
    Figure CN122334589A_ABST
Patent Text Reader

Abstract

This application relates to a method, system, device, and medium for predicting educational ethics deviations in large language models. The method includes: constructing a structured ethical knowledge graph with traceable digital fingerprints and fine-tuning the model; generating value-based agents to construct an adversarial testing environment for multi-round questioning, obtaining external dialogue text and internal knowledge traceability vectors, evaluating and generating a risk matrix and boundary use case library; extracting ethical personality basis vectors and setting dynamic thresholds, real-time projection monitoring of the model's internal activation state, triggering ethical deviation warnings, and generating analysis reports. This method, by constructing a structured ethical knowledge graph with traceable digital fingerprints and combining a collaborative mechanism of multi-value-based agent adversarial testing and real-time projection monitoring of internal knowledge call states, further improves the accuracy, traceability, and comprehensiveness of predicting educational ethics deviation risks in large language models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, and in particular relates to methods, systems, devices and media for predicting educational ethics biases for large language models. Background Technology

[0002] With the rapid development of Artificial Intelligence in Education (AIED), large language models, with their powerful natural language processing capabilities, have been widely applied in educational scenarios such as intelligent teaching and tutoring, educational content generation, and personalized learning support, driving innovation and upgrading of educational models. However, while empowering education, AIED also faces serious ethical challenges. These issues have a profound impact on educational equity, student mental health, and social inclusion, and have become core issues of concern for education policymakers and researchers both domestically and internationally.

[0003] Currently, ethical issues in the field of AI-generated educational tools (AIEDs) are multi-dimensional and complex. On the one hand, the training data for large language models largely originates from publicly available internet data, which contains a large amount of bias and misinformation. Without effective ethical constraints, these models are prone to generating content that violates authoritative educational ethical guidelines. On the other hand, AIED applications also suffer from problems such as data privacy leaks, ambiguous intellectual property ownership, and insufficient algorithm transparency. Some companies use user input information to continuously train models, leading to the risk of misuse of sensitive information belonging to students, teachers, and schools. Furthermore, the lack of uniformity in the ethical standards of existing filtering and review mechanisms further exacerbates these ethical risks. In addition, students' over-reliance on AI-generated tools to complete assignments and exams not only erodes the authenticity of the learning process but also limits the development of independent thinking and problem-solving abilities, posing a challenge to the essence of education and academic integrity.

[0004] To address these ethical dilemmas, various countries have undertaken relevant explorations and the formulation of regulations. For example, many universities in China have implemented an AIGC (Artificial Intelligence and Generic Content) system for graduation theses, and the Ministry of Education has explicitly proposed strengthening the standardization of artificial intelligence ethics and privacy protection in digital education. The U.S. Department of Education has issued four urgent recommendations on AIED (Artificial Intelligence and Generic Development) ethics, emphasizing data quality review, fairness assurance, and human checks and balances. The EU's Artificial Intelligence Act further includes high-risk AI systems in the education sector under strict regulation, stipulating that they must undergo thorough testing and review before being put into use. However, existing research and norms still have significant shortcomings: First, ethical discussions are fragmented, focusing on single-issue responses and lacking a systematic ethical framework that runs through the entire AIED development process; second, traditional ethical constraints, such as static rule bases and keyword filtering, are difficult to adapt to the structured presentation and dynamic updating needs of educational ethics guidelines, and cannot trace the root causes of ethical deviations in the model; third, existing testing methods mostly use single-scenario sample inputs and have not built adversarial testing environments covering diverse values, making it difficult to fully expose potential vulnerabilities of the model in complex ethical scenarios; fourth, early warning mechanisms are mostly based on the surface features of the generated text and do not delve into the internal activation state and knowledge retrieval process of the model, resulting in low accuracy and high false positive and false negative rates.

[0005] Furthermore, existing AIED tools such as ChatGPT, Turnitin, and ZeroGPT, while effective in specific scenarios, still have significant ethical flaws. For example, ChatGPT's generated content may contain biases and inaccuracies, and it can easily lead to students' over-reliance on the technology; Turnitin's database is subject to privacy and copyright controversies, and its lack of algorithm transparency can easily lead to misjudgments; ZeroGPT's recognition accuracy is affected by training data and algorithm design, making it difficult to balance academic integrity and student privacy protection. Meanwhile, the large language models that form the basis of AIED, such as BERT and GPT, lack ethical oversight in their transformer architecture and training process, and their parameter scale of hundreds of billions makes traditional oversight and review methods ineffective. Existing research indicates that ethical norms for AIED need to be integrated throughout the entire process, including model framework selection, training data control, and optimization of self-supervised learning mechanisms. However, there is currently a lack of technical solutions to transform authoritative educational ethical guidelines into structured constraints that can be enforced by models, and to achieve accurate prediction and traceable monitoring of ethical deviations. Therefore, how to construct a full-process ethical constraint system adapted to educational scenarios, address the shortcomings of existing technologies in terms of fragmented ethical norms, difficulty in tracing the source of risks, and low accuracy of early warning, and achieve forward-looking prediction, traceable monitoring, and effective early warning of ethical deviation risks in large language models has become an urgent technical problem to be solved. Summary of the Invention

[0006] Therefore, it is necessary to provide methods, systems, devices, and media for predicting educational ethics deviations in large language models to address the aforementioned technical issues. The aim is to improve the accuracy and comprehensiveness of ethical deviation predictions, enhance the interpretability and auditability of model ethical compliance, and achieve proactive identification, dynamic monitoring, and root cause tracing of educational ethical risks.

[0007] Firstly, this application provides a method for predicting educational ethics biases in large language models, including:

[0008] Based on pre-defined authoritative educational ethics guidelines, a structured knowledge graph with traceable digital fingerprints is constructed; the basic large language model is fine-tuned based on the structured knowledge graph to obtain an ethics knowledge enhancement model; based on the traceable digital fingerprints in the structured knowledge graph, a sparse autoencoder is trained to obtain a traceability vector extractor for extracting the knowledge call state inside the ethics knowledge enhancement model.

[0009] Based on the ethical knowledge enhancement model, multiple value agents are generated, forming an adversarial testing environment. In this environment, the ethical knowledge enhancement model undergoes multiple rounds of adversarial questioning. In each round, the external dialogue text generated by the model is obtained, and the corresponding internal knowledge source vector is extracted using a source vector extractor. Based on the internal knowledge source vectors and external dialogue texts output in each round, the ethical knowledge enhancement model is quantitatively evaluated for compliance with knowledge invocation, generating an ethical behavior risk matrix and a high-risk boundary use case library.

[0010] Based on a high-risk boundary use case library, an ethical personality basis vector set is obtained through comparative learning. Based on the ethical behavior risk matrix, a corresponding dynamic early warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set. Based on the ethical personality basis vector set and the dynamic early warning threshold, the internal activation state of the ethical knowledge enhancement model when processing user queries is monitored in real time. When the monitoring result indicates that an offset risk is detected, an ethical offset early warning is triggered, and an analysis report is generated.

[0011] In one embodiment, a structured knowledge graph with traceable digital fingerprints is constructed based on preset authoritative educational ethics guidelines; a basic large language model is fine-tuned based on the structured knowledge graph to obtain an ethics knowledge enhancement model; a sparse autoencoder is trained based on the traceable digital fingerprints in the structured knowledge graph to obtain a traceability vector extractor for extracting the knowledge call states within the ethics knowledge enhancement model, including:

[0012] Information is extracted from unstructured text in the pre-defined authoritative educational ethics guidelines, and a knowledge graph with triples as the basic unit is constructed. A unique traceable digital fingerprint is generated for each triple in the knowledge graph, resulting in a structured knowledge graph. The traceable digital fingerprint consists of the content hash value and metadata encoding value of the triple. The metadata encoding value includes the knowledge source, authority level, and effective time.

[0013] By integrating structured knowledge graphs with general educational corpora, training sample pairs are constructed, including text fragments, associated knowledge triples, and corresponding traceable digital fingerprints. The basic large language model is trained through an adaptive attention masking mechanism to obtain an ethical knowledge enhancement model. The adaptive attention masking mechanism is used to dynamically adjust the connection weights of the attention layer in the basic large language model based on the matching results of keywords and associated knowledge triples in the training sample pairs.

[0014] The training sample pairs are input into the ethics knowledge enhancement model. The activation states of the intermediate layers of the ethics knowledge enhancement model are collected when processing the training sample pairs. A training dataset is constructed based on the intermediate layer activation states and the traceable digital fingerprints corresponding to the training sample pairs. The sparse autoencoder is trained under supervision to obtain the traceability vector extractor. The training objective of the sparse autoencoder is to map the traceability vectors output by the bottleneck layer in the sparse autoencoder to the corresponding traceable digital fingerprints.

[0015] In one embodiment, based on the ethical knowledge enhancement model, multiple value agents are generated, forming an adversarial testing environment. In this environment, the ethical knowledge enhancement model undergoes multiple rounds of adversarial questioning. In each round, the external dialogue text generated by the model is obtained, and the corresponding internal knowledge source vector is acquired using a source vector extractor. Based on the internal knowledge source vectors and external dialogue text output in each round, the ethical knowledge enhancement model is quantitatively evaluated for compliance with knowledge invocation, generating an ethical behavior risk matrix and a high-risk boundary use case library, including:

[0016] Multiple value prototypes covering the spectrum of educational ethics are constructed. Initial corpora are generated based on the value prototypes using an independent language model. The initial corpora are then filtered using an ethics knowledge enhancement model to generate multiple value agents. The filtering process includes verifying the representativeness and non-extreme nature of the values ​​in the initial corpora using the ethics knowledge enhancement model.

[0017] A multi-turn dialogue simulation platform is constructed, forming an adversarial testing environment composed of multiple value-based intelligent agents. An ethical knowledge enhancement model is set as the system under test, and multiple value-based intelligent agents are set as interaction objects. The multi-turn dialogue simulation platform drives these agents to initiate multiple rounds of adversarial queries against the ethical knowledge enhancement model, obtaining a comprehensive risk score for each round. The comprehensive risk score is obtained through the following steps:

[0018] For each round of interaction, the natural language response generated by the ethical knowledge enhancement model is recorded to obtain the external dialogue text. The source vector extractor is then called to process the intermediate layer activation state of the ethical knowledge enhancement model in the current round of interaction to obtain the internal knowledge source vector.

[0019] Logical consistency and stance stability analyses were performed on the external dialogue texts to obtain and calculate the behavioral consistency score based on the first and second results. The internal knowledge tracing vector was decoded, and the knowledge call compliance score was obtained by combining the decoding results with the knowledge call matching degree and activation intensity. The behavioral consistency score and the knowledge call compliance score were weighted and fused to obtain the comprehensive risk score for the current round of interaction.

[0020] The comprehensive risk scores of each round are summarized and statistically analyzed according to the preset ethical dimensions and preset interaction scenario types to generate an ethical behavior risk matrix. Abnormal interaction rounds with knowledge call compliance scores lower than the preset call compliance threshold are selected, and the external dialogue text, internal knowledge tracing vector and comprehensive risk score corresponding to the abnormal interaction rounds are stored to generate a high-risk boundary use case library.

[0021] In one embodiment, an ethical personality basis vector set is obtained through comparative learning based on a high-risk boundary use case library; a corresponding dynamic warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set based on an ethical behavior risk matrix; based on the ethical personality basis vector set and the dynamic warning threshold, the internal activation state of the ethical knowledge enhancement model when processing user queries is monitored in real time by projection; when the monitoring result indicates that an offset risk has been detected, an ethical offset warning is triggered, and an analysis report is generated, including:

[0022] The internal activation states and corresponding dialogue contexts of the ethical knowledge enhancement model when generating high-risk responses are extracted from the high-risk boundary use case library to obtain abnormal state samples and target dialogue contexts. Based on the target dialogue context, the ethical knowledge enhancement model is guided to generate responses that conform to ethical norms, and the internal activation states in the generation process are extracted to obtain normal state samples. Based on the abnormal state samples and normal state samples, multiple vector directions are solved in the activation space of the ethical knowledge enhancement model through a contrastive learning algorithm to obtain a set of ethical personality basis vectors.

[0023] Locate each low-risk test case from the ethical behavior risk matrix, extract the projection value of the low-risk test case onto each ethical personality basis vector in the ethical personality basis vector set, and calculate and set the corresponding dynamic early warning threshold for each ethical personality basis vector based on the statistical distribution of the projection value.

[0024] An ethical knowledge enhancement model is deployed, and the internal activation state sequence of the deployed ethical knowledge enhancement model when processing user queries is obtained in real time through the monitoring module. The activation state sequence is projected onto the set of ethical personality basis vectors to obtain multiple sets of ethical trait projection curves. The ethical trait projection curves are compared and analyzed with the corresponding dynamic warning thresholds. When the comparison result meets the deviation risk judgment condition, the monitoring result is obtained. If the monitoring result indicates that deviation risk has been detected, an ethical deviation warning is triggered.

[0025] Record the user queries, internal activation state sequences, and ethical trait projection curves that trigger ethical deviation warnings to obtain warning-related data; call the source vector extractor to perform internal state analysis on the internal activation state sequences in the warning-related data to generate an analysis report; the analysis report includes knowledge call anomalies, corresponding entries in the structured knowledge graph, and risk level assessment results.

[0026] In one embodiment, the internal activation states and corresponding dialogue contexts of the ethical knowledge enhancement model when generating high-risk responses are extracted from a high-risk boundary use case library to obtain abnormal state samples and target dialogue contexts. Based on the target dialogue context, the ethical knowledge enhancement model is guided to generate responses that conform to ethical norms, and the internal activation states during the generation process are extracted to obtain normal state samples. Based on the abnormal state samples and normal state samples, multiple vector directions are solved in the activation space of the ethical knowledge enhancement model using a contrastive learning algorithm to obtain a set of ethical personality basis vectors, including:

[0027] S201. Select target cases related to the preset ethical dimension from the high-risk boundary use case library, extract and use the intermediate layer activation state matrix and corresponding dialogue context when the ethical knowledge enhancement model generates a high-risk response in the target cases, and use them as abnormal state samples and target dialogue contexts respectively.

[0028] S202. Input the target dialogue context into the ethics knowledge enhancement model, guide the ethics knowledge enhancement model to generate a response that conforms to the preset ethics dimensions, and extract and use the intermediate layer activation state matrix in the response generation process as a normal state sample.

[0029] S203. Extract features from abnormal state samples and normal state samples to obtain abnormal feature vectors and normal feature vectors respectively.

[0030] S204. Construct a contrastive learning loss function. The contrastive learning loss function aims to make the abnormal feature vectors approach the negative prototype vector to be solved, and to make the normal feature vectors move away from the negative prototype vector.

[0031] S205. Optimize the contrastive learning loss function through gradient descent algorithm, and solve for the direction of the negative prototype vector in the activation space of the ethical knowledge enhancement model. Define the direction as the ethical personality basis vector corresponding to the preset ethical dimension.

[0032] S206. For each preset ethical dimension, repeat steps S201 to S205 to obtain the ethical personality basis vectors corresponding to each preset ethical dimension, and summarize the ethical personality basis vectors to form an ethical personality basis vector set.

[0033] In one embodiment, an ethical knowledge enhancement model is deployed. A monitoring module acquires the internal activation state sequence of the deployed ethical knowledge enhancement model when processing user queries in real time. This activation state sequence is projected onto a set of ethical personality basis vectors to obtain multiple sets of ethical trait projection curves. The ethical trait projection curves are compared and analyzed with corresponding dynamic warning thresholds. When the comparison result meets the deviation risk judgment condition, a monitoring result is obtained. If the monitoring result indicates a deviation risk has been detected, an ethical deviation warning is triggered, including:

[0034] The ethical knowledge enhancement model is deployed to the online service environment, and a monitoring module is deployed in the online service environment. The monitoring module establishes a data interaction channel with the selected network layer of the ethical knowledge enhancement model.

[0035] When the ethics knowledge enhancement model receives a user query and starts generating a response, the monitoring module continuously collects the activation state vector of the selected network layer from the generation of the first response word to form an internal activation state sequence.

[0036] Calculate the dot product between each activation state vector in the internal activation state sequence and each ethical personality basis vector in the set of ethical personality basis vectors to obtain the instantaneous projection value of each ethical dimension at the corresponding generation step;

[0037] After the ethical knowledge enhancement model completes the generation of a full response, it generates an ethical trait projection curve corresponding to each ethical dimension based on the instantaneous projection values ​​of each ethical dimension.

[0038] Calculate the moving average and peak value of the projection curve of each ethical trait. Combine the dynamic warning threshold, which includes a first threshold corresponding to the moving average and a second threshold corresponding to the peak value, and compare the moving average value of each ethical dimension with the first threshold and the peak value of each ethical dimension with the second threshold to obtain the comparison results.

[0039] If the moving average of any ethical dimension is greater than the corresponding first threshold, or the peak value of any ethical dimension is greater than the corresponding second threshold, the comparison result is determined to meet the offset risk determination condition, the monitoring result is determined to be an offset risk detected, and an ethical offset warning is triggered.

[0040] In one embodiment, the overall risk score of the current round of interaction is calculated using the following formula:

[0041]

[0042] in, For the first The overall risk score for wheel interaction ranges from [0,10]. The total number of pre-defined educational ethics dimensions, and ; For the first In the first round of interaction The dynamic weights of each ethical dimension satisfy... From the formula calculate, For temperature coefficient, For the first In the first round of interaction Situational sensitivity across ethical dimensions; The weighting coefficient for the behavioral consistency score; For the first In the first round of interaction The behavioral consistency score for each ethical dimension, ranging from [0,1], is derived from the logical consistency score. and position stability score Weighted average; For the first In the first round of interaction A knowledge retrieval compliance score for each ethical dimension, ranging from [0,1], is determined by the knowledge matching degree. and activation intensity Normalization yields the result; This is the cumulative penalty coefficient for risk. For the first Wheel and front Risk change rate of the wheel , To avoid the minimum value where the denominator is 0, The initial risk score is unweighted, and , for The average score of behavioral consistency across ethical dimensions for The average score of knowledge access compliance across all ethical dimensions.

[0043] Secondly, this application also provides an educational ethics shift prediction system for large language models, including:

[0044] The knowledge enhancement and feature extraction module is used to construct a structured knowledge graph with traceable digital fingerprints based on preset authoritative educational ethics guidelines; fine-tune the basic large language model based on the structured knowledge graph to obtain an ethics knowledge enhancement model; and train a sparse autoencoder based on the traceable digital fingerprints in the structured knowledge graph to obtain a traceability vector extractor for extracting the knowledge call state inside the ethics knowledge enhancement model.

[0045] The ethics testing and risk quantification module is used to generate multiple value agents based on the ethics knowledge enhancement model, which together form an adversarial testing environment. In this environment, the ethics knowledge enhancement model is subjected to multiple rounds of adversarial questioning. In each round, the external dialogue text generated by the model is obtained, and the corresponding internal knowledge source vector is extracted using a source vector extractor. Based on the internal knowledge source vectors and external dialogue texts output in each round, the compliance of knowledge invocation in the ethics knowledge enhancement model is quantitatively evaluated, generating an ethical behavior risk matrix and a high-risk boundary use case library.

[0046] The real-time monitoring and dynamic early warning module is used to extract an ethical personality basis vector set based on a high-risk boundary use case library through comparative learning; based on the ethical behavior risk matrix, a corresponding dynamic early warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set; based on the ethical personality basis vector set and the dynamic early warning threshold, the internal activation state of the ethical knowledge enhancement model is projected and monitored in real time when processing user queries. When the monitoring result indicates that an offset risk is detected, an ethical offset early warning is triggered and an analysis report is generated.

[0047] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the first aspect.

[0048] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the first aspect.

[0049] The aforementioned method, system, device, and medium for predicting educational ethics deviations in a large language model first constructs a structured knowledge graph with traceable digital fingerprints based on authoritative educational ethics guidelines. This fine-tunes the basic large language model and trains a traceability vector extractor, solving the problems of fragmented and difficult-to-trace ethical constraints in traditional approaches and improving the accuracy of ethical knowledge embedding and the interpretability of the invocation process. Second, it constructs an adversarial testing environment based on a value-based intelligent agent generated from an ethical knowledge-enhanced model. Through multi-round questioning, it collects dual data streams and performs quantitative evaluation, effectively addressing the problem that single-scenario testing is insufficient to expose ethical vulnerabilities in the model and improving the comprehensiveness and quantitative accuracy of risk assessment. Finally, it extracts ethical personality basis vectors through comparative learning and sets dynamic early warning thresholds, enabling real-time projection monitoring of the model's internal activation state, thus improving the foresight and monitoring effectiveness of deviation prediction. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 Flowchart of an educational ethics shift prediction method for a large language model provided as an exemplary embodiment of the present invention;

[0052] Figure 2 A flowchart illustrating a method for obtaining a set of ethical personality basis vectors, provided as an exemplary embodiment of the present invention;

[0053] Figure 3 This is a schematic diagram of the structure of an educational ethics shift prediction system for a large language model, provided as an exemplary embodiment of the present invention. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0055] In one embodiment, such as Figure 1 As shown, a method for predicting educational ethics shifts in large language models is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and to a system including both a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0056] S101: Based on the pre-set authoritative educational ethics guidelines, construct a structured knowledge graph with traceable digital fingerprints; fine-tune the basic large language model based on the structured knowledge graph to obtain an ethics knowledge enhancement model; train a sparse autoencoder based on the traceable digital fingerprints in the structured knowledge graph to obtain a traceability vector extractor for extracting the knowledge call state inside the ethics knowledge enhancement model.

[0057] Specifically, when constructing a structured knowledge graph with traceable digital fingerprints based on pre-defined authoritative educational ethics guidelines, these guidelines, such as fairness, privacy protection, and academic integrity, can be deconstructed into a set of entity-relationship-attribute triplets. Each ethical rule node embeds a uniquely identified digital fingerprint, which can be constructed using cryptographic hash functions or high-dimensional sparse embedding vectors to ensure the traceability and version control of ethical knowledge. Subsequently, efficient parameter fine-tuning methods such as LoRA can be used to inject ethical constraints from the structured knowledge graph into a basic large language model, enabling the model's parameter space to form a deep semantic understanding of the ethical guidelines, resulting in an ethical knowledge enhancement model. Furthermore, graph neural networks or knowledge graph embedding techniques can be used to map traceable digital fingerprints into low-dimensional dense vectors, which can then be used as supervisory signals to train sparse autoencoders. These autoencoders, through an encoder-decoder structure, can compress and reconstruct the hidden layer activation states of the ethical knowledge enhancement model. By introducing L1 regularization or KL divergence sparsity constraints into the loss function, the encoder is forced to learn sparse traceability vectors that can represent specific ethical knowledge call patterns. This allows the construction of a mapping relationship from internal neural activations to external ethical knowledge sources, enabling interpretable tracking of the model's decision-making process.

[0058] S102: Based on the ethical knowledge enhancement model, generate multiple value agents, which constitute an adversarial testing environment. In the adversarial testing environment, conduct multiple rounds of adversarial questioning on the ethical knowledge enhancement model. In each round of questioning, obtain the external dialogue text generated by the ethical knowledge enhancement model, and obtain the corresponding internal knowledge source vector through the source vector extractor. Based on the internal knowledge source vectors and external dialogue texts output in each round, perform a quantitative assessment of the compliance of knowledge invocation of the ethical knowledge enhancement model, and generate an ethical behavior risk matrix and a high-risk boundary use case library.

[0059] Specifically, a multi-dimensional ethical stress testing environment can be constructed to test and uncover the potential vulnerabilities of the ethical knowledge enhancement model. For example, based on the ethical knowledge enhancement model, multiple value agents with specific value orientations can be generated through cue word engineering or role-playing mechanisms. Each agent represents a different cultural background, educational philosophy, or ethical stance. These agents form an adversarial testing environment through multi-turn dialogue protocols, which can form a red team testing architecture. In this environment, the value agents can initiate multiple rounds of adversarial questioning against the ethical knowledge enhancement model. Questioning strategies include, but are not limited to, inducing ethical dilemmas, probing boundary conditions, and constructing multilingual cultural conflict scenarios. In each round of interaction, the external dialogue text generated by the ethical knowledge enhancement model and its internal activation state matrix, such as the Transformer layer, are collected synchronously. The source vector extractor trained in step S101 can be used to encode the hidden layer states and extract the source vector representing the current knowledge call path. Subsequently, a dual-channel evaluation mechanism can be established, namely, semantic compliance analysis of external dialogue text and knowledge source consistency verification of internal source vectors. By calculating the semantic deviation between external output and ethical guidelines and the topological distance between internal activation and compliance knowledge graph, an ethical behavior risk matrix containing dimensions of risk type, severity, and frequency of occurrence can be constructed, and a high-risk boundary use case library can be generated by clustering. This use case library includes the model's failure modes and cognitive blind spots in extreme ethical scenarios.

[0060] S103: Based on the high-risk boundary use case library, an ethical personality basis vector set is obtained through comparative learning; based on the ethical behavior risk matrix, a corresponding dynamic early warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set; based on the ethical personality basis vector set and the dynamic early warning threshold, the internal activation state of the ethical knowledge enhancement model when processing user queries is monitored in real time by projection; when the monitoring result indicates that an offset risk is detected, an ethical offset early warning is triggered, and an analysis report is generated.

[0061] Specifically, based on positive and negative sample pairs (compliance and violation cases) in a high-risk boundary use case library, a contrastive learning framework (such as SimCSE or Triplet Loss) can be used to perform metric learning in the activation space of the ethical knowledge enhancement model. By bringing the internal state representations of similar ethical behaviors closer together and pushing away the representations of dissimilar behaviors, a set of ethical personality basis vectors representing specific ethical deviation patterns can be extracted. Each basis vector corresponds to an ethical risk direction in the high-dimensional activation space. Illustratively, based on the statistical distribution characteristics of various risks in the ethical behavior risk matrix, such as risk occurrence probability density and confidence intervals, an adaptive dynamic warning threshold can be set for each ethical personality basis vector. This threshold can be adjusted online according to the risk preferences of the model deployment environment. Therefore, during the real-time operation phase, the layer-by-layer activation state of the ethical knowledge enhancement model when processing user queries can be captured through hook mechanisms or forward propagation interception technology. This state is then projected onto the monitoring subspace composed of ethical personality basis vectors. The cosine similarity or Mahalanobis distance between the current activation state and each basis vector is calculated. When the projected component exceeds the corresponding dynamic warning threshold, it can be determined that an ethical deviation risk has been detected, triggering the warning mechanism and generating a structured analysis report that includes deviation type location, risk tracing path, confidence assessment, and mitigation suggestions. This enables proactive interception and root cause diagnosis of ethical risks.

[0062] The aforementioned method first enhances the basic model with ethical knowledge and trains a sparse autoencoder using a structured knowledge graph with traceable digital fingerprints. This achieves the structured embedding of authoritative educational ethical guidelines and the traceable extraction of internal knowledge call states, overcoming the shortcomings of traditional static rule bases in adapting to dynamic updates in educational ethics. Second, an adversarial testing environment is constructed based on multi-value agents. Multiple rounds of adversarial queries are used to obtain internal and external states for collaborative evaluation, improving the comprehensiveness and accuracy of ethical risk boundary identification. Finally, ethical personality basis vectors are extracted through comparative learning, and dynamic warning thresholds are set. Real-time projection monitoring of the model's internal activation states effectively solves the false positive and false negative problems caused by traditional methods relying solely on surface features of generated text, enhancing the accurate warning and root cause tracing capabilities for ethical deviation risks.

[0063] In one embodiment, a structured knowledge graph with traceable digital fingerprints is constructed based on preset authoritative educational ethics guidelines; a basic large language model is fine-tuned based on the structured knowledge graph to obtain an ethics knowledge enhancement model; a sparse autoencoder is trained based on the traceable digital fingerprints in the structured knowledge graph to obtain a traceability vector extractor for extracting the knowledge call states within the ethics knowledge enhancement model, including:

[0064] Information is extracted from unstructured text in the pre-defined authoritative educational ethics guidelines, and a knowledge graph with triples as the basic unit is constructed. A unique traceable digital fingerprint is generated for each triple in the knowledge graph, resulting in a structured knowledge graph. The traceable digital fingerprint consists of the content hash value and metadata encoding value of the triple. The metadata encoding value includes the knowledge source, authority level, and effective time.

[0065] By integrating structured knowledge graphs with general educational corpora, training sample pairs are constructed, including text fragments, associated knowledge triples, and corresponding traceable digital fingerprints. The basic large language model is trained through an adaptive attention masking mechanism to obtain an ethical knowledge enhancement model. The adaptive attention masking mechanism is used to dynamically adjust the connection weights of the attention layer in the basic large language model based on the matching results of keywords and associated knowledge triples in the training sample pairs.

[0066] The training sample pairs are input into the ethics knowledge enhancement model. The activation states of the intermediate layers of the ethics knowledge enhancement model are collected when processing the training sample pairs. A training dataset is constructed based on the intermediate layer activation states and the traceable digital fingerprints corresponding to the training sample pairs. The sparse autoencoder is trained under supervision to obtain the traceability vector extractor. The training objective of the sparse autoencoder is to map the traceability vectors output by the bottleneck layer in the sparse autoencoder to the corresponding traceable digital fingerprints.

[0067] Specifically,

[0068] A hybrid extraction scheme combining rules and pre-trained language models can be adopted. This involves analyzing the text structure of authoritative educational ethics guidelines to formulate ethical entity identification rules, such as part-of-speech tags and syntactic patterns for entity types like educational subjects, ethical behaviors, and constrained objects. Pre-trained language models, such as BERT, are then used for word segmentation and semantic encoding to identify the core entities within the ethical guidelines. Subsequently, dependency parsing techniques are used to mine the semantic relationships between entities, deconstructing each ethical rule into a "subject-relation-object" triple, ensuring that the triple accurately represents the core logic of the ethical guideline. To achieve unique identification and full lifecycle traceability for each piece of ethical knowledge, a unique and traceable digital fingerprint can be generated for each triple. This digital fingerprint consists of a content hash value and a metadata encoding value. Content hash values ​​are generated by cryptographic hash functions that operate on the text content and contextual semantic encoding of triples. This ensures that triples with the same ethical knowledge correspond to unique hash values, and that hash values ​​from different triples do not collide. Metadata encoding values ​​are structured information such as the knowledge source (e.g., policy document name, clause number), authority level (e.g., national level, industry level), and effective date. This information is transformed into a fixed-dimensional vector through a combination of one-hot encoding and embedding, and then compressed into a one-dimensional encoded value through linear mapping. The content hash value and metadata encoding value are concatenated and converted into a string using Base64 encoding. This results in a globally unique, traceable digital fingerprint. Triples bearing this fingerprint can collectively form a structured knowledge graph, enabling structured storage and traceable identification of ethical knowledge.

[0069] Furthermore, the general educational corpus can select text data from typical educational scenarios such as classroom teaching, homework guidance, college entrance examination consultation, and historical and cultural explanations. Through text segmentation and semantic clustering, text fragments associated with ethical triples in the structured knowledge graph can be selected, such as paragraphs containing keywords like educational evaluation and privacy protection. Each training sample pair can contain three parts: a text fragment, an associated knowledge triple, and a traceable digital fingerprint. The associated knowledge triple is determined by calculating the semantic similarity between the text fragment and the triple. Specifically, the cosine similarity algorithm can be used to calculate the similarity between the text fragment encoding vector and the triple vector. Triples with similarity higher than a set threshold are selected as associated objects to ensure the semantic relevance of the training sample pairs. Subsequently, when training the basic large language model through an adaptive attention mask mechanism, the core is to dynamically adjust the attention weights based on the matching results of keywords in the training sample pairs with the associated knowledge triples. For example, firstly, keywords are extracted from the text fragments, and the TF-IDF algorithm is used to calculate the importance score of words in the text. Combined with semantic similarity, keywords that match the core entities of the associated knowledge triples are selected. Furthermore, an attention mask generator can be constructed. This generator receives the matching results between keywords and related knowledge triples and outputs an adaptive attention mask matrix, where the result is represented by a matching score ranging from 0 to 1. Subsequently, during the attention weight adjustment process, for tokens in the text segment corresponding to words with high matching degrees to related knowledge triples, their weight in the self-attention calculation can be increased through the mask matrix; for irrelevant tokens, their weight is decreased. For example, the weight update formula can be:

[0070]

[0071] in, For the adjusted attention weights, Based on attention weights, This is the weighting adjustment coefficient (used to control the adjustment range). The matching score is given to the i-th token and the associated knowledge triple. Through this dynamic adjustment mechanism, the basic large language model can automatically focus on the associated ethical knowledge triple when processing ethically related texts, deeply integrating ethical constraints into the model's attention allocation process, and ultimately obtaining an ethical knowledge enhancement model that is sensitive to ethical knowledge.

[0072] Specifically, after enhancing the model with training samples and input ethical knowledge, considering that deep networks in the Transformer architecture are better able to represent core semantic information, the outputs of the last two Transformer blocks can be selected as intermediate layer activation states. These activation states are high-dimensional vectors with fixed dimensions, reflecting the model's processing of ethical knowledge. When constructing the training dataset based on the intermediate layer activation states and the traceable digital fingerprints corresponding to the training sample pairs, each data sample can be composed of an intermediate layer activation state vector and a traceable digital fingerprint vector. The traceable digital fingerprint vector is a fixed-dimensional vector converted from a string-form digital fingerprint after embedding encoding. Subsequently, a sparse autoencoder can be constructed, which consists of an encoder, a bottleneck layer, and a decoder. The encoder consists of three fully connected layers, which compress the high-dimensional intermediate layer activation state vector to a low-dimensional bottleneck layer using the ReLU activation function. The bottleneck layer dimension is set to the dimension of the traceable digital fingerprint vector to ensure accurate representation of traceability information. The decoder consists of three fully connected layers, which reconstruct the bottleneck layer output into a vector with the same dimension as the input using the Sigmoid activation function. Indicatively, the sparse autoencoder is trained using a supervised learning model. The core training objective is to ensure that the traceability vector output by the bottleneck layer accurately maps to the corresponding traceable digital fingerprint vector. During training, a joint loss function is employed, including reconstruction loss and sparsity loss. The reconstruction loss minimizes the difference between the decoder output and the activation state vector of the intermediate input layer, ensuring the model captures the core features of the activation state. The sparsity loss is implemented through L1 regularization to constrain the sparsity of the bottleneck layer output vector, ensuring that the traceability vector retains only key information related to the digital fingerprint. For example, the joint loss function expression can be:

[0073]

[0074] in, The reconstruction loss (calculated using mean squared error) is... For sparsity loss (calculated using the L1 norm), These are sparse coefficients (used to balance the weights of the two losses). The loss function is iteratively optimized using the gradient descent algorithm until the model converges. At this point, the source vector output by the bottleneck layer can establish an accurate mapping relationship with the traceable digital fingerprint. The trained sparse autoencoder is the source vector extractor, which has the ability to extract ethical knowledge call trajectories from the activation states of the intermediate layers of the model.

[0075] In one embodiment, based on an ethical knowledge enhancement model, multiple value agents are generated, forming an adversarial testing environment. In this environment, the ethical knowledge enhancement model undergoes multiple rounds of adversarial questioning. In each round, the external dialogue text generated by the model is obtained, and the corresponding internal knowledge source vector is acquired using a source vector extractor. Based on the internal knowledge source vectors and external dialogue text output in each round, the compliance assessment of knowledge invocation by the ethical knowledge enhancement model is performed, generating an ethical behavior risk matrix and a high-risk boundary use case library, including:

[0076] Multiple value prototypes covering the spectrum of educational ethics are constructed. Initial corpora are generated based on the value prototypes using an independent language model. The initial corpora are then filtered using an ethics knowledge enhancement model to generate multiple value agents. The filtering process includes verifying the representativeness and non-extreme nature of the values ​​in the initial corpora using the ethics knowledge enhancement model.

[0077] A multi-turn dialogue simulation platform is constructed, forming an adversarial testing environment composed of multiple value-based intelligent agents. An ethical knowledge enhancement model is set as the system under test, and multiple value-based intelligent agents are set as interaction objects. The multi-turn dialogue simulation platform drives these agents to initiate multiple rounds of adversarial queries against the ethical knowledge enhancement model, obtaining a comprehensive risk score for each round. The comprehensive risk score is obtained through the following steps:

[0078] For each round of interaction, the natural language response generated by the ethical knowledge enhancement model is recorded to obtain the external dialogue text. The source vector extractor is then called to process the intermediate layer activation state of the ethical knowledge enhancement model in the current round of interaction to obtain the internal knowledge source vector.

[0079] Logical consistency and stance stability analyses were performed on the external dialogue texts to obtain and calculate the behavioral consistency score based on the first and second results. The internal knowledge tracing vector was decoded, and the knowledge call compliance score was obtained by combining the decoding results with the knowledge call matching degree and activation intensity. The behavioral consistency score and the knowledge call compliance score were weighted and fused to obtain the comprehensive risk score for the current round of interaction.

[0080] The comprehensive risk scores of each round are summarized and statistically analyzed according to the preset ethical dimensions and preset interaction scenario types to generate an ethical behavior risk matrix. Abnormal interaction rounds with knowledge call compliance scores lower than the preset call compliance threshold are selected, and the external dialogue text, internal knowledge tracing vector and comprehensive risk score corresponding to the abnormal interaction rounds are stored to generate a high-risk boundary use case library.

[0081] Specifically, when constructing multiple value prototypes covering the spectrum of educational ethics, we can first define prototypes with different value orientations, such as egalitarianism, elitism, cultural conservatism, and progressivism, based on the ethical needs of educational scenarios. Each prototype should clearly define its core ethical principles (e.g., the core of the egalitarian prototype is that educational resources should be allocated equally to all students) and typical argumentative logic. Then, the core principles of the value prototypes can be used as system prompts input into an independent language model, guiding it to generate dialogues, interrogative statements, and ethical scenario descriptions that conform to the prototype, forming an initial corpus. Further, based on an ethical knowledge enhancement model, the initial corpus can be filtered to verify its value representativeness and non-extreme nature. For example, for value representativeness verification, a cosine similarity algorithm can be used to calculate the semantic similarity between the initial corpus and the core principles of the corresponding value prototypes, retaining corpora with similarity higher than a set threshold. For non-extreme nature verification, an ethical knowledge enhancement model can be used to pre-assess the ethical risks of the initial corpus, eliminating content containing discriminatory expressions, extreme viewpoints, or content that violates basic educational ethics. Ultimately, the filtered corpus can be bound to the corresponding behavioral strategies to generate multiple value-based intelligent agents, each with a stable value orientation and interaction logic.

[0082] Specifically, when constructing a multi-turn dialogue simulation platform, the platform can include a conversation management module, an agent scheduling module, and a data acquisition module. The conversation management module is responsible for maintaining the context information of each round of interaction to ensure the coherence of the dialogue. The agent scheduling module can randomly or according to scenario type select value-based agents to interact with the system under test based on preset adversarial strategies. The data acquisition module can simultaneously capture the text and internal state of the model during the interaction process. After multiple value-based agents and the platform jointly constitute an adversarial testing environment, an ethics knowledge enhancement model can be set as the system under test. The platform drives value-based agents to initiate multiple rounds of adversarial questioning. Questioning strategies can include ethical dilemma induction (e.g., "If a high-achieving student and a student from a disadvantaged family are competing for the only scholarship, which should be prioritized?"), boundary condition exploration (e.g., "Is it permissible to provide students with unverified historical anecdotes as teaching content?"), and the construction of multilingual and cultural conflict scenarios (e.g., "How to explain the controversial nature of a historical event to students from different cultural backgrounds"), ensuring that the test scenarios cover the core risk points of educational ethics. In a schematic representation, for each round of interaction, the natural language response generated by the ethics knowledge enhancement model can be recorded to obtain the external dialogue text. The source vector extractor can then be invoked to process the intermediate layer activation states of the model. Specifically, the output of the penultimate layer of the Transformer architecture in the ethics knowledge enhancement model can be selected as the intermediate layer activation state (this layer reflects the model's final processing result of ethical knowledge). This activation state is then input into the source vector extractor, and the encoder compresses the activation state to obtain the internal knowledge source vector representing the current knowledge call path, thus establishing a correlation between the external dialogue text and the internal knowledge call trajectory.

[0083] Furthermore, when analyzing the logical consistency and stance stability of external dialogue text, the logical consistency score, the first result, can be calculated using a natural language inference model. For example, the external dialogue text can be split into multiple sentence pairs, input into a pre-trained natural language inference model such as RoBERTa-MNLI, identify the implication, contradiction, or neutral relationship between sentence pairs, and statistically analyze the proportion of contradictory relationships, mapping it to a logical consistency score within the range [0,1]. The lower the score, the more significant the logical contradiction in the text. The stance stability score, the second result, can be calculated through a comparison of stances in multiple rounds of dialogue. For example, extract responses to the same ethical issue from the current round of interaction and the previous I rounds of interaction, encode each response as a stance vector, calculate the mean cosine distance between the current round's stance vector and the previous I round's stance vector, and map it to a stance stability score within the range [0,1]. The lower the score, the more significant the stance fluctuation. Finally, the logical consistency score and the stance stability score are weighted and fused to obtain the behavioral consistency score, where the fusion weights can be optimized using cross-validation.

[0084] Specifically, when decoding the internal knowledge tracing vector, the traceable digital fingerprint corresponding to the tracing vector can be parsed first. This fingerprint is then matched with the standard triplet fingerprint of the corresponding ethical dimension in the structured knowledge graph to obtain the knowledge call matching degree. The L2 norm of the activation state of the intermediate layer of the ethical knowledge enhancement model can be calculated and normalized to an activation intensity within the range [0,1]. Subsequently, the knowledge call matching degree and the square root of the activation intensity can be multiplied, and then divided by the maximum value of this product across all rounds to obtain the knowledge call compliance score within the range [0,1]. By weighted fusion of the behavioral consistency score and the knowledge call compliance score, the comprehensive risk score for the current round of interaction can be calculated using the following formula:

[0085]

[0086] in, For the first The comprehensive risk score for the round interaction ranges from [0,10], with a higher score indicating a higher risk of ethical deviation. The total number of pre-defined educational ethics dimensions, and Such as fairness, integrity, security, and suitability; For the first In the first round of interaction The dynamic weights of each ethical dimension satisfy... From the formula calculate, For temperature coefficient, For the first In the first round of interaction The scene sensitivity of each ethical dimension is obtained based on the preset interaction scene type; The weighting coefficient for the behavioral consistency score; For the first In the first round of interaction The behavioral consistency score for each ethical dimension, ranging from [0,1], is derived from the logical consistency score. and position stability score Weighted average; For the first In the first round of interaction The knowledge retrieval compliance score, representing one ethical dimension, ranges from [0,1] and is determined by the knowledge matching degree. and activation intensity Normalization yields, i.e. , This represents the matching degree between the internal knowledge tracing vector and the triples in the structured knowledge graph. To enhance the normalization strength of the activation states in the intermediate layers of the ethical knowledge model; This is a risk accumulation penalty coefficient, used to amplify the risk score of consecutive high-risk interactions; For the first Wheel and front Risk change rate of the wheel , To avoid the minimum value where the denominator is 0, The initial risk score is unweighted, and , for The average score of behavioral consistency across ethical dimensions for The average score of knowledge access compliance across all ethical dimensions.

[0087] After summarizing the comprehensive risk scores for each round, statistics can be compiled according to preset ethical dimensions and interaction scenario types. For example, ethical dimensions can be used as rows and interaction scenario types as columns, and the average comprehensive risk scores for the corresponding rounds can be filled into a matrix to generate an ethical behavior risk matrix. This matrix presents the model's risk level under different dimensions and scenarios in numerical or heatmap form. Furthermore, a preset compliance threshold (e.g., 0.5) can be set to filter out abnormal interaction rounds with knowledge call compliance scores below this threshold. The external dialogue text, internal knowledge tracing vector, comprehensive risk score, and corresponding ethical dimensions and scenario types for these rounds are then structured and stored to generate a high-risk boundary use case library. This use case library can be directly used for the training and optimization of subsequent early warning models.

[0088] In one embodiment, an ethical personality basis vector set is obtained through comparative learning based on a high-risk boundary use case library; a corresponding dynamic early warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set based on an ethical behavior risk matrix; based on the ethical personality basis vector set and the dynamic early warning threshold, the internal activation state of the ethical knowledge enhancement model when processing user queries is monitored in real time by projection; when the monitoring result indicates that an offset risk has been detected, an ethical offset early warning is triggered, and an analysis report is generated, including:

[0089] The internal activation states and corresponding dialogue contexts of the ethical knowledge enhancement model when generating high-risk responses are extracted from the high-risk boundary use case library to obtain abnormal state samples and target dialogue contexts. Based on the target dialogue context, the ethical knowledge enhancement model is guided to generate responses that conform to ethical norms, and the internal activation states in the generation process are extracted to obtain normal state samples. Based on the abnormal state samples and normal state samples, multiple vector directions are solved in the activation space of the ethical knowledge enhancement model through a contrastive learning algorithm to obtain a set of ethical personality basis vectors.

[0090] Locate each low-risk test case from the ethical behavior risk matrix, extract the projection value of the low-risk test case onto each ethical personality basis vector in the ethical personality basis vector set, and calculate and set the corresponding dynamic early warning threshold for each ethical personality basis vector based on the statistical distribution of the projection value.

[0091] An ethical knowledge enhancement model is deployed, and the internal activation state sequence of the deployed ethical knowledge enhancement model when processing user queries is obtained in real time through the monitoring module. The activation state sequence is projected onto the set of ethical personality basis vectors to obtain multiple sets of ethical trait projection curves. The ethical trait projection curves are compared and analyzed with the corresponding dynamic warning thresholds. When the comparison result meets the deviation risk judgment condition, the monitoring result is obtained. If the monitoring result indicates that deviation risk has been detected, an ethical deviation warning is triggered.

[0092] Record the user queries, internal activation state sequences, and ethical trait projection curves that trigger ethical deviation warnings to obtain warning-related data; call the source vector extractor to perform internal state analysis on the internal activation state sequences in the warning-related data to generate an analysis report; the analysis report includes knowledge call anomalies, corresponding entries in the structured knowledge graph, and risk level assessment results.

[0093] Specifically, we can first locate the interaction data corresponding to each high-risk case in the high-risk boundary use case library, and extract the internal activation state when the ethics knowledge enhancement model generates a high-risk response for that case. For example, we can select the output of the penultimate layer of the Transformer architecture as the internal activation state, where this layer can represent the final processing result of the model on ethical knowledge, and its dimension is consistent with the dimension of the model's hidden layers. Therefore, it can be used as an abnormal state sample, and the dialogue context of the case can be extracted to obtain the target dialogue context. Then, the target dialogue context can be completely input into the ethics knowledge enhancement model, and ethical guidance prompts such as "Please generate a response to this question based on the ethical principles of fair education" can be added to trigger the model to generate a normative response that conforms to the corresponding ethical dimension. At the same time, the internal activation state at the same level during the response generation process can be collected and used as a normal state sample. Through this process, we can ensure that the dialogue context of the abnormal and normal state samples is consistent, only the ethical response tendencies are different, providing effective positive and negative sample pairs for comparative learning.

[0094] Specifically, when performing comparative learning based on abnormal and normal state samples, the Triplet Loss framework can be used to construct a comparative learning model. For example, firstly, abnormal state samples are used as anchor samples, other abnormal state samples under the same ethical dimension are selected as positive samples, and the corresponding normal state samples are used as negative samples, constructing a triplet sample set of "anchor-positive sample-negative sample". Subsequently, the activation states in the sample set are mapped to a low-dimensional feature space through a linear layer to obtain the anchor embedding. Positive sample embedding Negative sample embedding The loss function for contrastive learning is:

[0095]

[0096] in, It is the L2 norm. The interval parameter (used to control the discrimination between positive and negative samples) is used. Gradient descent is used to optimize this loss function, bringing the anchor point closer to positive samples and further away from negative samples in the feature space. Ultimately, a feature space direction vector is learned that can distinguish between "abnormal" and "normal" states under this ethical dimension. This direction vector is defined as the ethical personality basis vector for the corresponding ethical dimension. The above process is repeated for all preset educational ethical dimensions. All the resulting direction vectors together constitute the set of ethical personality basis vectors. This set spans a low-dimensional ethical trait subspace, which can accurately represent the model's state shift tendency in each ethical dimension.

[0097] Based on the ethical behavior risk matrix, all test cases with risk scores below a preset low-risk threshold can be filtered out. The internal activation states of these test cases are extracted and projected onto each basis vector in the ethical personality basis vector set. This involves performing a dot product operation between the activation state vector and the basis vector, thus obtaining the projection value of each low-risk test case on the corresponding ethical dimension. Subsequently, when setting a dynamic warning threshold based on the statistical distribution of the projection values, the statistical characteristics (including mean, standard deviation, and quantiles) of the projection values ​​of all low-risk test cases under that ethical dimension can be calculated. The high percentile of the projection value (such as the 99th percentile) is selected as the dynamic warning threshold corresponding to that ethical personality basis vector, ensuring that the projection value of most compliant scenarios will not exceed this threshold, thereby accurately capturing abnormal deviations that exceed the normal range.

[0098] As an illustration, when deploying an ethics knowledge enhancement model, it can be deployed to an online service environment, with a lightweight monitoring module embedded within. This module can contain three core units: an activation state capture unit that uses model forward propagation hooks to continuously collect internal activation state vectors at each step, starting from the generation of the first response term, forming an internal activation state sequence; a projection calculation unit that performs a dot product operation between each activation state vector in this sequence and each basis vector in the ethical personality basis vector set, obtaining the instantaneous projection value of each ethical dimension at the corresponding generation step; and a curve generation unit that, based on the instantaneous projection values ​​of each generation step, plots the ethical trait projection curve corresponding to each ethical dimension, reflecting the dynamic changes in the ethical state of the model throughout the entire response generation process.

[0099] Subsequently, the ethical trait projection curves and dynamic warning thresholds can be compared and analyzed. First, the moving average of each curve can be calculated to smooth out instantaneous fluctuations and avoid false alarms. This average is then compared in real-time with the corresponding dynamic warning threshold for the ethical dimension. If the moving average of any ethical dimension exceeds the corresponding dynamic warning threshold, the comparison result is considered to meet the deviation risk judgment condition. The monitoring result is "deviation risk detected," triggering an ethical deviation warning. This warning signal can include core information such as the ethical dimension that triggered the risk and the difference between the current projection value and the threshold, and is simultaneously pushed to the system management terminal. During the above process, the user queries that triggered the warning, the complete internal activation state sequence, and the ethical trait projection curves can be structured and stored to obtain warning-related data. Furthermore, a source vector extractor can be invoked, inputting the internal activation state sequence from the warning-related data into the source vector extractor. This decoder obtains the traceable digital fingerprint corresponding to each activation state, and by matching entries in the structured knowledge graph, it can locate knowledge call anomalies such as calling the wrong ethical triplet or failing to call the corresponding ethical knowledge. Based on the degree to which the projection value exceeds the threshold, the risk level assessment result (such as mild deviation, moderate deviation, or severe deviation) can also be determined. Finally, an analysis report containing knowledge call anomalies, corresponding knowledge graph entries, and risk levels is generated, providing an actionable basis for model optimization and risk intervention.

[0100] In one embodiment, such as Figure 2 As shown, the internal activation states and corresponding dialogue contexts of the ethics knowledge enhancement model when generating high-risk responses are extracted from the high-risk boundary use case library, resulting in abnormal state samples and target dialogue contexts. Based on the target dialogue context, the ethics knowledge enhancement model is guided to generate responses that conform to ethical norms, and the internal activation states during the generation process are extracted to obtain normal state samples. Based on the abnormal state samples and normal state samples, multiple vector directions are solved in the activation space of the ethics knowledge enhancement model using a contrastive learning algorithm to obtain a set of ethical personality basis vectors, including:

[0101] S201. Select target cases associated with the preset ethical dimension from the high-risk boundary use case library, extract and use the intermediate layer activation state matrix and corresponding dialogue context generated by the ethical knowledge enhancement model in the target cases when generating high-risk responses, and use them as abnormal state samples and target dialogue contexts respectively.

[0102] Specifically, target cases related to preset ethical dimensions such as educational equity can be selected from the high-risk boundary use case library. The intermediate layer activation state matrix of the ethical knowledge enhancement model when generating a high-risk response for the case can be extracted. That is, the penultimate layer output of the Transformer architecture can be selected as the intermediate layer. The activation state of this layer is a two-dimensional matrix with the same dimension as the hidden layer dimension and sequence length of the model. At the same time, the dialogue context corresponding to the case can be extracted, that is, the user query and the high-risk response content of the model in the current round of interaction, which can be used as the target dialogue context to obtain the abnormal state sample and the target dialogue context respectively.

[0103] S202. Input the target dialogue context into the ethics knowledge enhancement model, guide the ethics knowledge enhancement model to generate a response that conforms to the preset ethics dimensions, and extract and use the intermediate layer activation state matrix in the response generation process as a normal state sample.

[0104] By inputting the target dialogue context into the ethics knowledge enhancement model, ethical guidance prompts can be added, such as "Please generate a response that conforms to educational ethics norms for the following context based on the [preset ethical dimension] criteria: [target dialogue context]". After triggering the model to generate a response, the activation state matrix of the same intermediate layer during the response generation process can be collected simultaneously and used as a normal state sample to ensure that the network layers and dimensions of the normal state samples are completely consistent with those of the abnormal state samples.

[0105] S203. Extract features from abnormal state samples and normal state samples to obtain abnormal feature vectors and normal feature vectors respectively.

[0106] Specifically, a 1×1 convolutional layer can be used to reduce the dimensionality of the two-dimensional activation state matrix, compressing the matrix into a one-dimensional vector. Then, a fully connected layer is used to perform a linear transformation on the vector, thereby obtaining a fixed-dimensional abnormal feature vector and a normal feature vector. The vector dimension is set according to the preset total number of ethical dimensions to ensure that features of different dimensions do not interfere with each other.

[0107] S204. Construct a contrastive learning loss function. The contrastive learning loss function aims to make the abnormal feature vectors approach the negative prototype vector to be solved, and to make the normal feature vectors move away from the negative prototype vector.

[0108] Schematic, the expression for the contrastive learning loss function above can be:

[0109]

[0110] in, For abnormal feature vectors, These are normal feature vectors. Let be the negative prototype vector to be solved. This is the function for calculating cosine similarity.

[0111] S205. Optimize the contrastive learning loss function through gradient descent algorithm, and solve for the direction of the negative prototype vector in the activation space of the ethical knowledge enhancement model. Define the direction as the ethical personality basis vector corresponding to the preset ethical dimension.

[0112] Specifically, the Adam optimizer can be selected, with an initial learning rate set to a preset value. The number of iterations can be adjusted based on the sample size. Updates are performed based on a contrastive learning loss function, meaning that in each iteration, the gradient of the loss function with respect to the negative prototype vector v can be calculated, and the parameters of v are updated until the loss function converges. Finally, the direction of the converged v in the activation space of the ethical knowledge enhancement model can be defined as the ethical personality basis vector corresponding to the current preset ethical dimension.

[0113] S206. For each preset ethical dimension, repeat steps S201 to S205 to obtain the ethical personality basis vectors corresponding to each preset ethical dimension, and summarize the ethical personality basis vectors to form an ethical personality basis vector set.

[0114] Specifically, for other pre-defined ethical dimensions such as academic integrity and cultural inclusiveness, the corresponding ethical personality basis vectors can be obtained by repeatedly executing steps S201 to S205. Arranging these basis vectors in order of ethical dimensions forms an ethical personality basis vector set, which is stored as a two-dimensional matrix, with each row corresponding to a basis vector for one ethical dimension.

[0115] In one embodiment, an ethical knowledge enhancement model is deployed. A monitoring module acquires the internal activation state sequence of the deployed model when processing user queries in real time. This activation state sequence is projected onto a set of ethical personality basis vectors to obtain multiple sets of ethical trait projection curves. The ethical trait projection curves are compared and analyzed with corresponding dynamic warning thresholds. When the comparison result meets the deviation risk judgment condition, a monitoring result is obtained. If the monitoring result indicates a deviation risk has been detected, an ethical deviation warning is triggered, including:

[0116] The ethical knowledge enhancement model is deployed to the online service environment, and a monitoring module is deployed in the online service environment. The monitoring module establishes a data interaction channel with the selected network layer of the ethical knowledge enhancement model.

[0117] When the ethics knowledge enhancement model receives a user query and starts generating a response, the monitoring module continuously collects the activation state vector of the selected network layer from the generation of the first response word to form an internal activation state sequence.

[0118] Calculate the dot product between each activation state vector in the internal activation state sequence and each ethical personality basis vector in the set of ethical personality basis vectors to obtain the instantaneous projection value of each ethical dimension at the corresponding generation step;

[0119] After the ethical knowledge enhancement model completes the generation of a full response, it generates an ethical trait projection curve corresponding to each ethical dimension based on the instantaneous projection values ​​of each ethical dimension.

[0120] Calculate the moving average and peak value of the projection curve of each ethical trait. Combine the dynamic warning threshold, which includes a first threshold corresponding to the moving average and a second threshold corresponding to the peak value, and compare the moving average value of each ethical dimension with the first threshold and the peak value of each ethical dimension with the second threshold to obtain the comparison results.

[0121] If the moving average of any ethical dimension is greater than the corresponding first threshold, or the peak value of any ethical dimension is greater than the corresponding second threshold, the comparison result is determined to meet the offset risk determination condition, the monitoring result is determined to be an offset risk detected, and an ethical offset warning is triggered.

[0122] Specifically, the online service environment can be deployed in a containerized manner on a Kubernetes cluster. By deploying the ethics knowledge enhancement model to this online service environment, high service availability can be ensured. A monitoring module, written in Python, can then be deployed within the online service environment. This module establishes a data interaction channel with the selected network layer of the model (i.e., the intermediate layer used to generate ethical personality basis vectors) through the PyTorchHook interface of the ethics knowledge enhancement model. When the ethics knowledge enhancement model receives a user query and begins generating a response, the monitoring module continuously collects the activation state vector of the selected network layer at a token-level granularity, starting from the generation of the first response token. That is, after each token is generated, the model triggers a Hook callback function, and the monitoring module reads the output vector of that layer, stores it in a cache queue, and ultimately forms an internal activation state sequence consistent with the length of the response.

[0123] Subsequently, L2 normalization can be performed on the activation state vector and basis vectors to eliminate the influence of differences in vector magnitude. By calculating the dot product of the normalized vectors, the instantaneous projection value of each ethical dimension at the corresponding generation step can be obtained. The larger the value, the stronger the model's bias in that dimension. Furthermore, after the ethical knowledge enhancement model completes the generation of a full response, curves can be plotted according to the generation step order based on the instantaneous projection values ​​of each ethical dimension to obtain the ethical trait projection curve corresponding to each ethical dimension. The horizontal axis of the curve represents the generation step number, and the vertical axis represents the instantaneous projection value.

[0124] Based on the projection curve of each ethical trait, a moving average method with a window size of 5 generation steps can be used to calculate the moving average, while the peak value is the maximum value of all instantaneous projection values ​​in the curve. The dynamic warning thresholds include a first threshold corresponding to the moving average and a second threshold corresponding to the peak value. Both can be determined by the statistical distribution of low-risk samples in the ethical behavior risk matrix. The first threshold can be the 99th quantile of the moving average of low-risk samples, and the second threshold can be the 95th quantile of the peak value of low-risk samples. Comparing the moving average corresponding to each ethical dimension with the first threshold and the peak value with the second threshold yields two sets of comparison results. Based on these results, if the moving average of any ethical dimension is greater than the corresponding first threshold, or the peak value of any ethical dimension is greater than the corresponding second threshold, the comparison result can be determined to meet the deviation risk judgment condition. An excessive moving average indicates that the model has a persistent ethical deviation tendency during the response process, while an excessive peak value indicates that the model has a serious ethical deviation at a certain step. Therefore, at this point, the monitoring result can be determined as a detected deviation risk, triggering an ethical deviation warning. A warning signal including the deviation dimension, the deviation value, and the difference between the threshold can be generated and simultaneously pushed to the system management terminal.

[0125] Based on the same inventive concept, this application also provides a system for predicting educational ethics deviations in a large language model, which implements the aforementioned method for predicting educational ethics deviations in a large language model. The solution provided by this system is similar to the implementation described in the above method. Therefore, the specific limitations of one or more embodiments of the system for predicting educational ethics deviations in a large language model provided below can be found in the limitations of the method for predicting educational ethics deviations in a large language model described above, and will not be repeated here.

[0126] In one exemplary embodiment, such as Figure 3 As shown, an educational ethics shift prediction system 300 for large language models is provided, including:

[0127] The knowledge enhancement and feature extraction module 301 is used to construct a structured knowledge graph with traceable digital fingerprints based on preset authoritative educational ethics guidelines; fine-tune the basic large language model based on the structured knowledge graph to obtain an ethical knowledge enhancement model; and train a sparse autoencoder based on the traceable digital fingerprints in the structured knowledge graph to obtain a traceability vector extractor for extracting the knowledge call state inside the ethical knowledge enhancement model.

[0128] The ethics testing and risk quantification module 302 is used to generate multiple value agents based on the ethics knowledge enhancement model, which together form an adversarial testing environment. In the adversarial testing environment, the ethics knowledge enhancement model is subjected to multiple rounds of adversarial questioning. In each round of questioning, the external dialogue text generated by the ethics knowledge enhancement model is obtained, and the corresponding internal knowledge tracing vector is obtained through the tracing vector extractor. Based on the internal knowledge tracing vectors and external dialogue texts output in each round, the knowledge call compliance of the ethics knowledge enhancement model is quantitatively evaluated, and an ethical behavior risk matrix and a high-risk boundary use case library are generated.

[0129] The real-time monitoring and dynamic early warning module 303 is used to extract an ethical personality basis vector set based on a high-risk boundary use case library through comparative learning; based on the ethical behavior risk matrix, it sets a corresponding dynamic early warning threshold for each ethical personality basis vector in the ethical personality basis vector set; based on the ethical personality basis vector set and the dynamic early warning threshold, it performs real-time projection monitoring of the internal activation state of the ethical knowledge enhancement model when processing user queries; when the monitoring result indicates that an offset risk has been detected, it triggers an ethical offset early warning and generates an analysis report.

[0130] In one exemplary embodiment, the present invention also provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the educational ethics shift prediction method for large language models of this application. A multi-core processor is preferred to improve the parallel processing capability of the system. The memory provides sufficient temporary storage space to support program execution and data processing. The memory capacity should be large enough to accommodate large amounts of data and computational tasks.

[0131] In one exemplary embodiment, the present invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the educational ethics shift prediction method for large language models of this application. The computer-readable storage medium may include: a read-only memory, a random access memory, a solid-state drive, or an optical disk, etc.

[0132] The above-described embodiments are merely illustrative of several implementation methods of the embodiments of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the embodiments of this application, and these modifications and improvements all fall within the protection scope of the embodiments of this application.

Claims

1. A large language model-oriented education ethics deviation prediction method, characterized in that, The method includes: Based on pre-defined authoritative educational ethics guidelines, a structured knowledge graph with traceable digital fingerprints is constructed; the basic large language model is fine-tuned based on the structured knowledge graph to obtain an ethics knowledge enhancement model; based on the traceable digital fingerprints in the structured knowledge graph, a sparse autoencoder is trained to obtain a traceability vector extractor for extracting the knowledge call state inside the ethics knowledge enhancement model. Based on the aforementioned ethical knowledge enhancement model, multiple value-based intelligent agents are generated, forming an adversarial testing environment. In this environment, the ethical knowledge enhancement model undergoes multiple rounds of adversarial questioning. In each round, the external dialogue text generated by the model is obtained, and the corresponding internal knowledge source vector is acquired through the source vector extractor. Based on the internal knowledge source vectors and external dialogue text output in each round, the ethical knowledge enhancement model undergoes a quantitative assessment of knowledge retrieval compliance, generating an ethical behavior risk matrix and a high-risk boundary use case library. Based on the high-risk boundary use case library, an ethical personality basis vector set is obtained through comparative learning; based on the ethical behavior risk matrix, a corresponding dynamic early warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set; based on the ethical personality basis vector set and the dynamic early warning threshold, the internal activation state of the ethical knowledge enhancement model when processing user queries is monitored in real time by projection; when the monitoring result indicates that an offset risk is detected, an ethical offset early warning is triggered, and an analysis report is generated.

2. The method of claim 1, wherein, Based on the preset authoritative educational ethics guidelines, a structured knowledge graph with traceable digital fingerprints is constructed; based on the structured knowledge graph, the basic large language model is fine-tuned to obtain an ethics knowledge enhancement model; Based on the traceable digital fingerprints in the structured knowledge graph, a sparse autoencoder is trained to obtain a source vector extractor for extracting the knowledge call states within the ethical knowledge enhancement model, including: Information is extracted from the unstructured text in the preset authoritative educational ethics guidelines to construct a knowledge graph with triples as the basic unit. A unique traceable digital fingerprint is generated for each triple in the knowledge graph to obtain the structured knowledge graph. The traceable digital fingerprint consists of the content hash value and metadata encoding value of the triple. The metadata encoding value includes the knowledge source, authority level and effective time. The structured knowledge graph is fused with a general educational corpus to construct training sample pairs including text fragments, associated knowledge triples, and corresponding traceable digital fingerprints. The basic large language model is then trained using an adaptive attention masking mechanism to obtain the ethical knowledge enhancement model. The adaptive attention masking mechanism is used to dynamically adjust the connection weights of the attention layer in the basic large language model based on the matching results between keywords in the training sample pairs and the associated knowledge triples. The training sample pairs are input into the ethical knowledge enhancement model, and the activation states of the intermediate layers of the ethical knowledge enhancement model are collected when processing the training sample pairs. A training dataset is constructed based on the intermediate layer activation states and the traceable digital fingerprints corresponding to the training sample pairs. The sparse autoencoder is trained under supervision to obtain the traceability vector extractor. The training objective of the sparse autoencoder is to map the traceability vectors output by the bottleneck layer in the sparse autoencoder to the corresponding traceable digital fingerprints.

3. The method of claim 1, wherein, The process involves generating multiple value-based intelligent agents based on the aforementioned ethical knowledge enhancement model, forming an adversarial testing environment. Within this environment, the ethical knowledge enhancement model undergoes multiple rounds of adversarial questioning. In each round, the external dialogue text generated by the model is obtained, and the corresponding internal knowledge source vector is acquired using the source vector extractor. Based on the internal knowledge source vectors output in each round and the external dialogue text, the ethical knowledge enhancement model is subjected to a quantitative assessment of knowledge retrieval compliance, generating an ethical behavior risk matrix and a high-risk boundary use case library, including: Multiple value prototypes covering the spectrum of educational ethics are constructed. An initial corpus is generated based on the value prototypes using an independent language model. The initial corpus is then filtered based on the ethical knowledge enhancement model to generate the multiple value agents. The filtering process includes verifying the representativeness and non-extreme nature of the values ​​in the initial corpus using the ethical knowledge enhancement model. A multi-turn dialogue simulation platform is constructed, comprising the adversarial testing environment consisting of the multiple value-based intelligent agents and the platform itself. The ethical knowledge enhancement model is set as the system under test, and the multiple value-based intelligent agents are set as the interaction objects. The multi-turn dialogue simulation platform drives the multiple value-based intelligent agents to initiate multi-turn adversarial queries against the ethical knowledge enhancement model, obtaining a comprehensive risk score for each round. The comprehensive risk score is obtained through the following steps: For each round of interaction, the natural language response generated by the ethical knowledge enhancement model is recorded to obtain the external dialogue text. The source vector extractor is then called to process the intermediate layer activation state of the ethical knowledge enhancement model in the current round of interaction to obtain the internal knowledge source vector. Logical consistency and stance stability analyses are performed on the external dialogue text to obtain and calculate a behavioral consistency score based on the first and second results. The internal knowledge tracing vector is decoded, and the knowledge call matching degree and activation intensity are verified based on the decoding results to obtain a knowledge call compliance score. The behavioral consistency score and the knowledge call compliance score are weighted and fused to obtain a comprehensive risk score for the current round of interaction. The comprehensive risk scores from each round are summarized and statistically analyzed according to preset ethical dimensions and preset interaction scenario types to generate the ethical behavior risk matrix. Abnormal interaction rounds with knowledge call compliance scores lower than preset call compliance thresholds are selected, and the external dialogue text, internal knowledge tracing vector, and comprehensive risk scores corresponding to the abnormal interaction rounds are stored to generate the high-risk boundary use case library.

4. The method of claim 1, wherein, Based on the high-risk boundary use case library, an ethical personality basis vector set is obtained through comparative learning; based on the ethical behavior risk matrix, a corresponding dynamic early warning threshold is set for each ethical personality basis vector in the ethical personality basis vector set; based on the ethical personality basis vector set and the dynamic early warning threshold, the internal activation state of the ethical knowledge enhancement model when processing user queries is monitored in real time by projection; when the monitoring result indicates that an offset risk is detected, an ethical offset early warning is triggered, and an analysis report is generated, including: Extract the internal activation states and corresponding dialogue contexts of the ethical knowledge enhancement model when generating high-risk responses from the high-risk boundary use case library to obtain abnormal state samples and target dialogue contexts; guide the ethical knowledge enhancement model to generate responses that conform to ethical norms based on the target dialogue context, extract the internal activation states during the generation process to obtain normal state samples; based on the abnormal state samples and the normal state samples, solve multiple vector directions in the activation space of the ethical knowledge enhancement model through a contrastive learning algorithm to obtain the set of ethical personality basis vectors; Locate each low-risk test case from the ethical behavior risk matrix, extract the projection value of the low-risk test case on each ethical personality basis vector in the ethical personality basis vector set, and calculate and set the corresponding dynamic early warning threshold for each ethical personality basis vector based on the statistical distribution of the projection value. The ethical knowledge enhancement model is deployed, and the internal activation state sequence of the deployed ethical knowledge enhancement model when processing user queries is obtained in real time through the monitoring module. The activation state sequence is projected onto the ethical personality basis vector set to obtain multiple sets of ethical trait projection curves. The ethical trait projection curves are compared and analyzed with the corresponding dynamic warning thresholds. When the comparison result meets the deviation risk judgment condition, the monitoring result is obtained. The monitoring result indicates that deviation risk has been detected, and the ethical deviation warning is triggered. Record the user query that triggers the ethical deviation warning, the internal activation state sequence, and the ethical trait projection curve to obtain warning-related data; call the source vector extractor to perform internal state analysis on the internal activation state sequence in the warning-related data to generate the analysis report; the analysis report includes knowledge call anomalies, the corresponding entries in the structured knowledge graph, and the risk level assessment results.

5. The method of claim 4, wherein, The internal activation state and corresponding dialogue context when the ethical knowledge enhancement model generates a high-risk response are extracted from the high-risk boundary use case library to obtain abnormal state samples and target dialogue contexts. Based on the target dialogue context, the ethical knowledge enhancement model is guided to generate responses that conform to ethical norms, and the internal activation states during the generation process are extracted to obtain normal state samples. Based on the abnormal state samples and the normal state samples, a contrastive learning algorithm is used to solve for multiple vector directions in the activation space of the ethical knowledge enhancement model to obtain the set of ethical personality basis vectors, including: S1. Select target cases associated with preset ethical dimensions from the high-risk boundary use case library, extract and use the intermediate layer activation state matrix and the corresponding dialogue context when the ethical knowledge enhancement model generates the high-risk response in the target cases, and use them as abnormal state samples and the target dialogue context, respectively. S2. Input the target dialogue context into the ethical knowledge enhancement model, guide the ethical knowledge enhancement model to generate a response that conforms to the preset ethical dimension, and extract and use the intermediate layer activation state matrix in the response generation process as the normal state sample. S3. Extract features from the abnormal state samples and the normal state samples to obtain abnormal feature vectors and normal feature vectors, respectively. S4. Construct a contrastive learning loss function, wherein the contrastive learning loss function aims to make the abnormal feature vector approach the negative prototype vector to be solved, and to make the normal feature vector move away from the negative prototype vector. S5. Optimize the contrastive learning loss function using the gradient descent algorithm, and solve for the direction of the negative prototype vector in the activation space of the ethical knowledge enhancement model. Define the direction as the ethical personality basis vector corresponding to the preset ethical dimension. S6. For each of the preset ethical dimensions, repeat steps S1 to S5 to obtain the ethical personality basis vectors corresponding to each of the preset ethical dimensions, and summarize the ethical personality basis vectors to form the ethical personality basis vector set.

6. The method of claim 4, wherein, The deployment of the ethical knowledge enhancement model involves real-time acquisition of the internal activation state sequence of the deployed ethical knowledge enhancement model when processing user queries through a monitoring module. The activation state sequence is then projected onto the ethical personality basis vector set to obtain multiple sets of ethical trait projection curves. The ethical trait projection curve is compared and analyzed with the corresponding dynamic warning threshold. When the comparison result meets the deviation risk judgment condition, the monitoring result is obtained. The monitoring result indicates that a deviation risk has been detected, triggering the ethical deviation warning, including: The ethical knowledge enhancement model is deployed to an online service environment, and the monitoring module is deployed in the online service environment. The monitoring module establishes a data interaction channel with the selected network layer of the ethical knowledge enhancement model. When the ethical knowledge enhancement model receives a user query and starts generating a response, the monitoring module continuously collects the activation state vector of the selected network layer from the generation of the first response term to form the internal activation state sequence. Calculate the dot product between each activation state vector in the internal activation state sequence and each ethical personality basis vector in the ethical personality basis vector set to obtain the instantaneous projection value of each ethical dimension at the corresponding generation step; After the ethical knowledge enhancement model completes the generation of a full response, a projection curve of the ethical trait corresponding to each ethical dimension is generated based on the instantaneous projection value of each ethical dimension. Calculate the moving average and peak value of each ethical trait projection curve, and combine the dynamic warning threshold, which includes a first threshold corresponding to the moving average and a second threshold corresponding to the peak value, to compare the moving average value corresponding to each ethical dimension with the first threshold and the peak value corresponding to each ethical dimension with the second threshold to obtain the comparison result; If the moving average of any ethical dimension is greater than the corresponding first threshold, or the peak value of any ethical dimension is greater than the corresponding second threshold, then the comparison result is determined to meet the offset risk determination condition, the monitoring result is determined to be an offset risk detected, and the ethical offset warning is triggered.

7. The method of claim 3, wherein, The comprehensive risk score for the current round of interaction is calculated using the following formula: in, For the first The comprehensive risk score for the round interaction has a value range of [0,10]. The total number of pre-defined educational ethics dimensions, and ; For the first In the first round of interaction The dynamic weights of each ethical dimension satisfy... From the formula calculate, For temperature coefficient, For the first In the first round of interaction Situational sensitivity across ethical dimensions; The weighting coefficient for the behavioral consistency score; For the first In the first round of interaction The behavioral consistency score for each ethical dimension, ranging from [0,1], is derived from the logical consistency score. and position stability score Weighted average; For the first In the first round of interaction The knowledge retrieval compliance score, representing one ethical dimension, ranges from [0,1] and is determined by the knowledge matching degree. and activation intensity Normalization yields the result; This is the cumulative penalty coefficient for risk. For the first Wheel and front Risk change rate of the wheel , To avoid the minimum value where the denominator is 0, The initial risk score is unweighted, and , for The average score of behavioral consistency across ethical dimensions for The average score of knowledge access compliance across all ethical dimensions.

8. A predictive system for educational ethics shifts in large language models, characterized in that, The system includes: The knowledge enhancement and feature extraction module is used to construct a structured knowledge graph with traceable digital fingerprints based on preset authoritative educational ethics guidelines; fine-tune the basic large language model based on the structured knowledge graph to obtain an ethical knowledge enhancement model; and train a sparse autoencoder based on the traceable digital fingerprints in the structured knowledge graph to obtain a traceability vector extractor for extracting the knowledge call state inside the ethical knowledge enhancement model. The ethics testing and risk quantification module is used to generate multiple value agents based on the ethics knowledge enhancement model, which constitute an adversarial testing environment. In this adversarial testing environment, the ethics knowledge enhancement model is subjected to multiple rounds of adversarial questioning. In each round of questioning, the external dialogue text generated by the ethics knowledge enhancement model is obtained, and the corresponding internal knowledge tracing vector is obtained through the tracing vector extractor. Based on the internal knowledge tracing vectors output in each round and the external dialogue text, the knowledge call compliance of the ethics knowledge enhancement model is quantitatively evaluated, generating an ethical behavior risk matrix and a high-risk boundary use case library. The real-time monitoring and dynamic early warning module is used to extract an ethical personality basis vector set through comparative learning based on the high-risk boundary use case library; based on the ethical behavior risk matrix, it sets a corresponding dynamic early warning threshold for each ethical personality basis vector in the ethical personality basis vector set; based on the ethical personality basis vector set and the dynamic early warning threshold, it performs real-time projection monitoring of the internal activation state of the ethical knowledge enhancement model when processing user queries; when the monitoring result indicates that an offset risk is detected, it triggers an ethical offset early warning and generates an analysis report.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.