A method and device for identifying risks of intelligent contracts based on a large language model

By constructing a legal knowledge graph and a risk case database, and combining large language models and reinforcement learning, the problems of high labor costs, low efficiency, and insufficient accuracy in existing contract review technologies have been solved, achieving efficient, reliable, and interpretable contract risk identification.

CN121706743BActive Publication Date: 2026-08-25BEIJING YULORE INNOVATION TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610187617.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-02-10
Publication Date
2026-08-25
Estimated Expiration
2046-02-10

AI Technical Summary

Technical Problem

Existing contract review technologies suffer from high labor costs, low efficiency, lack of unified standards, superficial analysis results, insufficient accuracy of single model architectures, and poor system interpretability.

Method used

We construct an intelligent contract risk identification system based on a large language model. By combining legal knowledge graphs and risk case databases with OCR recognition, text cleaning and standardization processing, we conduct parallel risk identification and analysis. We use graph traversal algorithms and correlation calculations for deep reasoning analysis and optimize the model through reinforcement learning.

Benefits of technology

It improves the accuracy and professionalism of contract risk identification, enhances the stability and reliability of the system, makes the risk identification results more reliable and interpretable, forms a closed-loop optimization mechanism, and continuously improves model performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121706743B_ABST
    Figure CN121706743B_ABST
Patent Text Reader

Abstract

The application provides a smart contract risk identification method and device based on a large language model, which constructs a legal knowledge graph and a risk case library, performs structured processing on a contract text, performs preliminary risk evaluation by using a joint large language model, performs deep reasoning and case verification in combination with the knowledge graph, generates a final report containing a risk type, a confidence, a reasoning chain and a modification suggestion, and continuously optimizes the model through user feedback data, so that efficient, accurate, interpretable and self-adaptive optimization of contract risk identification are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and legal technology, and in particular to an intelligent contract risk identification system and method based on a large language model, which is used to automatically identify potential risks in contract texts, provide legal basis and modification suggestions, and assist legal personnel in contract review. Background Technology

[0002] Contract risk identification and analysis is an important research direction in the field of legal technology. With the development of artificial intelligence technology, applying intelligent technology to contract review has become an industry trend. Traditional contract review mainly relies on manual operation, with lawyers or legal personnel manually reading contract texts, identifying potential risks, and providing modification suggestions. This method is inefficient when handling a large number of contracts and is prone to errors or omissions due to human factors.

[0003] Existing contract review technologies mainly fall into two categories: rule engine-based methods and simple machine learning models. Rule engine-based methods identify risk clauses in contracts through predefined rule sets, but lack flexibility and struggle to cope with diverse contract content. Simple machine learning models, such as text classifiers, can automatically identify some risk types, but lack a deep understanding of complex legal contexts.

[0004] Recent intelligent contract review systems have begun to explore the application of natural language processing (NLP) technology to identify risky clauses by extracting textual features. These systems typically employ a single model architecture, using a pre-trained language model to vectorize the contract text and then a classifier to determine the risk level of the clauses. However, this approach lacks the integration of specialized legal knowledge, struggles with in-depth reasoning and analysis, and performs poorly when handling multi-format contracts and non-standardized texts.

[0005] The main problems with existing technologies include: high labor costs and low efficiency, which cannot meet the needs of large-scale contract review; lack of unified standards leading to inconsistent review results; lack of deep integration of legal expertise into the technical model, resulting in superficial analysis results; single model architecture making it difficult to guarantee the accuracy and reliability of identification results; and lack of interpretability of the system, making it difficult for users to understand the basis and logical reasoning process of risk identification. Summary of the Invention

[0006] The purpose of this invention is to provide an intelligent contract risk identification system and method based on a large language model, aiming to solve the technical problems existing in the current contract risk identification technology, such as high labor costs, low efficiency, lack of unified standards, superficial analysis results, insufficient accuracy of single model architecture, and poor system interpretability.

[0007] To achieve the above objectives, this invention provides a method for identifying intelligent contract risks based on a large language model, comprising the following steps:

[0008] Based on existing legal text resources, a legal knowledge graph and a risk case database are constructed through entity extraction and relationship establishment;

[0009] Receive the contract document to be identified, and obtain structured contract text data through OCR recognition, text cleaning, segmentation and standardization processing;

[0010] Based on the structured contract text data, parallel risk identification and analysis are performed using a joint large language model. Preliminary risk assessment results are obtained through a unified prompt word template and weighted fusion calculation.

[0011] Based on the preliminary risk assessment results and the legal knowledge graph, deep reasoning analysis is performed using graph traversal algorithms and correlation calculations to obtain deep analysis results that include risk type, confidence level, reasoning chain, and modification suggestions.

[0012] Based on the in-depth analysis results and the risk case library, risk analogy analysis is performed through similarity calculation and case reasoning to obtain a complete risk report verified by the cases;

[0013] The complete risk report is displayed through a visual interface and user feedback is received. User feedback data is recorded to obtain a labeled dataset for model training. The feedback includes confirmation of the report or suggestions for correction.

[0014] Based on the labeled dataset, a reinforcement learning strategy is adopted, with the risk identification accuracy as the reward signal, to update and optimize the parameters of the joint large language model, resulting in the optimized joint large language model.

[0015] This invention also provides an intelligent contract risk identification device based on a large language model, comprising:

[0016] The module is used to build a legal knowledge graph and risk case library based on existing legal text resources through entity extraction and relationship establishment;

[0017] The recognition module receives the contract document to be recognized and obtains structured contract text data through OCR recognition, text cleaning, segmentation and standardization.

[0018] The assessment module is used to perform parallel risk identification and analysis based on the structured contract text data and a joint large language model, and to obtain preliminary risk assessment results through unified prompt word templates and weighted fusion calculations.

[0019] The deep analysis module is used to perform deep reasoning analysis based on the preliminary risk assessment results and the legal knowledge graph, through graph traversal algorithm and correlation calculation, to obtain deep analysis results including risk type, confidence level, reasoning chain and modification suggestions;

[0020] The report generation module is used to perform risk analogy analysis based on the deep analysis results and the risk case library, through similarity calculation and case reasoning, to obtain a complete risk report verified by the cases.

[0021] The visualization module is used to display the complete risk report based on the visualization interface and receive user feedback operations, record user feedback data, and obtain a labeled dataset for model training. The feedback operations include confirmation of the report or suggestions for correction.

[0022] The model optimization module is used to update and optimize the parameters of the joint large language model based on the labeled dataset, using a reinforcement learning strategy and risk identification accuracy as a reward signal, to obtain the optimized joint large language model.

[0023] The beneficial effects of the intelligent contract risk identification method and device based on large language models provided by this invention include: First, by constructing a legal knowledge graph and a risk case database, professional legal knowledge is integrated to improve the accuracy and professionalism of risk identification; second, a multi-model collaborative framework is adopted, combining the advantages of multiple large language models to improve the stability and reliability of the system; third, deep reasoning based on knowledge graphs and analogical analysis based on cases make the risk identification results more reliable and interpretable; fourth, through human-computer interaction and feedback collection, the system can continuously learn and optimize, forming a closed-loop optimization mechanism; and fifth, a reinforcement learning strategy is adopted, using the accuracy of risk identification as a reward signal to continuously improve model performance. Attached Figure Description

[0024] Figure 1 This is a schematic diagram of the overall process of the smart contract risk identification method of the present invention;

[0025] Figure 2 This is a schematic diagram of the intelligent contract risk identification device of the present invention. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0027] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to specific embodiments and accompanying drawings.

[0028] like Figure 1 As shown, this invention provides a method for identifying intelligent contract risks based on a large language model, comprising the following steps:

[0029] S1: Based on existing legal text resources, construct a legal knowledge graph and risk case database through entity extraction and relationship establishment.

[0030] This step is a foundational component of the entire intelligent contract risk identification system, aiming to establish a professional legal knowledge framework to provide knowledge support for subsequent risk analysis. First, the system collects a large amount of legal provisions, judicial interpretations, judicial precedents, industry standards, and historical contract samples through professional legal database API interfaces (such as Peking University Law Database and Wusong Cases) and publicly available legal text resources (such as the China Legal Information Network and the websites of publicly available judgments from courts at all levels). This raw legal text data undergoes data cleaning processing, including removing irrelevant information, standardizing formats, correcting typos and formatting issues, ultimately forming a standardized legal text dataset, laying the foundation for subsequent knowledge extraction.

[0031] Based on standardized legal text, the system applies named entity recognition technology for deep analysis to identify various legal entities. Specifically, it employs deep learning models such as BiLSTM-CRF or BERT-NER to automatically extract key legal entities from the text, including legal clauses, rights and obligations, and subject qualifications. Simultaneously, the system uses relation extraction algorithms, such as remote supervision methods or relation classifiers based on pre-trained language models, to automatically identify various relationships between legal entities, including "citation relationships" (e.g., which legal provisions a clause cites), "restrictive relationships" (e.g., a clause restricts the rights of a subject), and "conflict relationships" (e.g., a clause conflicts with a legal provision). Through this process, the system transforms unstructured legal text into a structured set of legal entity-relationship triples.

[0032] Based on extracted legal entity and relation triples, the system uses graph database technology (such as Neo4j) to construct a multi-layered legal knowledge graph. This knowledge graph comprises three main layers: the legal provisions layer (stores legal and regulatory clauses and their relationships), the case layer (stores judicial precedents and their association with legal provisions), and the contract clause layer (stores typical contract clause templates and their legal basis). The system establishes nodes for each entity and edges for relationships between entities, forming a complete network structure. A dedicated graph query interface has been developed to support complex path queries and semantic reasoning. This structure enables the system to quickly locate relevant legal knowledge and perform legal reasoning.

[0033] Alongside the construction of the legal knowledge graph, the system also built a dedicated risk case database. By analyzing a large number of historical contract dispute cases, the system extracts the risk points and ultimate legal consequences, establishing a mapping relationship of "contract clause - risk type - consequence". For example, the system may identify a case pattern such as "a certain disclaimer clause was deemed invalid by the court in an actual dispute, resulting in liability for compensation". To improve retrieval efficiency, the system uses vectorization methods such as BERT or Word2Vec to represent each case as a high-dimensional feature vector, supporting subsequent similarity-based case retrieval and analysis.

[0034] Finally, based on the legal knowledge graph and risk case database, a complete contract risk classification system and assessment rules were designed. The risk classification system includes multiple dimensions such as liability risk, performance risk, compliance risk, and interpretation risk; the assessment rules include risk judgment criteria such as "if a clause completely exempts one party from liability without equivalent conditions, it is considered high-risk." The system uses the Cypher query language to write knowledge graph reasoning rules, supporting automatic reasoning from legal knowledge to risk assessment. These classification systems and rule sets will provide standardized evaluation criteria for subsequent risk identification and analysis.

[0035] Through the above steps, the system establishes a complete knowledge infrastructure including a legal knowledge graph and a risk case database. This infrastructure preserves the knowledge and experience of legal experts in a structured and computable form, providing solid professional knowledge support for intelligent contract risk identification. These knowledge resources not only improve the accuracy and professionalism of risk identification but also provide interpretable legal evidence for risk assessment, enhancing the system's credibility and practical value.

[0036] In some embodiments, step S1 may specifically include the following steps: Based on a professional legal database API interface and publicly available legal text resources, collect legal provisions, judicial interpretations, judicial precedents, industry standards, and historical contract samples; through data cleaning and structuring processing, obtain a standardized legal text dataset; based on the standardized legal text dataset, identify legal entities using named entity recognition; extract the relationships between each legal entity using a relation extraction algorithm, obtaining a set of triples of legal entities and relationships, wherein the legal entities include legal clauses, rights and obligations, and subject qualifications, and the relationships include citations, restrictions, and conflicts; based on the set of triples, use a graph database... A network structure of nodes and edges is established to construct a multi-layered legal knowledge graph. An open graph query interface is provided to obtain a queryable legal knowledge graph, which includes a legal provision layer, a case layer, and a contract clause layer. Based on historical contract samples and judicial precedents, risk points and corresponding consequences in contract dispute cases are extracted. A mapping relationship between contract clauses, risk types, and consequences is established. Case feature vectors are calculated using vectorization methods to construct a searchable risk case library. Based on the legal knowledge graph and the risk case library, a contract risk classification system is constructed, risk assessment rules are defined, knowledge graph reasoning rules are determined, and a structured risk label system and a set of reasoning rules are output.

[0037] In this embodiment, a large number of legal provisions, judicial precedents, industry standards, and historical contract samples are first collected from professional legal databases (such as Peking University Legal Database and Wusong Cases) and publicly available legal text resources. These data are then cleaned and structured to obtain a standardized legal text dataset. Next, named entity recognition technology (such as BiLSTM-CRF or BERT-NER models) is used to identify legal entities such as legal clauses, rights and obligations, and subject qualifications. Relationship extraction algorithms (such as remote supervision methods or fine-tuning of pre-trained language models) are used to extract relationships such as "references," "restrictions," and "conflicts" between entities, resulting in a set of legal entity-relationship triples. Then, a graph database (such as Neo4j) is used to establish a network structure of nodes (entities) and edges (relationships), constructing a multi-layered legal knowledge graph containing legal provisions, case studies, and contract clauses. A graph query interface is designed to make the knowledge graph searchable. Simultaneously, risk points and corresponding consequences in contract dispute cases are extracted from historical contract samples and judicial precedents, establishing a mapping relationship of "contract clause - risk type - consequence." Vectorization methods (such as BERT and Word2Vec) are used to calculate case feature vectors, constructing a searchable risk case library. Finally, a contract risk classification system (such as liability risk, performance risk, compliance risk, etc.) is designed, risk assessment rules are defined (such as "if the clause restricts Party A's liability and there are no equivalent conditions, it is a high risk"), knowledge graph reasoning rules are written based on the Cypher query language, and a structured risk label system and reasoning rule set are output.

[0038] Specifically, this step is the knowledge foundation construction stage of the intelligent contract risk identification system. By systematically collecting, processing, and structuring legal knowledge, it provides comprehensive and accurate professional knowledge support for subsequent risk identification. This stage employs a combination of knowledge graph technology and case database construction, not only capturing the structured representation of legal knowledge but also accumulating experiential knowledge for risk identification through real-world cases. This forms a multi-layered, multi-dimensional legal knowledge system, providing a solid professional foundation for intelligent risk identification.

[0039] First, the system conducted comprehensive and precise legal text data collection, establishing a rich and diverse foundation of raw data. By establishing API connections with professional legal databases such as "Peking University Legal Database" and "Wolters Kluwer," the system batch-obtains the latest legal texts, judicial interpretations, and typical precedents. Simultaneously, the system developed a dedicated web crawler to regularly collect supplementary data from publicly available channels such as the China Judgments Online website, official websites of courts at all levels, and official websites of legislative bodies, ensuring the comprehensiveness and timeliness of the data. Regarding industry standards, the system accessed the database of the National Standardization Management Committee and standard texts published by various industry associations. For historical contract samples, while ensuring privacy protection, the system collected anonymized contract texts from cooperating legal service institutions, covering multiple fields such as sales, services, labor, and intellectual property. This multi-source data collection strategy ensured the breadth and depth of the knowledge base, providing rich raw materials for subsequent analysis.

[0040] The collected raw legal texts underwent systematic data cleaning and structuring, transforming unstructured text into a standardized dataset. First, text preprocessing was implemented, including removing irrelevant elements (such as headers, footers, and watermarks), correcting OCR errors, and standardizing text encoding and formatting. Then, document segmentation was performed, breaking down long texts into natural structures such as chapters and clauses, and extracting metadata such as publication date, effective status, and scope of application. The system pays particular attention to the timeliness of legal texts, establishing a version tracking mechanism to record the revision history of laws and regulations, ensuring that only the currently valid version is cited. For judicial precedents, the system implemented structured extraction, breaking down judgments into components such as basic case information, factual findings, court opinions, and judgment results. Furthermore, the system established a standardized process for handling professional terminology, unifying synonymous terms (such as "liquidation penalty" and "compensation for breach of contract"), and creating a terminology mapping table to address the diversity of legal language expression. These processes ensured the accuracy and consistency of subsequent analysis, laying the foundation for entity identification and relationship extraction.

[0041] Based on standardized legal text datasets, the system employs advanced natural language processing (NLP) techniques for legal entity identification and relation extraction, constructing basic units of legal knowledge. The system implements a named entity recognition model specifically for the legal domain. This model is fine-tuned based on a pre-trained language model, supplemented by a Conditional Random Field (CRF) layer to capture the transition probabilities of entity boundaries, accurately identifying key legal entities such as legal clauses (e.g., "Article 286 of the Contract Law"), statements of rights and obligations (e.g., "Party B shall pay within 3 days of receiving the goods"), and legal capacity (e.g., "persons without civil capacity"). To improve accuracy, the system also integrates an entity dictionary compiled by legal experts, employing a hybrid strategy combining dictionary matching and deep learning models. For relation extraction, the system uses a combination of remote supervision and graph attention networks to automatically identify citation relationships (e.g., Regulation A citing Regulation B), restrictive relationships (e.g., Clause A restricting the rights of Clause B), and conflict relationships (e.g., contradictions between provisions). The system innovatively extracts implicit relationships from legal texts, using semantic similarity calculation and rule reasoning to uncover entity connections not explicitly stated on the surface but existing in legal theory. Through these technologies, the system transforms complex legal texts into a structured set of triples in the form of <entity1, relation type, entity2>, providing basic data units for knowledge graph construction.

[0042] Based on the extracted triple set, the system constructs a multi-layered legal knowledge graph, realizing the networked representation and efficient querying of legal knowledge. The system uses the Neo4j graph database as its storage and management platform, transforming entities in triples into nodes and relationships into edges, and adding rich attribute labels to nodes and edges. The knowledge graph is designed with a three-layer architecture: the top layer is the legal provisions layer, containing nodes and their relationship networks of formal legal documents such as laws, regulations, and judicial interpretations, reflecting the official structure of the legal system; the middle layer is the case layer, containing judicial precedent nodes and their citation relationships with legal provisions, reflecting the application and interpretation of law in practice; the bottom layer is the contract clause layer, containing standardized contract clause templates and their correspondence with upper-level legal norms, reflecting the specific manifestation of legal norms in contract practice. The layers form an organic whole through cross-layer relationships (such as the citation of legal provisions by precedents and the basis of legal provisions in contract clauses). The system provides a complete CRUD operation interface for the knowledge graph, supports complex queries based on SPARQL and Cypher, and knowledge reasoning functions. To improve query efficiency, the system also implements graph index optimization and caching mechanisms, ensuring millisecond-level query responses even on large-scale graphs. Furthermore, the system provides a visual interface that supports interactive exploration of the knowledge graph, helping users intuitively understand the complex network of relationships between legal concepts.

[0043] Based on a large number of historical contract samples and judicial precedents, the system has constructed a dedicated database of contract risk cases, capturing risk experiences from actual legal practice. The system employs a hybrid approach to extract risk points and corresponding consequences from contract dispute cases: first, rule template matching is used to identify typical risk expressions (such as "unclear agreement" and "clashing clauses"); second, supervised learning is used to train a risk classifier using manually labeled training data; finally, a causal relationship extraction algorithm is combined to analyze the causal logic in the judgment documents, clarifying the correspondence between risk points and legal consequences. The system establishes a multi-dimensional risk-consequence mapping system, including direct economic losses (such as compensation amount), legal liability determination (such as breach of contract liability and tort liability), and impact on contract validity (such as invalid clauses and contract termination). For each case, the system uses an advanced language model to calculate its feature vector, capturing the semantic information of the case, and establishes a multi-level index structure based on these feature vectors, supporting case retrieval based on similarity. The system also implements a composite retrieval mechanism combining attribute-based precise retrieval and semantic-based fuzzy retrieval, enabling users to find relevant risk cases through multiple methods. To enhance the usability of the case library, the system also performs cluster analysis on the cases, identifies common risk patterns and hot issues, and generates risk prevention suggestions, forming a comprehensive risk knowledge base that not only records problems but also provides solutions.

