A multi-modal knowledge distillation method and system for legal consultation

By employing information flow analysis, confusion perception contrastive learning, and legal case trajectory tree exploration strategies, combined with multi-perspective and metacognitive training, a rule compliance loss function is constructed. This addresses the lack of professionalism in the legal consultation field in existing technologies, enabling efficient, professional, and privacy-protected legal consultation services in complex scenarios using a small model.

CN121051216BActive Publication Date: 2026-03-27GUIZHOU IND VOCATIONAL & TECH COLLEGE +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511575009.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-03-27
Estimated Expiration
2045-10-31

AI Technical Summary

Technical Problem

Existing multimodal knowledge distillation technology is difficult to effectively convey complex logical reasoning and legal rules in the field of legal consultation. It lacks a dynamic optimization mechanism, resulting in the inadequate performance of small models in professional and complex scenarios.

Method used

We employ information flow analysis, confusion perception contrastive learning, and legal case trajectory tree exploration strategies, combined with multi-perspective thinking and metacognitive awareness training strategies, to construct a distillation loss function that includes a rule compliance loss term. This allows us to perform knowledge distillation and model compression to adapt the model to terminal devices.

Benefits of technology

It enhances the professionalism of small-scale models in legal consultation scenarios, possesses multimodal processing capabilities, meets the needs of complex scenarios, and runs locally on resource-constrained devices, protecting user privacy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121051216B_ABST
    Figure CN121051216B_ABST
Patent Text Reader

Abstract

The application discloses a kind of multi-modal knowledge distillation methods and systems for legal consultation, comprising: obtaining large legal professional model and multi-modal legal consultation data, using information flow analysis method and multi-round dialogue evaluation model professional ability, using first-order logic formalism and comparative learning framework to refine legal rule knowledge base;Based on the knowledge base, use the confusion perception contrast learning mechanism to identify small model confusion points, use legal case trajectory tree exploration strategy to analyze complex case reasoning path, dynamically optimize legal rule set;Construct a distillation loss function containing rule compliance loss term, integrate multi-perspective thinking and metacognition awareness training strategy for knowledge distillation;Lightweight processing is carried out to small model after distillation and deployed to terminal equipment.The application realizes the localization, privacy protection legal consultation service, effectively solves the problem of insufficient professional application of traditional multi-modal knowledge distillation technology in the legal field.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of artificial intelligence, in particular to the fields of multi-modal artificial intelligence, knowledge distillation and legal technology, and more specifically to a method and system for efficiently and faithfully migrating the capabilities of large, specialized legal domain models to resource-constrained terminal devices for providing localized, privacy-protected legal consultation services. BACKGROUND

[0002] With the development of deep learning technology, large pre-trained models have shown excellent performance in natural language processing and computer vision and other fields. However, their huge parameter quantity and computational requirements limit their direct application in edge devices or scenarios with high privacy requirements. Knowledge distillation technology has emerged to transfer the knowledge of the "teacher" large model to the "student" small model, enabling it to approach the performance of the teacher model as much as possible while maintaining low resource consumption.

[0003] In the field of knowledge distillation, common techniques include response-based knowledge distillation, in which the student model learns to fit the output probability distribution (soft label) of the teacher model, and feature-based knowledge distillation, in which the student model learns to fit the feature representation of the intermediate layers of the teacher model. For example, the classic knowledge distillation method proposed by Hinton et al. introduces a temperature coefficient to smooth the output probability of the teacher model, guiding the student model to learn. In the multi-modal field, existing work attempts to fuse information from different modalities (such as text and images) into a large model for processing and compresses such multi-modal large models through knowledge distillation techniques. For example, some methods jointly distill the knowledge of text and visual modalities, enabling the student model to learn the multi-modal fusion capabilities of the teacher model.

[0004] The most relevant prior art to the present application is mainly those methods that aim to distill the knowledge of general large multi-modal models to small models. Such techniques usually use an end-to-end training approach, enabling the student model to mimic the overall behavior of the teacher model for multi-modal input. For example, after receiving text and image input, the teacher model outputs a comprehensive judgment or description, and the student model learns to replicate this output. The technical principle is to minimize the output difference between the student model and the teacher model under the same input, or the difference in intermediate layer feature representations, through a carefully designed loss function. These methods may use contrastive learning to align the representation spaces of different modalities, or use attention mechanisms to learn the importance of different modalities, and transfer these learned "knowledge" to the student model.

[0005] However, such general multi-modal knowledge distillation techniques have obvious technical problems and defects when applied to the highly specialized and highly logical and rule-based legal consulting field. First, existing technologies often fail to effectively transfer the complex logical reasoning ability specific to the legal field and the precise understanding of legal provisions during the distillation process. They focus more on imitating surface output, while the deep rules and reasoning processes embedded in legal knowledge are easily lost during the distillation process, resulting in small models that can handle multi-modal input but greatly compromise on legal professionalism. Second, existing technologies lack effective mechanisms and strategies for dynamically and specifically optimizing legal rules and logic during the distillation process, and for evaluating and enhancing the multi-perspective thinking and meta-cognitive ability of models in legal scenarios, making it difficult for small models to meet the complex needs of real legal consulting scenarios. SUMMARY

[0006] The purpose of the present application is to provide a multi-modal knowledge distillation method and system for legal consulting, aiming to solve the technical problems of the general multi-modal knowledge distillation method in the prior art when applied to the legal field, such as lack of professionalism, difficulty in effectively transferring complex legal reasoning ability, and lack of dynamic optimization mechanism.

[0007] To achieve the above-mentioned purpose, the present application provides a multi-modal knowledge distillation method for legal consulting, comprising the following steps:

[0008] A large legal professional model and multi-modal legal consulting data are obtained, and an information flow analysis method is used to track the internal information flow of the large legal professional model processing the multi-modal legal consulting data. The professional ability of the large legal professional model in legal reasoning and case analysis is evaluated in combination with multi-round dialogue mode, and the legal rules involved in the process of the large legal professional model processing the multi-modal legal consulting data and dialogue evaluation are structured expressed in first-order logic formalism, and a comparative learning framework is used to compare the output of the legal professional model with professional legal knowledge sources to obtain a professional ability evaluation report and a refined legal rule knowledge base;

[0009] Based on the legal rule knowledge base and the professional ability evaluation report, a confusion perception contrast learning mechanism is used to identify the confusion points of the small distillation model in legal concepts and rule application, a legal case trajectory tree exploration strategy is used to analyze the reasoning path and key decision nodes of complex legal cases, and the legal rule set and its logical relationship in the legal rule knowledge base are dynamically adjusted and optimized to obtain an optimized legal rule set and dynamic distillation logic;

[0010] Based on the optimized legal rule set and the dynamic distillation logic, a distillation loss function containing a rule compliance loss term is constructed, and the large legal professional model is used as a teacher model to perform knowledge distillation training on the small model to be distilled, and a multi-perspective thinking and meta-cognition awareness training strategy is integrated into the distillation process to obtain a small legal professional model with multi-modal processing capability.

[0011] The small legal professional model with multi-modal processing capability is subjected to model compression technology for lightweight processing to adapt to the hardware environment of the terminal device, and a lightweight small legal professional model is obtained, and the lightweight small legal professional model is deployed to the target terminal device and integrated into the local legal consultation application to obtain a multi-modal legal consultation system that can run locally.

[0012] Further, the information flow analysis method is used to track the internal information flow of the large legal professional model in processing the multi-modal legal consultation data, including:

[0013] Based on the multi-modal legal consultation data, a pre-set input probe is designed for the large legal professional model, and the internal activation value change and attention weight distribution are monitored to track the transmission path of information between different network levels, and internal information flow analysis data is obtained;

[0014] Based on the internal information flow analysis data, a real legal consultation process is simulated in combination with a multi-round dialogue mode, and the performance of the large legal professional model in terms of legal reasoning coherence and knowledge depth is gradually explored, and a professional capability evaluation report is obtained.

[0015] Further, the legal rules involved in the process of the large legal professional model processing the multi-modal legal consultation data and the dialogue evaluation process are structured and expressed in the form of first-order logic formalism, and a comparative learning framework is used to compare the output of the legal professional model with a professional legal knowledge source, including:

[0016] Based on professional legal texts and first-order logic formalism definitions, legal principles and adjudication rules are structured and expressed by elements including predicates, functions and quantifiers, and a preliminary legal rule library is obtained;

[0017] Based on the preliminary legal rule library and the output results of the large legal professional model when processing test data, a comparative learning framework is used to compare and analyze the output results with a professional legal knowledge source in multiple dimensions, identify consistency and differences, and obtain the refined legal rule knowledge base.

[0018] Further, a confusion perception contrast learning mechanism is used to identify confusion points of the small model to be distilled in terms of legal concepts and rule application, including:

[0019] Based on the legal rule knowledge base and the professional ability evaluation report, the small distillation model is used to predict the multi-modal legal consultation data and output the prediction results, and the prediction results are compared with the correct legal logic and rules to obtain a list of potential confusion points;

[0020] Based on the list of potential confusion points, combined with the confusion perception comparison learning mechanism definition, for each confusion point in the list of potential confusion points, the original data is filtered or constructed to have deceptive negative samples, the discrimination ability of the model is trained, and an enhanced negative sample set for comparison learning is obtained.

[0021] Further, the reasoning path and key decision node of the complex legal case are analyzed by using the legal case trajectory tree exploration strategy, including:

[0022] Based on the legal rule knowledge base, combined with the complex legal case sample, the case resolution process of the complex legal case sample is represented as a tree structure, wherein the node represents the case fact, evidence and applicable legal provisions, and the edge represents the reasoning step, to obtain a set of legal case trajectory trees;

[0023] Based on the set of legal case trajectory trees, the key decision nodes, multiple reasoning paths and the influence of different evidence combinations on the case trend in the case handling process of the complex legal case sample are identified by traversing the trajectory tree through a depth-first search algorithm, to obtain a trajectory tree traversal analysis report.

[0024] Further, the distillation loss function containing the rule compliance loss term is constructed, including:

[0025] Based on the optimized legal rule set and the dynamic distillation logic, a soft label loss term is designed for the small distillation model, so that the output of the small distillation model fits the output probability distribution of the large legal professional model, to obtain a basic distillation loss term;

[0026] Based on the basic distillation loss term, an intermediate layer feature alignment loss term is designed for the small distillation model, so that the small distillation model learns to fit the feature representation of the intermediate layer of the large legal professional model, to obtain a feature alignment loss term;

[0027] Based on the feature alignment loss term and the optimized legal rule set, a rule compliance loss term is designed for the small distillation model, which calculates a penalty or reward according to whether the reasoning process and output of the small distillation model comply with the legal rules, to obtain a rule constraint loss term;

[0028] designing a logical consistency loss term for the small-sized model to be distilled based on the rule constraint loss term and the dynamic distillation logic, so as to evaluate logical consistency and reasoning consistency of an output of the small-sized model to be distilled, and obtaining a logical consistency loss term;

[0029] constructing a comprehensive distillation loss function by means of weighted combination based on the basic distillation loss term, the feature alignment loss term, the rule constraint loss term and the logical consistency loss term, and obtaining the distillation loss function containing the rule compliance loss term.

[0030] Further, the training strategy of integrating multi-perspective thinking and meta-cognitive awareness in the distillation process comprises:

[0031] annotating different legal role perspectives, including a plaintiff perspective, a defendant perspective and a neutral perspective, for a training sample based on the distillation loss function containing the rule compliance loss term and the multi-modal legal consultation data, and obtaining multi-perspective annotated training data;

[0032] training the small-sized model to be distilled to analyze from a plaintiff evidence advantage perspective based on the multi-perspective annotated training data, learning to fit a judgment process of the large-sized legal professional model in the plaintiff perspective, and obtaining a plaintiff perspective analysis capability;

[0033] training the small-sized model to be distilled to analyze from a defendant evidence defect perspective based on the plaintiff perspective analysis capability, learning to fit a reasoning process of the large-sized legal professional model in the defendant perspective, and obtaining a defendant perspective analysis capability;

[0034] training the small-sized model to be distilled to analyze from a neutral judgment perspective based on the defendant perspective analysis capability, learning to fit a judgment logic of the large-sized legal professional model in the neutral perspective, and obtaining a neutral perspective analysis capability;

[0035] training the small-sized model to be distilled to integrate analysis results of different perspectives by means of multi-perspective consistency constraint based on the plaintiff perspective analysis capability, the defendant perspective analysis capability and the neutral perspective analysis capability, and obtaining a training model with multi-perspective thinking capability.

[0036] Further, the training strategy of integrating multi-perspective thinking and meta-cognitive awareness in the distillation process comprises:

[0037] training the small-sized model to be distilled to predict a confidence score of an output thereof by means of a meta-cognitive awareness training algorithm based on the training model with multi-perspective thinking capability, and comparing the confidence score with a confidence score of the large-sized legal professional model to learn, and obtaining a confidence evaluation capability;

[0038] Based on the confidence evaluation capability, the small distillation model to be trained is trained to identify situations of insufficient input information or exceeding the capability range, learn to output a "need more information" judgment when uncertain, and obtain a knowledge boundary identification capability;

[0039] Based on the knowledge boundary identification capability, the small distillation model to be trained is trained to evaluate the reliability of its own judgment, learn the meta-cognition behavior of the large legal professional model expressing the degree of judgment grasp, and obtain a self-evaluation capability;

[0040] Based on the self-evaluation capability, the small distillation model to be trained is trained to actively identify knowledge blind spots and seek supplementary information, learn cautious judgment strategies in complex legal problems, and obtain an active learning capability;

[0041] Based on the confidence evaluation capability, the knowledge boundary identification capability, the self-evaluation capability, and the active learning capability, the meta-cognition performance of the small distillation model is optimized through meta-cognition consistency constraints to obtain the small legal professional model with multi-modal processing capability.

[0042] Further, the small legal professional model with multi-modal processing capability is subjected to lightweight processing using model compression technology to adapt to the hardware environment of the terminal device, comprising:

[0043] Based on the small legal professional model with multi-modal processing capability, combined with the hardware specifications of the target terminal device, the model parameters of the small legal professional model with multi-modal processing capability are converted from floating-point numbers to low-precision integer representations using weight quantization technology, reducing model storage space and computational complexity, and obtaining quantized model parameters;

[0044] Based on the quantized model parameters, network pruning technology is used to identify and remove neuron connections and redundant parameters that have less impact on the model performance of the small legal professional model with multi-modal processing capability, while maintaining the core functions of the model and reducing the number of parameters, obtaining a pruned model structure;

[0045] Based on the pruned model structure, low-rank decomposition technology is used to decompose large weight matrices into the product of multiple small matrices, reducing the computational complexity and memory occupation of the small legal professional model with multi-modal processing capability, and obtaining decomposed model weights;

[0046] Based on the decomposed model weights, knowledge distillation technology is used to further compress the small legal professional model with multi-modal processing capability, maintaining the accuracy of legal professional knowledge, and obtaining a compressed and optimized model version;

[0047] Based on the model version optimized by compression, performance indicators including inference speed, memory occupation and processor load are tested under a target terminal device environment to verify model adaptability, and a lightweight small legal professional model is obtained.

[0048] Further, the lightweight small legal professional model is deployed to a target terminal device and integrated into a local legal consultation application, including:

[0049] Based on the lightweight small legal professional model and a software development kit of the target terminal device, model format conversion and operator compatibility adaptation are performed to ensure that the lightweight small legal professional model can be correctly called by the local legal consultation application of the target terminal device, and an adapted model file is obtained.

[0050] Based on the adapted model file, a model file, related dependent libraries and configuration files are packaged to build a deployment package that can be installed and run on a target terminal device, and a multi-modal legal consultation system capable of local operation is obtained.

[0051] The application also provides a multi-modal knowledge distillation system for legal consultation, including:

[0052] A professional ability evaluation module is configured to obtain a large legal professional model and multi-modal legal consultation data, track the internal information flow of the large legal professional model processing the multi-modal legal consultation data using an information flow analysis method, evaluate the professional ability of the large legal professional model in legal reasoning and case analysis in combination with a multi-round dialogue mode, and structure the legal rules involved in the process of the large legal professional model processing the multi-modal legal consultation data and dialogue evaluation using a first-order logic formalism, and compare the output of the legal professional model with a professional legal knowledge source using a comparative learning framework to obtain a professional ability evaluation report and a refined legal rule knowledge base.

[0053] A dynamic optimization module is configured to use a confusion-aware contrast learning mechanism to identify confusion points of a small model to be distilled in terms of legal concepts and rule application based on the legal rule knowledge base and the professional ability evaluation report, analyze the reasoning path and key decision nodes of a complex legal case using a legal case trajectory tree exploration strategy, and dynamically adjust and optimize the legal rule set and the logical relationship of the legal rule knowledge base to obtain an optimized legal rule set and a dynamic distillation logic.

[0054] A knowledge distillation module is configured to construct a distillation loss function containing a rule compliance loss term based on the optimized legal rule set and the dynamic distillation logic, and perform knowledge distillation training on the small model to be distilled by taking the large legal professional model as a teacher model, wherein a multi-perspective thinking and meta-cognition awareness training strategy is integrated into the distillation process to obtain a small legal professional model with multi-modal processing capability.

[0055] A terminal deployment module is configured to perform lightweight processing on the small legal professional model with multi-modal processing capability by using a model compression technology to adapt to the hardware environment of a terminal device, obtain a lightweight small legal professional model, and deploy the lightweight small legal professional model to a target terminal device and integrate the lightweight small legal professional model into a local legal consultation application to obtain a multi-modal legal consultation system capable of local operation.

[0056] The present application has the following advantages:

[0057] 1. The rule-enhanced knowledge distillation method based on the first-order logic formalism and the comparative learning framework can accurately extract and transfer structured legal rule knowledge from a large legal professional model to a small model, effectively solving the problem of insufficient professionalism of traditional knowledge distillation methods in the legal field.

[0058] 2. The dynamic optimization method combining the confusion perception contrast learning mechanism with the legal case trajectory tree exploration strategy can specifically optimize the legal logic and rules in the distillation process, and improve the ability of the small model to handle complex and easily confused legal scenarios.

[0059] 3. The distillation training strategy integrating multi-perspective thinking and meta-cognition awareness significantly improves the practicality and reliability of the small model in real legal consultation scenarios.

[0060] 4. The model lightweight and terminal deployment technology realizes the local operation of the legal professional model on resource-constrained devices, effectively protects user privacy, and meets the high requirements of legal consultation scenarios for data security. BRIEF DESCRIPTION OF DRAWINGS

[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0062] Figure 1 The flowchart of the multi-modal knowledge distillation method for legal consultation provided by the embodiments of the present application;

[0063] Figure 2A structural block diagram of the multi-modal knowledge distillation system for legal consultation provided by the embodiment of the present application. DETAILED DESCRIPTION

[0064] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0065] In some processes described in the specification and claims of the present application and the above description, a plurality of operations are included, which occur in a specific order, but it should be clearly understood that these operations can be executed in the order in which they appear in this text or in parallel. The serial numbers of the operations, such as S11, S12, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes can include more or fewer operations, and the operations can be executed in sequence or in parallel. It should be noted that the descriptions of “first”, “second” and the like in this text are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence. In addition, “first” and “second” are different types.

[0066] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms “a”, “an” and “the” used herein also include the plural forms. It should be further understood that the phrase “comprising” used in the specification of the present application means that the features, integers, steps, operations, elements and / or components exist, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we say that an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there can be intermediate elements. In addition, “connected” or “coupled” used herein can include wireless connection or wireless coupling. The phrase “and / or” used herein includes all or any single unit and all combinations of the associated listed items.

[0067] Those skilled in the art can understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as that generally understood by those skilled in the art to which the present application belongs. It should also be understood that terms such as those defined in a general dictionary should be understood to have meanings consistent with those in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as such.

[0068] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. The same or similar labels represent the same or similar elements or elements with the same or similar functions throughout the drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.

[0069] Please refer to Figure 1 , Figure 1 The flowchart of the multi-modal knowledge distillation method for legal consultation provided by the embodiments of the present application is shown in FIG. 1. As shown in FIG. 1, the method comprises the following steps: Figure 1

[0070] Step S1: Obtain a large legal professional model and multi-modal legal consultation data, track the internal information flow of the large legal professional model in processing the multi-modal legal consultation data by using an information flow analysis method, evaluate the professional ability of legal reasoning and case analysis of the large legal professional model in combination with multi-round dialogue mode, simultaneously structure the legal rules involved in the process of the large legal professional model processing the multi-modal legal consultation data and dialogue evaluation by using first-order logic formalism for structured expression, and compare the output of the legal professional model with professional legal knowledge sources by using a comparative learning framework to obtain a professional ability evaluation report and a refined legal rule knowledge base.

[0071] In this step, a well-trained large legal professional model is first needed, which should have the ability to process legal text consultation, contract scanning images and evidence photos and other multi-modal inputs, and a legal consultation data set containing various legal problems and multi-modal data is collected. Then, specific input probes are designed, which are carefully designed input samples used to trigger specific activation patterns in the model. Through these probes, the internal activation value changes, attention weight distribution and information transmission paths between different network levels of the large legal professional model when processing multi-modal legal consultation data are monitored, so as to deeply understand how the model processes legal information. For example, when the model processes an input containing a contract image and related consultation text, it can be observed how the model fuses visual information with text information, and which network layers play a key role in legal clause identification. This information flow analysis method can reveal the internal working mechanism of the model and provide a basis for subsequent knowledge extraction.

[0072] ​Meanwhile, a series of multi-turn dialogue scenarios are designed to simulate real legal consultation processes. These dialogue scenarios should cover different types of legal issues, such as contract disputes, tort liability, criminal defense, etc., and contain interactive elements such as follow-up questions, refutations, and the provision of new information. Through this multi-turn dialogue approach, the large-scale legal professional model can be comprehensively evaluated in terms of legal reasoning coherence, knowledge depth, and ability to handle ambiguous or contradictory information. For example, a basic legal question can be asked first, and then more details or relevant legal articles can be introduced according to the model's answers to observe whether the model can maintain the consistency and accuracy of reasoning. This evaluation method can measure the legal professional ability of the model from multiple dimensions and form a detailed professional ability evaluation report.

[0073] In addition, legal experts are invited to express core legal principles, elements, and adjudication rules through first-order logic formal language. First-order logic formalism provides an accurate and unambiguous way to represent legal rules, using predicates, functions, and quantifiers to build formal legal knowledge representation. For example, the elements of "intentional injury" can be represented as a series of logical predicates and conditions to clearly define the relationship between each element. This formal expression helps to convert legal knowledge into a machine-understandable form, laying the foundation for subsequent rule extraction and verification.

[0074] Finally, a comparative learning framework is used to compare the output of the large-scale legal professional model when processing the test data set with authoritative legal knowledge sources (such as judgment document databases, legal expert systems), and the preliminary formalized legal rules are analyzed in multiple dimensions. Through this comparison, the consistency and inconsistency of the model output with authoritative knowledge can be identified, and the preliminary legal rule library can be verified and corrected, while extracting effective rules from the large model that are consistent with authoritative knowledge. This process not only verifies the professional ability of the model, but also extracts structured legal rule knowledge from the model, forming a verified and refined legal rule knowledge base, which provides a high-quality knowledge source for subsequent knowledge distillation.

[0075] Step S2: Based on the legal rule knowledge base and the professional ability evaluation report, a confusion-aware contrast learning mechanism is used to identify the confusion points of the small-scale model to be distilled in terms of legal concepts and rule application, a legal case trajectory tree exploration strategy is used to analyze the reasoning path and key decision nodes of complex legal cases, and the legal rule set and its logical relationship in the legal rule knowledge base are dynamically adjusted and optimized to obtain an optimized legal rule set and dynamic distillation logic.

[0076] In this step, a small untrained or preliminarily trained model is introduced to make predictions or inferences on a portion of representative multi-modal legal consultation data. Then, the output of the small model is compared and analyzed with the "refined legal rule knowledge base" obtained in step S1 and the correct logic and rules revealed in the "large legal professional model professional ability evaluation report". Through this comparison, it can systematically identify where the small model is likely to be confused or mistaken in specific legal concepts, rule application conditions, and multi-modal information interpretation. For example, the small model may have difficulty distinguishing between "fraud" and "significant misunderstanding", two similar but legally distinct concepts, or making mistakes in determining the starting point of different litigation time limits, or incorrectly identifying key clauses from contract photos. The identification of these confusion points provides a clear direction for subsequent targeted training.