[0044] Finally, based on the constructed legal knowledge graph and risk case database, the system developed a specialized contract risk knowledge system and inference rule set. The system constructs a multi-layered contract risk classification system, with the top level divided into four main categories: legal compliance risk, rights protection risk, performance risk, and dispute resolution risk. These are further subdivided into multiple second- and third-level risk categories, forming a complete risk classification tree structure. For each type of risk, the system defines assessment rules, including risk identification conditions (such as specific clause patterns, keywords, and structural characteristics), risk level assessment standards (based on dimensions such as severity, probability of occurrence, and scope of impact), and applicable legal basis. The system also developed a knowledge graph-based inference rule set, implementing three inference mechanisms: ontology-based TBox inference, which uses hierarchical relationships between concepts to expand knowledge; rule-based inference, which applies predefined IF-THEN rules to identify potential risks; and case-based analogical inference, which predicts possible risks through comparative analysis of similar cases. These rules are expressed in declarative language and can be executed automatically by the system or reviewed and modified by legal experts. The system organizes the classification system, assessment rules, and reasoning rules into a structured risk labeling system and rule set, forming a complete knowledge base for risk identification and providing professional guidance for subsequent intelligent risk analysis.

[0045] Through this systematic knowledge-based construction process, the intelligent contract risk identification system has formed a powerful knowledge support system integrating a legal knowledge graph and a risk case database. This system not only includes static legal norms but also incorporates dynamic case experience, and establishes a methodological framework for risk identification. This diversified and comprehensive knowledge base enables the system to conduct professional-level legal analysis and risk identification, laying a solid foundation for subsequent intelligent risk analysis. As new laws, regulations, precedents, and cases are continuously added, this knowledge base will continue to expand and optimize, forming an ever-evolving legal knowledge ecosystem that continuously improves the professionalism and accuracy of intelligent contract risk identification.

[0046] S2: Receive the contract document to be identified, and obtain structured contract text data through OCR recognition, text cleaning, segmentation and standardization.

[0047] This step is the data preprocessing stage of the intelligent contract risk identification system. Its purpose is to convert raw contract documents in various formats into standardized structured text data, laying the foundation for subsequent risk analysis. In practical applications, legal professionals submit contract documents in diverse formats, including electronic Word documents, PDF files (both editable text PDFs and scanned image PDFs), and direct scanned images of contracts. The system needs to flexibly process these different input formats and uniformly convert them into an analyzable text format.

[0048] First, the system receives contract documents through multiple interfaces, including a web interface upload function, automatic email attachment parsing, and dedicated API calls. Once a document is uploaded, the system automatically identifies the document format and calls the corresponding text extraction module based on the format. For Word documents, the system uses a professional document parsing library (such as Apache POI) to directly extract the text content and its structural information; for text-based PDFs, the system uses PDF parsing tools (such as pdfminer or PyPDF2) to obtain the text content; and for image-based PDFs or scanned images, the system requires more complex processing.

[0049] For scanned PDF or image-formatted contract documents, the system deploys high-precision OCR models based on deep learning (such as PaddleOCR or Tesseract OCR) for text recognition. These modern OCR engines can accurately recognize Chinese text in various fonts and layouts, including small-font clauses commonly found in contracts. The system also incorporates layout analysis technology to automatically identify elements such as page layout, title positions, and table structures, preserving the contract's basic structural information. After OCR processing, the system outputs the original text content with layout markers, including information such as titles, chapters, and paragraphs, laying the foundation for subsequent text structuring.

[0050] After obtaining the original text, the system performs a comprehensive text cleaning process. In this step, regex and text pattern recognition techniques are first applied to filter out irrelevant information such as headers, footers, watermarks, etc. Then, the system conducts text normalization, including unifying whitespace characters (e.g., replacing multiple consecutive spaces with a single space), standardizing punctuation marks (e.g., converting full-width punctuation to half-width punctuation), and correcting common errors (e.g., confusion between the number "0" and the letter "O"). For recognition errors generated during the OCR process, the system also performs intelligent correction through the edit distance algorithm and context semantic checking. For example, the system may identify an OCR error like "合伺" and correct it to "合同" based on the context. After this series of processing, the system obtains a cleaned and normalized contract text.

[0051] Next, the system performs a structured segmentation process on the normalized text. First, common structural markers in the contract, such as patterns like "Article X" and "Chapter X", are identified through rule matching methods. At the same time, the system also applies text segmentation algorithms such as TextTiling to perform intelligent paragraph division based on topic changes and semantic transition points. By combining rules and algorithms, the system identifies the logical structure of the contract, including the preamble (contract preface and party information), definitions (terminology explanation section), main body clauses (rights and obligations clauses), and appendices (supplementary clauses, dispute resolution methods, etc.). The system adds structure tags to each identified paragraph, forming a segmented contract text with a hierarchical structure.

[0052] Finally, the system uses pre-trained language models such as BERT to perform feature extraction and semantic analysis on the segmented text. The system automatically identifies key terms and entities in the contract, such as core information like contract parties, contract amount, performance period, liability for breach of contract, etc. At the same time, the system calculates the semantic vector representation of each paragraph to capture the deep semantic features of the paragraph. These text contents and features are uniformly converted into a standard JSON format, forming a well-structured and information-rich contract text data structure. This structure not only retains all the content of the original contract but also adds enhanced information such as structure tags, entity markers, and semantic features.

[0053] Through the above processing flow, the system successfully converts original contract documents in various formats into standardized structured text data, providing high-quality input for the subsequent risk identification and analysis processes. This preprocessing step overcomes the technical challenges of diverse contract document formats and complex structures, achieving data standardization and structuring, and is an important fundamental step in the entire intelligent contract risk identification system.

[0054] In some embodiments, step S2 may specifically include: receiving the contract document in multiple formats; calling the corresponding extraction module according to the format type to obtain the extracted original text content; the multiple formats include PDF, Word, and images; when the contract document is in image format, performing text recognition based on a deep learning OCR model, and combining layout analysis technology to identify the structural information of the contract document to obtain the original text content with layout markings; the structural information includes titles, chapters, and paragraphs; based on the original text content, applying regular expressions to filter irrelevant information, unifying whitespace characters and punctuation marks, and using edit distance algorithms and context checks. The OCR errors are corrected to obtain cleaned and standardized text, including irrelevant information such as headers, footers, and watermarks. Based on the standardized text, rule matching and the TextTiling algorithm are used to segment the text, identify the logical structure of the contract document, and add structure tags to each paragraph to obtain segmented structured contract text. The logical structure includes a preamble, definitions, main clauses, and supplementary provisions. Based on the segmented structured contract text, a BERT pre-trained language model is used to extract text feature vectors, identify key terms and entities in the contract document, and convert the text and features into a unified JSON format to obtain the structured contract text data.

[0055] In this embodiment, the system receives contract documents in various formats (PDF, Word, images, etc.) through a web interface upload interface, email attachment parsing, or API calls. Based on the file type, it calls the corresponding processing module (such as a PDF parser or OCR engine) to output uniform text content. For scanned PDF or image-format contracts, a deep learning OCR model (such as PaddleOCR) is used for text recognition, combined with layout analysis technology to identify the document's structural information (titles, chapters, paragraphs, etc.), outputting the original text content with layout markings. Then, regular expressions are applied to filter irrelevant information such as headers, footers, and watermarks, unify whitespace characters and punctuation, and correct OCR errors (through edit distance algorithms and context checks) to obtain cleaned and standardized text. Next, rule matching (such as the "Article X" pattern) and machine learning models (such as the TextTiling algorithm) are used for text segmentation, identifying the contract's logical structure (preamble, definitions, main clauses, supplementary provisions, etc.), and adding structure tags to each paragraph, outputting segmented and structured contract text. Finally, pre-trained language models (such as BERT) are used to extract text feature vectors, identify key terms and entities (such as contract subjects, amounts, dates, etc.), convert the text and features into a unified JSON format, and output standardized structured contract text data.

[0056] Specifically, this step is the text preprocessing stage of the intelligent contract risk identification system. Through a series of sophisticated document processing techniques, it transforms raw contract documents in different formats into standardized, structured data representations. This process addresses real-world challenges such as diverse contract document formats, complex structures, and information noise, laying a solid foundation for subsequent deep semantic analysis and risk identification. This step integrates technologies such as OCR recognition, text cleaning, structural analysis, and semantic representation, achieving a complete conversion from unstructured documents to structured data, ensuring the integrity, accuracy, and processability of contract information.

[0057] First, the system implements a flexible framework for receiving and processing multi-format contract documents, adapting to the diversity of document formats in real-world business environments. The system features a unified document receiving interface, supporting various methods such as API uploads, email attachments, and cloud storage synchronization to retrieve contract documents. Upon receiving a document, the system identifies its file type, accurately determining its specific format, including PDFs (distinguishing between scanned and digital PDFs), various versions of Word documents (.doc, .docx, etc.), images (.jpg, .png, .tiff, etc.), and other possible formats such as HTML and plain text files. Based on the identified file type, the system dynamically calls the corresponding dedicated extraction module: for Word documents, it uses the open-source python-docx or commercial-docx libraries to extract text and basic formatting information; for digital PDFs, it uses the improved PDFMiner library for precise text hierarchical extraction; for plain text files, it directly reads the content and performs basic format inference. The system also implements a format conversion function; when the document format provided by the upstream system is not in the directly supported list (such as certain proprietary formats), it automatically converts it to a processable standard format before content extraction. This modular design ensures the system's broad compatibility with various contract document formats. Regardless of the format of the document provided by the user, the original text content can be extracted through the corresponding channel, providing a unified text basis for subsequent processing.

[0058] For image-formatted contract documents (including images converted from scanned PDFs), the system implements a high-precision OCR recognition process based on deep learning, solving the difficulties of traditional OCR in recognizing complex layouts. First, the system uses an improved YOLOv5 model for document preprocessing, achieving automatic angle correction, removal of skew and distortion, and image enhancement to improve the clarity of low-quality scans. In the text recognition stage, the system employs an OCR model based on the Transformer architecture, combined with an attention mechanism and a visual feature extraction network, achieving high-precision recognition of mixed Chinese and English text, special symbols, and table content. Unlike traditional OCR, the system has specifically optimized its model for the characteristics of legal texts, improving the accuracy of recognizing technical terms and formatted clauses through domain-adaptive training on legal documents and contract datasets. Simultaneously, the system implements layout analysis functions, using image segmentation and object detection technologies to identify structural elements of the document, including titles (identified through font size and position features), chapters (identifying numbering patterns and format features), paragraph boundaries, table areas, and illustrations. The system can also recognize special layout elements such as two-column layouts, headers and footers, and signature areas, and retain this structural information during text extraction, outputting text content with layout markings. This method, which combines OCR recognition and layout analysis, not only extracts text content but also preserves the document's structural information, providing important clues for subsequent text segmentation and structured processing.

[0059] Based on the extracted original text content, the system performed a comprehensive text cleaning and normalization process, eliminating various noises and non-standard representations in the original document. The system used a carefully designed regular expression library to filter out irrelevant information, including identifying and removing non-essential content such as headers (e.g., company names, document numbers), footers (e.g., page numbers, copyright notices), watermark text, repeated decorative lines, and blank area markers. In terms of text normalization, the system achieved the unification of full-width and half-width characters, the unification of Chinese and English punctuation marks (e.g., unifying full-width commas into half-width commas), the standardization of whitespace characters (merging multiple spaces, replacing special whitespace characters), and the handling of line-ending hyphens (joining words split by line breaks). Specifically for text errors generated by OCR, the system designed a multi-level automatic correction mechanism: First, based on the edit distance algorithm and a pre-built legal term dictionary, it detected and corrected common OCR errors (e.g., misidentifying "合同" as "合同"); Second, it used the n-gram language model to evaluate the probability distribution of text fragments and identify inconsistent words in the context; Finally, combining the masked prediction function of the BERT model, it inferred the possible correct text according to the context. The system also specifically addressed the issue of numerical representations in contracts, unifying the formats of Arabic numerals and Chinese numerals (intelligently selecting according to the context) to ensure the accuracy of key information such as amounts and dates. Through this series of delicate text cleaning and normalization operations, the system effectively removed the noises and inconsistencies in the original text, producing high-quality normalized text, providing a clear and reliable text basis for subsequent structural analysis and semantic understanding.

[0060] Based on standardized text, the system conducts in-depth logical structure analysis of contract documents, identifying the contract's organizational structure and functional units. The system employs a hybrid approach for text segmentation: first, rule matching is used to identify obvious structural markers, such as numbering patterns ("Article 1," "1.2.3," etc.), keywords ("whereas," "definitions," "attachments," etc.), and formatting features (indentation, blank lines, etc.); then, for sections with less obvious structure, an improved TextTiling algorithm is applied. This algorithm automatically identifies topic boundaries by calculating the lexical coherence and semantic coherence of adjacent text segments, achieving more refined paragraph division. In terms of logical structure identification, the system implements contract-specific structure parsing functions, accurately identifying the standard components of a contract: the preamble (including information about the contracting parties and the background of the agreement), the terminology definition section (identifying the special format and grammatical structure of the definition clauses), the main clauses (further subdivided by function into rights and obligations, delivery conditions, price clauses, confidentiality clauses, etc.), and the supplementary provisions (including dispute resolution, conditions for effectiveness, etc.). The system can also identify the referencing relationships in appendices and annexes, constructing a complete contract document structure diagram. Based on the identified structural information, the system adds standardized structural tags to each paragraph, including hierarchical relationships (such as "Chapter 1 - Article 2 - Section 3"), functional types (such as "Definition Clause" and "Breach of Contract Clause"), and location information (relative position in the document). This structured tagging enables the system to accurately locate various parts of the contract, providing a clear navigation framework for subsequent clause analysis and risk identification.

[0061] Finally, the system performs semantic enhancement on the segmented, structured contract text, extracting deep features and converting them into a unified data format. The system uses a pre-trained BERT language model (specifically a Legal-BERT variant fine-tuned for legal text) to generate context-aware feature vectors for each contract paragraph. These vectors capture the semantic information of the text, reflecting the paragraph's theme, sentiment, and legal implications. Based on these feature vectors, the system automatically identifies key terms and entities: through a fine-grained named entity recognition model, it accurately labels entities such as parties (e.g., "Party A," "Party B," and their actual names), dates and times, monetary amounts, products and services, locations, and technical terms in the contract; simultaneously, it identifies core terms and their definitions in the contract through a term extraction algorithm. For the identified entities and terms, the system also establishes a coreference resolution mechanism to determine the specific entities referred to by pronouns used in different parts of the document (e.g., "the product," "the aforementioned services"). All this information is organized into a unified JSON format, forming the final structured contract text data. The JSON structure comprises a metadata layer (document source, processing time, etc.), a structure layer (reflecting paragraph hierarchy and functional types), a content layer (raw text and cleaned text), and a feature layer (BERT feature vectors, entity tags, terminology definitions, etc.). This multi-layered JSON representation not only preserves the complete information of the contract but also provides rich semantic annotations through feature vectors and entity tags, offering an ideal data structure for subsequent in-depth analysis.

[0062] The system also establishes a quality assurance mechanism for structured data, including integrity checks (ensuring no content is missing), structural consistency verification (checking the logical consistency of hierarchical relationships), and key information verification (such as the accuracy of extracting key elements like contract parties and amounts). For high-value or complex contracts, the system also supports manual correction, displaying the structured results through a user-friendly interface, allowing professionals to make necessary adjustments and confirmations. The final structured data is provided to subsequent processing modules via the system API and simultaneously stored in a structured database, supporting efficient retrieval and analysis operations.

[0063] Through this series of sophisticated text processing steps, the system achieves a complete transformation from raw, multi-format contract documents to standardized structured data, effectively overcoming challenges such as diverse document formats, complex structures, and information noise. This high-quality structured representation not only preserves the full substantive content and organizational structure of the contract but also provides rich semantic information through feature vectors and entity tags, laying a solid foundation for subsequent risk identification and analysis. The system's modular design and standardized processes ensure consistency and scalability, enabling it to adapt to contract documents of various types and complexities, and meeting diverse needs in real-world business environments.

[0064] S3: Based on the structured contract text data, parallel risk identification and analysis are performed based on the joint large language model. Preliminary risk assessment results are obtained through unified prompt word templates and weighted fusion calculation.

[0065] This step is the core analytical component of intelligent contract risk identification. It leverages the parallel collaboration of multiple large language models to perform a comprehensive risk scan and preliminary assessment of the contract text. Unlike traditional single-model methods, this system employs a joint multi-model architecture, significantly improving the accuracy and stability of risk identification through model complementarity and result fusion.

[0066] First, the system features specialized prompt word templates and adaptive parameter configurations. For the specific task of contract risk identification, the system has developed standardized prompt word templates that include detailed task instructions, output format specifications, and examples. A typical prompt word template includes: "Analyze the following contract terms to identify potential legal risks. The output should include: 1) Risk type (e.g., limitation of liability, breach of contract, intellectual property, etc.); 2) Specific risk description; 3) Risk level (high / medium / low); 4) Confidence score (1-10). Please return the results in JSON format." Simultaneously, the system configures dedicated adaptive parameters for different large language models. For example, the ChatGLM model is configured with temperature=0.2 to maintain output stability, while the Qwen model is configured with a higher top_p value to enhance innovative analysis. These differentiated configurations fully leverage the unique advantages of each model, providing diverse perspectives for subsequent risk analysis.

[0067] Next, the system established a high-efficiency parallel computing framework, simultaneously invoking multiple large language models, including ChatGLM, Qwen, and Llama3. The system segments the preprocessed structured contract text into logical paragraphs (such as individual clauses or groups of related clauses) and sends these text fragments to each large language model simultaneously via API interfaces. Each model independently analyzes the potential risks in the contract paragraphs, identifying risk types (such as liability risks, performance risks, interpretation risks, etc.), generating detailed risk descriptions, assessing risk levels, and providing confidence scores. For example, for a clause limiting liability, ChatGLM might identify "limitation of liability risk," Qwen might identify "legal compliance risk," and Llama3 might identify "liability exemption risk." This multi-faceted analysis greatly expands the breadth and depth of risk identification.

[0068] Because different large language models have different output formats and expressions, the system implements a standardization mechanism. First, key information, including risk type, descriptive text, and scoring data, is extracted from the output of each model using unified parsing rules (such as regular expressions and structured text parsing). Then, the system standardizes the risk description language, unifying terminology (e.g., unifying "liability exclusion" and "disclaimer clause" into "liability limitation") and formatting the risk description text. Simultaneously, the system also standardizes the confidence level representation of each model to ensure consistency in scoring standards. These processes ensure that analytical results from different models can be compared and integrated within the same framework.