[0077] Next, based on the confusion-aware contrast learning (CACL) mechanism, for each identified confusion point, negative samples with misleading characteristics are selected or artificially constructed from the original data. The CACL mechanism emphasizes the construction of contrast learning samples, with particular attention to sample pairs that are easily confused by the model. Through the contrast learning of these sample pairs, the model's discrimination ability is enhanced. For example, if it is found that the small model easily confuses the two criminal law concepts of "intentional injury" and "inadvertent serious injury", negative samples containing similar case elements but different legal definitions can be constructed, or subtle but critical difference elements such as the type or use of the injury tool can be introduced in image evidence. These carefully designed negative samples can help the model learn more refined legal concept differentiation capabilities.

[0078] At the same time, the legal case trajectory tree exploration strategy is used to structure and analyze the solution process of complex legal cases. The legal case trajectory tree is a method of representing the solution process of a complex case as a tree structure, where nodes represent case facts, evidence, applicable legal provisions or intermediate reasoning conclusions, and edges represent reasoning steps or decision branches. By constructing such a trajectory tree, it can clearly show the various possible paths of a complex legal case from the initial facts to the final judgment. Then, using depth-first search, breadth-first search or search algorithms combined with heuristic information, the trajectory trees are traversed to identify key decision nodes, multiple possible reasoning paths and the impact of different evidence combinations on the case outcome during the case handling process. This analysis can reveal the complexity and diversity of legal reasoning, providing important basis for dynamic optimization of distillation logic.

[0079] Finally, based on the performance of the small model in handling enhanced negative samples and the complex case reasoning logic revealed by the analysis of the legal case trajectory tree, the "refined legal rule knowledge base" is dynamically adjusted and supplemented. For example, according to the trajectory tree analysis, if it is found that there is a conflict or ambiguity zone in the application of certain rules in a specific combination of situations, the rules are refined or supplemented with exception clauses; if the small model continues to perform poorly in handling certain negative samples, the weight of related rules in the distillation process is strengthened or more explicit logical constraints are introduced. Through this dynamic optimization process, a more accurate, comprehensive and adaptive legal rule set and distillation logic that meets the complex case reasoning requirements are finally formed, providing more effective guidance for subsequent knowledge distillation.

[0080] Step S3: Based on the optimized legal rule set and the dynamic distillation logic, a distillation loss function containing a rule compliance loss term is constructed, and the large legal professional model is used as the teacher model to perform knowledge distillation training on the small model to be distilled, and a multi-perspective thinking and meta-cognition awareness training strategy is integrated into the distillation process to obtain a small legal professional model with multi-modal processing capability;

[0081] In this step, a distillation loss function containing multiple terms is designed based on the "dynamically optimized and enhanced legal rule set" and "dynamic distillation logic" output in step S2. Traditional knowledge distillation usually only focuses on making the student model (small model) fit the output distribution or intermediate layer features of the teacher model (large model), but in the legal field, simply mimicking the output is not enough, the student model also needs to ensure that it can correctly understand and apply legal rules. Therefore, the present application specially designs a "rule compliance loss term", which calculates the penalty or reward according to whether the reasoning process and final output of the student model in handling multi-modal input comply with the rules defined in the optimized legal rule set and the logical coherence required by the dynamic distillation logic. For example, if the student model correctly identifies the elements of contract establishment but incorrectly applies the breach of contract rules when handling a contract dispute case, the rule compliance loss term will give corresponding punishment to guide the model to correct this error in subsequent training. This design can explicitly guide the student model to learn and internalize legal rules, rather than just mimic the surface output of the teacher model.

[0082] Next, during the training process of knowledge distillation, a multi-perspective thinking training strategy is incorporated. Legal issues often involve multiple parties, each with their own perspective and stance. To cultivate the comprehensive analysis ability of the student model, a multi-perspective thinking distillation enhancement algorithm is designed, which labels different legal role perspectives, such as plaintiff, defendant, and neutral third party, for the training samples, and requires the student model to provide analysis under different perspectives or learn the differentiated output of the teacher model under different perspectives. For example, for the same case of infringement, the student model needs to learn to analyze the evidence advantage from the perspective of the plaintiff, point out the evidence defects from the perspective of the defendant, and make a neutral judgment from the perspective of the judicial staff. This multi-perspective training enables the student model to obtain more comprehensive and balanced legal analysis ability, avoiding one-sidedness from a single perspective.

[0083] At the same time, a meta-cognitive awareness training strategy is also incorporated during the distillation process. Meta-cognitive awareness refers to the model's ability to recognize its own knowledge and judgment, which is particularly important in the legal field, as legal professionals need to clearly understand their judgment boundaries and certainty levels. A meta-cognitive awareness distillation enhancement algorithm is designed to train the student model to evaluate the reliability of its own judgment (e.g., output a confidence score accompanying the legal conclusion), identify its knowledge boundaries (e.g., actively express uncertainty when the input information is insufficient or beyond its ability), and learn the meta-cognitive behavior of the teacher model in similar situations. For example, when faced with a case lacking key facts, the student model should learn to explicitly express "need more information" like the teacher model, rather than making an uncertain judgment. This meta-cognitive training can improve the reliability and practicality of the student model in actual applications.

[0084] Finally, the student model is jointly optimized and fine-tuned. In this stage, all loss terms (fitting teacher output, rule compliance, multi-perspective consistency, meta-cognitive accuracy, etc.) are optimized simultaneously, and the enhanced negative sample set generated in step S2 is particularly used to consolidate the model's ability to distinguish between confusing points. Through this comprehensive optimization, the student model is balanced and optimized in various capabilities, ultimately obtaining a small legal professional model that has been distilled and optimized, has the ability to handle multi-modal input, and has been significantly enhanced in legal reasoning, rule following, multi-perspective thinking, and meta-cognition. Although the parameter quantity of this model is much smaller than that of the original large legal professional model, it can maintain a high level of legal professional ability, laying the foundation for subsequent terminal deployment.

[0085] Step S4: The multi-modal processing capable small legal professional model is subjected to lightweight processing using model compression techniques to adapt to the hardware environment of the terminal device, obtaining a lightweight small legal professional model, and deploying the lightweight small legal professional model to the target terminal device and integrating it into the local legal consultation application, obtaining a multi-modal legal consultation system that can run locally.

[0086] In this step, the small legal professional model obtained in step S3 needs to be further lightened to adapt to the hardware limitations of terminal devices such as personal computers, tablets or dedicated legal consultation devices. Although the model size has been greatly reduced through knowledge distillation, in order to achieve smooth operation on resource-limited terminal devices, a series of model compression techniques need to be applied. These techniques include weight quantization (converting model parameters from floating-point numbers to low-precision integer representations, reducing storage space and computational complexity), network pruning (identifying and removing neural connections and redundant parameters that have less impact on model performance), low-rank decomposition (decomposing large weight matrices into the product of multiple small matrices, reducing computational complexity), etc. While applying these compression techniques, the performance of the model on legal professional tasks needs to be continuously evaluated to ensure that the compression process does not significantly reduce the professional ability of the model. For example, a validation set containing typical legal consultation scenarios can be set up to test the model's performance in these scenarios after each round of compression, and only when the performance meets the preset threshold will the compression result be accepted.

[0087] At the same time, the inference speed, memory usage, CPU / GPU load and other performance indicators of the model need to be analyzed and evaluated in a simulated or real terminal device environment. These performance indicators are directly related to user experience, for example, if the model inference speed is too slow, the user may need to wait a long time to get a legal consultation reply; if the memory usage is too high, it may cause the device to run slowly or crash. Through these performance tests, the best balance between model compression degree and performance can be found to ensure that the model can meet the resource limitations of the terminal device while maintaining good response speed and stability.

[0088] Next, based on the lightened model version and the specific SDK (Software Development Kit) or API (Application Programming Interface) of the target terminal device, necessary model format conversion, operator compatibility adaptation and input / output interface encapsulation are carried out. Different terminal devices may support different model formats and computing frameworks, for example, mobile devices may need to convert the model to TensorFlow Lite or Core ML format, while some special devices may need a specific optimized format. Through appropriate format conversion and interface encapsulation, ensure that the model can be correctly called by the terminal application, and realize the complete processing flow from user input (text, image, etc.) to legal consultation output.

[0089] Then, the adapted model files, relevant dependent libraries, and necessary configuration files are packaged to build a deployment package that can be installed and run on the target terminal device. This deployment package should contain all necessary components, enabling end users to quickly deploy and use the legal consultation system through simple installation steps. Next, the deployment package is installed on the actual terminal device, and the model is integrated into the backend logic of the local legal consultation application. This application should provide a friendly user interface, allowing users to consult through various means such as text input of legal questions, uploading of contract scan images or evidence photos, and passing these multi-modal inputs to the backend legal professional model for processing.

[0090] Finally, a series of integration test cases are designed and executed, which should cover typical multi-modal legal consultation scenarios such as users uploading contracts through the App for analysis, inputting voice descriptions of cases with attached image evidence, etc. Through these tests, the functional integrity, response timeliness, and interaction correctness of the model in a real terminal environment are verified. At the same time, the effectiveness of the privacy protection mechanism of the system during local operation is verified, confirming that all multi-modal data (text, images, voice, etc.) input by users are processed locally, without uploading raw sensitive information to the cloud server, and that encryption measures during local storage and transmission of data are in place. After ensuring that privacy protection meets the requirements and passing all tests, the localized multi-modal legal consultation system running on terminal devices that can provide professional legal advice and protect user privacy is officially launched, providing users with convenient, professional, and secure legal consultation services.

[0091] Step S1 specifically includes the following sub-steps:

[0092] Step S11: Define evaluation dimensions and build multi-modal legal consultation test set. Based on large legal professional models, first-order logic (FOL) formalism definition, comparative learning (CL) framework, and knowledge of legal experts, first define the key dimensions for evaluating the professional capabilities of large legal professional models, such as the accuracy of legal concept understanding, the appropriateness of legal provision application, the logic of complex case reasoning, the relevance of case citation, and the comprehensive analysis ability of multi-modal information (such as key clauses in contract images, details in evidence photos), then collect and build a legal consultation test data set containing diversified text consultation, typical contract scan images, and representative evidence photos, etc. This data set will serve as the basis for subsequent evaluation.

[0093] Step S12: Large model behavior tracking based on information flow analysis. Based on the "standardized multi-modal legal consultation test dataset" output in sub-step S11 and the large legal professional model, through the design of specific input probes and the monitoring of the changes of internal activation values, the distribution of attention weights, and the transmission path of information between different network levels, etc. Information flow analysis techniques, track and record the internal information processing flow and key decision path of the large legal professional model when processing various samples in the multi-modal legal consultation test dataset, so as to deeply understand the response mechanism of the model to different legal problems.

[0094] Step S13: Large model interactive ability evaluation based on multi-round dialogue. Based on the "standardized multi-modal legal consultation test dataset" output in sub-step S11, "clear professional ability evaluation dimension list", and large legal professional model, a series of structured and open multi-round dialogue scenarios are designed and executed, which simulate real legal consultation process, gradually and deeply explore the model's ability in legal reasoning consistency, knowledge depth under questioning, and processing ability of ambiguous or contradictory information, etc. According to the preset evaluation dimensions, the performance of the model is recorded and scored.

[0095] Step S14: Formal expression of legal rules based on first-order logic (FOL). Based on authoritative legal texts (such as codes, judicial interpretations, guiding cases, etc.) and first-order logic (FOL) formalism definition, invite legal experts to participate, accurately and unambiguously structure and formalize the knowledge of core legal principles, constitutive elements, adjudication rules, etc. Through the elements of predicate, function, quantifier, etc. of first-order logic, a preliminary, machine-understandable legal rule library is constructed.

[0096] Step S15: Legal rule knowledge refinement and verification based on comparative learning (CL). Based on the "internal information flow analysis report" output in sub-step S12, "multi-round dialogue evaluation record and model ability score" output in sub-step S13, "preliminary legal rule library based on first-order logic formal expression" output in sub-step S14, and large legal professional model and authoritative legal knowledge source (such as judgment document database, legal expert system), use comparative learning (CL) framework, compare and analyze the output of large legal professional model in processing test dataset (including final answer and intermediate reasoning steps) with authoritative legal knowledge source and preliminary formalized legal rule in multiple dimensions, identify the consistent and inconsistent places of model output with authoritative knowledge, and verify and correct the preliminary legal rule library in reverse, while refining the effective rules implied in the large model and consistent with the authoritative knowledge, finally obtaining an evaluation report containing various professional ability indicators of the large legal professional model and a structured, verified and refined legal rule knowledge base.

[0097] In one specific embodiment, the internal information flow of the large legal professional model in processing the multi-modal legal consultation data is tracked by using an information flow analysis method, including:

[0098] Based on the multi-modal legal consultation data, a preset input probe is designed for the large legal professional model, and the internal activation value change and attention weight distribution are monitored to track the transmission path of information between different network levels, and internal information flow analysis data is obtained.

[0099] Based on the internal information flow analysis data, the performance of the large legal professional model in legal reasoning coherence and knowledge depth is gradually probed by simulating the real legal consultation process in combination with multi-round dialogue mode, and the professional ability evaluation report is obtained.

[0100] In one specific embodiment, the legal rules involved in the large legal professional model processing the multi-modal legal consultation data and dialogue evaluation process are structured by using first-order logic formalism, and the output of the legal professional model is compared with professional legal knowledge sources by using a comparative learning framework, including:

[0101] Based on professional legal texts and first-order logic formalism definition, legal principles and adjudication rules are structured by elements including predicates, functions and quantifiers, and a preliminary legal rule library is obtained.

[0102] Based on the preliminary legal rule library and the output of the large legal professional model in processing test data, the comparative learning framework is used to compare and analyze the output with professional legal knowledge sources in multiple dimensions, identify consistency and difference, and obtain the refined legal rule knowledge base.

[0103] Step S2 specifically includes the following sub-steps:

[0104] Step S21: Identify potential confusion points of the small model in legal concepts and rules. Based on the "refined legal rule knowledge base" and "large legal professional model professional ability evaluation report" output in step S1, as well as an untrained or preliminarily trained small distillation model and original multi-modal legal consultation data, first let the small model predict or reason on a part of representative multi-modal legal consultation data, then compare its output with the correct logic and rules revealed in the "refined legal rule knowledge base" and "large legal professional model professional ability evaluation report", and analyze where the small model is prone to confusion or error in specific legal concepts (such as the difference between "fraud" and "major misunderstanding"), rule application conditions (such as the starting point of different litigation time limits), and multi-modal information interpretation (such as incorrectly identifying key clauses from contract photos).

[0105] Step S22: Generate targeted negative samples based on the confusion-aware contrastive learning (CACL) mechanism. Based on the "list of small model potential confusion points" output in sub-step S21, the original multi-modal legal consultation data, and the pre-defined confusion-aware contrastive learning (CACL) mechanism definition (which emphasizes that when constructing contrastive learning samples, special attention should be paid to those sample pairs that are easily confused by the model), for each confusion point, screen or artificially construct deceptive negative samples from the original data. For example, if the model is easily confused between "intentional injury" and "inadvertent serious injury", construct cases containing similar case elements but different legal definitions as negative samples, or introduce minor but critical difference elements in image evidence to train the model to have more refined discrimination ability.

[0106] Step S23: Construct and traverse the legal case trajectory tree. Based on the "refined legal rule knowledge base" output in step S1 and the complex legal case samples in the original multi-modal legal consultation data, as well as the pre-defined legal case trajectory tree exploration strategy (which aims to represent the solution process of a complex case as a tree structure, where nodes represent case facts, evidence, applicable legal provisions or intermediate reasoning conclusions, and edges represent reasoning steps or decision branches), construct the corresponding case trajectory tree for each complex case, and traverse these trajectory trees through algorithms such as depth-first search, breadth-first search or search combined with heuristic information, to identify key decision nodes, multiple possible reasoning paths and the influence of different evidence combinations on the case outcome.

[0107] Step S24: Dynamically optimize the legal rule set and logical relationship for distillation. Based on the "enhanced negative sample set" output in sub-step S22, the "set of legal case trajectory trees and traversal analysis reports" output in sub-step S23, the "refined legal rule knowledge base" and "large legal professional model professional ability evaluation report" output in step S1, combined with the performance of the small model in handling enhanced negative samples and the complex case reasoning logic revealed by the legal case trajectory tree analysis, dynamically adjust and supplement the "refined legal rule knowledge base". For example, according to the trajectory tree analysis, if it is found that certain rules have application conflicts or ambiguous zones in certain situation combinations, the rules are refined or supplemented with exception clauses; if the small model continues to perform poorly in handling certain negative samples, the weight of related rules in the distillation process is strengthened or more explicit logical constraints are introduced, ultimately forming a set of dynamically optimized and enhanced legal rule sets and a set of dynamic distillation logic that adapts to complex case reasoning.

[0108] In this embodiment, the proposed confusion-aware contrastive learning (CACL) mechanism is a learning method specially designed for the concept confusion problem unique to the legal field. In actual implementation, the specific implementation of the CACL mechanism is as follows:

[0109] First, based on the confusion patterns exhibited by the small model in handling legal cases, a confusion matrix is constructed to record the frequency of confusion between pairs of legal concepts. For example, in the field of contract law, the concept pairs of "fraud" and "major misunderstanding", "manifest injustice" and "taking advantage of others" are easily confused; in the field of criminal law, the concept pairs of "intentional injury" and "inadvertent injury", "robbery" and "extortion" are also often misclassified. Through systematic analysis of these confusion patterns, the main weaknesses in the cognition of the small model can be identified.

[0110] Then, for each high-frequency confused concept pair, "hard pairs" are selected or constructed from the original data. These hard pairs are highly similar in surface features but belong to different categories in legal characterization. For example, two cases are constructed, both involving information asymmetry at the time of signing a contract, but one constitutes fraud (because there is subjective intent to conceal important information), and the other constitutes only major misunderstanding (because there is no evidence of intentional deception). These hard pairs are very close in feature space, but should be classified into different categories.

[0111] During training, the CACL mechanism uses a weighted contrastive loss function, giving higher weights to concept pairs with high confusion frequency. Specifically, when the model processes a sample, it not only learns to pull its feature representation closer to that of the same class samples (positive sample pairs), but also emphasizes pushing its feature representation away from that of easily confused class samples (hard negative sample pairs). This targeted contrastive learning approach effectively enhances the model's ability to distinguish subtle differences between legal concepts.

[0112] In addition, the CACL mechanism also introduces a dynamic difficulty adjustment strategy, dynamically adjusting the proportion and difficulty of hard examples according to the model's learning progress. In the early stages of training, relatively obvious distinguishing cases are provided; as training progresses, more challenging boundary cases are gradually introduced, which even legal professionals need to carefully analyze to correctly classify. Through this gradual learning strategy, the model can gradually establish an accurate understanding of legal concepts.

[0113] In a specific embodiment, the confusion-aware contrastive learning mechanism is used to identify the confusion points of the small distillation-ready model in legal concepts and rule application, including:

[0114] Based on the legal rule knowledge base and the professional ability assessment report, the small distillation-ready model is used to predict the multi-modal legal consultation data and output the prediction results, and the prediction results are compared and analyzed with the correct legal logic and rules to obtain a list of potential confusion points;

[0115] Based on the list of potential confusion points, combined with a confusion-aware contrast learning mechanism definition, filter or construct deceptive negative samples from the original data for each confusion point in the list of potential confusion points, train the discriminative ability of the model, and obtain an enhanced negative sample set for contrast learning.

[0116] In one specific embodiment, the reasoning path and key decision nodes of a complex legal case are analyzed using a legal case trajectory tree exploration strategy, including:

[0117] Based on the legal rule knowledge base, combined with a complex legal case sample, the case resolution process of the complex legal case sample is represented as a tree structure, where nodes represent case facts, evidence, and applicable legal provisions, and edges represent reasoning steps, obtaining a set of legal case trajectory trees;

[0118] Based on the set of legal case trajectory trees, the key decision nodes in the case handling process of the complex legal case sample, multiple reasoning paths, and the influence of different evidence combinations on the case outcome are identified by traversing the trajectory trees through a depth-first search algorithm, obtaining a trajectory tree traversal analysis report.

[0119] In the process of constructing the legal case trajectory tree, first, the rules and provisions related to a specific case need to be extracted from the legal rule knowledge base. For example, for a complex case involving a contract dispute, rules related to contract establishment, contract validity, breach of contract liability, and damage calculation need to be extracted. Then, the initial facts of the case are taken as the root node of the trajectory tree, and these initial facts usually include basic case information such as party information, contract signing time, and contract main clauses. Then, based on these initial facts, the branches of the trajectory tree are gradually constructed according to the logical order of legal reasoning. Each branch represents a possible reasoning path, and the nodes represent key fact determination, evidence evaluation, or legal provision application on that path. For example, in a contract dispute case, one branch may first determine whether the contract is established, then determine whether the contract is valid, then determine whether there is a breach of contract, and finally determine the responsibility bearing method. Another branch may consider whether the contract is voidable due to fraud, or whether it needs to be changed or terminated due to changed circumstances. In this way, the resolution process of the case is represented as a tree structure containing multiple paths, fully reflecting the complexity and diversity of case handling.

[0120] After constructing the set of legal case trajectory trees, it is necessary to systematically traverse and analyze these trajectory trees through algorithms. This embodiment uses the depth-first search (DFS) algorithm, starting from the root node of the trajectory tree, exploring a path all the way to the leaf node (i.e. the final conclusion of the case), then backtracking to the nearest branching point and continuing to explore other paths. This traversal method can completely explore each possible reasoning path, especially suitable for legal reasoning which needs to consider complete logical chains. During the traversal process, the access of each node, the transition probability between nodes and the integrity score of the path are recorded. Through these records, key decision nodes in the case handling process can be identified, which are usually branching points of multiple paths and represent important turning points in the case. For example, in a tort liability case, the judgment of "whether the behavior of the actor has fault" may be a key decision node, because it directly determines whether to apply the fault liability principle or the no-fault liability principle, and further affects the subsequent responsibility identification and compensation calculation.

[0121] The depth-first search algorithm not only can identify key decision nodes, but also can reveal the influence of different evidence combinations on the development of the case. During the traversal process, the system simulates the possible development paths of the case under different evidence combinations, and evaluates the influence and decisiveness of each evidence combination. For example, in a medical dispute case, if there are hospital medical records, patient medical records, expert opinions and other evidence, the system will analyze the possible different judgment results of the case under different evidence combinations (such as having expert opinions but no medical records, or having medical records but expert opinions are controversial, etc.). This analysis can help identify key evidence that has a decisive influence on the case outcome, providing important reference for subsequent knowledge distillation. At the same time, by comparing the reasoning logic and conclusions of different paths, potential logical conflicts or boundary conditions of rule application can be found, which have important value for optimizing the legal rule set and distilling logic.

[0122] Finally, the results of the trace tree analysis are compiled into a detailed trace tree analysis report. This report includes a description of the trace tree structure for each complex case, a list of key decision nodes, a comparison of multiple possible reasoning paths, an impact analysis of different evidence combinations, and the discovery of rule application boundaries or conflicts. This report not only visually demonstrates the complexity and diversity of legal reasoning, but also provides data support and theoretical basis for subsequent dynamic optimization of legal rule sets and logical relationships. For example, if the report shows that a particular legal rule may lead to inconsistent application results in different situations in a certain type of case, then when optimizing the legal rule set, the rules need to be refined or additional application conditions need to be added to ensure that the small model after distillation can correctly handle such complex situations. Through this systematic analysis based on the trace tree of the case, the accuracy and pertinence of legal knowledge distillation can be significantly improved, and the small model has stronger reasoning ability and adaptability when handling complex legal cases.

[0123] Step S3 specifically includes the following sub-steps:

[0124] Step S31: Construct a rule-enhanced distillation loss function. Based on the "dynamically optimized and enhanced legal rule set" and "dynamic distillation logic" output in step S2, as well as the large legal professional model (teacher model) and the small model to be distilled (student model), a distillation loss function containing multiple items is designed. In addition to the traditional items that require the student model to output to fit the teacher model output (such as soft label loss based on KL divergence, intermediate layer feature alignment loss), a "rule compliance loss term" is specially introduced. This rule compliance loss term calculates the penalty or reward according to whether the student model's reasoning process and final output comply with the rules defined in the "dynamically optimized and enhanced legal rule set" and the logical consistency required by the "dynamic distillation logic" when processing multi-modal input, thereby explicitly guiding the student model to learn and internalize these legal rules.

[0125] In this embodiment, the rule compliance loss term is a key innovation point in the knowledge distillation process, and its design purpose is to ensure that the small model not only imitates the output results of the teacher model, but also follows the inherent rules and logic of legal reasoning. In actual implementation, the rule compliance loss term is constructed as follows:

[0126] The rule compliance loss term is calculated based on the rules defined in the "dynamically optimized and enhanced legal rule set". These rules are represented as a series of logical conditions and reasoning relationships, such as "if condition A is met and condition B is met, then conclusion C should be drawn". In order to evaluate the compliance of the model output with these rules, a rule execution evaluator is designed, which receives the model's intermediate reasoning steps and final output, and checks whether it complies with the pre-defined legal rules.

[0127] Specifically, for each legal consultation sample, the system first determines the subset of rules applicable to the case. Then, for the reasoning process and conclusion generated by the student model, the rule execution evaluator calculates the degree of compliance in terms of the accuracy of rule trigger condition identification, the rationality of rule application order, the correctness of priority handling in multi-rule interaction, the ability to identify exceptions, and the consistency of the final conclusion with the expected results of the rules.

[0128] During training, the rule compliance loss term is combined with traditional distillation losses such as KL divergence loss. When the model's output violates key legal rules, the rule compliance loss produces a large penalty value, guiding the model to adjust its parameters to better follow legal rules. This explicit rule guidance mechanism enables the student model to master complex legal reasoning capabilities even with limited parameter quantities.

[0129] It is worth noting that the rule compliance loss term adopts a soft enforcement mechanism rather than a hard constraint. This means that the model still has some flexibility to handle edge cases or new situations not covered in the rule base. This design balances rule compliance and model innovation capabilities, allowing the system to maintain normativity while maintaining flexibility when facing complex and variable legal issues.

[0130] Step S32: Implement multi-perspective thinking-based distillation training. Based on the "rule-enhanced distillation loss function" output by sub-step S31, the large legal professional model, the small model to be distilled, the original multi-modal legal consultation data, and the preset multi-perspective thinking distillation enhancement algorithm (which may include labeling different legal role perspectives for training samples, such as plaintiff, defendant, and neutral third party, and requiring the student model to provide analysis under different perspectives, or learning the differentiated output of the teacher model under different perspectives), in the training process of knowledge distillation, guide the student model to analyze and predict the same legal problem or case from different preset legal perspectives (e.g., from the perspective of the prosecution's evidence advantage, the defense's evidence defects, and neutral judgment), and make it learn to fit the teacher model's judgment or reasoning process under these different perspectives.

[0131] Step S33: Implementing meta-cognition-aware distillation training. Based on the "preliminarily trained student model on multi-perspective analysis ability" output by sub-step S32, the "rule-enhanced distillation loss function" output by sub-step S31, the large-scale legal professional model, and the preset meta-cognition-aware distillation enhancement algorithm (which can include having the student model predict the confidence of its own output and comparing it with the confidence of the teacher model or the true accuracy; or training the student model to recognize the limitations of its own knowledge and output "need more information" or "cannot determine" when necessary), the knowledge distillation training is continued. At this stage, the student model is mainly trained to evaluate the reliability of its own judgment (for example, outputting a confidence score accompanying the legal conclusion), identify its knowledge boundaries (for example, actively expressing uncertainty when the input information is insufficient or beyond its ability), and learn the meta-cognitive behavior of the teacher model in similar situations (such as how the teacher model expresses the degree of confidence in its judgment).

[0132] Step S34: Joint optimization and model fine-tuning. Based on the "further trained student model on meta-cognitive ability" output by sub-step S33, the "rule-enhanced distillation loss function" output by sub-step S31, the "dynamically optimized and enhanced legal rule set" and "dynamic distillation logic" output by step S2, and the complete training data set containing the original multi-modal legal consultation data and the "enhanced negative sample set" generated by sub-step S22, the student model is subjected to the final joint optimization and fine-tuning. At this stage, all loss terms (fitting teacher output, rule compliance, multi-perspective consistency, meta-cognitive accuracy, etc.) are optimized simultaneously, and the enhanced negative sample set is particularly used to consolidate the model's ability to distinguish confusing points, ensuring that the model is balanced and optimized in all aspects. Finally, a small-scale legal professional model is obtained that has been distilled and optimized, has the ability to handle multi-modal input, and has been significantly enhanced in legal reasoning, rule following, multi-perspective thinking, and meta-cognition.

[0133] In actual implementation, the small-scale model to be distilled adopts a model structure based on the Transformer architecture, and its specific construction method is as follows:

[0134] In terms of model architecture design, the small distillation model adopts a 6-layer Transformer encoder structure, each layer containing 8 attention heads, with a hidden layer dimension of 512 and a feedforward neural network dimension of 2048. To adapt to the processing needs of multi-modal input, the model is designed with a dual-input channel: the text channel uses a combination of word embedding layer and position encoding; the image channel uses a convolutional neural network to extract visual features, followed by a feature mapping layer to project the image features into the same semantic space as the text features. The features of the two modalities are interactively fused through a multi-head attention mechanism, and finally output the prediction results through a linear layer and a Softmax layer. To improve the model's expression ability, residual connections and layer normalization are added between layers, and the activation function is ReLU, effectively alleviating the gradient vanishing problem.

[0135] In terms of training data, the multi-modal legal consultation dataset mainly comes from three channels: first, desensitized historical legal consultation records containing about 100,000 text question and answer pairs; second, about 20,000 scanned images of legal documents and contracts covering civil, commercial, criminal and other legal fields; third, about 5,000 evidence photos from simulated cases. All data are processed before use, including privacy information removal, text standardization, and image preprocessing (including size adjustment, light normalization, etc.). The dataset is divided into training set, validation set and test set in the ratio of 8:1:1 to ensure the generalization ability of the model.

[0136] During training, the main hyperparameter settings include: the initial learning rate is set to 0.0001, and the cosine annealing strategy is used for dynamic adjustment; the batch size is set to 64; the training epoch is 50 rounds, and an early stopping mechanism is set to stop training when the validation set loss does not improve for 5 consecutive rounds; the optimizer is Adam, where β1=0.9, β2=0.999, ε=1e-8; to prevent overfitting, weight decay regularization with a weight decay of 0.01 and a dropout rate of 0.1 are also applied. In the knowledge distillation process, the temperature coefficient is set to 2.5 to obtain a smoother soft label distribution.

[0137] To solve the "black box" problem, explainability enhancement techniques are used during the distillation process. Specifically, at each key reasoning node, the model is designed to output intermediate reasoning results and corresponding legal basis, forming a complete reasoning chain. In addition, through attention visualization technology, the model can show the text and image areas it focuses on when processing legal problems, making the reasoning process traceable and verifiable. In the model evaluation stage, in addition to the conventional indicators such as accuracy and recall, legal reasoning chain integrity score and legal rule compliance score are also introduced to comprehensively evaluate the professional ability of the model.

[0138] In one specific embodiment, the distillation loss function containing the rule compliance loss term is constructed, including:

[0139] Based on the optimized legal rule set and the dynamic distillation logic, a soft label loss term is designed for the small distillation model, so that the output of the small distillation model fits the output probability distribution of the large legal professional model, to obtain a basic distillation loss term;

[0140] Based on the basic distillation loss term, an intermediate layer feature alignment loss term is designed for the small distillation model, so that the small distillation model learns to fit the feature representation of the intermediate layer of the large legal professional model, to obtain a feature alignment loss term;

[0141] Based on the feature alignment loss term and the optimized legal rule set, a rule compliance loss term is designed for the small distillation model, which calculates a penalty or reward according to whether the inference process and output of the small distillation model comply with the legal rules, to obtain a rule constraint loss term;

[0142] Based on the rule constraint loss term and the dynamic distillation logic, a logic coherence loss term is designed for the small distillation model, for evaluating the logical consistency and reasoning coherence of its output, to obtain a logic consistency loss term;

[0143] Based on the basic distillation loss term, the feature alignment loss term, the rule constraint loss term and the logic consistency loss term, a comprehensive distillation loss function is constructed by weighted combination, to obtain the distillation loss function containing the rule compliance loss term.

[0144] In the first step of building the knowledge distillation loss function, a soft label loss term needs to be designed, which is a fundamental component of knowledge distillation. Soft labels refer to the probability distribution output by the teacher model (i.e., the large legal professional model), rather than just the hard label corresponding to the highest probability. In the legal field, this is particularly important because legal judgments are often not simple binary classification problems, but rather complex decisions involving multiple possibilities. For example, in judging a contract dispute case, the large model may output a probability distribution of different solutions, such as "the contract is valid and constitutes a breach of contract" with a probability of 0.7, "the contract is valid but does not constitute a breach of contract" with a probability of 0.2, and "the contract is invalid" with a probability of 0.1. This probability distribution contains the model's assessment of uncertainty in different legal paths and is very valuable knowledge. The soft label loss term usually uses the Kullback-Leibler divergence (KL divergence) to measure the difference between the probability distribution output by the student model and the probability distribution output by the teacher model. In implementation, a temperature parameter T is also introduced to adjust the "softness" of the soft label, and a higher temperature will make the probability distribution smoother, helping the student model learn the uncertainty knowledge of the teacher model. By minimizing this loss term, the student model can learn the overall judgment pattern of the teacher model on legal issues.

[0145] After ensuring that the student model can mimic the output distribution of the teacher model, attention needs to be paid to the feature representation learning within the model, which requires the design of an intermediate layer feature alignment loss term. The large legal professional model processes legal issues in the intermediate layers, forming rich feature representations that may capture abstract representations of legal concepts, key elements of case facts, or intermediate states of legal reasoning. By guiding the student model to learn these intermediate layer feature representations, the student model can better understand the internal structure of legal problems. In specific implementation, the feature mapping between the key intermediate layers of the teacher model (such as attention layers or specific encoder layers) and the corresponding layers of the student model can be selected, and then the mean square error (MSE) or cosine similarity can be used to calculate the difference between them. To address the problem that the teacher model and student model architectures may be different, an adapter layer is usually introduced to adjust the feature dimensions. In the legal field, special attention can be paid to intermediate layers related to legal concept understanding and reasoning, such as layers that capture the semantics of contract clauses when processing contract texts, or layers that extract key factual elements when analyzing case facts. By minimizing this loss term, the student model can better mimic the legal knowledge processing mechanism of the teacher model at the internal representation level.

[0146] Based on the first two loss terms, the core innovation of the present application is to introduce a rule compliance loss term, which is specially designed for legal knowledge distillation. Legal reasoning highly depends on the correct application of rules, and traditional knowledge distillation methods may not fully capture this rule dependency. The goal of the rule compliance loss term is to ensure that the student model not only mimics the teacher model in output, but also correctly applies legal rules. In specific implementation, first, the optimized legal rule set needs to be converted into a computable form, for example, a rule like "if conditions A and B are met, apply article C" is expressed as a logical function. Then, for each training sample, evaluate whether the student model's reasoning process and output comply with these rules. This evaluation can be achieved by checking the student model's attention distribution (whether it focuses on the rule-related keywords), intermediate reasoning steps (whether it follows the correct reasoning order), and final output (whether it draws a conclusion that complies with the rules). If the student model correctly applies the rules, it will be rewarded (loss reduction); if it violates the rules, it will be punished (loss increase). For example, when dealing with a case of liability for infringement, if the rule stipulates that "determining fault liability must first determine whether the actor has fault", but the student model directly skips the fault judgment and draws a conclusion of responsibility, it will be punished. This explicit rule constraint can guide the student model to internalize the legal rules, rather than just mimic the surface output.

[0147] After ensuring that the student model can correctly apply individual legal rules, attention needs to be paid to the logical coherence of the entire reasoning process, which requires the design of a logical coherence loss term. Legal reasoning is usually a multi-step process, with strict logical relationships between each step. For example, when determining contract breach of liability, it is necessary to first confirm the establishment of the contract, then judge whether the contract is valid, then judge whether there is a breach of contract, and finally determine the way of liability. The coherence of this reasoning chain is crucial to the correctness of legal judgment. The goal of the logical coherence loss term is to evaluate the logical consistency and reasoning coherence of the student model's output, ensuring that its reasoning process complies with the logical relationships defined in the dynamic distillation logic. In specific implementation, the reasoning process can be represented as a directed graph, with nodes representing reasoning steps and edges representing logical relationships between steps. Then, check whether the student model's reasoning path complies with the constraints of this directed graph. For example, if the student model directly judges the breach of liability before judging whether the contract is valid, it will be considered to violate the logical coherence. This check can be achieved by analyzing the student model's attention flow, intermediate state transitions, or explicit reasoning step outputs. By minimizing this loss term, the student model can learn the structured thinking way of legal reasoning, ensuring that it follows the correct logical order when dealing with complex legal problems.