[0069] After obtaining the normalized analysis results of multiple models, the system uses a weighted fusion algorithm to integrate the outputs of each model and generate a comprehensive evaluation result. Specifically, the system assigns a corresponding weight to each model based on its accuracy performance in historical tests (for example, if ChatGLM has an accuracy of 85% in historical evaluations, it may receive a weight of 0.5; Qwen has an accuracy of 75% and receives a weight of 0.3; Llama3 has an accuracy of 70% and receives a weight of 0.2). Then, the system uses a weighted average algorithm to calculate the comprehensive score and confidence level of each risk point, with the formula: Comprehensive Score = ∑(Model Weight i × Model Score i). In addition, the system also calculates a consistency index (such as the Kappa coefficient) between models to assess the consistency of the results from multiple models. For risk points where there are significant disagreements between models (such as a consistency index below a preset threshold of 0.6), the system applies a decision tree algorithm or a rule-based logical judgment mechanism to resolve conflicts, ensuring the consistency and reliability of the final output.

[0070] Finally, after weighted fusion and conflict resolution, the system generates a preliminary risk assessment report. This report contains detailed information for each identified risk point, including the risk type, its location within the relevant clause, risk description, overall risk rating (high / medium / low), confidence score, and inter-model consistency indicators. The system also marks high-risk clauses requiring special attention and clauses with model discrepancies, providing key directions for subsequent in-depth analysis.

[0071] Through the above process, the system achieves a comprehensive risk scan and preliminary assessment of the contract text. The parallel analysis architecture combining multiple large language models not only improves the coverage and accuracy of risk identification but also enhances the system's stability and reliability through model complementarity and result fusion. This preliminary risk assessment based on large language models lays a solid foundation for subsequent in-depth legal reasoning and case analysis.

[0072] In some embodiments, step S3 may specifically include: determining the prompt word template and adaptive parameters of the joint large language model to obtain a model invocation configuration, wherein the joint large language model includes ChatGLM, Qwen, and Llama3; based on the structured contract text data and the model invocation configuration, invoking the interfaces of each large language model in parallel, segmenting the structured contract text data as input to identify potential risks in each segment, and obtaining a preliminary identification result set containing risk type, description, and confidence level; based on the preliminary identification result set, extracting key information through unified parsing rules, converting the format of the preliminary identification result set, and performing standardized risk description language and unified confidence level representation to obtain a standardized multi-model risk identification result; based on the multi-model risk identification result, assigning weights according to the historical accuracy of each large language model, applying a weighted average algorithm to calculate the comprehensive score of each risk point, calculating the consistency index of judgments among the models, and applying a decision tree algorithm to resolve conflicts between models for risk points with significant discrepancies, thereby obtaining the preliminary risk assessment result.

[0073] In this embodiment, the system first designs a unified prompt word template (including task description, output format requirements, and examples), configures adaptive parameters (such as temperature and top-p value) for different large language models, and obtains standardized model call configurations. Then, based on these configurations, it calls the APIs of multiple large language models (such as ChatGLM, Qwen, and Llama3) in parallel, taking segmented contract text as input, requiring the models to identify the potential risks in each segment, and obtaining a preliminary identification result set containing risk type, description, and confidence level. Next, it applies unified parsing rules to extract key information, performs format conversion on unstructured output, standardizes the risk description language, and unifies the confidence level representation, obtaining standardized multi-model risk identification results. Afterward, it assigns weights according to the historical accuracy of each model, and applies a weighted average algorithm to calculate the comprehensive score of each risk point, with the formula: final score = ∑(wi·si), where wi is the weight of model i, and si is the output score of model i. Finally, the consistency index of the judgments between the models (such as the Kappa coefficient) is calculated. For risk points with significant disagreements (consistency below the threshold), decision tree algorithms or rule-based judgment logic are applied to resolve conflicts between the models and output verified preliminary risk assessment results.

[0074] Specifically, this step is the core analysis stage of the intelligent contract risk identification system. By integrating the collaborative work of multiple advanced large language models, it achieves deep semantic understanding of contract texts and accurate risk identification. This stage employs a "model fusion" strategy, which does not rely on a single model for judgment but integrates the analysis results of multiple large language models, significantly improving the accuracy and reliability of risk identification. The entire process encompasses prompt word engineering, parallel model invocation, result standardization, and integrated decision-making, forming a complete multi-model collaborative analysis framework.

[0075] First, the system meticulously designed dedicated prompt word templates and adaptive parameter configurations for each large language model, ensuring that the models can fully leverage their respective strengths to perform contract risk identification tasks. For prompt word template design, the system adopted a structured prompt engineering approach, creating a three-tiered prompt word system: the basic prompt layer provides the task definition and expected output format, clearly informing the model that its role is that of a "contract risk identification expert," requiring analysis of contract terms and identification of potential risks; the guiding prompt layer provides a professional framework and methodology for risk identification, including a risk classification system, typical risk patterns, and evaluation criteria; the example prompt layer, through few-shot learning, provides 2-3 annotated contract term examples and their corresponding risk analyses to help the model understand task details. Specific optimizations were made to the prompt word templates for different models: the Chinese legal terminology and logical reasoning parts were strengthened for ChatGLM; explicit requirements for structured output were added for Qwen; and more cross-language understanding and professional legal knowledge prompts were added for Llama3. Regarding adaptive parameters, the system determines the optimal combination of invocation parameters for each model, including the temperature coefficient, kernel sampling parameters (top_p, top_k), and maximum output length. These parameters were determined through offline evaluation experiments, with specific parameter configuration sets set for each contract type. The system also implements a parameter adaptation mechanism that automatically adjusts parameter values ​​based on the complexity, length, and professionalism of the contract text, achieving an optimal balance between maintaining model creativity and accuracy. Through this meticulous prompt word engineering and parameter optimization, the system creates the most suitable invocation configuration for each large language model to fulfill the contract risk identification task.

[0076] Based on prepared structured contract text data and model call configuration, the system implements an efficient parallel model call mechanism, simultaneously activating multiple large language models for risk identification and analysis. First, the system intelligently segments the contract text, ensuring that each input segment meets the model's maximum input length limit while maintaining semantic integrity. The segmentation algorithm is based on several factors: prioritizing segmentation at natural paragraph and clause boundaries; ensuring context-related clauses are grouped together; and processing key clauses (such as breach of contract liability and dispute resolution) separately for more refined analysis. The system employs a sliding window technique to retain the preceding and following contextual information for each paragraph, ensuring the model understands the complete context of the clauses. In terms of the call architecture, the system builds a high-concurrency asynchronous call framework capable of simultaneously sending requests to the interfaces of ChatGLM, Qwen, and Llama3, maximizing hardware resource utilization and significantly reducing overall processing time. To handle potential model call failures, the system implements a robust error handling and retry mechanism, including an exponential backoff strategy and automatic switching to a backup model. For each text segment, the system instructs the large language model to perform multi-dimensional risk analysis, including identifying risk types (such as compliance risks, rights protection risks, etc.), providing detailed risk descriptions, assessing the degree of risk, suggesting possible mitigation measures, and requiring the model to provide a confidence score, indicating its degree of confidence in the analysis results. The system collects the analysis results of all models on all text segments to form a preliminary identification result set, which contains rich risk identification information, but the format and expression may vary and require further standardization.

[0077] The system comprehensively standardizes the risk identification results returned by different large language models, converting heterogeneous outputs into a consistent standard format. First, the system implements a powerful result parsing engine capable of handling various output formats (including natural language descriptions, JSON, and tabular forms) and extracting key information fields. The parsing engine employs a multi-strategy approach: for structured output, a dedicated parser directly extracts fields; for semi-structured text, regular expressions and pattern matching are used to identify key parts; for natural language descriptions, rule-based and machine learning-based information extraction techniques are used to obtain core content. All extracted information is converted into a unified internal representation format, including standardized fields such as risk ID, risk type, risk description, impact level, and confidence level. The system places particular emphasis on the standardization of risk description language, achieving unified terminology and standardized expression: a contract risk terminology mapping table is established, mapping different expressions (such as "missing clause," "omitted clause," "unagreed clause") to standard terms; a templated language is used to generate standard risk descriptions, ensuring both accuracy and consistency; and language standardization techniques are applied to unify tone, tense, and the use of professional terminology. For confidence level representation, the system converts the confidence scores of different models (which may use different scales or methods) into a unified 0-1 standard score, employing a calibration method based on historical performance to ensure the comparability of confidence levels across different models. Furthermore, the system adds metadata tags to each risk record, including information such as the source model, analysis time, and applicable clauses, facilitating subsequent tracing and interpretation. Through these normalization processes, the system transforms the raw outputs of each model into a standardized risk identification result set with a unified structure, standard language, and consistent representation.

[0078] Finally, based on the standardized multi-model risk identification results, the system implements a complex integrated decision-making process, synthesizing the judgments of each model to arrive at the final risk assessment result. The system first calculates the historical accuracy weights for each model. These weights are dynamically adjusted based on the model's performance on historical assessment data. Specifically, this includes: statistically analyzing the historical accuracy of each large language model across different contract types and risk categories; considering the time factor, giving higher weight to recent performance; and assessing the model's "calibration degree" by combining the correlation between the model's self-reported confidence level and its actual accuracy. Based on these weights, the system applies a weighted average algorithm to calculate the comprehensive score for each identified risk point. The formula is: Comprehensive Score = Σ(Risk Score of Model i × Weight of Model i). In addition to the comprehensive score, the system also calculates a consistency index for risk judgment, measuring the degree of consistency among different models in judging the same risk point. This includes two measures: the coefficient of variation (CV) assesses the dispersion of numerical scores; and the Fleiss' Kappa coefficient assesses the consistency of risk type determination. For risk points where model judgments show significant discrepancies (consistency index below a preset threshold), the system applies a decision tree-based conflict resolution algorithm: First, a feature vector is constructed, including indicators such as model scores, confidence levels, and historical accuracy. Then, a pre-trained decision tree model is used to predict the most likely correct risk judgment based on these features. Finally, adjustments are made in conjunction with conflict resolution rules developed by human experts, such as prioritizing the most conservative risk judgment in specific situations. Through this integrated decision-making mechanism, the system can fully leverage the complementary advantages of multiple model judgments, reduce the potential bias and errors of a single model, and obtain more objective and accurate preliminary risk assessment results.

[0079] The system also establishes a detailed explanation mechanism for the assessment results, providing sufficient evidence and background information for each risk judgment, including: the original text of the specific clauses identifying the risk; the original judgments and basis of each model; the calculation process of the comprehensive score; and relevant laws, regulations, and case references. These explanations not only improve the credibility of the assessment results but also provide strong support for subsequent manual review. The final assessment results are output in a structured manner, including multiple views such as a risk list, a risk map (showing the distribution of risks in the contract), and risk hotspot analysis (high-frequency, high-severity risks), providing users with comprehensive risk insights.