[0148] Finally, the four loss terms mentioned above need to be combined into a comprehensive distillation loss function through weighted combination. This weighted combination is not simply an average, but needs to dynamically adjust the weights according to the importance of different loss terms and the training stage. For example, in the early stage of training, more attention may be paid to the basic distillation loss term and the feature alignment loss term to ensure that the student model can basically imitate the teacher model; while in the later stage of training, more attention may be paid to the rule constraint loss term and the logical consistency loss term to strengthen the legal rule application ability and reasoning coherence of the student model. In addition, different types of legal problems may require different weight configurations, for example, for contract law problems that rely heavily on rule application, the weight of the rule constraint loss term may be increased; while for tort cases that rely more on factual judgment, the weight of the feature alignment loss term may be increased. This dynamic weight adjustment strategy can make the distillation process more flexible and targeted, ultimately obtaining a small legal professional model that performs well in legal reasoning, rule application, and logical coherence. Through this comprehensive distillation loss function containing the rule compliance loss term, the invention can effectively transfer the knowledge of large legal professional models to small models, while ensuring that small models have the ability to correctly apply legal rules and conduct coherent reasoning, which is crucial for legal consultation scenarios.

[0149] In one specific embodiment, the training strategy of integrating multi-perspective thinking and meta-cognitive awareness in the distillation process includes:

[0150] Based on the distillation loss function containing the rule compliance loss term and the multi-modal legal consultation data, different legal role perspectives are labeled for the training samples, including the plaintiff perspective, the defendant perspective, and the neutral perspective, to obtain multi-perspective labeled training data;

[0151] Based on the multi-perspective labeled training data, the small-sized to-be-distilled model is trained to analyze from the perspective of the plaintiff's evidence advantage, learn to fit the judgment process of the large-sized legal professional model in the plaintiff's perspective, and obtain the plaintiff's perspective analysis ability;

[0152] Based on the plaintiff's perspective analysis ability, the small-sized to-be-distilled model is trained to analyze from the perspective of the defendant's evidence defects, learn to fit the reasoning process of the large-sized legal professional model in the defendant's perspective, and obtain the defendant's perspective analysis ability;

[0153] Based on the defendant's perspective analysis ability, the small-sized to-be-distilled model is trained to analyze from the perspective of neutral judgment, learn to fit the judgment logic of the large-sized legal professional model in the neutral perspective, and obtain the neutral perspective analysis ability;

[0154] Based on the plaintiff perspective analysis ability, the defendant perspective analysis ability and the neutral perspective analysis ability, the small distillation model is trained to integrate the analysis results of different perspectives through multi-perspective consistency constraints, so as to obtain a trained model with multi-perspective thinking ability.

[0155] In the legal field, multi-perspective thinking is a necessary ability for professionals, because legal issues usually involve multiple parties, each of which has its own position, interests and evidence support. An excellent legal professional needs to be able to analyze problems from different roles and fully evaluate all aspects of the case. In order to transfer this multi-perspective thinking ability to a small model, first of all, different legal role perspectives need to be labeled for training samples. Specifically, for each legal consultation case, three main perspectives need to be labeled: the plaintiff perspective (focusing on evidence and legal basis favorable to the plaintiff), the defendant perspective (focusing on defense reasons and evidence favorable to the defendant), and the neutral perspective (such as judicial staff, based on all evidence and law for objective judgment). This labeling can be done manually by legal experts adding multi-perspective labels to each case; it can also be done semi-automatically by first having a large legal professional model analyze the case from different perspectives, and then having legal experts review and correct it. For example, for a contract dispute case, the plaintiff perspective may focus on the clearly stated clauses in the contract and the defendant's breach of contract, the defendant perspective may focus on the flaws in the contract establishment process or force majeure factors, and the neutral perspective needs to weigh the evidence of both parties and apply relevant legal provisions for comprehensive judgment. Through this multi-perspective labeling, the training dataset is no longer single-dimensional, but contains rich role perspective information, laying the foundation for subsequent multi-perspective training.

[0156] After completing the multi-perspective labeling, the small distillation model is first trained to analyze from the plaintiff perspective. The training goal of this stage is to enable the small model to think like a lawyer representing the plaintiff, identifying and emphasizing evidence and legal basis favorable to the plaintiff. During the training process, the model needs to learn how to interpret the facts of the case from the plaintiff's point of view, identify the other party's possible illegal or breach of contract behavior, find legal provisions and precedents supporting the plaintiff's claims, and predict possible counterarguments and prepare countermeasures in advance. For example, in a tort case, the plaintiff perspective analysis will focus on the defendant's fault behavior, the evidence chain of causality and the severity of the damage consequences. In order to achieve this training, specific prompt words (such as "please analyze the following case from the plaintiff's perspective") can be used to guide the model output, and it is required to learn to fit the output of the large legal professional model under the same prompt. By minimizing the distillation loss under the plaintiff perspective, the small model gradually acquires the ability to analyze legal problems from the plaintiff's perspective, including identifying evidence advantages, constructing legal arguments and predicting possible judgment results.

[0157] After mastering the plaintiff's perspective analysis, the next step is to train the model to think from the defendant's perspective. The defendant's perspective is fundamentally different from the plaintiff's perspective, as it focuses on how to refute the plaintiff's claims, find factors that can reduce or eliminate legal liability, and propose procedural or substantive defenses. In this stage, the model needs to learn how to identify evidence defects, logical flaws, or legal application errors in the plaintiff's claims and propose strong refutation opinions. For example, in a contract dispute case, the defendant's perspective analysis may focus on whether the contract is valid, whether there are defects in the expression of intent such as fraud or coercion, whether there are factors of force majeure affecting performance, or whether the plaintiff also has a breach of contract. The training method is similar to the plaintiff's perspective, guiding the model to think from the defendant's perspective through specific prompts and allowing it to learn to fit the large model's output from the defendant's perspective. It is worth noting that the training in this stage is not simply negating the conclusions of the plaintiff's perspective, but requires the model to learn a different mode of thinking and examine the same case facts and legal application from another angle. Through this training, the small model can acquire the ability to analyze cases from the defendant's perspective, laying the foundation for a comprehensive understanding of legal issues.

[0158] After mastering the plaintiff's and defendant's opposing perspectives, the model also needs to learn to analyze from a neutral judge's perspective, which is one of the most important abilities for legal professionals. The neutral perspective is different from simply compromising or averaging the views of the plaintiff and the defendant, but requires the model to objectively evaluate all evidence, correctly apply legal rules, and give a fair judgment like a judicial staff. In this stage, the model needs to learn how to balance the claims and evidence of both parties, identify key dispute points, apply relevant legal provisions and judicial interpretations, and follow the legal rules and procedures for adjudication. For example, in a civil compensation case, the neutral perspective needs to objectively determine the facts, determine the subject of liability, judge the nature of liability (fault liability or no-fault liability), calculate the amount of compensation, and give the final judgment. The training method is also to guide the model to think from the neutral perspective through specific prompts and allow it to learn to fit the large model's judgment logic under the neutral perspective. This stage of training is particularly important because it not only requires the model to master legal knowledge and reasoning ability, but also requires it to have a fair and objective judgment attitude, which is crucial for providing reliable legal advice.

[0159] Finally, after the model has mastered the analysis capabilities of the plaintiff, defendant, and neutral perspectives, it needs to be trained to integrate the analysis results from different perspectives through multi-perspective consistency constraints. The goal of this stage is to enable the model to think from multiple angles on the same case and maintain logical consistency between these different perspectives. Multi-perspective consistency constraints require that the model's analysis under different perspectives, although with different focuses, should maintain consistency in the identification of basic facts, understanding of legal rules, and logic of reasoning processes. For example, the model cannot consider a piece of evidence to be authentic and valid in the plaintiff's perspective, but consider the same evidence to be fake in the defendant's perspective; it cannot make contradictory interpretations of the same legal provision under different perspectives. To achieve this training, a special loss function can be designed to evaluate the consistency of the model's output under three perspectives and penalize situations where logic is contradictory or facts are not consistent. Through this multi-perspective consistency constraint, the model can learn to switch between different perspectives while maintaining professionalism and logic, forming a comprehensive and balanced legal analysis capability.

[0160] The core value of this multi-perspective thinking training strategy lies in its ability to enable small legal professional models not only to provide single-angle legal analysis, but also to switch between different perspectives according to user needs, providing more comprehensive and practical legal consulting services. For example, when the user is a potential plaintiff, the model can analyze the case's win probability and evidence preparation strategy from the plaintiff's perspective; when the user is a potential defendant, the model can provide defense suggestions and risk assessment from the defendant's perspective; when the user needs an objective evaluation, the model can provide possible judgment predictions from a neutral perspective. This multi-perspective analysis capability greatly enhances the model's applicability and value in actual legal consulting scenarios, enabling it to provide more targeted and practical legal advice to users of different roles, and truly realizing personalized legal consulting services that "treat people differently."

[0161] In one specific embodiment, the training strategy that incorporates multi-perspective thinking and meta-cognitive awareness during the distillation process includes:

[0162] Based on the training model with multi-perspective thinking capability, a meta-cognitive awareness training algorithm is used to train the small-scale to-be-distilled model to predict the confidence score of its output and compare it with the confidence score of the large-scale legal professional model to learn confidence assessment capability;

[0163] Based on the confidence assessment capability, the small-scale to-be-distilled model is trained to identify situations where input information is insufficient or exceeds its capacity range, learn to output "need more information" when uncertain, and obtain knowledge boundary recognition capability;

[0164] Based on the knowledge boundary recognition ability, the small distillation model is trained to evaluate the reliability of its own judgment, learn the metacognition behavior of the large legal professional model expressing the degree of judgment grasp, and obtain self-evaluation ability;

[0165] Based on the self-evaluation ability, the small distillation model is trained to actively identify knowledge blind spots and seek supplementary information, learn cautious judgment strategies in complex legal problems, and obtain active learning ability;

[0166] Based on the confidence evaluation ability, the knowledge boundary recognition ability, the self-evaluation ability and the active learning ability, the metacognition consistency constraint is used to optimize the metacognition performance of the small distillation model, and the small legal professional model with multi-modal processing ability is obtained.

[0167] In the field of legal consultation, metacognition ability is as important as professional knowledge. An excellent legal professional not only needs to master rich legal knowledge, but also needs to clearly know what he knows, what he does not know, and how much he is sure about his judgment. This metacognition ability is crucial for providing responsible legal consultation, because wrong legal advice may lead to serious consequences. Therefore, after completing the training of multi-perspective thinking ability, this embodiment further integrates the training strategy of metacognition awareness, so that the small model can not only provide legal analysis, but also evaluate the reliability and limitations of its own analysis. First, a metacognition awareness training algorithm is used to train the small model to predict the confidence score of its own output. Specifically, for each legal consultation question, in addition to generating substantive legal analysis, the model also needs to output a confidence score between 0 and 1, indicating its degree of certainty about its analysis. For example, when facing a standard contract breach case with sufficient evidence, the model may give a high confidence of 0.95; while when facing a case involving emerging fields and ambiguous legal provisions, the model may only give a medium confidence of 0.60. In order to train this ability, the large legal professional model can first generate analysis results and corresponding confidence scores for a series of legal questions, and then train the small model to predict the confidence consistent with the large model through contrastive learning. This training not only requires the small model to learn when it should have high confidence and when it should have low confidence, but also requires it to understand the factors that affect confidence, such as evidence sufficiency, legal provision clarity, case complexity, etc.

[0168] After mastering basic confidence assessment, the next step is to train the small model to recognize situations where the input information is insufficient or beyond its capabilities. In real-life legal consultations, users often provide incomplete information, or the question may involve a specialized area that the model is not well-trained in. In these cases, it is responsible to explicitly state "more information is needed" or "this is beyond my expertise" rather than giving an uncertain answer. To train this ability to recognize knowledge boundaries, a series of special training samples can be constructed, such as cases where key facts are intentionally omitted, questions that involve highly specialized or emerging fields, or consultations that contain ambiguous or contradictory information. Then, the large legal professional model is shown how to recognize these situations and appropriately request additional information or express limitations of capability, and the small model learns this behavior through imitation. For example, when a user consults on a contract dispute without providing the contract content, the model should learn to respond "an accurate analysis cannot be given without seeing the original contract"; when a user consults on a highly specialized international tax law question, the model should learn to say "this involves the specialized field of international tax law, it is recommended to consult a professional tax lawyer." Through this training, the small model can develop the ability to recognize its own knowledge boundaries, which is crucial for providing responsible legal consultation.

[0169] Based on the confidence assessment and knowledge boundary recognition abilities, the small model is further trained to evaluate the reliability of its own judgments, which involves more complex metacognitive behaviors. In the legal field, the reliability of a judgment is not only dependent on the completeness of information, but also influenced by factors such as the clarity of legal provisions, the consistency of relevant cases, and the complexity of case facts. A model with self-evaluation ability should be able to analyze these factors and express the degree of confidence in its judgment in an appropriate manner. For example, the model may say "based on the existing legal provisions and cases, the court is likely (more than 90% confident) to support the plaintiff's claim" or "due to the interpretive space in relevant legal provisions and inconsistent judgments in similar cases, it is not possible to give a high degree of certainty, but there is a tendency (60% confident) to support the defendant's defense." To train this ability, the large legal professional model can be shown how to express the degree of confidence in its judgment in different situations, including using appropriate qualifiers (such as "very likely", "likely", "somewhat likely", etc.), explicitly pointing out the source of uncertainty, and providing multiple possible explanations or outcomes when necessary. The small model learns these expression patterns and gradually masters the ability to assess and express the reliability of its own judgments, making its legal consultation more professional and responsible.

[0170] On the basis of self-evaluation ability, higher-level metacognitive ability is to actively identify knowledge gaps and seek additional information, which reflects the cautious judgment strategy of legal professionals when facing complex problems. In actual legal practice, when professionals encounter unfamiliar fields or complex problems, they will actively consult relevant legal documents, consult professional colleagues or seek expert opinions, rather than making hasty judgments based on limited knowledge. In order to train this active learning ability, special training scenarios can be designed to simulate the multi-round interaction process of legal consultation. In these scenarios, the initial information is intentionally set to be incomplete or ambiguous, requiring the model to learn to ask questions actively to obtain key information or express the need to consult specific legal documents to give accurate answers. For example, when a user consults a problem involving special industry regulations, the model should learn to ask "Is there a specific regulatory provision or industry standard for that industry?" When faced with a complex problem that may involve the intersection of multiple legal fields, the model should learn to express "This problem involves the intersection of contract law and intellectual property law, I need to understand more about the specific content of intellectual property license clauses to give a comprehensive analysis." Through this training, small models can develop the ability to actively identify information needs and seek supplements, making them more cautious and professional when dealing with complex legal problems.

[0171] Finally, in order to ensure that small models perform consistently and coordinately in various metacognitive abilities, they are optimized as a whole through metacognitive consistency constraints. Metacognitive consistency requires the model's confidence assessment, knowledge boundary identification, self-evaluation expression, and information seeking behavior to maintain logical consistency. For example, if the model indicates low confidence in a certain judgment, its expression should be correspondingly cautious; if the model identifies insufficient information, it should actively seek additional information rather than give a low-confidence judgment. In order to achieve this consistency, special loss functions can be designed to evaluate the model's performance in different metacognitive dimensions and their consistency, and to punish inconsistent behavior. For example, if the model exhibits high confidence and high uncertainty at the same time, or claims to need more information while giving a definitive judgment, this inconsistency will be penalized. Through this metacognitive consistency constraint, small models can develop coordinated metacognitive abilities, making them perform more professionally, reliably and responsibly in legal consultation scenarios.

[0172] The core value of this training strategy that integrates meta-cognitive awareness is that it enables small legal professional models not only to provide legal analysis, but also to assess the reliability and limitations of their own analysis, and actively seek additional information or express uncertainty when necessary. This meta-cognitive ability is particularly important for legal consultation, as legal advice can directly affect users' important decisions and interests. Through this training, small models can increase the wisdom of judgment on the basis of knowledge, like professional legal personnel, know when to give certain advice, when to express caution and uncertainty, and when to need more information or professional support. This not only improves the quality and reliability of the legal consultation provided by the model, but also reduces the risk of misleading users, making it a more responsible and trustworthy legal assistant. Ultimately, through this meta-cognitive training, combined with the previous multi-perspective thinking ability, small models can develop comprehensive legal professional ability and provide high-quality, responsible legal consultation services on resource-constrained terminal devices.

[0173] Step S4 specifically includes the following sub-steps:

[0174] Step S41: Model lightweight and performance analysis. Based on the "small legal professional model" output in step S3 and the hardware specifications (such as CPU / GPU model, memory size, storage capacity) and software environment (operating system, dependent library version) of the target terminal device, use model compression techniques (such as weight quantization, network pruning, low-rank decomposition, etc.) to further lightweight the small legal professional model, and at the same time, analyze and evaluate its inference speed, memory occupancy, CPU / GPU load, etc. performance indicators in a simulated or real terminal device environment.

[0175] Step S42: Terminal adaptation and deployment package construction. Based on the "lightweight processed model version" and "performance analysis report" output in sub-step S41, and the specific SDK (software development kit) or API (application program interface) of the target terminal device, perform necessary model format conversion, operator compatibility adaptation, and input / output interface encapsulation to ensure that the model can be correctly called by the terminal application, then package the adapted model file, related dependent libraries, and necessary configuration files to build a deployment package that can be installed and run on the target terminal device.

[0176] Step S43: Localization deployment and integration testing. Based on the "complete deployment package" output in sub-step S42 and the actual target terminal device, install the deployment package on the terminal device and integrate the model into the backend logic of the local legal consultation application. Then, design and execute a series of integration test cases that cover typical multi-modal legal consultation scenarios (such as users uploading contracts for analysis by taking pictures through the App, inputting voice descriptions of the case and attaching picture evidence, etc.) to verify the functional integrity, responsiveness, and correct interaction with other modules of the application of the model in a real terminal environment.

[0177] Step S44: Privacy protection mechanism verification and system online. Based on the "legal consultation application successfully deployed on the target terminal device and completed preliminary integration testing" output in sub-step S43, focus on verifying whether the privacy protection mechanism of the system is effective during local operation, for example, confirming that all multi-modal data (text, images, voice, etc.) input by users are processed locally without uploading raw sensitive information to the cloud server, and whether the encryption measures for data storage and transmission are in place. After ensuring that privacy protection meets the requirements and passes all tests, the localized multi-modal legal consultation system running on the terminal device that can provide professional legal advice and protect user privacy is officially put online.

[0178] In this embodiment, the multi-modal legal consultation system has shown good performance and practical value in actual application. The following is a typical application case to illustrate its performance in handling real legal consultation scenarios:

[0179] In a contract dispute consultation case, the user uploaded a scanned image of a housing contract through the terminal device and inputted a consultation text about whether the delay in delivering the house by the developer can terminate the contract. The system first processes the contract image, identifies the key clauses, including the agreed delivery date, the calculation method of the late penalty, and the contract termination conditions. Then, the system combines the user's text description for multi-modal information fusion analysis.

[0180] From three legal perspectives: from the perspective of the home buyer (plaintiff), it is pointed out that the developer has obviously breached the contract, the delay time has exceeded the agreed tolerance period, and according to the relevant provisions of Article X of the Contract and the Judicial Interpretation of the Contract for Sale of Commercial Housing, the home buyer has the right to terminate the contract and claim compensation; from the perspective of the developer (defendant), the possible force majeure defense and its establishment conditions are analyzed; from the neutral judicial perspective, the sufficiency of evidence and the legal consequences of terminating the contract are comprehensively evaluated.

[0181] During the analysis process, the lack of information was identified, such as the lack of specific reason for the developer's delay, so in the conclusion, it is clearly stated that "based on the existing information, it is preliminarily judged that the user can cancel the contract, but the final conclusion still needs to be seen whether the developer can provide the proof of force majeure", which reflects the meta-cognition ability of the system.

[0182] The whole process of the case processing is completed locally on the user terminal, without transmitting the original text of the contract or user personal information to the cloud, effectively protecting the user privacy. The response time is controlled within 3 seconds, the CPU occupancy rate during running is not more than 40%, and the memory occupancy is about 200MB, which shows good terminal adaptation performance.

[0183] Through comparison test, the miniaturized legal professional model realized by the application achieves a professional score of 92% in handling such contract dispute cases as the large-scale legal professional model, and the model size is only 15% of the original model, fully proving the technical effect of the application in knowledge distillation.

[0184] In one specific embodiment, the miniaturized legal professional model with multi-modal processing capability is subjected to lightweight processing by using model compression technology to adapt to the hardware environment of the terminal device, including:

[0185] Based on the miniaturized legal professional model with multi-modal processing capability, combined with the hardware specifications of the target terminal device, the model parameters of the miniaturized legal professional model with multi-modal processing capability are converted from floating-point numbers to low-precision integer representations by using weight quantization technology, reducing the model storage space and calculation complexity, and obtaining quantized model parameters;

[0186] Based on the quantized model parameters, network pruning technology is used to identify and remove neuron connections and redundant parameters that have less impact on the model performance of the miniaturized legal professional model with multi-modal processing capability, while maintaining the core function of the model and reducing the parameter amount, and obtaining the pruned model structure;

[0187] Based on the pruned model structure, low-rank decomposition technology is used to decompose a large weight matrix into the product of multiple small matrices, reducing the calculation complexity and memory occupancy of the miniaturized legal professional model with multi-modal processing capability, and obtaining the decomposed model weight;

[0188] Based on the decomposed model weight, knowledge distillation technology is used to further compress the miniaturized legal professional model with multi-modal processing capability, while maintaining the accuracy of legal professional knowledge, and obtaining the compressed and optimized model version;

[0189] Based on the compression-optimized model version, performance indicators including inference speed, memory occupation and processor load are tested under a target terminal device environment to verify model adaptability, and a lightweight small legal professional model is obtained.

[0190] In one specific embodiment, the lightweight small legal professional model is deployed to a target terminal device and integrated into a local legal consultation application, including:

[0191] Based on the lightweight small legal professional model and a software development kit of the target terminal device, model format conversion and operator compatibility adaptation are performed to ensure that the lightweight small legal professional model can be correctly called by the local legal consultation application of the target terminal device, and an adapted model file is obtained.

[0192] Based on the adapted model file, a deployment package that can be installed and run on the target terminal device is constructed by packaging the model file, related dependent libraries and configuration files, and a multi-modal legal consultation system that can run locally is obtained.

[0193] Please refer to Figure 2 , Figure 2 The structure diagram of the multi-modal knowledge distillation system for legal consultation provided by the embodiments of the present application is shown in FIG. 1. Figure 2 As shown in FIG. 1, the system includes:

[0194] The professional ability evaluation module 201 is configured to obtain a large legal professional model and multi-modal legal consultation data, track the internal information flow of the large legal professional model processing the multi-modal legal consultation data using an information flow analysis method, evaluate the professional ability of the large legal professional model in legal reasoning and case analysis in combination with a multi-round dialogue mode, structure the legal rules involved in the process of the large legal professional model processing the multi-modal legal consultation data and dialogue evaluation using a first-order logic formalism, and compare the output of the legal professional model with a professional legal knowledge source using a comparative learning framework to obtain a professional ability evaluation report and a refined legal rule knowledge base.

[0195] The dynamic optimization module 202 is configured to identify confusion points of a small model to be distilled in terms of legal concepts and rule application using a confusion-aware contrastive learning mechanism based on the legal rule knowledge base and the professional ability evaluation report, analyze the reasoning path and key decision nodes of a complex legal case using a legal case trajectory tree exploration strategy, and dynamically adjust and optimize the legal rule set and the logical relationship of the legal rule knowledge base to obtain an optimized legal rule set and a dynamic distillation logic.

[0196] The knowledge distillation module 203 is configured to construct a distillation loss function containing a rule compliance loss term based on the optimized legal rule set and the dynamic distillation logic, and perform knowledge distillation training on the small legal professional model by taking the large legal professional model as a teacher model, and in the distillation process, a multi-perspective thinking and meta-cognition awareness training strategy is adopted to obtain a small legal professional model with multi-modal processing capability.

[0197] The terminal deployment module 204 is configured to perform lightweight processing on the small legal professional model with multi-modal processing capability by using a model compression technology to adapt to the hardware environment of a terminal device, obtain a lightweight small legal professional model, and deploy the lightweight small legal professional model to a target terminal device and integrate the lightweight small legal professional model into a local legal consultation application to obtain a multi-modal legal consultation system capable of local operation.