[0080] Through this complex and sophisticated multi-model collaborative analysis framework, the system achieves in-depth identification and assessment of contract risks, significantly exceeding the capabilities of single-model solutions. The complementary strengths of different large language models (such as ChatGLM's expertise in Chinese comprehension, Qwen's strength in structured output, and Llama3's strength in legal logic reasoning), coupled with meticulously designed prompt word engineering, standardization processing, and integrated decision-making mechanisms, enable the system to produce accurate, comprehensive, and interpretable risk assessment results. As the number of model calls increases and human feedback accumulates, the system's assessment accuracy will continue to improve, achieving a virtuous cycle of model performance optimization.

[0081] S4: Based on the preliminary risk assessment results and the legal knowledge graph, deep reasoning analysis is performed using graph traversal algorithms and correlation calculations to obtain deep analysis results that include risk type, confidence level, reasoning chain, and modification suggestions.

[0082] This step is the in-depth analysis stage of the intelligent contract risk identification system. It combines the preliminary risk assessment results provided by the large language model with the legal knowledge graph, and through rigorous legal reasoning, conducts in-depth analysis and verification of potential risks, ultimately generating in-depth analysis results with professional legal basis. This step compensates for the shortcomings of the large language model in the legal field, significantly improving the professionalism and reliability of risk identification.

[0083] First, the system establishes a mapping mechanism between preliminary risks and legal knowledge. For each risk point identified by the large language model, the system extracts key concepts and terms (such as "breach of contract liability," "ownership of intellectual property rights," and "disclaimer clauses") from the risk description and locates relevant nodes in the legal knowledge graph through vector similarity calculation and keyword matching technology. For example, when the system identifies the risk of "insufficient liability ceiling" in the preliminary assessment, it will locate relevant nodes such as "limitation of liability," "contractual liability," and "maximum compensation" in the knowledge graph. This mapping establishes a bridge between preliminary risk assessment and professional legal knowledge, providing an entry point for subsequent in-depth reasoning.

[0084] After establishing the mapping, the system deploys a professional graph traversal algorithm. Starting from risk-related nodes, it performs multi-level, multi-path depth-first traversal of the legal knowledge graph. The system employs an improved bidirectional breadth-first search algorithm (Bi-BFS), considering both node relevance and edge weights. Within a reasonable search depth (typically limited to 3-5 layers), it explores laws, regulations, judicial interpretations, typical cases, and industry standards related to the risk points. During the traversal, the system dynamically calculates path weights, prioritizing the exploration of highly relevant knowledge paths. For example, starting from the "liquidation penalty clause" node, the system will prioritize traversing Article 114 of the Contract Law regarding the adjustment of liquidated damages, as well as related judicial interpretations and typical cases, while reducing the search priority for content with lower relevance. This targeted graph traversal ensures the professionalism and efficiency of the reasoning process.

[0085] After acquiring relevant legal knowledge, the system performs multi-dimensional legal relevance calculations to accurately assess the degree of correlation between risk points and legal norms. The relevance calculation comprehensively considers factors such as legal hierarchy (e.g., laws take precedence over administrative regulations), timeliness (e.g., new regulations take precedence over old regulations), professional field matching (e.g., industry-specific norms are more applicable to the industry), and clause similarity (using semantic similarity algorithms to calculate the degree of matching between contract clauses and legal provisions). Based on these factors, the system calculates a comprehensive relevance score and filters out the legal basis most relevant to the risk point. For example, for personal information processing clauses in internet service contracts, the system calculates their relevance to specific clauses of the Personal Information Protection Law and identifies the most relevant legal provisions and potential compliance risks.

[0086] After identifying key legal grounds, the system constructs a rigorous legal reasoning chain to verify and refine the preliminary risk assessment results. This chain is based on a legal syllogism structure, comprising factual premises (contractual terms), normative premises (applicable legal provisions), and legal conclusions (risk assessment and consequence prediction). The system employs formalized reasoning rules, such as deductive reasoning (deriving applicable conclusions from general legal principles), analogical reasoning (inferring the current situation based on judgments in similar cases), and hypothetical reasoning (predicting the potential legal consequences of specific clauses in different contexts). Each reasoning step is supported by clear legal grounds, forming a complete reasoning process. For example, the system might construct the following reasoning chain: "Article 8 of this contract completely excludes the seller's liability for product quality assurance → According to Article 26 of the Consumer Rights Protection Law, businesses may not exclude quality liability to consumers using standard clauses → Furthermore, Article 27 of the Supreme People's Court's Interpretation on Several Issues Concerning the Application of Law in the Trial of Sales Contract Disputes stipulates that such exemption clauses are invalid → Therefore, this clause carries a high risk of being deemed invalid, potentially preventing the seller from being exempted from liability based on this clause."

[0087] Based on a complete reasoning chain analysis, the system further generates risk ratings and modification suggestions. The risk rating comprehensively considers factors such as the severity of legal consequences (e.g., potential invalidity of clauses, contract termination, or substantial damages), the likelihood of disputes (based on statistical data from historical cases), and the commercial impact (potential impact on corporate reputation and business continuity), precisely classifying risks into high, medium, and low levels, and attaching a percentage-based confidence score. For identified risks, the system also generates targeted modification suggestions, including clause rewriting suggestions, applicable legal compliance paths, and alternative wording options. These suggestions are based on compliance clause templates and successful cases in the legal knowledge graph and consider the balance between corporate business objectives and legal compliance. For example, for overly broad intellectual property transfer clauses, the system might suggest: "Modify 'All intellectual property developed by Party B belongs to Party A' to 'Intellectual property results developed by Party B specifically for Party A during the performance of this contract and directly related to the project belong to Party A,' to balance the interests of both parties and reduce the possibility of disputes."

[0088] Finally, the system integrates the above analysis to generate structured, in-depth analysis results. These results include risk type, risk level, confidence score, complete reasoning chain (including legal basis), predicted possible legal consequences, and specific modification suggestions. The system also groups multiple interconnected risk points into risk clusters based on their correlation, identifying core and derived risks within each cluster, forming a hierarchical risk structure diagram. This structured representation facilitates legal professionals' quick understanding of complex risk relationships and priorities.

[0089] Through the above in-depth analysis process, the system combines the initial risk identification of the large language model with professional legal knowledge and reasoning to generate in-depth analysis results with legal expertise. These results not only accurately reveal potential risks in the contract but also provide clear legal basis and modification suggestions, offering substantial professional support to legal professionals and significantly improving the efficiency and professionalism of contract risk management.

[0090] In some embodiments, step S4 may specifically include: based on the preliminary risk assessment results, extracting the identified risk clauses, mapping the clause content to the corresponding legal entities in the legal knowledge graph using cosine similarity and BM25 algorithms, obtaining the mapping relationship between the risk clauses and the legal entities; based on the mapping relationship between the risk clauses and the legal entities, performing depth-first search and shortest path algorithms in the legal knowledge graph to find the association relationship between the mapped legal entities and the relevant legal provisions, judicial interpretations, and judicial precedents, calculating the association strength based on path length and relationship weight, and obtaining the legal association analysis results; based on the legal association analysis results and the reasoning rule set, applying a rule engine to perform logical reasoning, assessing the risk level and compliance, and obtaining the risk assessment results based on legal reasoning; based on the risk assessment results, recording the key nodes and logical links in the reasoning process, constructing a visualized reasoning chain containing contract clauses, legal provisions, and risk conclusions, generating natural language explanations, and generating targeted modification suggestions by combining alternative clause templates and best practice cases in the legal knowledge graph, obtaining the deep analysis results.

[0091] In this embodiment, the system first extracts the risk clauses identified in the preliminary risk assessment results. It then maps the clause content to relevant entities (such as legal provisions and typical clauses) in the legal knowledge graph using text similarity calculations (e.g., cosine similarity, BM25 algorithm), outputting the risk clause-legal entity mapping relationship. Next, it executes graph traversal algorithms (e.g., depth-first search, shortest path algorithm) in the legal knowledge graph to find the association between the mapped entities and relevant legal provisions, judicial interpretations, and case judgments, calculating the association strength (based on path length and relationship weight), and outputting the legal association analysis results. Then, it applies a rule engine for logical reasoning (e.g., "If a clause restricts Party A's liability and relevant laws stipulate that this liability cannot be exempted, then it is marked as a legal conflict risk"), assessing the risk level (high, medium, low) and compliance, and outputting the risk assessment results based on legal reasoning. Finally, it records the key nodes and logical links in the reasoning process, constructing a visualized reasoning chain (e.g., "Contract clause X → Limitation of liability → Violation of Article Y of the Contract Law → Risk conclusion"), generating a natural language explanation. Finally, by combining alternative clause templates and best practice cases in the legal knowledge graph, targeted modification suggestions (such as adjusting the scope of liability, adding protection clauses, etc.) are generated, risk mitigation solutions are developed, and in-depth analysis results containing specific suggestions are output.

[0092] Specifically, this step is the in-depth legal analysis stage of the intelligent contract risk identification system. It deeply integrates the preliminary risk identification results from the large language model with a professional legal knowledge system. Through knowledge graph retrieval, legal correlation analysis, rule reasoning, and interpretation generation, it achieves legal professionalism and interpretability in risk assessment. This stage represents a crucial shift for the system from "identifying risks" to "explaining risks and providing solutions," ensuring that the risk assessment results are based on a solid legal foundation and possess professional depth and practical value. The entire process integrates technologies such as graph computing, information retrieval, rule reasoning, and natural language generation to construct a complete legal reasoning and interpretation framework.

[0093] First, the system achieves precise mapping between contract risk clauses and entities in the legal knowledge graph, connecting unstructured contract clauses with structured legal knowledge. The system extracts identified risk clauses from the preliminary risk assessment results, including the original clause text, contextual information, and preliminary risk type. For each risk clause, the system employs a dual-path mapping strategy: on the one hand, semantic vector mapping is used to convert the clause text into a high-dimensional vector representation through a pre-trained legal domain language model (such as Legal-BERT), and then the similarity between the vector and entity vectors in the legal knowledge graph is calculated using cosine similarity to find the set of legal entities with the closest semantics; on the other hand, keyword mapping is used, applying an improved BM25 algorithm (incorporating weighted adjustments for legal terminology) to calculate the relevance score between the clause and the descriptive text of legal entities in the graph. The system weightedly fuses the two mapping results, considering both deep semantic similarity and precise matching of key terms. To improve mapping quality, the system has implemented specific optimizations: it identifies and standardizes key legal terms in contract clauses, such as identifying and uniformly expressing professional terms like "liquidation penalty" and "force majeure"; it constructs a clause subject classifier to categorize clauses (e.g., "confidentiality clause," "liability for breach of contract"), narrowing the mapping search space; and it implements fuzzy matching and partial matching mechanisms to handle subtle differences between clause wording and standard legal terminology. Through these technologies, the system can accurately map risk clauses in contracts to corresponding entities in the legal knowledge graph, such as legal clauses ("Article 114 of the Contract Law"), rights and obligations concepts ("obligation to pay liquidated damages"), or legal risk types ("clause conflict risk"). This mapping establishes a bridge between contract text and the legal knowledge system, laying the foundation for subsequent in-depth analysis.

[0094] Based on the established mapping relationships, the system performs complex graph traversal and path analysis within the legal knowledge graph to uncover deep connections between risk clauses and various legal resources. The system employs a dual-engine graph computing architecture: on one hand, it uses a depth-first search (DFS) algorithm to explore connections, starting from the mapped legal entities and recursively traversing along the relationship edges in the graph to discover legal provisions, judicial interpretations, and judicial precedents related to the initial entities. The system implements an intelligent pruning mechanism, setting a maximum depth limit (typically 3-4 layers) and a relevance threshold to avoid excessive expansion of irrelevant paths. On the other hand, the system applies an improved shortest path algorithm to find the optimal connection path between predefined important legal nodes (such as key legal provisions and high court precedents) and the mapped entities, discovering implicit but important legal connections. In path computation, the system introduces a multi-dimensional edge weight design: relationship type weight (e.g., "direct citation" relationships have higher weight than "related" relationships); legal authority level weight (e.g., Supreme Court precedents have higher weight than lower court precedents); timeliness weight (recent precedents or regulations have higher weight than older ones); and application frequency weight (frequently cited legal provisions have higher weight). Based on these weights and path lengths, the system calculates the strength score for each associated path: Association Strength = f(Path Length, ΠRelationship Weight), where f is a decreasing function, indicating a weaker association as the path length increases. The system hierarchically organizes the search results, grouping them by categories such as legal provisions, judicial interpretations, and precedents, and sorting them by association strength to obtain complete legal association analysis results. This depth graph traversal analysis enables the system to discover various complex relationships between contractual terms and legal norms, including direct regulatory relationships, legal support, and potential conflicts, providing a rich knowledge base for subsequent legal reasoning.

[0095] Based on the results of legal correlation analysis, the system employs a professional rule engine to conduct rigorous legal logic reasoning, grounding risk assessment on a solid legal foundation. The system activates a pre-built set of reasoning rules covering multiple dimensions of contractual legal risk assessment: compliance rules (checking whether clauses comply with mandatory legal provisions); validity rules (assessing whether clauses are legally valid and enforceable); risk level rules (assessing risk levels based on the severity of legal consequences); and conflict detection rules (identifying internal conflicts between clauses or conflicts with the law). The system adopts a hybrid reasoning architecture: combining forward reasoning (deriving possible conclusions from known conditions) and backward reasoning (finding supporting evidence from the target conclusion) to adapt to different risk assessment scenarios. During the reasoning process, the system specifically implements an "uncertainty reasoning" mechanism, using fuzzy logic to handle the "gray areas" in legal reasoning, assigning a confidence score to the conclusion rather than a simple yes / no judgment. The system's reasoning engine supports complex conditional expressions and multi-step derivations: it can handle compound conditions (AND, OR, and NOT logical combinations); it supports the application of recursive rules, allowing the conclusion of one rule to serve as a premise for another; and it implements a priority mechanism to handle rule conflicts (such as the hierarchical application of different legal norms). During reasoning, the system also incorporates legally specific reasoning rules, such as the jurisprudential principle of "strict interpretation of disclaimers" and "law takes precedence over contractual terms." The reasoning process dynamically records the reasoning steps, applied rules, and intermediate conclusions, forming a complete reasoning trajectory. Through this professional legal rule-based reasoning mechanism, the system conducts in-depth assessments of each risk point, generating detailed assessment results that include risk type, risk level, legal basis, and possible consequences. These results are directly based on legal norms and jurisprudential logic, possessing professional reliability.

[0096] Finally, the system transforms the complex reasoning process into clear and understandable analytical results, and provides specific and feasible modification suggestions. First, the system records and structures the entire reasoning process, capturing key decision nodes and reasoning links. Based on these records, the system constructs a visual reasoning chain, using a directed graph to display the complete logical path from contract terms to legal basis to risk conclusions, using node colors and edge types to distinguish different reasoning elements and relationship types. Simultaneously, the system generates natural language explanations, transforming the reasoning process into professional yet easy-to-understand explanatory text. These explanations employ a combination of template generation and dynamic text generation: the core structure is generated through predefined legal interpretation templates to ensure professional standardization; the specific content is dynamically created by the natural language generation module, adjusting the expression according to specific cases. The explanatory text typically includes four parts: risk identification (describing the identified risks and their location in the contract); legal basis (citing relevant legal provisions and judicial interpretations and explaining their applicability); potential impact (analyzing the possible legal consequences and commercial impacts of the risk); and expert analysis (providing in-depth analysis from a legal professional perspective). The system places special emphasis on the adaptability of its explanations, adjusting the density of technical terms used according to the user's professional background. This satisfies the rigorous needs of legal professionals while providing clear understanding for non-professionals.

[0097] In providing modification suggestions, the system has developed a professional solution generation mechanism. First, it retrieves alternative clause templates and best practice cases related to the current risk clause from the legal knowledge graph, matching and filtering them based on clause type, risk nature, and contract background. Then, it adapts the retrieved templates to the specific circumstances of the current contract (such as transaction type, party relationships, and transaction amount) to ensure the feasibility of the suggestions. For particularly complex risk points, the system also features a multi-solution comparison mechanism, generating 2-3 solutions with different focuses (e.g., one emphasizing legal security, another emphasizing operational convenience), listing the advantages and disadvantages of each solution, allowing users to choose according to their needs. All modification suggestions are accompanied by legal explanations, explaining why the suggestion can effectively reduce or eliminate the identified risks. Finally, the system integrates risk analysis and solutions, generating a structured, in-depth analysis report, including five main parts: risk summary, detailed analysis, legal basis, modification suggestions, and references, providing users with comprehensive and practical risk response guidance.

[0098] This in-depth legal analysis phase significantly enhances the professional depth and practical value of risk assessment. Compared to methods relying solely on large language models, this analysis based on legal knowledge graphs and professional reasoning rules offers clear advantages: assessment results are directly linked to authoritative legal basis, rather than the "black box" judgment of a model; the reasoning process follows legal professional logic, considering the unique hierarchical application and interpretation principles of law; and the proposed modifications are based on actual legal practice and best practices, ensuring operability. Through this professional processing, the system can not only identify risks but also explain their legal basis and provide concrete solutions, achieving full-process support from risk discovery to risk resolution. As the legal knowledge graph continues to expand and the reasoning rules are continuously optimized, the system's legal analysis capabilities will be further enhanced, providing users with increasingly accurate and professional legal risk management services.

[0099] S5: Based on the in-depth analysis results and the risk case library, risk analogy analysis is performed through similarity calculation and case reasoning to obtain a complete risk report verified by the cases.

[0100] This step is the verification and enrichment phase of the intelligent contract risk identification system. By comparing and analogizing the results of the preliminary in-depth analysis with real judicial cases, the accuracy of risk prediction is further verified. Real-world cases demonstrate the actual consequences of potential risks, ultimately generating a highly credible and persuasive comprehensive risk report. This step overcomes the limitations of purely theoretical analysis, adding a practical dimension to risk assessment.

[0101] First, the system establishes a precise matching mechanism between in-depth analysis results and a case library. For each identified risk point, the system extracts key elements from the risk description, relevant contract terms, and legal basis to construct a multi-dimensional feature vector. These features include risk type (such as breach of contract liability, intellectual property risk, etc.), applicable legal provisions, points of contention, industry sector, and potential consequences. The system then uses these feature vectors to search and match in a structured risk case library, identifying historical cases similar to the current risk point. The matching process employs a multi-stage screening strategy. First, a coarse-grained screening is performed based on risk type and legal provisions. Then, algorithms such as cosine similarity and Jaccard similarity are used to calculate the comprehensive similarity between the cases and the current risk point. Finally, several cases with the highest similarity (usually 3-5) are selected as reference cases.

[0102] Next, the system conducts in-depth case similarity analysis to accurately assess the relevance and applicability of historical cases to the current risk context. The case similarity analysis employs a weighted multi-feature comparison method, assigning different weights to different dimensions of the cases. For example, when assessing intellectual property risks, the similarity of contractual wording carries a higher weight; while when assessing liability limitation clauses, the equality of the parties' status and industry practices carry higher weights. The system also considers the time factor, assigning higher weights to recent cases to reflect the latest trends in judicial practice. Furthermore, the system analyzes the trial level and influence of the cases, giving higher weights to Supreme Court judgments and guiding cases. Through this multi-dimensional weighted calculation, the system generates a comprehensive similarity score for each matched case and sorts the most relevant cases from highest to lowest similarity.

[0103] After identifying relevant cases, the system employs case-based reasoning techniques to extract valuable information and experience for current risk analysis from historical cases. Case-based reasoning first analyzes the key elements of the case, including the points of contention, the arguments adopted by the court, the reasoning behind the judgment, and the final outcome. Then, the system applies case analogy to map the context, arguments, and results of historical cases to the current contractual situation. For example, if the current contract contains a unilateral interpretation clause similar to one in a historical case, the system analyzes the court's attitude and handling of such clauses in that case and infers the potential legal risks of the current clause. This case analogy not only verifies the accuracy of the preliminary theoretical analysis but also provides more specific risk realization paths and possible consequences.

[0104] Based on case analysis, the system further optimizes and adjusts the risk assessment results. The system compares the similarities and differences between theoretical analysis results and case practice results, adjusting risk ratings and predictions when significant discrepancies are found. For example, if theoretical analysis considers a clause to have low risk, but multiple similar cases show that such clauses are frequently ruled invalid by courts, the system will correspondingly increase the risk level. Simultaneously, the system also extracts the courts' judgment tendencies and considerations from the cases, generating more actionable risk avoidance suggestions. This approach, combining theory and practice, significantly improves the accuracy and practicality of risk assessment.

[0105] Next, the system generates specific risk consequences and impact analyses supported by the case studies. For each risk point, the system extracts the actual legal consequences from the matched cases, including situations where the clause is deemed invalid, the actual amount of compensation awarded, and the impact on business relationships. These actual consequences are then compared and analyzed with the current contractual context. For example, for a contract containing excessively high liquidated damages clauses, the system cites multiple cases where courts reduced liquidated damages under Article 114 of the Contract Law, demonstrating the actual reduction percentages and the factors considered by the courts, and predicting the potential range of adjustment for liquidated damages in the current contract. This consequence analysis based on real-world cases makes risk assessment more concrete and intuitive, helping legal professionals clearly understand the actual impact of risks.

[0106] Finally, the system integrates the results of the preliminary in-depth analysis and case studies to generate a comprehensive and detailed risk report. The report adopts a hierarchical structure, first presenting a risk summary and overall assessment, then detailing each risk point in descending order of risk level. For each risk point, the report includes the risk type, risk level, confidence score, theoretical reasoning chain (including legal basis), case support (including brief descriptions and key judgment points of 3-5 typical cases), expected legal consequences, business impact assessment, and specific modification suggestions. The report also includes a risk correlation diagram, illustrating the relationships and impact paths between different risk points. Furthermore, based on case analysis, the system generates differentiated risk management recommendations, including high-risk clauses that must be modified, medium-risk clauses that can be balanced by other clauses, and acceptable low-risk clauses. It also provides multiple modification options tailored to different business objectives, helping decision-makers balance legal risks and business goals.

[0107] Through this case study verification and enrichment process, the system combines theoretical analysis with practical experience to generate a comprehensive risk report that is both theoretically profound and practically supported. This approach, combining theoretical reasoning and case analogy, significantly improves the accuracy, credibility, and persuasiveness of risk analysis, providing legal professionals with a comprehensive and practical risk management tool. The complete risk report not only helps users identify and understand potential risks in contracts but also demonstrates the specific paths and consequences of risk realization through real-world cases, providing targeted solutions to maximize support for enterprises' contract risk management efforts.

[0108] In some embodiments, step S5 may specifically include: extracting key features of the risk clause based on the deep analysis results, converting the key features into high-dimensional vector representations using a BERT pre-trained language model to obtain a feature vector set of the risk clause, wherein the key features include clause type, restricted object, and scope of liability; calculating the similarity with each judicial precedent based on the feature vector set of the risk clause and the risk case library, identifying judicial precedents with similarity exceeding a preset threshold to obtain a set of similar cases; analyzing the risk evolution path and final result in the judicial precedents based on the set of similar cases, identifying common risk patterns and characteristics, applying case reasoning algorithms for analogical analysis, predicting the possible consequences of the current risk, and obtaining a risk prediction result based on the judicial precedents; calculating a risk score based on the risk prediction result and the deep analysis results, combined with the risk severity, probability of occurrence, and legal impact, to obtain a risk rating result; and generating a structured risk report including a summary, detailed analysis, and visualization based on the risk rating result, combined with the risk point, the legal provisions, the reasoning chain, the judicial precedents, and the modification suggestions, to obtain the complete risk report.

[0109] In this embodiment, the system first extracts key features of the risk clauses (such as clause type, restricted objects, scope of liability, etc.), and converts the text features into high-dimensional vector representations using a pre-trained language model (such as BERT), outputting a feature vector set of the risk clauses. Then, a vector similarity calculation algorithm (such as cosine similarity: similarity(A,B)=A·B / (|A|·|B|)) is applied to compare the current contract risk with historical cases, retrieving historical cases with similarity exceeding a threshold (such as 0.8), and outputting a set of similar cases. Next, the system analyzes the risk evolution path and final outcome in historical cases, identifies common risk patterns and characteristics, and applies case-based reasoning algorithms for analogical analysis to predict the potential consequences of the current risk, outputting a case-based risk prediction result. Finally, considering the severity of the risk (such as the potential loss size), the probability of occurrence (based on historical case statistics), and the legal impact (based on legal authority), a risk score is calculated, prioritized, and the risk rating result is output. Finally, by integrating all the information from the aforementioned analysis (risk points, legal basis, reasoning chain, similar cases, suggested solutions, etc.), a structured and complete risk report is generated, including a summary, detailed analysis, and visualization, and the final contract risk report is output.

[0110] Specifically, this step is the case prediction and report generation stage of the intelligent contract risk identification system. Through case reasoning, risk quantification, and professional report generation, it achieves a leap from static risk identification to dynamic risk prediction, transforming complex analysis results into clear and practical decision support tools. This stage integrates similar case retrieval, case reasoning, risk scoring, and report generation, forming the system's final output layer. Through this stage, the system not only answers the question "What risks exist in the contract?" but also predicts "How these risks might evolve and what consequences they might bring," providing users with comprehensive risk prevention and control information.

[0111] First, based on deep analysis results, the system extracts multi-dimensional key features of risk clauses and transforms these features into machine-computable vector representations, laying the foundation for case similarity calculation. The system employs a combined structured and unstructured feature extraction method: for structured features, the system identifies and extracts clause types (e.g., confidentiality clauses, breach of contract clauses, dispute resolution clauses), restricted objects (e.g., rights holders, obligors, third parties), scope of liability (e.g., compensation limits, exemption circumstances), and other standardized features such as time limits, geographical scope, and behavioral restrictions. For unstructured features, the system extracts the semantic core of the clauses, including key verb phrases (e.g., "shall pay," "right to terminate"), risk triggering conditions, and consequence descriptions. To achieve high-quality feature vectorization, the system uses a customized BERT pre-trained language model—specifically trained on legal corpora—capable of capturing the unique semantics of legal texts. The vectorization process employs a hierarchical representation method: first, a separate embedding vector is generated for each standardized feature (such as clause type); then, context-aware vector representations of the text features are generated using BERT; finally, the feature vectors are weighted and merged according to their importance to form a comprehensive feature vector representing the entire risk clause. The system also implements a dynamic adjustment mechanism for feature importance, automatically adjusting the weights of each dimension of features based on different risk types. For example, for confidentiality clauses, the weights of information scope and time restrictions are automatically increased. Through this meticulous feature engineering, the system transforms each risk clause into a high-dimensional vector representation of hundreds of dimensions, fully capturing the semantic and structural features of the clause, providing a precise computational foundation for subsequent similar case retrieval.

[0112] Based on the generated feature vector set of risk clauses, the system achieves efficient and accurate judicial precedent similarity retrieval, identifying historical cases highly related to the current risk clauses. The system first constructs a case retrieval engine connected to a pre-established judicial precedent database containing hundreds of thousands of labeled and vectorized contract-related judicial cases. In terms of retrieval implementation, the system employs a hybrid retrieval strategy: first, it performs coarse screening using key attributes such as risk type and clause type to narrow down the candidate case range; then, it uses vector similarity calculation for precise matching within the candidate set. The similarity calculation integrates multiple algorithms: cosine similarity assesses the directional consistency of the overall vectors; weighted Euclidean distance assesses the precise matching degree of key dimensions; and Locality Sensitive Hash (LSH) technology accelerates the nearest neighbor search of large-scale vectors. The system pays special attention to the specific characteristics of legal case similarity, implementing similarity adjustments based on legal context: increasing the weight of similar cases (such as the same contract type); court level factors (higher court cases have higher weight); time factors (recent cases have higher weight); and case outcome factors (cases with clear judgments are prioritized). The system employs an adaptive similarity threshold mechanism, dynamically adjusting the threshold based on risk type and search result distribution to ensure a sufficient number of high-quality similar cases are retrieved. For each similar case, the system not only records the case ID and similarity score but also extracts key elements, including basic case information (court, date, parties), points of contention, court reasoning, and outcome. Through this specialized case retrieval mechanism, the system can accurately locate historical cases highly similar to current risk provisions from a massive case law database, forming a high-value set of similar cases.

[0113] Based on the retrieved set of similar cases, the system conducts in-depth case reasoning analysis to predict the potential legal consequences of current risk clauses. The system first performs a structured analysis of each similar case, extracting the risk evolution path—the complete development chain from contract signing to dispute occurrence and final judgment. These paths typically include: risk-triggered events (such as breach of contract by one party or changes in the external environment); the dispute development process (such as negotiation, mediation, and litigation); key facts and applicable law determined by the court; and the final judgment and allocation of responsibility. By comparing and analyzing multiple similar cases, the system identifies common risk patterns and characteristics, such as typical points of contention for specific types of clauses, arguments that courts tend to support, and common defenses. Based on this, the system applies a specially developed case reasoning algorithm. This algorithm, based on the special logic of legal reasoning, achieves a reasonable analogy from historical cases to the current situation: first, it identifies key similarities and differences between cases; then, it assesses the impact of these differences on the legal reasoning outcome; finally, based on the legal principle of "treating similar cases similarly," it derives the most likely development path and consequences of the current risk. The system also intelligently allocates case weights, assigning higher weights to more similar and referential cases. To address potential conflicts in outcomes among cases, the system employs a voting mechanism and trend analysis: the consistent outcomes of a majority of cases determine the primary predictive direction; time series analysis identifies trends in case law development, prioritizing predictions aligned with the latest trends. Through this case-based reasoning grounded in actual judicial precedents, the system generates predictions for current risk clauses, including possible risk triggering scenarios, potential points of contention, possible court rulings, and the probability distribution of liability for each party. This prediction, directly grounded in real judicial practice, possesses significant practical reference value.

[0114] Based on risk prediction and in-depth analysis, the system achieves quantitative risk assessment, transforming qualitative analysis into clear risk scores and levels. The system constructs a multi-dimensional risk scoring model, comprehensively considering three core dimensions: Risk Severity—assessing the potential losses after the risk materializes, considering direct economic losses (such as compensation amounts), indirect commercial losses (such as reputational damage), and long-term impacts (such as market access restrictions); Probability—assessing the likelihood of the risk materializing based on historical case statistics and specific contract scenarios, considering factors such as the trigger rate of similar risks in historical cases, current business environment characteristics, and contract enforcement difficulty; and Legal Impact—assessing the degree of impact of the risk on the validity and enforcement of the contract, considering whether it affects core clauses, renders the contract invalid or voidable, or affects dispute resolution. The system designs a scoring standard of 1-10 points for each dimension and implements automatic scoring based on expert rules and machine learning models. The comprehensive risk score is calculated using a weighted formula: Total Risk Score = α × Severity + β × Probability of Occurrence + γ × Legal Impact, where the weighting coefficients (α, β, γ) are dynamically adjusted based on different contract types and user risk preferences. The system maps the calculated risk score to five risk levels: Extremely High Risk (>8.5 points), High Risk (7-8.5 points), Moderate Risk (5-7 points), Low Risk (3-5 points), and Extremely Low Risk (<3 points). For each risk point, the system provides not only an overall rating but also sub-scores across three dimensions, enabling users to gain a deeper understanding of the specific components of the risk. The risk rating results also include a comparison of risk distribution within similar contracts, helping users understand the relative position of their current risk within the industry context. This quantitative risk assessment system transforms complex legal risks into intuitive and comparable numerical indicators, significantly improving the efficiency of risk communication and decision-making.

[0115] Finally, based on all the analysis results, the system generates a structured and complete risk report, transforming complex risk analysis into a clear and easy-to-understand decision support tool. The system features a modular report generation engine that automatically organizes report content and format according to user needs and risk characteristics. The standard complete risk report comprises three main parts: the summary section provides a concise risk overview, including basic contract information, risk rating charts, a quick preview of high-risk points, and a summary of key recommendations, helping decision-makers quickly grasp the overall risk situation; the detailed analysis section provides in-depth analysis of each risk point, sorted by risk level, with each risk point including a risk description, legal basis (related legal provisions and judicial interpretations), case references (similar judicial precedents and their judgments), risk prediction (possible consequences and liabilities), detailed scoring (scoring and reasons for each dimension), and modification suggestions (specific clause modification plans); the visualization section enhances the intuitive understanding of risk information through various charts, including a risk heatmap (showing the distribution of risks in different parts of the contract), a risk correlation network (showing the relationships between risk points), a reasoning chain visualization (showing key legal reasoning paths), and a risk trend chart (showing the possible evolution of risks over time).

[0116] The system implements a multi-layered report adaptation mechanism, generating differentiated content for different user roles: providing legal professionals with legal details and complete reasoning processes; offering business decision-makers risk summaries and business impact analyses; and providing technical implementation personnel with specific modification plans and operational guidance. In report generation, the system places particular emphasis on readability and usability: it uses natural language generation technology to transform technical analysis into fluent narrative text; it features a clear information hierarchy and visual guidance to highlight key information; and it provides interactive elements, allowing users to expand or collapse detailed content as needed. The system also supports multiple output formats, including web-based versions (with interactive features), PDF documents (suitable for formal archiving), and presentations (suitable for team discussions). To ensure report quality, the system implements a report quality check mechanism that automatically assesses the completeness, consistency, and professional accuracy of the report, ensuring that the generated report meets professional standards. Through this carefully designed report generation process, the system transforms complex risk analysis results into a clear, professionally presented, accurately expressed, and easily understood complete risk report, providing users with a high-value decision support tool.

[0117] This case prediction and report generation phase transforms the intelligent contract risk identification system from technical analysis to practical decision support. Through case reasoning and risk prediction, the system not only identifies static risk points but also anticipates the possible evolution paths and consequences of these risks, providing forward-looking guidance for risk prevention and control. Through risk quantification and rating, the system transforms complex legal risks into intuitive numerical indicators, facilitating user understanding of risk severity and priority. Through professional report generation, the system integrates all analytical results into structured and visualized decision-making tools, helping users efficiently understand and address contract risks. This end-to-end support of "discovery-analysis-prediction-decision" demonstrates the system's high level of professionalism and practical value, truly achieving the goal of transforming advanced artificial intelligence technology into real business value.

[0118] As the system continues to operate and evolve, the risk case database expands, further improving the accuracy of similar case retrieval and case reasoning. The risk scoring model is continuously optimized through user feedback, resulting in more precise ratings. Report generation capabilities will also be increasingly sophisticated, providing more personalized and professional decision support. This virtuous cycle of evolution ensures the system can continuously adapt to changes in the legal environment and the evolving needs of users, maintaining its long-term professional value.

[0119] S6: Display the complete risk report based on the visual interface and receive user feedback, record user feedback data, and obtain a labeled dataset for model training. The feedback includes confirmation reports or correction suggestions.

[0120] This step is the interactive feedback and continuous optimization phase of the intelligent contract risk identification system. It presents the risk analysis results to users through an intuitive visual interface and collects user feedback through a carefully designed feedback mechanism. This not only facilitates user understanding and application of the risk analysis results but also establishes a mechanism for the system's continuous learning and evolution. This phase realizes a human-machine collaborative risk identification model, combining the experience of legal professionals with the analytical capabilities of the intelligent system to form a virtuous cycle of knowledge.

[0121] First, the system features a multi-layered visualization interface, presenting risk reports to users in the most intuitive and effective way. The top layer is a risk overview dashboard, using pie charts to display the distribution of risk types, bar charts to show the distribution of risk levels, and heatmaps to highlight high-risk areas in the contract. Users can click on different areas to view detailed information. The second layer is a risk relationship network diagram, employing a force-directed graph algorithm to display the relationships and impact paths between risk points. Node size represents risk level, and edge thickness represents relationship strength. This visualization method makes complex risk relationships intuitive and understandable. The third layer is a detailed risk list, arranging risk points from highest to lowest risk level. Each risk point can be expanded to view a complete analysis, including risk description, legal basis, reasoning chain, case support, and modification suggestions. In addition, the interface provides a contract text view, highlighting risk clauses directly on the original contract text and providing sidebar annotations. This multi-layered visualization design adapts to the needs of different users, allowing for both a quick grasp of the overall risk situation and a deeper understanding of specific risk details.

[0122] Building upon a visual interface, the system implements diverse interactive functions to facilitate user understanding and operation of risk reports. Users can interact with visual elements through clicking, hovering, and dragging; for example, clicking on a risk node to view details, dragging the relationship diagram to adjust the perspective, and hovering over a clause to display risk warnings. The system also provides powerful filtering and search functions, allowing users to filter risk points by risk type, risk level, contract section, and other dimensions, or to locate specific risks through keyword searches. For complex legal analyses, the system provides an interactive reasoning chain display, allowing users to progressively view the analytical reasoning process and relevant legal basis, enhancing their understanding and trust in the risk analysis. Furthermore, the system supports report export, allowing risk reports to be exported as PDF, Word, or HTML formats for easy sharing and archiving. These interactive functions make the risk report a dynamic and explorable tool, rather than a static document, significantly improving user experience and efficiency.

[0123] The core user feedback mechanism is a key innovation of this step. The system provides refined feedback options for each risk point, including risk confirmation (fully agree / partially agree / disagree), risk level assessment (too high / moderate / too low), reasoning chain evaluation (logically correct / partially correct / incorrect), and modification suggestion evaluation (useful / partially useful / impractical). For options indicating disagreement, the system guides users to provide specific reasons and correct information. For example, when disagreeing with a risk assessment, users can choose specific reasons such as "risk assessment is incorrect," "legal basis is inapplicable," or "case analogy is inappropriate," and can enter detailed explanations or upload relevant legal evidence. Furthermore, users can add new risk points not identified by the system, or annotate and comment on existing risks. This structured feedback mechanism not only collects user evaluations but also captures valuable expertise, providing high-quality training data for the system's continuous learning.

[0124] The system employs a real-time feedback processing mechanism to ensure that user feedback immediately impacts the current analysis results. When a user provides corrective suggestions, the system immediately updates the displayed content and records a comparison of the original analysis and the user's corrections in the background. For new risk points added by the user, the system executes a risk analysis process in real time, generating a preliminary risk assessment and recommendations, and marking it as "user-added." For user-modified risk levels or descriptions, the system clearly indicates the differences between the original assessment and the user's corrections on the interface. This real-time response design allows users to immediately see the effects of feedback, enhancing the interactive experience and sense of participation. Simultaneously, the system periodically demonstrates to users how their feedback has helped improve system performance, establishing a positive feedback loop.

[0125] The system has established a comprehensive feedback data recording and annotation mechanism, transforming user feedback into high-quality training datasets. Each piece of user feedback is recorded in detail, including feedback type, content before and after modification, reasons and supplementary information provided by the user, timestamp, and user role (e.g., legal expert, contract administrator). The system performs structured processing on this raw feedback data, forming a standardized annotated dataset. Each dataset includes fields such as input text (contract terms), output labels (risk type, level, etc.), annotation source (system analysis / user correction), and reliability score (based on user's professional background and consistency). For annotations with differing opinions, the system marks the points of contention and collects opinions from multiple parties to form a weighted consensus. This annotated data is used to supervise the training and improvement of the learning model, particularly for fine-tuning the risk identification and legal reasoning capabilities of the large language model.

[0126] The system also implements a continuous learning mechanism based on user feedback, improving system performance through various methods using collected labeled data. First, model fine-tuning: the system periodically uses accumulated labeled data to perform domain-specific fine-tuning of the core language model, improving its performance in contract risk analysis. Second, knowledge base updates: new legal bases, interpretations, and cases provided by users are automatically integrated into the legal knowledge graph, enriching the knowledge foundation. Third, prompt word optimization: prompt word templates for the large language model are adjusted based on user feedback, improving the accuracy and recall rate of risk identification. Furthermore, the system monitors user feedback patterns to identify weaknesses and areas for improvement, such as a tendency for missed or incorrect identification of specific types of risks, and provides targeted training in these areas. Through these mechanisms, the system forms a closed loop of "analysis-feedback-learning-improvement," continuously enhancing the accuracy and practicality of risk analysis.

[0127] Finally, the system establishes a collaborative knowledge-sharing mechanism, transforming validated user feedback into organizational knowledge assets. The system extracts high-quality feedback confirmed by multiple experts to form a best practice library and case study library for reference and learning by other members within the organization. For specific industries or types of contracts, the system generates specialized risk checklists and guidelines based on historical feedback. Furthermore, the system supports team collaboration, allowing multiple users to comment on and discuss the same contract risk report, promoting knowledge exchange and the formation of collective wisdom. This knowledge-sharing mechanism not only improves the work efficiency of individual users but also enhances the risk management capabilities of the entire organization.

[0128] Through this interactive feedback and continuous optimization process, the system not only provides an intuitive and user-friendly visual interface for risk reports but also establishes a knowledge bridge between the system and professional users, enabling the system to continuously learn and evolve from practical use. This human-machine collaborative risk identification model combines the experience of legal professionals with the analytical capabilities of intelligent systems, forming a virtuous cycle of knowledge that continuously improves the system's performance and value. As usage time increases and feedback data accumulates, the system's risk identification capabilities will continuously strengthen, providing increasingly accurate and in-depth support for enterprises' contract risk management.

[0129] In some embodiments, step S6 may specifically include: based on the complete risk report, determining an interactive interface presentation scheme, combining the contract document with highlighted risk content, listing risk entries in tabular form containing the risk type, the confidence level, and the modification suggestion, generating an interactive chart of the inference chain, and obtaining a visual interface; based on the model output variance and inference confidence level, calculating a confidence threshold, identifying risk content with a confidence level lower than the confidence threshold, and sorting them by priority to obtain a list of risk items to be reviewed; obtaining the user's processing decisions and modification opinions for each risk item in the list of risk items to be reviewed, recording the user's operation trajectory and time data, and obtaining structured user interaction data; based on the user interaction data, extracting the risk judgment results confirmed or corrected by the user, comparing the user's modifications with the system suggestions, generating labeled data containing correct labels and error types, and obtaining the labeled dataset.

[0130] In this embodiment, the system first designs a web interface presentation method, combining the original contract text with highlighted risk points, listing risk items in tabular form (including risk type, location, confidence level, and recommendations), generating an interactive inference chain diagram, and outputting a user-friendly visual risk report interface. Then, based on the model output variance and inference confidence level, the system applies the confidence level calculation formula (e.g., confidence=1-σ² / max_variance) to identify risk points with confidence levels below a threshold, prioritizes them, and recommends them to users for manual review, outputting a list of risk items to be reviewed. Next, user feedback interaction components (such as confirmation / correction buttons, rating sliders, and modification suggestion input boxes) are designed to capture user decisions and modification opinions for each risk point, record user operation trajectories and time data, and output structured user interaction data. Finally, the system extracts the risk judgment results confirmed or corrected by the user, compares the user's modifications with the system's suggestions, automatically generates labeled data (including correct labels, error types, etc.), and outputs a structured training labeled dataset. Simultaneously, statistical analysis methods are applied to identify common error types and patterns in the system, calculate the accuracy and recall of various risks, and identify performance bottlenecks and improvement directions.

[0131] Specifically, this step is the interactive optimization and self-learning phase of the intelligent contract risk identification system. It presents the analysis results through a user-friendly interface, guides professionals to participate in review and correction, and transforms user feedback into training data for system improvement. This phase achieves a triple transformation: from static reporting to dynamic interaction, from one-way output to two-way collaboration, and from a closed system to open learning, constructing an intelligent closed loop of human-machine collaboration. The entire process integrates technologies such as interaction design, uncertainty quantification, user behavior analysis, and data annotation, establishing a mechanism for continuous system learning and evolution.

[0132] First, based on a complete risk report, the system features a meticulously designed and implemented intuitive and efficient interactive interface, transforming complex risk analysis results into user-friendly visual presentations. The system adopts an "information hierarchy" design concept, displaying risk information in layers according to importance and level of detail, avoiding information overload while ensuring key content is readily apparent. In terms of interface layout, the system implements a three-column design: the left side is the original contract document area, the middle is the risk summary area, and the right side is the detailed analysis area. The original contract document area displays the complete contract content, but uses intelligent enhanced display: risk clauses are highlighted with different colors (red for high risk, yellow for medium risk, and blue for low risk); the highlighted areas support click interaction, automatically displaying relevant analysis in the detailed analysis area on the right; it supports full-text search and risk navigation functions for quick location of specific clauses or risk points. The risk summary area displays all risk entries in a table format, including core fields such as risk ID, risk type, risk level, confidence level, and brief description, supporting multi-dimensional sorting and filtering (such as sorting by risk level or viewing only specific types of risks). The detailed analysis area adopts a card-style design, providing a comprehensive analysis of selected risk points, including five expandable panels: Risk Details (including risk description, impact analysis, and risk score); Legal Basis (listing relevant legal provisions and judicial interpretations, supporting viewing of the original text); Case References (displaying similar precedents and results, supporting viewing of case details); Reasoning Process (displaying the reasoning chain with interactive charts); and Modification Suggestions (providing specific clause modification plans, supporting one-click application to the document).

[0133] The system prioritizes professionalism and ease of use in its interface implementation. For displaying the reasoning chain, a dedicated interactive chart component visualizes the reasoning path as a directed graph. Nodes represent reasoning elements (such as contract terms, legal provisions, case judgments, etc.), and edges represent reasoning relationships (such as "support" and "conflict"). Users can click on nodes to view detailed content, expand or collapse chart sections, and adjust the layout to focus on the critical path. In presenting modification suggestions, the system uses a difference comparison approach, displaying the original clauses and suggested modified versions side-by-side, using color to highlight deleted and added content, clearly showing the changes. The system also implements customization settings, allowing users to adjust the interface layout, risk thresholds, and level of detail according to their preferences. Technically, the system employs responsive design, supporting adaptive display on different devices (desktop computers, tablets) and achieving interface persistence, ensuring users can save and resume analysis sessions. Through this meticulously designed interface, the system transforms complex risk analysis into an intuitive and easy-to-use visualization tool, significantly reducing the cognitive burden on users to understand and apply the analysis results.

[0134] Based on rigorous uncertainty quantification methods, the system identified risk items requiring special attention and review by professionals, generating a priority review list. The system first established a comprehensive confidence assessment framework, quantifying the uncertainty of risk identification results through multiple dimensions: model output variance—measuring the consistency of judgments on the same risk point by different large language models; a large variance indicates significant discrepancies between models, increasing the uncertainty of the judgment; reasoning confidence—assessing the degree of certainty at each step in the reasoning chain, calculating the confidence score of the overall reasoning chain, considering factors such as the number of reasoning steps, the strength of evidence used at each step, and the clarity of the applicability of relevant legal rules; case matching degree—assessing the similarity level between the current risk point and historical cases; a low matching degree indicates a lack of sufficient case support; risk type characteristics—analyzing the historical accuracy of judgments for different types of risks; certain complex risk types (such as clause conflict risks) typically have high uncertainty. Based on these dimensions, the system calculated a comprehensive confidence score for each risk point and determined a reasonable confidence threshold through an adaptive algorithm. This threshold is not a fixed value, but is dynamically calculated based on the current contract type, risk distribution, and historical accuracy rate to ensure that the system can identify boundary cases that truly require manual review.

[0135] For risk points with confidence levels below a threshold, the system further implements an intelligent prioritization mechanism to ensure that professionals focus their attention on the most critical uncertain risks. The prioritization algorithm considers multiple factors: risk severity (high-risk items receive higher priority); confidence gap (the larger the gap from the threshold, the higher the priority); scope of impact (risks affecting multiple clauses or core clauses have higher priority); and decision urgency (time constraints related to contract signing or business processes). The system also establishes a risk item grouping mechanism, combining interrelated risk points (such as multiple risks within the same clause or risks in different logically dependent clauses) for easier overall review and judgment. The final generated list of risk items to be reviewed is presented in a clear hierarchical structure, with each risk item accompanied by a brief explanation of its uncertainty source and suggested areas of focus, guiding users to conduct efficient review. This intelligent uncertainty-based screening mechanism enables the system to accurately identify key risk points requiring human intervention, avoiding unnecessary workload for professionals while ensuring that complex situations truly requiring professional judgment receive sufficient attention, achieving optimal resource allocation through human-machine collaboration.

[0136] The system has established a comprehensive user interaction mechanism, collecting and recording the decision-making and modification opinions of professionals regarding the review of risk items, forming structured interactive data. The system provides users with multiple risk handling options: confirming the system's judgment (acknowledging the risk type and level identified by the system); correcting the risk type (selecting a more accurate risk classification from a preset type list); adjusting the risk level (upgrading or downgrading the severity of the risk assessed by the system); modifying the risk description (editing or rewriting the risk description text to provide a more accurate risk expression); adding missing risks (marking risk points that the system failed to identify); deleting misjudged risks (marking non-risk items incorrectly identified by the system); and adjusting modification suggestions (editing the modification suggestions provided by the system, or providing entirely new solutions). Users can complete these processing decisions through an intuitive form interface or by directly annotating on the document. The system employs a comprehensive user behavior monitoring mechanism, recording the user's complete operation trajectory, including key event data (such as viewing time, dwell time, click operations, editing behavior, etc.) and decision data (such as risk judgment modification, suggestion adoption rate, custom modification content, etc.).

[0137] To improve the quality and completeness of interactive data, the system implements intelligent assistance functions: providing structured feedback forms to guide users in providing standardized modification suggestions; achieving context-aware auto-completion to provide intelligent suggestions when users make modifications; and designing a decision-making reason collection mechanism to encourage users to briefly explain their reasons for modification or confirmation, enriching the contextual information of the feedback data. The system also pays special attention to collecting user sentiment and satisfaction data, understanding user satisfaction with the system's analysis through brief rating questions or emoticon selections. All collected interactive data undergoes preprocessing and structuring to form a unified formatted user interaction dataset, including multiple dimensions such as risk ID, original judgment, user decision, modified content, operation time, and dwell time. This rich interactive data not only provides valuable training material for system improvement but also offers in-depth insights into understanding user decision-making behavior and professional judgment patterns. The system strictly adheres to data privacy protection principles, desensitizing and anonymizing all interactive data to ensure the privacy and security of users and contractual parties while improving the system.

[0138] Finally, based on the collected user interaction data, the system generated a high-quality labeled dataset through a carefully designed data processing workflow, providing valuable resources for the system's continuous learning and evolution. The system first extracts and standardizes users' risk judgment results, including two categories: confirmed judgments and corrected judgments. For risk items confirmed by users, the system marks them as correct judgment samples, enhancing the confidence of the corresponding model parameters. For risk items corrected by users, the system records in detail the differences between the original judgment and the corrected judgment, forming error correction samples. To generate high-quality training labels, the system further analyzes the specific differences between user modifications and system suggestions, performing a refined difference analysis: identifying modification types (such as risk type correction, level adjustment, description optimization, etc.); calculating the magnitude of modifications (such as the number of risk level adjustments, the similarity difference of text modifications); extracting modification patterns (identifying common modification types and patterns); and associating modification basis (such as the reasons for modification provided by users, cited legal provisions, etc.).

[0139] Based on these analyses, the system generates a structurally complete and information-rich labeled dataset. Each record includes: original input data (contract text, clause context); system judgment results (risk type, risk description, risk level, confidence level, reasoning path); correct label (judgment confirmed or corrected by the user); error type (e.g., misjudgment, omission, level misjudgment); error severity (measures the deviation between the original judgment and the correct judgment); modification details (specific modifications and reasons made by the user); and metadata (timestamp, user's professional background, and other contextual information). The system also implements a data quality control mechanism to filter out anomalous samples that may contain random operations or obvious errors, ensuring the reliability of the labeled data. To further enrich the value of the labeled data, the system performs annotation enhancement processing: adding case association information to link user judgments with relevant judicial precedents; generating comparative samples to group similar but different judgments to help the model learn subtle differences; and constructing a difficult sample set, specifically marking cases where multiple users have made corrections or made significant corrections as key learning targets.

[0140] These carefully processed labeled datasets were used for several system improvements: training and fine-tuning large language models to improve the accuracy of risk identification; optimizing inference rules and adjusting rule parameters that might lead to misjudgments; improving similar case matching algorithms to enhance the accuracy of case retrieval; and optimizing risk scoring models by adjusting the weighting system of various risk factors. Through this continuous learning mechanism based on feedback from professional users, the system can continuously accumulate professional knowledge, optimize judgment logic, and improve analytical accuracy, forming a virtuous cycle of evolution. As labeled data continues to accumulate, the system's performance will gradually approach the judgment level of professional legal personnel, achieving a deep integration of artificial intelligence and legal expertise.

[0141] This interactive optimization and self-learning phase enables the intelligent contract risk identification system to transcend the one-way service model of traditional AI systems, establishing a true intelligent ecosystem of human-machine collaboration and co-evolution. Through a meticulously designed interface, the system transforms complex risk analysis into intuitive and usable decision-making tools, significantly improving user experience and work efficiency. By quantifying uncertainty and identifying items requiring review, the system achieves optimal allocation of human and machine resources, allowing professionals to focus on complex situations that truly require expert judgment. Through user interaction data collection and labeled data generation, the system constructs a continuous learning mechanism, transforming every piece of feedback from professionals into a driving force for system improvement. This "Human-in-the-Loop" design philosophy allows the system to continuously learn from professional practice, gradually narrowing the gap with human experts, ultimately becoming a powerful assistant to legal professionals and significantly improving the efficiency and quality of contract risk management.

[0142] As the system continues to operate and its user base expands, the collected labeled data will become increasingly rich and diverse, covering a wider range of contract types and risk scenarios. The system's learning ability will also continuously improve, gradually mastering more complex legal reasoning patterns and professional judgment standards. This continuous evolutionary characteristic enables the system to maintain a leading professional level, adapt to the ever-changing legal environment and business needs, and provide long-term value support to users. The system's ultimate goal is to become an intelligent assistant that can seamlessly collaborate with legal professionals, handling a large amount of routine analysis work to reduce the burden on professionals, while also providing valuable references on complex issues to support professional decision-making, truly realizing the beneficial supplement of artificial intelligence to legal work.

[0143] S7: Based on the labeled dataset, a reinforcement learning strategy is adopted, with the risk identification accuracy as the reward signal, to update and optimize the parameters of the joint large language model, thereby obtaining the optimized joint large language model.

[0144] This step is the self-evolutionary stage of the intelligent contract risk identification system. Through advanced reinforcement learning technology, it continuously optimizes the system's core large language model using user feedback data, enabling the model to learn and improve its risk identification capabilities through practical applications. This stage constructs a closed-loop mechanism for the system's autonomous learning, ensuring that system performance continuously improves with usage time, forming a continuously evolving intelligent system.

[0145] First, the system employs a data preprocessing and annotation quality assessment mechanism to ensure that the data used for model optimization is of high quality and representativeness. Collected user feedback data undergoes rigorous screening and cleaning to remove inconsistent, incomplete, or low-quality feedback. The system assigns a credibility weight to each piece of labeled data based on multiple factors, including the user's professional background (e.g., senior legal advisors are weighted higher than junior contract administrators), the consistency of historical user feedback (calculated by the historical consistency rate between user feedback and expert consensus), the level of detail in the feedback (feedback providing detailed reasons and legal basis receives higher weight), and the recentity of the feedback (newer feedback reflects updated legal practices). Through this weighting mechanism, the system can prioritize learning from high-quality, high-credibility labeled data, improving learning efficiency. Furthermore, the system performs cluster analysis on the labeled data to identify imbalances in data distribution. For risk types with scarce samples, data augmentation techniques, such as synonym rewriting and template expansion, are used to generate additional training samples, ensuring that the model can learn the characteristics of various risks.

[0146] Next, a dedicated reward model was designed to transform user feedback into quantifiable reward signals to guide the reinforcement learning process. The reward model is based on multi-dimensional evaluation metrics, including the accuracy of risk identification (the proportion of correctly identified risks), recall (the proportion of successfully identified risks out of the total actual risks), the accuracy of risk level judgment (the consistency between the risk level assessed by the model and the user's confirmed level), the applicability of legal basis (the relevance and accuracy of cited laws and regulations), the logicality of the reasoning chain (the rigor and persuasiveness of the legal reasoning process), and the practicality of modification suggestions (the proportion of suggestions adopted by users). These metrics are comprehensively calculated into a weighted total score, serving as the primary reward signal for model optimization. The reward calculation considers the relative importance of different metrics; for example, in legal risk analysis, recall (avoiding the omission of important risks) is usually more critical than accuracy and therefore receives a higher weight. Furthermore, additional rewards are given for the correct identification of high-risk clauses, while significant penalties are imposed for the omission of serious risks, guiding the model to prioritize major risks.

[0147] Building upon this foundation, the system employs Proximal Policy Optimization (PPO) as its core reinforcement learning strategy to optimize the parameters of the joint large language model. PPO is an advanced policy gradient method characterized by high sample efficiency and stable training, making it particularly suitable for fine-tuning large language models. The system first constructs training batches from preprocessed labeled data, each batch containing multiple contract texts and their corresponding risk labels. For each sample, the system uses the current model to generate a risk analysis result and compares it with the standard answer (the user-confirmed risk report) to calculate the reward value. Then, based on the calculated reward, the system updates the model parameters using the PPO algorithm, aiming to maximize the expected reward. To prevent over-optimization from causing the model to deviate from its original language understanding capabilities, the PPO algorithm incorporates a policy constraint mechanism to ensure that the updated model does not differ excessively from the previous model. This progressive optimization method guarantees that the model can stably absorb new knowledge while retaining its basic language capabilities.

[0148] To address the complexity of legal expertise, the system employs a Mixture of Experts Fine-tuning approach. This method decomposes the joint large language model into multiple expert sub-models, each responsible for identifying a specific type of legal risk, such as contract subject risk experts, liability clause experts, and intellectual property experts. The system independently optimizes each expert sub-model by assigning labeled data from relevant legal domains, and then integrates the outputs of each expert through a gating network. The gating network dynamically allocates weights to each expert based on the characteristics of the input contract text, generating the final risk analysis results. This divide-and-conquer approach allows the model to accumulate expertise across different legal domains simultaneously, avoiding the interference and forgetting problems that occur when a single model learns all domains. Furthermore, the modular design of the expert models facilitates targeted updates to specific legal domain changes (such as the introduction of new regulations), improving the model's adaptability and maintenance efficiency.

[0149] The system also implements a knowledge distillation mechanism to more effectively integrate knowledge learned from user feedback into the large language model. First, the system trains a dedicated teacher model based on high-quality labeled data, focusing on accurate risk identification and legal reasoning capabilities. Then, the system uses the teacher model to generate a large amount of labeled synthetic data, including not only risk labels but also detailed reasoning processes and explanations. The joint large language model (acting as a student model) then learns by imitating the output of the teacher model, absorbing its legal reasoning capabilities. The knowledge distillation process employs soft labeling technology, preserving the uncertainty information in the teacher model's predictions, enabling the student model to learn more nuanced risk judgment criteria. This approach significantly improves the efficiency of knowledge transfer, allowing the model to maximize its gains from limited user feedback.

[0150] To evaluate optimization effectiveness and avoid overfitting, the system establishes a rigorous validation and testing mechanism. Labeled data is divided into training, validation, and test sets. The validation set is used for real-time monitoring of training progress and early stopping, while the test set is used for final evaluation. The system defines a comprehensive evaluation metric system, including accuracy, recall, and F1 score for risk identification, as well as more specialized legal reasoning quality scores and practicality scores for modification suggestions. During optimization, the system periodically evaluates model performance on the validation set. If performance metrics show no improvement for several consecutive rounds, an early stopping mechanism is triggered to prevent overfitting. Furthermore, the system conducts comparative tests on the models before and after optimization, including A / B testing and human evaluation, to ensure that the new model truly outperforms the old model in practical applications. Only models that pass multiple validation rounds are deployed to the production environment.

[0151] Finally, the system implements a progressive deployment and continuous monitoring mechanism to ensure that the model optimization results can be safely and effectively applied to real-world scenarios. The optimized model is first run in parallel with the production model in a sandbox environment, and the output differences between the two are compared and analyzed. Only when the new model performs better than or equal to the production model on a sufficient number of samples will its application scope be gradually expanded. The deployment process adopts a canary release strategy, first applying the new model to a small number of user requests, gradually increasing the proportion, while closely monitoring performance indicators and user feedback. If any problems are discovered, a rapid rollback to a stable version can be initiated. In addition, the system has established a long-term performance monitoring mechanism to continuously track changes in the model's performance across different types of contracts and risk categories, promptly identifying performance degradation or deviations and triggering targeted re-optimization.

[0152] Through this self-evolutionary process, the system establishes a complete closed loop from user feedback to model optimization, enabling the intelligent contract risk identification system to continuously learn and evolve from practical applications. As user feedback data accumulates and the model is iteratively optimized, the system's risk identification capabilities will continuously improve, becoming increasingly adaptable to the needs of specific organizations and industries, and transforming into a truly intelligent and personalized legal risk management assistant. This self-evolutionary capability is the core guarantee of the system's long-term value, enabling it to adapt to the ever-changing legal environment and business needs, providing enterprises with continuously value-added risk management support.

[0153] In some embodiments, step S7 may specifically include: based on the labeled dataset, performing data cleaning and augmentation, balancing the proportion of various risk samples, constructing a training set, validation set, test set, standardized features and label formats to obtain a dataset for model training; designing a reward function with risk identification accuracy as the core, constructing a reinforcement learning environment, defining contract text features as the state space and risk judgment decisions as the action space, constructing a state transition function to obtain a reinforcement learning training environment; based on the reinforcement learning training environment and the dataset for model training, applying the PPO or A2C policy gradient algorithm to train the agent, updating model parameters through gradient descent, optimizing the decision strategy, and obtaining updated model parameters; based on the updated model parameters, performing performance evaluation on the test set, calculating precision, recall and F1 score, comparing with the baseline model, selecting the best-performing model version, updating the model configuration in the production environment, determining the continuous optimization process, and obtaining performance-improved model parameters; based on the performance-improved model parameters, optimizing the joint large language model to obtain the optimized joint large language model.

[0154] In this embodiment, the system first performs data cleaning and enhancement (e.g., balancing the proportion of various risk samples and generating adversarial examples), constructs training, validation, and test sets, standardizes feature and label formats, and outputs a dataset for model training. Then, it designs a reward function centered on risk identification accuracy (e.g., R = α·accuracy + β·precision, where α and β are hyperparameters), constructs a reinforcement learning environment, defines the state space (contract text features), action space (risk judgment decision), and transition function, and outputs the reinforcement learning training environment. Next, it applies policy gradient algorithms (e.g., PPO, A2C) to train the agent, updates model parameters using gradient descent, optimizes the decision policy, and outputs the updated model parameters and optimized policy. Afterward, it performs performance evaluation on the test set, calculates metrics such as precision, recall, and F1 score, compares it with the baseline model, selects the best-performing model version, and outputs an evaluation report and the selected model parameters. Finally, it updates the model configuration in the production environment, designs model version control and rollback mechanisms to achieve hot model updates, establishes a continuous optimization process (periodic retraining and evaluation), and outputs a complete model deployment and optimization plan.

[0155] Specifically, this step is the model optimization and iterative improvement stage of the intelligent contract risk identification system. Through systematic data preparation, reinforcement learning training, and rigorous evaluation processes, user feedback is transformed into substantial improvements in model capabilities. This stage achieves a triple evolution from passive learning to active exploration, from single optimization to system iteration, and from experience-based models to data-driven approaches, establishing a technological closed loop for system self-improvement. The entire process integrates advanced technologies such as data engineering, reinforcement learning, model evaluation, and continuous integration, constructing a mechanism framework for continuous improvement of model capabilities. The core value of this stage lies in transforming user feedback data collected at the front end into performance improvements for the back end model, achieving a crucial leap from "knowing it's not good enough" to "becoming better."

[0156] First, the system performs comprehensive data engineering processing on the labeled dataset collected from user interactions, transforming raw feedback into structured, high-quality, and balanced model training resources. The system implements a multi-layered data cleaning process: outlier detection and removal—using statistical methods and domain rules to identify and remove obviously erroneous labels, such as random clicks with excessively short operation times or judgments that seriously conflict with legal common sense; duplicate sample processing—identifying highly similar clause samples and retaining the best samples or merging label information based on sample quality and label consistency; conflicting label coordination—when different users have different judgments on the same risk point, the system determines the final label through weighted voting (considering user professional background and historical accuracy) or expert review; and noisy label smoothing—for ambiguous labels in marginal cases, soft labeling techniques are applied, using probability distributions instead of hard labels to represent category attribution. The cleaned data is further expanded and balanced through data augmentation techniques: synthetic sample generation—using rule templates and controlled text transformations to generate additional risk samples, especially for risk types with scarce samples; contrast sample construction—creating clause pairs with only subtle differences but different risk judgments to help the model learn to distinguish boundary cases; feature transformation—applying transformations such as synonym substitution and word order adjustment to the original clauses to maintain semantic integrity while enriching the diversity of expression; negative sample augmentation—increasing the proportion of risk-free or low-risk clauses to avoid the model over-predicting risks.

[0157] The system pays special attention to sample balance, implementing a multi-dimensional balancing strategy: Risk type balance—by oversampling rare risk types and undersampling common risk types, it ensures a relatively balanced number of samples for each risk type while still retaining certain natural distribution characteristics; Risk level balance—ensuring a reasonable distribution of samples for high, medium, and low risk levels to avoid model bias towards specific levels; Contract type balance—balancing the number of samples for different types of contracts (such as sales contracts, service contracts, and labor contracts) to improve the model's domain generalization ability; Error type balance—ensuring that samples for various error types (such as missed judgments, misjudgments, and level misjudgments) are sufficiently representative. The processed dataset is divided into training, validation, and test sets in a 70% / 15% / 15% ratio. The partitioning process uses stratified sampling to ensure consistent distribution of key features such as risk type and contract type across the three datasets. Finally, the system standardizes all features and labels into a unified format, including input features (contract text, clause context, metadata) and output labels (risk type, risk level, risk description, etc.), forming a structurally consistent, high-quality, and balanced model training dataset. This meticulous data engineering process laid a solid foundation for subsequent model training, ensuring that the "garbage in, garbage out" problem would not affect the model optimization effect.

[0158] Based on a prepared dataset, the system designs a dedicated reinforcement learning training environment, formalizing the contract risk identification task as a decision-making problem for the agent. A reward mechanism guides the model to learn the optimal identification strategy. The system first defines a reasonable state space, which represents the environmental information observed by the agent, including: contract text features—contract clause text representations extracted using a pre-trained language model, capturing semantic and structural information; context features—including the current clause's position, its relationship with other clauses, and the overall contract structure; historical states—previously analyzed clauses and judgments made, establishing a coherent analytical context; and domain features—meta-information such as contract type, industry background, and legal environment. The action space is defined as a complete set of risk judgment decisions, including: risk type judgment—selecting one or more type labels from a predefined set of risk types; risk level assessment—determining the severity level of the risk (high, medium, low); risk description generation—generating natural language text describing the identified risk; and confidence assessment—scoring the degree of confidence in the judgment result.

[0159] The system is designed with a composite reward function centered on the accuracy of risk identification, precisely quantifying the value of different judgment results and guiding the model to make optimal decisions. The reward function comprehensively considers multiple dimensions: Basic accuracy reward – positive or negative rewards are given based on the correctness of the risk type judgment; correct identification receives a positive reward, while misjudgment and omission receive a negative reward; Risk level accuracy reward – assesses the accuracy of the risk level judgment; complete accuracy receives a full score reward, and the reward value decreases for each additional level of discrepancy; Description quality reward – assesses the similarity and professionalism of the risk description to the standard description, calculated using a semantic similarity algorithm; Key discovery reward – provides additional rewards for successfully identifying high-risk or hidden risks, encouraging the model to focus on important risk points; Confidence calibration reward – assesses the consistency between the model's confidence level and actual correctness, encouraging the model to give high confidence when certain and low confidence when uncertain. The system also introduces legally specific reward adjustments: Risk type weighting—different risk types are assigned different weights, and higher rewards are given for correctly identifying high-impact risks (such as the risk of invalid clauses); Practical value weighting—risk judgments that can lead to specific modification suggestions receive additional rewards; Misjudgment cost considerations—the legal consequences of different types of errors are taken into account, and greater penalties are given for misjudgments that may lead to serious consequences (such as omitting key risks is more serious than misjudging low risks).

[0160] The system constructs a complete state transition function to simulate the sequential process of contract analysis: starting from the initial state of the contract, each time a clause is selected for analysis, the agent makes a risk judgment decision (action), the system calculates a reward based on the standard answer and updates the state, moving to the next clause, until the entire contract is analyzed. The complete state transition process considers the correlation between clauses and overall consistency, enabling the agent to learn a coherent analysis strategy. The system also designs an exploration mechanism during training. By adjusting the randomness parameter, more exploration is encouraged in the early stages of training to discover potential optimal strategies. As training progresses, exploration is gradually reduced while utilization is increased to ensure convergence to the optimal solution. This complete reinforcement learning environment formalizes the contract risk identification task into a clear decision problem, and guides the model to learn professional risk judgment strategies through a carefully designed reward mechanism, achieving a key shift from passive learning to active exploration.

[0161] Based on the constructed reinforcement learning environment, the system applies advanced reinforcement learning algorithms to optimize model parameters and improve risk identification decision-making strategies through continuous interaction with the environment. The system prioritizes the stable and efficient Proximal Policy Optimization (PPO) algorithm as the primary training method, supplemented by the Advantage Actor-Critic (A2C) algorithm in certain scenarios. The core advantage of the PPO algorithm lies in its good stability and sample efficiency. By limiting the step size of policy updates (through limiting the KL divergence between the old and new policies), drastic fluctuations during training are avoided. The system's training process includes four key steps: Experience Collection—allowing the current policy to interact with the environment, analyzing a certain number of contract samples, and collecting experience data such as state, action, reward, and next state; Advantage Estimation—calculating the advantage value of each action relative to the average performance, identifying which actions bring higher-than-expected returns; Policy Optimization—updating the policy network parameters based on the calculated advantage value using gradient descent to increase the probability of selecting high-advantage actions; and Value Function Optimization—synchronously updating the value network to improve the accuracy of future reward predictions.

[0162] To adapt to the specific needs of contract risk identification, the system has been specifically optimized for standard algorithms: Multi-objective policy network – a multi-head policy network capable of simultaneously outputting risk type, level, and confidence level is designed to handle multi-dimensional decision-making problems; Hierarchical decision-making process – risk identification is decomposed into a hierarchical decision-making process of "risk existence → risk type → risk level," with each level using a dedicated sub-policy network; Joint reward decomposition – the composite reward function is decomposed into the contributions of each component, achieving more refined credit allocation and clarifying the advantages and disadvantages of different decision dimensions; Course learning strategy – simple samples and lenient rewards are used in the early stages of training, gradually increasing the difficulty and reward precision as the model's capabilities improve, achieving progressive learning. The system adopts a deep neural network based on the Transformer architecture as the basic model for the policy network and value network, fully utilizing its advantages in processing sequence data. To further improve training efficiency, the system implements a distributed training framework, supporting parallel interaction in multiple environments to accelerate experience collection; it implements an experience replay buffer to reuse valuable historical experience; and it employs adaptive learning rate adjustment, automatically adjusting the optimization step size according to training progress.

[0163] Through this specialized reinforcement learning training process, the system enables the model to gradually master the optimal mapping relationship from contract text features to risk assessment, and learn to make appropriate risk assessment decisions based on different situations. Compared with traditional supervised learning methods, reinforcement learning has significant advantages: it can directly optimize the final evaluation metric (such as the F1 score) rather than an intermediate loss function; it can learn sequential decision-making strategies, considering the correlation between clauses; and it can balance the costs of different types of errors, adapting to the specific needs of legal risk assessment. During training, the system continuously monitors performance metrics on the validation set, implements an early stopping strategy to avoid overfitting, and ultimately obtains the optimal model parameters. These parameters, optimized through reinforcement learning, capture complex legal risk judgment patterns, guiding the model to make risk identification decisions that more closely resemble those of professionals.

[0164] Based on the updated model parameters, the system implemented a rigorous performance evaluation process to ensure the effectiveness and reliability of model improvements and to establish an iterative mechanism for continuous optimization. The evaluation process first involved comprehensive testing on a reserved test set, calculating a series of key performance indicators: Precision – assesses the proportion of true risks among the risk points identified by the model, measuring the reliability of the model's judgment; Recall – assesses the proportion of true risks successfully identified by the model, measuring the model's risk coverage capability; F1 score – the harmonic mean of precision and recall, comprehensively evaluating the model's overall performance; Risk level accuracy – assesses the accuracy of risk level judgments; Confidence calibration error – assesses the consistency between the model's confidence level and the actual accuracy. These indicators are not only calculated at the overall level but also analyzed in detail according to risk type, contract type, and other dimensions, forming a multi-dimensional performance profile. The system also includes specialized legally specific evaluation metrics: Key Risk Coverage – assessing the completeness of high-risk point identification; Misjudgment Cost – calculating the weighted error cost considering the actual impact of different error types; Consistency Index – assessing the consistency of the model's judgments in similar situations; Improvement Rate – assessing the extent of the model's progress after learning compared to the user's judgment before correction.

[0165] In addition to quantitative metrics, the system also implemented qualitative evaluation: typical case analysis—in-depth analysis of the model's performance on specific representative cases to identify its strengths and weaknesses in specific scenarios; error pattern analysis—classifying and summarizing common error types and causes to identify system shortcomings; boundary testing—using specially designed challenging cases to test the model's robustness and assess its reliability under extreme conditions. The evaluation results were comprehensively compared with baseline models, including the original model before optimization, variants trained with purely supervised learning, and comparable commercial systems. Based on the multi-dimensional comparison results, the system selected the best-performing model version, paying particular attention to improvements in key metrics and enhancements in practical application value. To ensure the model's stability in real-world environments, the system also implemented a canary release strategy: first deploying the updated model in a limited production environment, closely monitoring actual performance, and only fully updating the production configuration after confirming stability and reliability.

[0166] The system has established a comprehensive continuous optimization process to ensure long-term, continuous improvement of the model: Regular model retraining—automated retraining plans are set up, triggering the training process once sufficient new labeled data has been accumulated; continuous evaluation and monitoring—model performance metrics are continuously tracked in the production environment to promptly identify potential problems; an A / B testing framework—supports running multiple model versions simultaneously, comparing actual results to select the optimal solution; and data recycling—new feedback from the production environment is automatically incorporated into the training dataset, forming a continuous learning loop. Through this rigorous evaluation and optimization process, the system not only verifies the effectiveness of current improvements but also establishes a long-term, continuous improvement mechanism, ensuring the model can adapt to constantly changing legal environments and user needs.

[0167] Finally, the system integrates the optimized model parameters into the joint large language model architecture, achieving a synergistic improvement in the overall system capabilities. The optimization process mainly includes four aspects: large language model fine-tuning—using PEFT (Parameter-Efficient Fine-Tuning) technology to efficiently fine-tune the parameters of the basic large language model, injecting risk identification knowledge obtained from reinforcement learning while retaining the model's general capabilities; decision-making layer update—replacing the risk identification decision-making layer in the joint model with reinforcement learning-optimized parameters to enhance core judgment capabilities; knowledge enhancement integration—adding newly learned knowledge to the model's knowledge base in a structured form to enhance the knowledge foundation for risk reasoning; and reasoning strategy optimization—adjusting reasoning strategy parameters based on reinforcement learning results to improve the accuracy and efficiency of legal reasoning. The system places particular emphasis on maintaining the balance and synergy among the model's components: ensuring that the improvement in risk identification capabilities does not impair text understanding and generation capabilities; guaranteeing the consistency of legal analysis and professional interpretation capabilities; and maintaining the coherence of risk rating and modification suggestion generation.

[0168] The system implements a model fusion strategy, combining the advantages of multiple training versions: conditional fusion—dynamically selecting the most suitable model version for judgment based on contract type and risk characteristics; voting fusion—for key decisions, combining the judgment results of multiple model versions and arriving at a final conclusion through a weighted voting mechanism; and hierarchical fusion—different models are responsible for different stages of the decision-making process, such as one focusing on risk detection and another on risk classification. Through this composite optimization strategy, the system achieves a synergistic improvement in the overall capabilities of the joint big language model, significantly enhancing the professional depth and accuracy of risk identification while maintaining the model's general capabilities. The optimized joint big language model not only performs excellently in quantitative indicators but also demonstrates judgment capabilities closer to those of professional legal personnel in practical applications, providing users with more reliable and professional contract risk analysis services.

[0169] This model optimization and iterative improvement phase completes the full learning loop of the intelligent contract risk identification system, transforming front-end user feedback into a substantial improvement in back-end model capabilities. Through systematic data engineering, the system transforms disorganized user feedback into high-quality training resources; through a professionally designed reinforcement learning environment, the system formalizes the risk identification task into an optimizable decision problem; through advanced reinforcement learning algorithms, the system extracts the optimal risk judgment strategy from empirical data; through rigorous evaluation and deployment processes, the system ensures the effectiveness and reliability of model improvements; and through overall optimization and integration, the system achieves synergistic improvement of the joint large language model. This complete "data-training-evaluation-deployment-optimization" loop enables the system to continuously learn and evolve from practical applications, constantly narrowing the gap with human experts.

[0170] As the system continues to operate and evolve, its performance will show an accelerating trend of improvement: with the accumulation of labeled data, the data foundation for model training becomes increasingly rich; with the improvement of optimization techniques, the model learning efficiency continues to increase; and with the expansion of the system's application scope, it can cover more diverse contract scenarios and risk types. This virtuous cycle will drive the system's continuous development, ultimately achieving risk identification capabilities approaching those of professional legal personnel, truly becoming a trustworthy intelligent assistant for legal professionals. The system's success is not only reflected in the improvement of technical indicators, but more importantly, in the growth of its practical application value—helping users identify and manage contract risks more efficiently and accurately, providing tangible guarantees for the organization's legal compliance and business success.

[0171] Furthermore, in some embodiments, the model parameter update process also includes a hyperparameter tuning step based on convex quadratic programming: the parameter optimization problem of the risk identification model is transformed into a standard convex quadratic programming form, a dual-loop control structure containing inner and outer loops is constructed, a solver based on the primal and dual interior-point methods is implemented, a composite reward function is designed to evaluate the model accuracy, solution efficiency, and parameter stability, and a hyperparameter optimization environment is obtained; based on the hyperparameter optimization environment, a reinforcement learning state space containing the current model performance index, the interior-point solver state, historical hyperparameter values ​​and their effects, and task difficulty index is constructed, an action space containing interior-point parameters, model complexity control parameters, reward function weights, learning rate, and momentum parameters is defined as the hyperparameter adjustment vector, a hyperparameter adjustment mechanism based on congestion detection and flow regulation is implemented, and a hyperparameter adjustment strategy is trained using a proximal policy optimization algorithm to obtain an optimized hyperparameter configuration.

[0172] This step represents the hyperparameter adaptive tuning stage in the intelligent contract risk identification system. By combining traditional convex optimization theory with modern reinforcement learning methods, dynamic adaptive optimization of hyperparameters is achieved, solving the complex challenge of hyperparameter selection during large-scale language model fine-tuning. This innovative approach not only improves the efficiency and stability of model optimization but also enables the system to automatically adjust the optimal parameter configuration according to different task characteristics, significantly enhancing the model's generalization ability and robustness.

[0173] First, the system innovatively transforms the parameter optimization problem of large language models into a standard convex quadratic programming form, laying the foundation for accurate solutions and theoretical analysis. Although the optimization problem of deep neural networks is typically non-convex, the system employs a local quadratic approximation technique, expanding the objective function into a quadratic form near the current parameter point in each iteration. Specifically, the system calculates the first-order gradient of the loss function with respect to the model parameters and the second-order Hessian matrix, and then constructs a quadratic approximation objective function: f(θ) ≈ f(θ). k ) + ∇f(θ k )ᵀ(θ-θ k ) + 0.5(θ-θ k )ᵀH(θ k )(θ-θ k ), where θ k Let represent the parameter vector for the k-th iteration. To handle the potential non-positive definiteness of the Hessian matrix, the system uses an improved Levenberg-Marquardt method, adding regularization terms to the diagonal elements of the Hessian matrix to ensure the convexity of the quadratic programming problem. Furthermore, the system introduces a trust region constraint based on KL divergence to limit the step size of each parameter update, forming a complete convex quadratic programming problem: min_θ ∇f(θ) k )ᵀ(θ-θ k ) + 0.5(θ-θ k )ᵀ(H(θ k )+λI)(θ-θ k ), stKL(πθ||πθ) k ) ≤ δ, where πθ represents the policy distribution with parameter θ, and δ is the radius of the trust region. This formalization enables the system to leverage mature convex optimization theory and efficient numerical solution methods to improve the accuracy and stability of parameter updates.

[0174] Based on this mathematical framework, the system constructs a dual-loop control structure comprising an inner loop and an outer loop to achieve hierarchical management of parameter optimization and hyperparameter tuning. The inner loop is responsible for solving the convex quadratic programming problem under a given hyperparameter configuration and updating the model parameters; while the outer loop evaluates the optimization effect of the inner loop and adjusts the hyperparameter configuration to improve the parameter optimization in the next round. This hierarchical structure enables the system to optimize parameters at different levels on different time scales, effectively handling the complexity of model optimization. The inner loop adopts an iterative solution strategy, performing a parameter update after each training batch; while the outer loop performs hyperparameter tuning once after multiple inner loops are completed (usually a complete training cycle). To ensure coordination between the two loops, the system designs a state transfer mechanism, passing the optimization state of the inner loop (such as the objective function value, gradient norm, Hessian matrix eigenvalue distribution, etc.) to the outer loop as the basis for hyperparameter tuning. This dual-loop structure not only improves the computational efficiency of the system but also decouples hyperparameters from model parameters, enabling hyperparameter tuning to be based on a more global optimization objective.

[0175] To efficiently solve convex quadratic programming problems within inner loops, a dedicated solver based on primal and dual interior-point methods is implemented. Interior-point methods are powerful tools for handling constrained optimization problems, transforming constraints into penalty terms by introducing barrier functions, thus turning the problem into unconstrained optimization. The implemented interior-point solver has the following innovative features: First, it employs a preprocessed conjugate gradient method to solve linear systems in the interior-point method, avoiding direct computation and storage of large-scale Hessian matrices, significantly reducing memory requirements and computational complexity. Second, it implements the primal-dual interior-point method, simultaneously updating both primal variables (model parameters) and dual variables (Lagrange multipliers), improving convergence speed and numerical stability. Third, it adopts an adaptive step-size strategy, dynamically adjusting the step size based on the curvature of the objective function and the strictness of the constraints, balancing convergence speed and stability. Finally, it implements a warm-start mechanism, using the solution from the previous interior-point iteration as the initial point for the next iteration, accelerating the solution process. These techniques enable the interior-point solver to efficiently handle large-scale model parameter optimization problems, quickly converging to high-quality solutions even with millions of parameters.

[0176] The system employs a multi-objective composite reward function to comprehensively evaluate all aspects of model optimization, providing holistic guidance for hyperparameter tuning. This reward function consists of three main components: model accuracy evaluation, solution efficiency evaluation, and parameter stability evaluation. The model accuracy component calculates the model performance score based on metrics such as accuracy, recall, and F1 score for risk identification. The solution efficiency component considers the convergence speed, iteration count, and computational resource consumption of the interior-point solver, encouraging efficient optimization. The parameter stability component monitors the magnitude of model parameter changes, gradient norm, and eigenvalue distribution to prevent excessive parameter updates from causing training instability. These components are weighted and combined using adjustable weights to form the final composite reward signal. Importantly, these weights are themselves part of the hyperparameters, and the system dynamically adjusts the relative importance of each component based on task characteristics and training phases. For example, in the early stages of training, more emphasis may be placed on optimization efficiency, while in later stages, more attention may be paid to model performance and stability. In this way, the composite reward function can comprehensively guide hyperparameter optimization, balancing the trade-offs between multiple objectives.

[0177] Based on the above design, the system constructs a complete hyperparameter optimization environment, serving as the interactive space for reinforcement learning agents to adjust hyperparameters. This environment includes three core components: state observation, action execution, and reward calculation. The state observation module collects various information to construct rich state representations, including: current model performance metrics (such as accuracy, loss value, validation set performance, etc.), interior-point solver states (such as convergence speed, KKT condition satisfaction, obstacle parameter values, etc.), historical hyperparameter values ​​and their effects (hyperparameter configurations and corresponding reward values ​​from previous adjustments), and task difficulty metrics (such as data complexity, gradient noise level, model capacity utilization, etc.). This information undergoes feature engineering to form a structured state vector, which is provided to the reinforcement learning agent as a decision-making basis. The action execution module receives the agent's decision (hyperparameter adjustment vector), applies it to the inner loop optimization process, and then runs the inner loop for a certain number of steps to observe its effect. The reward calculation module evaluates the effect of this hyperparameter adjustment based on a composite reward function and generates a reward signal to feed back to the agent. The entire environment design follows the Markov decision process framework, enabling reinforcement learning methods to effectively learn hyperparameter adjustment strategies.

[0178] Based on this environment, the system constructs a detailed reinforcement learning state space to capture key information during the hyperparameter optimization process. This state space is a high-dimensional vector containing four types of information: First, the current model performance metrics, including accuracy, recall, F1 score, loss value, etc. on the training and validation sets, as well as the trends of these metrics (difference values ​​from recent iterations); second, the interior-point solver state, including technical metrics such as iteration count, KKT residuals, central parameters, and duality gap, reflecting the efficiency and quality of the solution process; third, historical hyperparameter values ​​and their effects, recording the hyperparameter configurations and corresponding composite reward values ​​adjusted in the past few iterations, helping the agent understand the relationship between parameter changes and performance changes; and finally, task difficulty metrics, including the complexity estimate of the current batch of data, the noise level of the model gradient, and whether the model's capacity is sufficient for the current task. These metrics are normalized and feature selected to form a well-structured state vector, enabling the reinforcement learning agent to accurately perceive the state of the optimization environment and make informed hyperparameter adjustment decisions.

[0179] Accordingly, the system defines a comprehensive hyperparameter action space, containing key parameters that affect various aspects of model optimization. This action space is a multi-dimensional vector, with each dimension corresponding to a class of hyperparameters: The first class is interior-point method parameters, including initial obstacle parameter μ0, obstacle reduction coefficient σ, centering parameter γ, etc., which control the convergence characteristics of the interior-point method; the second class is model complexity control parameters, including L1 and L2 regularization coefficients, Dropout rate, early stopping threshold, etc., which affect the model's generalization ability and prevent overfitting; the third class is reward function weights, which determine the relative importance of each component in the composite reward function and affect the focus of optimization; the fourth class is learning rate-related parameters, including the base learning rate and learning rate scheduler parameters (such as decay rate, period length, etc.); and finally, momentum parameters, including momentum coefficient, Nesterov accelerator switch, etc., which affect the stability and convergence speed of optimization. To improve exploration efficiency, the system imposes appropriate constraints and transformations on the action space. For example, it uses a logarithmic scale to represent parameters with a wide range of values ​​and uses relative changes rather than absolute values ​​to represent adjustments to certain parameters. These designs enable reinforcement learning agents to explore and utilize the action space more effectively.

[0180] The system innovatively implements a hyperparameter adjustment mechanism based on congestion detection and flow regulation, drawing inspiration from network transmission control protocols to address instability during optimization. This mechanism comprises three core components: congestion detection, a response strategy, and a recovery mechanism. The congestion detection module continuously monitors key metrics during optimization, such as loss fluctuations, gradient explosion, and parameter divergence, identifying potential "congestion" (training instability) states. Upon detecting a congestion signal, the response strategy module is immediately triggered, taking corresponding measures such as temporarily reducing the learning rate, increasing regularization strength, and shrinking the trust region radius, similar to reducing the congestion window in network protocols. After congestion is resolved, the recovery mechanism gradually adjusts the hyperparameters back to a more aggressive configuration, improving optimization efficiency, similar to the additive increase of the congestion window. This mechanism enables the system to achieve a balance between pursuing rapid convergence and maintaining training stability, adapting to changes in different training stages and data characteristics. Especially when dealing with noisy user feedback data, this adaptive mechanism effectively prevents model updates from deviating from the correct direction, improving the stability and sample efficiency of reinforcement learning.

[0181] Finally, the system uses the Proximal Policy Optimization (PPO) algorithm to train the hyperparameter tuning policy. This is an advanced policy gradient reinforcement learning method, particularly suitable for problems with continuous action spaces and high-dimensional state spaces. The PPO algorithm introduces a policy ratio pruning mechanism, ensuring stable policy updates while achieving efficient sample utilization. The PPO training process implemented in the system has several distinctive features: First, it employs an attention-based policy network architecture, enabling the agent to focus on the most relevant features in the state space; second, it introduces prioritization of historical experience replay to enhance the learning of rare but important states; third, it implements multi-step bootstrapping estimation and generalized advantage estimation to reduce the variance of value function estimation; and finally, it adopts a parameter-sharing actor-commentator architecture to improve training efficiency. During training, the agent gradually learns to map states to the optimal hyperparameter tuning policy through continuous interaction with the hyperparameter optimization environment. As training progresses, the agent adapts to different training stages and data characteristics, providing increasingly accurate hyperparameter configurations, ultimately converging to a robust and efficient hyperparameter tuning policy.

[0182] Through this hyperparameter tuning step based on convex quadratic programming, the system achieves adaptive optimization of hyperparameters, making the training process of the joint large language model more efficient, stable, and automated. This method not only reduces the burden of manual hyperparameter tuning but also automatically finds the optimal parameter configuration based on specific task characteristics and data distribution, significantly improving the model's performance and generalization ability. As the system processes more types of contracts and collects more user feedback, this hyperparameter optimization mechanism will continuously learn and improve, making the model training process increasingly intelligent and efficient, further enhancing the self-evolutionary capability and practical value of the intelligent contract risk identification system.

[0183] The following specific examples illustrate the implementation process of this invention:

[0184] In a practical application, a company's legal department received a supplier contract and needed to conduct a risk review. The legal staff uploaded the contract document (PDF format) to the system's web interface. The system first extracted the text content using a PDF parser, applied regular expressions to filter headers and footers, used the TextTiling algorithm to segment the text, identified the preamble, definitions, main clauses, and supplementary provisions, and converted it into structured contract text data in JSON format.

[0185] Then, the system calls three large language models—ChatGLM, Qwen, and Llama3—in parallel, providing them with a unified prompt word template and segmented contract text, requiring them to identify the potential risks in each segment. For example, the system might provide the model with the following prompt: "Analyze the following contract paragraphs, identify potential legal risks, and provide the risk type, specific issue, and confidence score (1-10)," followed by a specific clause paragraph from the contract. The three models return risk analysis results, which the system then standardizes and formats. Finally, it performs a weighted fusion calculation based on the historical accuracy of each model (e.g., ChatGLM: 0.5, Qwen: 0.3, Llama3: 0.2) to obtain a preliminary risk assessment result.

[0186] Next, the system maps the identified risk clauses to a legal knowledge graph. For example, for a clause regarding "limitation of supplier liability," the system uses cosine similarity calculation to find relevant legal provisions (such as Article 40 of the Contract Law), judicial interpretations, and typical cases in the knowledge graph. The system then performs a graph traversal algorithm within the knowledge graph to analyze the relationships between these legal entities, applies reasoning rules (such as "if a clause completely exempts the supplier from liability without exceptions, it violates mandatory legal provisions") for evaluation, and generates a deep analysis result containing reasoning chains and modification suggestions.

[0187] The system then extracts key features of the risk clauses (such as "limitation of liability" and "force majeure"), converts them into feature vectors, and searches for similar cases in the risk case database. The system finds three similar cases (similar scores of 0.92, 0.88, and 0.81), analyzes the consequences and handling methods of the risk clauses in these cases, predicts the possible consequences of the current risk, and generates a risk prediction result. Based on the severity of the risk, its probability of occurrence, and its legal impact, the system calculates a risk score and generates a complete risk report.

[0188] Legal personnel view the risk report through a visual interface. The system highlights risk points in the original contract and lists risk details in a table. For risk points with low confidence, the system specifically marks them and recommends manual review. After reviewing the report, the legal personnel confirmed that most of the risk identification results were correct, but corrected two risk points. The system records this feedback and generates labeled data containing correct labels and error types.

[0189] Finally, the system periodically updates the model using the collected labeled data. It employs a reinforcement learning strategy, using risk identification accuracy as a reward signal to update the model parameters. The system tests the performance of the optimized model, and once the performance improvement is confirmed, it is deployed to the production environment, completing one closed-loop optimization cycle.

[0190] Through the above steps, this invention achieves intelligent risk identification of contract documents, providing legal personnel with an efficient, accurate, and interpretable risk analysis tool, which greatly improves the efficiency and quality of contract review.

[0191] In some embodiments, the present invention also provides an intelligent contract risk identification device based on a large language model, comprising:

[0192] The module is used to build a legal knowledge graph and risk case library based on existing legal text resources through entity extraction and relationship establishment;

[0193] The recognition module receives the contract document to be recognized and obtains structured contract text data through OCR recognition, text cleaning, segmentation and standardization.

[0194] The assessment module is used to perform parallel risk identification and analysis based on the structured contract text data and a joint large language model, and to obtain preliminary risk assessment results through unified prompt word templates and weighted fusion calculations.

[0195] The deep analysis module is used to perform deep reasoning analysis based on the preliminary risk assessment results and the legal knowledge graph, through graph traversal algorithm and correlation calculation, to obtain deep analysis results including risk type, confidence level, reasoning chain and modification suggestions;

[0196] The report generation module is used to perform risk analogy analysis based on the deep analysis results and the risk case library, through similarity calculation and case reasoning, to obtain a complete risk report verified by the cases.

[0197] The visualization module is used to display the complete risk report based on the visualization interface and receive user feedback operations, record user feedback data, and obtain a labeled dataset for model training. The feedback operations include confirmation of the report or suggestions for correction.

[0198] The model optimization module is used to update and optimize the parameters of the joint large language model based on the labeled dataset, using a reinforcement learning strategy and risk identification accuracy as a reward signal, to obtain the optimized joint large language model.

[0199] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.

[0200] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for identifying intelligent contract risks based on a large language model, characterized in that, Includes the following steps: Based on existing legal text resources, a legal knowledge graph and a risk case database are constructed through entity extraction and relationship establishment; Receive the contract document to be identified, and obtain structured contract text data through OCR recognition, text cleaning, segmentation and standardization processing; Based on the structured contract text data, parallel risk identification and analysis are performed using a joint large language model. Preliminary risk assessment results are obtained through a unified prompt word template and weighted fusion calculation. Based on the preliminary risk assessment results and the legal knowledge graph, deep reasoning analysis is performed using graph traversal algorithms and correlation calculations to obtain deep analysis results that include risk type, confidence level, reasoning chain, and modification suggestions. Based on the in-depth analysis results and the risk case library, risk analogy analysis is performed through similarity calculation and case reasoning to obtain a complete risk report verified by the cases; The complete risk report is displayed through a visual interface and user feedback is received. User feedback data is recorded to obtain a labeled dataset for model training. The feedback includes confirmation of the report or suggestions for correction. Based on the labeled dataset, a reinforcement learning strategy is adopted, with the risk identification accuracy as the reward signal, to update and optimize the parameters of the joint large language model, resulting in the optimized joint large language model.

2. The method according to claim 1, characterized in that, Based on existing legal text resources, the method constructs a legal knowledge graph and risk case database through entity extraction and relationship establishment, including: Based on professional legal database API interfaces and publicly available legal text resources, we collect legal provisions, judicial interpretations, judicial precedents, industry standards, and historical contract samples. Through data cleaning and structuring, we obtain a standardized legal text dataset. Based on the standardized legal text dataset, legal entities are identified using named entity recognition, and the relationships between the legal entities are extracted using a relation extraction algorithm to obtain a set of triples of legal entities and relationships. The legal entities include legal clauses, rights and obligations, and subject qualifications, and the relationships include references, restrictions, and conflicts. Based on the set of triples, a network structure of nodes and edges is established based on a graph database to construct a multi-level legal knowledge graph. A graph query interface is then opened to obtain a queryable legal knowledge graph. The multi-level legal knowledge graph includes a legal provisions layer, a case layer, and a contract clause layer. Based on the historical contract samples and judicial precedents, risk points and corresponding consequences in contract dispute cases are extracted, a mapping relationship between contract terms, risk types and consequences is established, case feature vectors are calculated based on vectorization methods, and a searchable risk case library is constructed. Based on the legal knowledge graph and the risk case database, a contract risk classification system is constructed and risk assessment rules are defined. Knowledge graph reasoning rules are determined, and a structured risk label system and a set of reasoning rules are output.

3. The method according to claim 1, characterized in that, The received contract document to be identified is processed through OCR recognition, text cleaning, segmentation, and standardization to obtain structured contract text data, including: The system receives the contract documents in multiple formats, calls the corresponding extraction module according to the format type, and obtains the extracted original text content. The multiple formats include PDF, Word, and images. When the contract document is in image format, text recognition is performed based on a deep learning OCR model, and the structural information of the contract document is identified by combining layout analysis technology to obtain the original text content with layout markings. The structural information includes titles, chapters, and paragraphs. Based on the original text content, regular expressions are used to filter out irrelevant information, unify whitespace characters and punctuation marks, and correct OCR errors through edit distance algorithm and context check to obtain cleaned and standardized text. The irrelevant information includes headers, footers and watermarks. Based on the standardized text, the text is segmented using rule matching and the TextTiling algorithm to identify the logical structure of the contract document. A structure tag is added to each paragraph to obtain the segmented structured contract text. The logical structure includes a preamble, definitions, main clauses, and supplementary provisions. Based on the segmented structured contract text, a BERT pre-trained language model is used to extract text feature vectors, identify key terms and entities in the contract document, and convert the text and features into a unified JSON format to obtain the structured contract text data.

4. The method according to claim 1, characterized in that, Based on the structured contract text data, parallel risk identification and analysis are performed using a joint large language model. Through a unified prompt word template and weighted fusion calculation, preliminary risk assessment results are obtained, including: The prompt word template and adaptive parameters of the joint large language model are determined to obtain the model invocation configuration. The joint large language model includes ChatGLM, Qwen, and Llama3. Based on the structured contract text data and the model call configuration, the interfaces of various large language models are called in parallel. The structured contract text data is segmented and used as input to identify the potential risks of each segment, and a preliminary identification result set containing risk type, description and confidence level is obtained. Based on the preliminary identification result set, key information is extracted through unified parsing rules, the format of the preliminary identification result set is converted, and a standardized risk description language and a unified confidence level representation method are applied to obtain the standardized multi-model risk identification result. Based on the multi-model risk identification results, weights are assigned according to the historical accuracy of each large language model, and a weighted average algorithm is applied to calculate the comprehensive score of each risk point. The consistency index of judgments among the various models is calculated, and a decision tree algorithm is applied to resolve the conflicts between models for the risk points with significant discrepancies, thereby obtaining the preliminary risk assessment results.

5. The method according to claim 2, characterized in that, Based on the preliminary risk assessment results and the legal knowledge graph, deep reasoning analysis is performed using graph traversal algorithms and correlation calculations to obtain deep analysis results that include risk type, confidence level, reasoning chain, and modification suggestions, including: Based on the preliminary risk assessment results, the identified risk clauses are extracted, and the content of the clauses is mapped to the corresponding legal entities in the legal knowledge graph through cosine similarity and BM25 algorithm to obtain the mapping relationship between the risk clauses and the legal entities. Based on the mapping relationship between the risk clauses and the legal entities, a depth-first search and shortest path algorithm are performed in the legal knowledge graph to find the association between the mapped legal entities and the relevant legal provisions, judicial interpretations and judicial precedents. The association strength is calculated based on the path length and relationship weight to obtain the legal association analysis results. Based on the legal relationship analysis results and the inference rule set, a rule engine is applied to perform logical reasoning, assess the degree of risk and compliance, and obtain a risk assessment result based on legal reasoning. Based on the risk assessment results, key nodes and logical links in the reasoning process are recorded, and a visualized reasoning chain containing contract terms, legal provisions, and risk conclusions is constructed. Natural language interpretation is generated, and targeted modification suggestions are generated by combining alternative clause templates and best practice cases in the legal knowledge graph, thus obtaining the in-depth analysis results.

6. The method according to claim 5, characterized in that, Based on the in-depth analysis results and the risk case library, risk analogy analysis is performed through similarity calculation and case reasoning to obtain a complete risk report verified by cases, including: Based on the deep analysis results, the key features of the risk clause are extracted, and the key features are converted into high-dimensional vector representations through a BERT pre-trained language model to obtain the feature vector set of the risk clause. The key features include the clause type, the restricted object, and the scope of liability. Based on the feature vector set of the risk clause and the risk case library, the similarity with each of the judicial precedents is calculated, and the judicial precedents with similarity exceeding a preset threshold are determined to obtain a set of similar cases; Based on the set of similar cases, the risk evolution path and final result in the judicial precedents are analyzed, common risk patterns and characteristics are identified, and case reasoning algorithms are applied to conduct analogy analysis to predict the possible consequences of the current risk, thereby obtaining risk prediction results based on the judicial precedents. Based on the risk prediction results and the in-depth analysis results, combined with the risk severity, probability of occurrence and legal impact, a risk score is calculated to obtain a risk rating result. Based on the risk rating results, combined with the risk points, legal provisions, reasoning chains, judicial precedents, and modification suggestions, a structured risk report including a summary, detailed analysis, and visualization is generated, resulting in the complete risk report.

7. The method according to claim 4, characterized in that, The process involves displaying the complete risk report via a visual interface, receiving user feedback, recording user feedback data, and obtaining a labeled dataset for model training, including: Based on the complete risk report, an interactive interface presentation scheme is determined, combining the contract document with the highlighted risk content, listing risk items in tabular form that include the risk type, the confidence level, and the modification suggestions, generating an interactive chart of the reasoning chain, and obtaining a visual interface; Based on the model output variance and inference confidence, a confidence threshold is calculated, and the risk items with a confidence level lower than the confidence threshold are identified and sorted by priority to obtain a list of risk items to be reviewed. Obtain the user's processing decisions and modification opinions for each of the risk items in the list of risk items to be reviewed, record the user's operation trajectory and time data, and obtain structured user interaction data; Based on the user interaction data, the risk assessment results of user confirmation or correction are extracted, the user modifications are compared with the system suggestions, and labeled data containing correct labels and error types are generated to obtain the labeled dataset.

8. The method according to claim 1, characterized in that, Based on the labeled dataset, a reinforcement learning strategy is employed, using risk identification accuracy as a reward signal, to update and optimize the parameters of the joint large language model, resulting in an optimized joint large language model, including: Based on the labeled dataset, data cleaning and augmentation are performed, the proportion of various risk samples is balanced, and training set, validation set, test set, standardized features and label format are constructed to obtain a dataset for model training. We design a reward function with risk identification accuracy as the core, construct a reinforcement learning environment, define contract text features as the state space and risk judgment and decision as the action space, construct a state transition function, and obtain the reinforcement learning training environment. Based on the reinforcement learning training environment and the dataset used for model training, the agent is trained using the PPO or A2C policy gradient algorithm, the model parameters are updated using gradient descent, the decision-making strategy is optimized, and the updated model parameters are obtained. Based on the updated model parameters, performance evaluation is performed on the test set, precision, recall and F1 score are calculated, compared with the baseline model, the best performing model version is selected, the model configuration in the production environment is updated, the continuous optimization process is determined, and the model parameters for performance improvement are obtained. Based on the improved model parameters, the joint large language model is optimized to obtain the optimized joint large language model.

9. The method according to claim 8, characterized in that, The updating of the model parameters also includes a hyperparameter tuning step based on convex quadratic programming: The parameter optimization problem of the risk identification model is transformed into a standard convex quadratic programming form. A dual-loop control structure containing inner and outer loops is constructed, a solver based on the primal and dual interior point methods is implemented, and a composite reward function is designed to evaluate the model's accuracy, solution efficiency, and parameter stability, thus obtaining the hyperparameter optimization environment. Based on the hyperparameter optimization environment, a reinforcement learning state space is constructed, which includes the current model performance index, interior point solver state, historical hyperparameter values ​​and their effects, and task difficulty index. An action space containing interior point parameters, model complexity control parameters, reward function weights, learning rate, and momentum parameters is defined as the hyperparameter adjustment vector. A hyperparameter adjustment mechanism based on congestion detection and flow regulation is implemented. The hyperparameter adjustment strategy is trained using a proximal policy optimization algorithm to obtain the optimized hyperparameter configuration.

10. A smart contract risk identification device based on a large language model, characterized in that, include: The module is used to build a legal knowledge graph and risk case library based on existing legal text resources through entity extraction and relationship establishment; The recognition module receives the contract document to be recognized and obtains structured contract text data through OCR recognition, text cleaning, segmentation and standardization. The assessment module is used to perform parallel risk identification and analysis based on the structured contract text data and a joint large language model, and to obtain preliminary risk assessment results through unified prompt word templates and weighted fusion calculations. The deep analysis module is used to perform deep reasoning analysis based on the preliminary risk assessment results and the legal knowledge graph, through graph traversal algorithm and correlation calculation, to obtain deep analysis results including risk type, confidence level, reasoning chain and modification suggestions; The report generation module is used to perform risk analogy analysis based on the deep analysis results and the risk case library, through similarity calculation and case reasoning, to obtain a complete risk report verified by the cases. The visualization module is used to display the complete risk report based on the visualization interface and receive user feedback operations, record user feedback data, and obtain a labeled dataset for model training. The feedback operations include confirmation of the report or suggestions for correction. The model optimization module is used to update and optimize the parameters of the joint large language model based on the labeled dataset, using a reinforcement learning strategy and risk identification accuracy as a reward signal, to obtain the optimized joint large language model.

Citation Information

Patent Citations

  • Contract risk assessment and compliance check method, system and equipment based on large language model, and medium

    CN119863119A

  • Gravity dam safety risk management and control method and system based on knowledge graph and large model

    CN120373844A