[0198] The above merely describes the preferred embodiments of the present application but should not be used to limit the present application. Various modifications and changes can be made by those skilled in the art within the spirit and principle of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A multimodal knowledge distillation method for legal consultation, characterized in that, Includes the following steps: This process involves acquiring a large-scale legal professional model and multimodal legal consultation data. Information flow analysis is used to trace the internal information flow of the large-scale legal professional model in processing the multimodal legal consultation data. A multi-turn dialogue approach is used to evaluate the model's professional capabilities in legal reasoning and case analysis. Furthermore, the legal rules involved in the model's processing of the multimodal legal consultation data and the dialogue evaluation process are structured using first-order logical formalism. A comparative learning framework is then used to compare the model's output with professional legal knowledge sources, resulting in a professional capability assessment report and a refined legal rule knowledge base. Based on the legal rule knowledge base and the professional competence assessment report, the confusion perception contrastive learning mechanism is used to identify the confusion points of small distillation models in terms of legal concepts and rule application. The legal case trajectory tree exploration strategy is used to analyze the reasoning path and key decision nodes of complex legal cases. The legal rule set and its logical relationship in the legal rule knowledge base are dynamically adjusted and optimized to obtain the optimized legal rule set and dynamic distillation logic. Based on the optimized legal rule set and the dynamic distillation logic, a distillation loss function containing a rule compliance loss term is constructed. The large-scale legal professional model is used as a teacher model to train the small model to be distilled with knowledge distillation. In the distillation process, training strategies of multi-perspective thinking and metacognitive awareness are incorporated to obtain a small-scale legal professional model with multimodal processing capabilities. The small legal professional model with multimodal processing capability is lightweighted by model compression technology to adapt to the hardware environment of the terminal device, resulting in a lightweight small legal professional model. The lightweight small legal professional model is then deployed to the target terminal device and integrated into the local legal consultation application to obtain a multimodal legal consultation system that can run locally. The method of using legal case trajectory trees to explore and analyze the reasoning paths and key decision nodes of complex legal cases includes: Based on the aforementioned legal rule knowledge base, and combined with complex legal case samples, the case resolution process of the complex legal case samples is represented as a tree structure, where nodes represent case facts, evidence, and applicable legal provisions, and edges represent reasoning steps, resulting in a set of legal case trajectory trees; Based on the legal case trajectory tree set, the trajectory tree is traversed using a depth-first search algorithm to identify key decision nodes, multiple reasoning paths, and the impact of different evidence combinations on the case outcome in the case handling process of the complex legal case sample, and to obtain a trajectory tree traversal analysis report.

2. The method according to claim 1, characterized in that, The method of using information flow analysis to trace the internal information process of the large-scale legal professional model in processing the multimodal legal consultation data includes: Based on the multimodal legal consultation data, a preset input probe is designed for the large-scale legal professional model, and its internal activation value changes and attention weight distribution are monitored. The transmission path of information between different network layers is tracked to obtain internal information flow analysis data. Based on the internal information flow analysis data, and combined with multi-round dialogue to simulate a real legal consultation process, the performance of the large-scale legal professional model in terms of legal reasoning coherence and knowledge depth is gradually explored, resulting in the professional capability assessment report.

3. The method according to claim 1, characterized in that, The simultaneous processing of multimodal legal consultation data and dialogue evaluation processes by the large-scale legal professional model employs first-order logical formalism for structured expression of legal rules, and uses a comparative learning framework to compare the output of the legal professional model with professional legal knowledge sources, including: Based on professional legal texts and first-order logical formalism definitions, legal principles and adjudication rules are expressed in a structured manner by including elements such as predicates, functions, and quantifiers, resulting in a preliminary legal rule library; Based on the preliminary legal rule base and the output results of the large-scale legal professional model when processing test data, a comparative learning framework is used to conduct a multi-dimensional comparative analysis of the output results with professional legal knowledge sources to identify consistency and differences, thereby obtaining the refined legal rule knowledge base.

4. The method according to claim 1, characterized in that, The confusion-aware contrastive learning mechanism is used to identify confusion points in the application of legal concepts and rules in small distillation models, including: Based on the legal rule knowledge base and the professional competence assessment report, the small-scale distillation model is used to predict the multimodal legal consultation data and output the prediction results. The prediction results are compared and analyzed with the correct legal logic and rules to obtain a list of potential confusion points. Based on the list of potential confusion points, and in conjunction with the definition of the confusion-aware contrastive learning mechanism, for each confusion point in the list of potential confusion points, deceptive negative samples are selected or constructed from the original data to train the model's discrimination ability, thereby obtaining an enhanced negative sample set for contrastive learning.

5. The method according to claim 1, characterized in that, The construction of the distillation loss function, which includes a rule compliance loss term, includes: Based on the optimized legal rule set and the dynamic distillation logic, a soft-label loss term is designed for the small model to be distilled, so that the output of the small model to be distilled fits the output probability distribution of the large legal professional model, and the basic distillation loss term is obtained. Based on the basic distillation loss term, an intermediate layer feature alignment loss term is designed for the small model to be distilled, so that the small model to be distilled learns to fit the feature representation of the intermediate layer of the large legal professional model, thus obtaining the feature alignment loss term. Based on the feature alignment loss term and the optimized legal rule set, a rule compliance loss term is designed for the small model to be distilled. The rule compliance loss term calculates the penalty or reward based on whether the reasoning process and output of the small model to be distilled comply with the legal rules, thus obtaining the rule constraint loss term. Based on the rule constraint loss term and the dynamic distillation logic, a logical coherence loss term is designed for the small model to be distilled, which is used to evaluate the logical consistency and reasoning coherence of its output, and a logical consistency loss term is obtained. Based on the basic distillation loss term, the feature alignment loss term, the rule constraint loss term, and the logical consistency loss term, a comprehensive distillation loss function is constructed by weighted combination, resulting in the distillation loss function that includes the rule compliance loss term.

6. The method according to claim 1, characterized in that, The training strategies that incorporate multi-perspective thinking and metacognitive awareness into the distillation process include: Based on the distillation loss function containing the rule compliance loss term and the multimodal legal consultation data, different legal role perspectives, including the plaintiff's perspective, the defendant's perspective, and the neutral perspective, are labeled for the training samples to obtain multi-perspective labeled training data. Based on the training data labeled with the multi-perspective, the small model to be distilled is trained to analyze the same legal issue from the perspective of the plaintiff's evidence advantage, and learns to fit the judgment process of the large legal professional model from the plaintiff's perspective, thereby obtaining the plaintiff's perspective analysis capability. Based on the plaintiff's perspective analysis capability, the small model to be distilled is trained to analyze from the perspective of the defendant's evidence defects, and learns to fit the reasoning process of the large legal professional model from the defendant's perspective, thus obtaining the defendant's perspective analysis capability. Based on the defendant's perspective analysis capability, the small model to be distilled is trained to analyze from the perspective of a neutral judge, and learns to fit the judgment logic of the large legal professional model from a neutral perspective, thus obtaining the neutral perspective analysis capability. Based on the plaintiff's perspective analysis capability, the defendant's perspective analysis capability, and the neutral perspective analysis capability, the small distillation model is trained by multi-perspective consistency constraints to integrate the analysis results from different perspectives, thereby obtaining a training model with multi-perspective thinking capability.

7. The method according to claim 6, characterized in that, The training strategies that incorporate multi-perspective thinking and metacognitive awareness into the distillation process include: Based on the training model with multi-perspective thinking ability, a metacognitive awareness training algorithm is used to train the small distillation model to predict its own output confidence score, and compare it with the confidence score of the large legal professional model to obtain the confidence assessment ability. Based on the confidence assessment capability, the small distillation model is trained to identify situations where the input information is insufficient or exceeds its capability range, and learns to output the judgment "more information is needed" when there is uncertainty, thereby obtaining the knowledge boundary recognition capability. Based on the knowledge boundary recognition capability, the small distillation model is trained to assess the reliability of its own judgment, and the large legal professional model is learned to express the metacognitive behavior of the degree of judgment mastery, thereby obtaining self-assessment ability. Based on the self-assessment ability, the small distillation model is trained to actively identify knowledge blind spots and seek supplementary information, learn prudent judgment strategies in complex legal issues, and obtain active learning ability. Based on the confidence assessment capability, the knowledge boundary identification capability, the self-assessment capability, and the active learning capability, the metacognitive performance of the small model to be distilled is optimized through metacognitive consistency constraints, thereby obtaining the small legal professional model with multimodal processing capabilities.

8. The method according to claim 1, characterized in that, The process of using model compression technology to lightweight the small legal professional model with multimodal processing capabilities to adapt it to the hardware environment of the terminal device includes: Based on the small legal professional model with multimodal processing capabilities, and combined with the hardware specifications of the target terminal device, the model parameters of the small legal professional model with multimodal processing capabilities are converted from floating-point numbers to low-precision integer representation using weight quantization technology, thereby reducing model storage space and computational complexity, and obtaining quantized model parameters. Based on the quantized model parameters, network pruning technology is used to identify and remove neural connections and redundant parameters that have little impact on the model performance of the small legal professional model with multimodal processing capabilities, while maintaining the core function of the model and reducing the number of parameters, to obtain the pruned model structure. Based on the pruned model structure, a low-rank decomposition technique is used to decompose the large weight matrix into the product of multiple small matrices, thereby reducing the computational complexity and memory usage of the small legal professional model with multimodal processing capabilities, and obtaining the decomposed model weights. Based on the decomposed model weights, the knowledge distillation technique is used to further compress the small legal professional model with multimodal processing capabilities, while maintaining the accuracy of legal professional knowledge, to obtain a compressed and optimized model version. Based on the compressed and optimized model version, performance indicators including inference speed, memory usage, and processor load were tested in the target terminal device environment to verify the model's adaptability and obtain the lightweight small legal professional model.

9. The method according to claim 1, characterized in that, The process of deploying the lightweight, small-scale legal professional model to the target terminal device and integrating it into the local legal consultation application includes: Based on the lightweight small legal professional model and the software development kit of the target terminal device, model format conversion and operator compatibility adaptation are performed to ensure that the lightweight small legal professional model can be correctly called by the local legal consultation application of the target terminal device to obtain the adapted model file. Based on the adapted model file, the model file, related dependency libraries, and configuration files are packaged to build a deployment package that can be installed and run on the target terminal device, thus obtaining the multimodal legal consultation system that can run locally.

10. A multimodal knowledge distillation system for legal consultation, characterized in that, include: The professional competence assessment module is used to acquire large-scale legal professional models and multimodal legal consultation data. Information flow analysis is used to track the internal information flow of the large-scale legal professional model in processing the multimodal legal consultation data. Multi-turn dialogue is combined to assess the professional competence of the large-scale legal professional model in legal reasoning and case analysis. Simultaneously, the legal rules involved in the large-scale legal professional model's processing of the multimodal legal consultation data and the dialogue assessment process are structured using first-order logical formalism. A comparative learning framework is used to compare the output of the legal professional model with professional legal knowledge sources, resulting in a professional competence assessment report and a refined legal rule knowledge base. The dynamic optimization module, based on the legal rule knowledge base and the professional competence assessment report, uses a confusion-aware contrastive learning mechanism to identify confusion points in legal concepts and rule application in small-scale distillation models. It then uses a legal case trajectory tree exploration strategy to analyze the reasoning paths and key decision nodes of complex legal cases. Finally, it dynamically adjusts and optimizes the legal rule set and its logical relationships within the legal rule knowledge base to obtain an optimized legal rule set and dynamic distillation logic. The step of using the legal case trajectory tree exploration strategy to analyze the reasoning paths and key decision nodes of complex legal cases includes: Based on the aforementioned legal rule knowledge base, and combined with complex legal case samples, the case resolution process of the complex legal case samples is represented as a tree structure, where nodes represent case facts, evidence, and applicable legal provisions, and edges represent reasoning steps, resulting in a set of legal case trajectory trees; Based on the legal case trajectory tree set, the trajectory tree is traversed using a depth-first search algorithm to identify key decision nodes, multiple reasoning paths, and the impact of different evidence combinations on the case outcome in the case handling process of the complex legal case sample, and to obtain a trajectory tree traversal analysis report. The knowledge distillation module is used to construct a distillation loss function containing a rule compliance loss term based on the optimized legal rule set and the dynamic distillation logic, and to use the large legal professional model as a teacher model to train the small model to be distilled with knowledge distillation. The training strategy of multi-perspective thinking and metacognitive awareness is incorporated into the distillation process to obtain a small legal professional model with multimodal processing capabilities. The terminal deployment module is used to perform lightweight processing on the small legal professional model with multimodal processing capabilities using model compression technology to adapt it to the hardware environment of the terminal device, thereby obtaining a lightweight small legal professional model. The lightweight small legal professional model is then deployed to the target terminal device and integrated into the local legal consultation application to obtain a multimodal legal consultation system that can run locally.

Citation Information

Patent Citations

  • Intelligent auxiliary handling method for legal affairs and multi-agent system

    CN120256605A

  • Immersive law education system based on artificial intelligence

    CN120258150A