Legal case factor extraction method based on re-attention mechanism

By combining a hierarchical structure and a re-attention mechanism, the problems of temporal logic and multi-subject interaction in legal document processing are solved, and highly accurate extraction and interpretable analysis of legal case elements are achieved.

CN121524326APending Publication Date: 2026-02-13DALIAN OCEAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511702389.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-19
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing legal document processing methods are unable to effectively model the temporal logic, multi-subject interaction characteristics, and legal knowledge of legal documents, resulting in a low accuracy rate in extracting legal case elements.

Method used

A re-attention mechanism-based approach is adopted, which parses legal documents into factual and legal provision layers through a hierarchical structure. A pre-constructed state slot matrix and attention mechanism are used to perform cross-layer knowledge fusion, dynamically track the status of responsible parties, and generate knowledge-enhanced case information.

Benefits of technology

It improves the accuracy and interpretability of extracting legal case elements, enabling better handling of complex cases and providing more accurate legal analysis support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121524326A_ABST
    Figure CN121524326A_ABST
Patent Text Reader

Abstract

The invention discloses a law case factor extraction method based on a re-attention mechanism, and relates to the technical field of law text intelligent analysis, and the method comprises the steps: receiving a to-be-processed law document; analyzing the legal document into a layered structure at least comprising a fact layer and a law article layer; loading a pre-constructed layered state slot matrix, wherein the matrix comprises legal provision layer state slots with legal provision information; coding the fact layer into a fact vector sequence, wherein each fact vector comprises a time feature, a responsibility subject feature and a text semantic feature; identifying all responsibility subjects involved in the legal document, and creating an independent state tracking vector for each responsibility subject; sequentially processing each fact vector in the fact vector sequence according to a time sequence to obtain final case factor information; the method has the beneficial effect that the accuracy and interpretability of legal case factor extraction can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent analysis technology of legal texts, and in particular to a method for extracting legal case elements based on a re-attention mechanism. Background Technology

[0002] Legal case element extraction is one of the core tasks of intelligent legal document processing. It aims to automatically identify and extract key case information from legal documents such as judgments and rulings, such as breach of contract, reminders, responsible parties, and legal citations. Accurate element extraction can not only improve the efficiency of legal document analysis, but also provide auxiliary support for judicial decisions, and has important practical application value.

[0003] Existing methods for extracting legal elements are mainly based on sequence labeling or text classification frameworks, typically treating legal documents as ordinary text. However, legal documents have distinct characteristics:

[0004] First, legal documents contain strict temporal logic, with the facts of the case unfolding in chronological order, and causal relationships and state transitions existing between events at different times;

[0005] Secondly, legal documents involve multiple responsible parties, such as the plaintiff, defendant, and guarantor, and the liability status of each party changes dynamically as the case progresses;

[0006] Furthermore, the factual findings in legal documents need to correspond with the relevant legal provisions to achieve a legal reasoning process that is "based on facts and guided by law."

[0007] Finally, the determination of legal documents needs to take into account procedural requirements such as statutory time limits.

[0008] Traditional natural language processing methods struggle to effectively model the aforementioned legal specificities. On one hand, existing methods lack effective utilization of legal knowledge and cannot establish an accurate correspondence between case facts and legal provisions. On the other hand, existing methods fail to fully consider the temporal evolution characteristics and multi-subject interaction characteristics of legal documents, resulting in low accuracy when handling complex cases.

[0009] In view of this, a method for extracting legal case elements based on the re-attention mechanism is proposed. Summary of the Invention

[0010] In view of the aforementioned state of the prior art, this application is hereby proposed. Embodiments of this application provide a method for extracting legal case elements based on a re-attention mechanism, which can solve problems such as knowledge gaps, insufficient temporal modeling, and difficulties in multi-agent tracking that exist in traditional methods in legal document processing, thereby improving the accuracy and interpretability of legal case element extraction.

[0011] According to an aspect of the present application, a legal case element extraction method based on a re-attention mechanism is provided, comprising: receiving a legal document to be processed; parsing the legal document into a hierarchical structure comprising at least a fact layer and a law article layer; loading a pre-constructed hierarchical state slot matrix, the matrix comprising law article layer state slots with legal article information; encoding the fact layer into a fact vector sequence, each fact vector comprising time features, responsible subject features, and text semantic features; identifying all responsible subjects involved in the legal document and creating an independent state tracking vector for each responsible subject; sequentially processing each fact vector in the fact vector sequence in chronological order, the processing comprising: using the fact vector as a query vector to read relevant information from the law article layer state slots through an attention mechanism to obtain a law article knowledge vector associated with the fact vector; performing vector fusion of the law article knowledge vector and the fact vector to generate a knowledge-enhanced fact vector; identifying the responsible subjects involved in the fact vector and updating the state tracking vector of the corresponding responsible subject based on the knowledge-enhanced fact vector; and outputting case element information corresponding to the fact vector based on the knowledge-enhanced fact vector and the state tracking vector of the involved responsible subjects.

[0012] According to another aspect of the present application, a legal case element extraction system based on a re-attention mechanism is provided, comprising: a receiving module for receiving a legal document to be processed; a parsing module for parsing the legal document into a hierarchical structure comprising at least a fact layer and a law article layer; a loading module for loading a pre-constructed hierarchical state slot matrix, the matrix comprising law article layer state slots with legal article information; an encoding module for encoding the fact layer into a fact vector sequence, each fact vector comprising time features, responsible subject features, and text semantic features; a subject tracking module for identifying all responsible subjects involved in the legal document and creating an independent state tracking vector for each responsible subject; a processing module for sequentially processing each fact vector in the fact vector sequence in chronological order, the processing comprising: using the fact vector as a query vector to read relevant information from the law article layer state slots through an attention mechanism to obtain a law article knowledge vector associated with the fact vector; performing vector fusion of the law article knowledge vector and the fact vector to generate a knowledge-enhanced fact vector; identifying the responsible subjects involved in the fact vector and updating the state tracking vector of the corresponding responsible subject based on the knowledge-enhanced fact vector; and outputting case element information corresponding to the fact vector based on the knowledge-enhanced fact vector and the state tracking vector of the involved responsible subjects.

[0013] According to another aspect of this application, an electronic device is provided, including a memory and a processor, the memory being used to store computer-executable instructions, and the processor being used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method described above.

[0014] According to another aspect of this application, a computer storage medium is provided that stores computer-executable instructions thereon, which, when executed by a processor, implement the steps of the method described above.

[0015] Compared with existing technologies, the legal case element extraction method based on the re-attention mechanism according to the embodiments of this application can solve the problems of knowledge gaps, insufficient temporal modeling and difficulties in multi-subject tracking in traditional methods in legal document processing, thereby improving the accuracy and interpretability of legal case element extraction. Attached Figure Description

[0016] The above and other objects, features, and advantages of this application will become more apparent from the more detailed description of the embodiments of this application in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the embodiments of this application to explain this application and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.

[0017] Figure 1 This is a flowchart of the legal case element extraction method based on the re-attention mechanism of the present invention.

[0018] Figure 2 This is a flowchart of the fact vector sequence processing of the legal case element extraction method based on the re-attention mechanism of the present invention.

[0019] Figure 3 This is a block diagram of the legal case element extraction system based on the re-attention mechanism of the present invention.

[0020] Figure 4 This is a block diagram of an electronic device according to the present invention. Detailed Implementation

[0021] Hereinafter, exemplary embodiments according to this application will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments of this application. It should be understood that this application is not limited to the exemplary embodiments described herein.

[0022] Exemplary methods

[0023] Figure 1The illustration shows a legal case element extraction method based on a re-attention mechanism according to an embodiment of this application, including steps S1 to S6.

[0024] It should be noted that this embodiment describes the process of inference using a pre-trained model. All parameters involved in the model (including weight matrix, bias vector, projection matrix, etc.) are learnable parameters, automatically learned during the training phase through optimization algorithms.

[0025] This application's method employs a layered architecture to process legal documents: First, the document is parsed into a fact layer and a legal provision layer, and the legal provisions are encoded into fixed knowledge representations using a pre-trained model. Then, when processing each fact, relevant legal knowledge is retrieved from the legal provision layer through a cross-layer attention mechanism, and a temporal bias mechanism is introduced when the clause layer is included, adjusting the attention weights according to statutory time limits (e.g., 30 days for notice of action, 3 years for statute of limitations). Simultaneously, an independent state vector is maintained for each responsible party, dynamically tracking the evolution of responsibility. Finally, based on the knowledge-enhanced representation, the case elements, legal provision citations, and information on the responsible parties are output. The following detailed explanation of each step is provided in conjunction with the accompanying drawings.

[0026] like Figure 1 As shown, in step S1, the legal documents to be processed are received.

[0027] Legal documents can be various types of judicial documents, such as civil judgments, criminal judgments, administrative judgments, rulings, and mediation agreements. In this embodiment, a civil judgment concerning a contract dispute will be used as an example.

[0028] Legal documents typically include the following main parts: basic case information, claims, facts and reasons, findings of the court, the court's opinion, and judgment. Among these, the "findings of the court" section contains a chronological statement of the facts of the case and is the primary source of information for analysis.

[0029] In step S2, the legal document is parsed into a hierarchical structure that includes at least a factual layer and a legal provision layer.

[0030] Traditional legal text processing methods treat documents as a flat sequence of texts, failing to reflect their inherent hierarchical structure. Legal documents actually contain multiple semantic levels: the lowest level is the specific statement of the facts of the case; the middle level may involve citations of legal norms in the judgment; and the highest level is the legal provisions themselves. This hierarchical structure reflects the basic logic of legal reasoning: starting from specific facts, based on legal norms, a judgment is reached.

[0031] Specifically, the construction of a hierarchical structure includes the following steps:

[0032] First, legal citations in legal documents are identified using rule matching or weak oversight methods. Legal citations typically appear in the form of "pursuant to Article X" or "according to Article XXX of the Civil Code of the People's Republic of China," and may also be indicated by parentheses in the "This Court Holds" section of a judgment. For documents without explicit legal citations, a BERT-based text classification model can be used to identify legal normative paragraphs.

[0033] Next, the legal provision layer is constructed. This layer contains the complete text of the cited legal provisions and their unique legal provision IDs. The legal provision ID can be a standard legal provision number (e.g., "Civil Code-563" represents Article 563 of the Civil Code of the People's Republic of China). For external legal provisions (such as judicial interpretations), ID mapping is achieved through metadata alignment.

[0034] Next, construct the factual layer. Divide the "Ascertained by this Court" section into sentences or paragraphs to obtain the basic units of the factual layer. Each factual unit contains a coherent statement of the case and is associated with a time stamp. The time stamp can be a date explicitly mentioned in the text (e.g., "January 15, 2023") or a relative time expression (e.g., "within the following 30 days"). Relative times need to be normalized to absolute times or relative offsets.

[0035] In some implementations, the hierarchical structure may also include a clause layer, located between the legal provision layer and the factual layer, consisting of paragraphs in the judgment that cite legal norms. While these paragraphs are not the legal provisions themselves, they contain restatements or interpretations of the legal provisions and can serve as a supplementary source of legal knowledge.

[0036] Here, we assume that we are parsing a judgment in a contract dispute, and the hierarchical structure we construct is as follows:

[0037] Factual level:

[0038] Date: 2023-01-15; Facts: "Plaintiff Company A and Defendant Company B signed an Equipment Procurement Contract on January 15, 2023, stipulating that Company B should deliver the equipment before March 1, 2023."

[0039] Date: March 10, 2023; Fact: "Company B failed to deliver the equipment within the agreed time limit."

[0040] Date: March 15, 2023; Fact: "Company A issued a demand letter to Company B, requiring it to fulfill its delivery obligations within 30 days."

[0041] Date: April 20, 2023; Fact: "Company B failed to deliver the equipment after the expiration of the notice period, and Company A terminated the contract on April 20, 2023."

[0042] Legal provisions level:

[0043] Article ID: Civil Code-563, Article: "If one party delays performance of its obligations or commits other breaches of contract that render the purpose of the contract impossible to achieve, the other party may terminate the contract."

[0044] Article ID: Civil Code-577, Article: "If one party fails to perform its contractual obligations or performs them in a manner that does not conform to the agreement, it shall bear the liability for breach of contract, such as continuing performance, taking remedial measures, or compensating for losses."

[0045] Terms layer (if present):

[0046] Date: April 20, 2023 (the date cited in the judgment), Content: "According to Article 563 of the Civil Code of the People's Republic of China, if one party delays performance of its obligations, making it impossible to achieve the purpose of the contract, the other party may terminate the contract. In this case, the defendant's delay in performance constitutes a fundamental breach of contract."

[0047] Through the aforementioned hierarchical structure, legal documents are transformed from flat texts into a structured representation with hierarchical relationships, laying the foundation for subsequent knowledge enhancement and attention computing.

[0048] Compared to traditional flat text processing methods, hierarchical structures have the following advantages:

[0049] First, the semantic hierarchy is clear. Information at different levels has different degrees of abstraction. Legal provisions are abstract legal norms, while facts are specific statements of case details. Layered representation can maintain this semantic hierarchy relationship.

[0050] Second, knowledge injection is convenient. As an independent source of knowledge, legal provisions can be pre-coded and fixed during reasoning, thus avoiding damage to the integrity of legal knowledge during training.

[0051] Third, legal reasoning is essentially a mapping from concrete facts to abstract norms, and the hierarchical structure allows this cross-level reasoning to be achieved naturally through attention mechanisms.

[0052] Fourth, it is highly interpretable. By tracking the attention weight between the factual layer and the legal provision layer, the legal basis corresponding to each case fact can be seen intuitively.

[0053] Through the above steps, the hierarchical structure of legal documents was constructed, providing structured input for subsequent feature encoding and knowledge enhancement.

[0054] return Figure 1 In step S3, a pre-constructed hierarchical state slot matrix is ​​loaded, which contains legal provision layer state slots with legal provision information.

[0055] A state slot is a vectorized slot used to store and represent specific semantic information. In this invention, the state slot matrix includes legal provision-level state slots and clause-level state slots (if a clause level exists). Each legal provision-level state slot corresponds to a legal provision and stores the semantic representation of that provision; each clause-level state slot corresponds to a normative paragraph in a judgment and stores the semantic representation of that paragraph.

[0056] The legal provision layer state slots are obtained by encoding the legal provision text using pre-trained legal language models such as Legal-BERT and LawFormer. Specifically, for each legal provision in the legal provision database... Encoding is done using Legal-BERT:

[0057] ;

[0058] in, Let i be the state slot vector corresponding to the i-th law. The vector dimension is typically 768 or 1024.

[0059] By combining the state slot vectors of all legal provisions, we obtain the state slots of the legal provision layer, which are in matrix form:

[0060] ;

[0061] in, This represents the number of legal provisions in the legal provisions library.

[0062] It should be noted that in this application, the parameters of the legal provision layer state slot are fixed parameters. This design is based on the following considerations:

[0063] Firstly, it is to maintain the stability of legal knowledge. Legal provisions are normative texts confirmed by the legislature, and their meaning should remain stable. If the expression of legal provisions is allowed to change during training, it may cause the meaning of the provisions to deviate from their original meaning.

[0064] Secondly, to avoid catastrophic forgetting, the pre-trained Legal-BERT model is trained on a large-scale legal corpus and has already learned rich legal semantic knowledge. If the legal provisions are updated during training on downstream tasks, it may destroy the knowledge structure learned by the pre-trained model.

[0065] Thirdly, it is to improve training efficiency. Since the number of state slots in the law layer is usually large, possibly containing hundreds or even thousands of laws, fixing these parameters can reduce the number of trainable parameters, thereby reducing the computational overhead and memory usage of training.

[0066] Finally, as knowledge anchors, fixed legal provisions serve as stable knowledge anchors, providing the model with consistent legal semantic references during training, which helps the model learn more stable and reliable fact-legal provisions correspondences.

[0067] It should be noted that although the state slot parameters of the legal provision layer are fixed, this does not mean that the model cannot learn the relationship between legal provisions and facts. On the contrary, by training the parameters of the attention mechanism, the model can learn how to extract information related to the current facts from the fixed legal provision representation.

[0068] In implementations that include a clause layer, the clause layer status slots are obtained by encoding the clause layer text:

[0069] ;

[0070] in, For the text sequence of the clause layer, the encoder can use the same Legal-BERT model as the legal clause layer, or it can use other pre-trained models.

[0071] Unlike the state slots at the legal provision level, the state slots at the clause level can be updated during training. This is because the clause level comes from specific judgment texts and does not possess the normative and stable nature of legal provisions, allowing it to be adjusted during training to better adapt to the expression styles of different cases.

[0072] In addition, each clause-level status slot is associated with a corresponding clause reference timestamp. This indicates the time when the clause was cited in the judgment or the time of the case related to the clause. This timestamp will be used in subsequent time offset calculations.

[0073] In practical applications, the legal provision layer state slots are typically pre-built and saved as part of the model. During reasoning, the pre-built matrix is ​​directly loaded, eliminating the need to re-encode the legal provision text. This design not only improves reasoning efficiency but also ensures that the same legal provision representation is used in the analysis of different cases, guaranteeing the consistency of the analysis results.

[0074] Through the above steps, the construction and loading of the hierarchical state slot matrix were completed, providing a vectorized representation of legal knowledge for subsequent cross-layer attention calculation.

[0075] In step S4, the fact layer is encoded into a sequence of fact vectors, each of which contains time features, responsible entity features, and textual semantic features.

[0076] Unlike general text processing, factual statements in legal documents contain not only semantic information but also rich legal-specific information. To fully utilize this information, this invention designs a fact vector representation that includes multiple features.

[0077] For the first in the fact layer Fact fragment Its vector representation It consists of the following parts:

[0078] One is the semantic features of the text. Using pre-trained The model encodes factual text to obtain a semantic vector representation of the text. It can capture the syntactic and semantic information of text, providing a basic text representation for subsequent processing.

[0079] Secondly, there is the characteristic of time. This indicates the time when the fact occurred. The time characteristics include two aspects: one is the absolute time encoding, which is the numerical encoding directly converted from the date (such as "2023-01-15"); the other is the relative time difference, which is the time interval between the current fact and the previous fact. This relative time difference is used to determine whether the statutory period has been exceeded (such as a 30-day notice period).

[0080] Thirdly, the characteristics of the responsible parties. This identifies the type of liable party involved in the fact. Types of liable parties include, but are not limited to: plaintiff, defendant, third party, guarantor (guarantor, mortgagor, pledgor), joint and several liability party, supplementary liability party, etc. Discrete subject types are mapped to continuous vectors through an embedding layer.

[0081] Fourthly, the characteristics of legal acts. This identifies the type of legal act described by the fact. Types of legal acts include, but are not limited to: contract formation, performance, partial performance, delayed performance, refusal to perform, demand for performance, termination, breach of contract, and compensation. It is also mapped to a vector through the embedding layer.

[0082] The above features are combined through a concatenation operation, and then mapped to a unified dimension through a projection layer:

[0083] ;

[0084] Where ∥ represents the vector concatenation operation, As a linear projection layer, it maps the concatenated high-dimensional vector to a uniform dimension d (such as 768 or 1024).

[0085] Continuing with the aforementioned example of a contract dispute, the construction process of the fact vector for the fact that "Company A issued a demand letter to Company B, requiring it to fulfill its delivery obligation within 30 days" is as follows:

[0086] For text semantic features: using Encoding the sentence yields a 768-dimensional semantic vector.

[0087] Regarding the time characteristics: the fact occurred on March 15, 2023, and is converted into a numerical code; the time difference with the previous fact (March 10, 2023) is 5 days.

[0088] Regarding the characteristics of the liable parties: This fact involves the plaintiff (Company A) and the defendant (Company B), and the subject type is coded as a combination vector of "plaintiff-defendant".

[0089] Regarding the legal behavior characteristics: This fact describes the behavior of "demanding" and the corresponding behavior type embedding vector.

[0090] By concatenating and projecting the above features, we obtain the complete vector representation of this fact. .

[0091] This multi-feature fusion fact vector design enables fact representation to include not only textual semantics but also legal expertise.

[0092] Through the above steps, each text fragment in the fact layer is encoded into a fact vector containing rich legal information, forming a sequence of fact vectors. ,in This represents the total number of fragments in the fact layer.

[0093] return Figure 1 In step S5, all responsible parties involved in the legal documents are identified, and an independent status tracking vector is created for each responsible party.

[0094] Legal cases typically involve multiple liable parties, whose liability status changes dynamically as the case progresses. For example, in a guarantee contract dispute, the principal debtor's breach of contract can trigger the guarantor's liability; in joint and several liability cases, one party, after assuming liability, may seek recourse from other jointly and severally liable parties. Traditional sequence labeling methods process information from all parties together, making it difficult to accurately track the independent status of each party and the relationships between them.

[0095] Specifically, this step consists of the following sub-steps:

[0096] First, named entity recognition (NER) technology is used to identify all relevant entities in legal documents. These entities typically appear in sections such as basic case information, claims, and factual statements.

[0097] Then, the identified entities are categorized to determine their type of liable entity. Types of liable entities include:

[0098] Basic parties: Plaintiff, Defendant, and Third Party;

[0099] Guarantee entities: guarantor, mortgagor, pledgor;

[0100] Special liability entities: joint and several liability persons and supplementary liability persons.

[0101] In some implementations, a BERT-based text classification model can be used to determine the type of liability of the subject by combining contextual information. For example, if the text contains phrases like "Company X acts as guarantor," then the subject can be identified as a guarantor.

[0102] Finally, for each identified responsible party Create an independent state tracking vector The state tracking vector is used to record the evolution of the subject's responsibility status during the progress of the case. The initial state tracking vector can be initialized in the following ways:

[0103] One approach is to initialize the initial state vectors of all subjects to zero vectors, indicating that each subject is in a neutral state at the start of the case.

[0104] Secondly, based on the type of liability of the subject, the initial state vector is initialized as an embedding vector of the corresponding type. For example, the initial state of a guarantor can be initialized as a vector representation of "potential guarantee liability".

[0105] Thirdly, the initial liability status of each party is encoded using basic case information (such as contract terms and guarantee terms) to obtain richer initialization vectors.

[0106] Continuing with the previous example, suppose this contract dispute involves three responsible parties:

[0107] Plaintiff: Company A (the other party to the contract);

[0108] Defendant: Company B (principal debtor);

[0109] Guarantor: Company C (providing a guarantee for Company B's contract performance);

[0110] After identifying the three entities, an independent state tracking vector is created for each entity:

[0111] ;

[0112] in, The dimension of the state vector is usually the same as the dimension of the fact vector.

[0113] Through the above steps, an independent state vector is maintained for each responsible entity, enabling this application to track the changes in the responsibility status of each entity at different times, avoiding confusion of information among multiple entities, and providing a foundation for subsequent modeling of relationships between entities (such as joint liability and transfer of guarantee liability). The mutual influence of states can be realized through the attention mechanism between entities.

[0114] return Figure 1 In step S6, each fact vector in the fact vector sequence is processed sequentially according to time order, such as... Figure 2 As shown, the process includes steps S61 to S64:

[0115] This is the core step of this application, which uses a re-attention mechanism to enhance legal knowledge and track the state of multiple subjects. "Re-attention" is manifested in the following three levels: First, the fact vector is encoded through intra-layer attention; then, relevant information is read from the legal provision layer and clause layer through cross-layer attention; finally, multi-source information is fused through a gating mechanism to achieve a gradual refinement from the original text representation to the legal knowledge-enhanced representation.

[0116] The following details the processing procedure for each fact vector.

[0117] In step S61, the fact vector is used as the query vector, and relevant information is read from the state slot of the legal provision layer through the attention mechanism to obtain the legal provision knowledge vector associated with the fact vector.

[0118] The core of legal reasoning is "based on facts and guided by law." The facts of a case need to correspond to the relevant legal provisions in order to make a correct legal judgment. However, legal provisions are usually abstract normative expressions, while the facts of a case are concrete descriptions of events, creating a semantic gap between the two. Cross-layer attention mechanisms achieve an automatic mapping from concrete facts to abstract norms by learning the semantic connections between facts and legal provisions.

[0119] Specifically, for the fact vector currently being processed The attention mechanism is used to obtain the state slot matrix of the legal layer. Reading relevant information from the database includes the following steps:

[0120] First, the fact vector and the legal statistic layer state slots are transformed linearly to obtain the query vector, key vector, and value vector, respectively:

[0121] ;

[0122] in, , , It is a learnable projection matrix.

[0123] Then, the similarity between the query vector and each key vector is calculated to obtain the attention weights:

[0124] ;

[0125] Where d is the vector dimension, divided by This is to prevent gradient vanishing.

[0126] Finally, the value vector is weighted and summed using attention weights to obtain the law provision attention vector:

[0127] ;

[0128] Legal attention vector It includes the legal provisions most relevant to the current facts. For example, for the fact that "the defendant failed to perform the contract on time," the model will automatically focus on Article 577 of the Civil Code of the People's Republic of China regarding liability for breach of contract; for the fact that "the plaintiff issued a demand letter," the model will focus on Article 563 regarding the termination of a contract after a demand letter.

[0129] In some implementations, the hierarchical structure also includes a clause layer, which consists of normative paragraphs extracted from legal documents and containing timestamps of clause citations.

[0130] When the clause layer is included, the hierarchical state slot matrix also includes clause layer state slots, which are obtained by encoding the clause layer. Each clause layer state slot is associated with a corresponding clause reference timestamp.

[0131] At this point, reading relevant information also includes reading from the clause-level state slots. Specifically, obtaining the legal provision knowledge vector associated with the fact vector includes the following sub-steps:

[0132] The first step is to use the fact vector as the query vector and perform attention calculations on the state slots of the legal provisions layer and the state slots of the clause layer respectively to obtain the legal provision attention vector and the clause attention vector.

[0133] The attention calculation for the clause-level state slots includes the following detailed steps:

[0134] First, each clause-level state slot is transformed linearly to obtain a key vector and a value vector:

[0135] .

[0136] Then, the similarity between the query vector and each key vector is calculated:

[0137] ;

[0138] in, Representation of fact vector Similarity between the term layer state slot j and the term layer state slot j.

[0139] Next, we calculate the time difference between the temporal features of the fact vector and the term reference timestamp corresponding to each term-level state slot:

[0140] ;

[0141] in, The time stamp corresponding to the fact vector. This is the timestamp for the clause reference corresponding to the clause layer status slot j.

[0142] Then, obtain the statutory period of the clause corresponding to each clause layer status slot. Statutory time limits are crucial information in legal document processing, for example:

[0143] The deadline for issuing a notice of demand: Article 563 of the Civil Code of the People's Republic of China stipulates that if performance is not performed within a "reasonable period" after issuing a notice of demand, the contract may be terminated, which is usually 30 days in practice.

[0144] Statute of Limitations: Article 188 of the Civil Code of the People's Republic of China stipulates that the general statute of limitations is three years.

[0145] Limitation Period: Article 564 of the Civil Code of the People's Republic of China stipulates that the limitation period for the right of rescission is one year.

[0146] The statutory deadline can be pre-stored in the metadata of the clause layer status slot, or it can be extracted from the clause text by rules.

[0147] Next, based on the time difference and the statutory deadline, calculate the time-series bias term representing the comparison result between the time interval and the statutory deadline:

[0148] ;

[0149] in, , , For learnable parameters, The function is used to map the ratio of the time difference to the statutory deadline to the interval [-1, 1]. This is an indicator function; its value is 1 when the time difference exceeds the legally stipulated deadline, and 0 otherwise. In this formula, the first term... The second term is used to provide a smooth time offset. Used to impose additional penalties or enhancements when the statutory period has expired.

[0150] The mechanism of action of the aforementioned timing bias terms is as follows:

[0151] when That is, when the time interval does not exceed the statutory period: A negative or small positive value has a negative or neutral effect on the attention weight. An indicator function term of 0 has no additional effect, and its overall effect is to make the attention weight of the clause to the current fact lower.

[0152] when When, that is, when the time interval is close to the statutory deadline: When the term is close to 0, the indicator function term is 0, and the overall effect is to give the term a moderate attention weight.

[0153] when When, that is, when the time interval exceeds the legally stipulated period: When the term is positive and the indicator function term is 1, an additional positive bias is applied, the overall effect of which is to significantly increase the attention weight of the term to the current facts.

[0154] Continuing with the aforementioned contract dispute example, suppose the contract terms include a clause regarding the time limit for issuing a demand for performance: "According to Article 563 of the Civil Code of the People's Republic of China, if one party delays performance of its obligations, the other party may demand performance within a reasonable period. If performance is still not made within a reasonable period after the demand, the other party may terminate the contract." This clause is cited on March 15, 2023 (i.e., the date the demand was issued), corresponding to a statutory period of 30 days.

[0155] Regarding the fact that "Company A terminated the contract" on April 20, 2023:

[0156] Time difference: day;

[0157] Statutory deadline: day;

[0158] ratio: =1.2;

[0159] Approximately 0.8 (assuming) (1)

[0160] Indicator Function ;

[0161] Timing bias term = Assuming It is 0.5. If it is 0.3, then It is 0.7.

[0162] This positive timing bias will significantly increase the attention weight of the clause to the fact of "contract termination", enabling the model to automatically determine that "contract termination after the expiration of the notice period" complies with legal procedures.

[0163] Conversely, if the fact is that "Company A attempted to terminate the contract" on March 20, 2023 (only 5 days after the notice), the timing bias term can be calculated similarly. A value of 0.08 is a small positive bias. This small bias indicates that the clause is less relevant to this fact, and the model will determine that terminating the contract at this time does not meet the statutory time limit requirements.

[0164] Continuing with the attention calculation for the clause-level state slots, the next step is to perform Softmax normalization on the sum of the temporal bias term and the corresponding similarity to obtain the attention weights for each clause-level state slot:

[0165] ;

[0166] in, , .

[0167] Finally, based on the attention weights corresponding to the state slots of each clause layer, all value vectors are weighted and summed to obtain the clause attention vector:

[0168] ;

[0169] Through the above process, the legal provision attention vector from the legal provision layer is obtained. It also obtained the clause attention vector from the clause layer. .

[0170] Returning to the sub-step of obtaining the legal knowledge vector associated with the fact vector, the second step is to perform gating fusion of the legal attention vector and the clause attention vector to obtain the legal knowledge vector.

[0171] The gating fusion mechanism can adaptively determine the proportion of information from the legal provisions layer and the clause layer, avoiding information conflicts that may result from simple linear combinations.

[0172] Specifically, gating fusion includes the following steps:

[0173] First, the legal provision attention vector and the clause attention vector are concatenated to obtain the concatenated vector:

[0174] .

[0175] Then, a linear transformation is performed on the concatenated vector, and the result is input into the Sigmoid activation function to calculate the gate value:

[0176] .

[0177] in, This is the weight matrix. For bias vectors, This is the Sigmoid function, with output values ​​in the interval [0,1]. The weight matrix and bias vector here are the learnable parameters of the model, which are automatically optimized based on the loss function during training through backpropagation and gradient descent algorithms.

[0178] Finally, the legal provision attention vector and the clause attention vector are weighted and summed using the gating value to obtain the legal provision knowledge vector:

[0179] .

[0180] in, This indicates element-wise multiplication.

[0181] Compared to simple weighted averaging or splicing, gated fusion has the following advantages:

[0182] First, the gate value It is dynamically calculated based on the specific circumstances of the current situation, and can adaptively adjust the weight of information from the two sources.

[0183] Second, when there is a conflict between the information provided by the legal provisions layer and the clause layer, the gating mechanism can select a more reliable information source to reduce the impact of noise.

[0184] Third, by observing the size of the gating value, we can understand which information source the model relies on more when processing current facts, thus enhancing the interpretability of the model.

[0185] return Figure 2 In step S62, the legal knowledge vector and the fact vector are fused to generate a knowledge-enhanced fact vector.

[0186] Fact Vector It mainly includes the textual semantics and basic characteristics of the case facts (time, subjects, etc.), but lacks an understanding of legal norms. Legal knowledge vector It contains legal provisions related to the fact, but lacks specific factual details. Combining the two can generate an enhanced representation that includes both factual details and legal knowledge.

[0187] Vector fusion can be achieved in the following ways:

[0188] The first method is simple splicing: ;

[0189] The second method is weighted summation: ;

[0190] The third type is gating fusion:

[0191] ;

[0192] The fourth type is the multilayer perceptron. .

[0193] Through the above steps, we obtain the knowledge-enhanced fact vector. This vector retains the specific details of the original facts while incorporating relevant legal knowledge, providing high-quality input for subsequent state updates and element predictions.

[0194] return Figure 2 In step S63, the responsible parties involved in the fact vector are identified, and the status tracking vector of the corresponding responsible party is updated based on the knowledge-enhanced fact vector.

[0195] Different facts may involve different liable parties. For example, "the defendant failed to deliver the equipment on time" mainly involves the defendant, while "the guarantor refused to assume the guarantee liability" mainly involves the guarantor. Therefore, it is necessary to dynamically identify the involved parties when processing each fact, update only the state vectors of these parties, and keep the state of uninvolved parties unchanged.

[0196] Since the fact vector already contains the characteristics of the responsible party. Therefore, the responsible parties involved in the fact vector can be directly extracted.

[0197] In this embodiment, it is assumed that the set of responsible parties involved in the current facts is identified through the above method as follows: For each responsible party involved Updating the state tracking vector of the corresponding responsible entity based on knowledge-enhanced fact vectors includes:

[0198] The updated state tracking vector is calculated by using the knowledge-enhanced fact vector and the state tracking vector of the responsible entity in the previous moment as inputs through a pre-defined recurrent neural network unit.

[0199] Recurrent neural network units can adopt a gated recurrent unit (GRU) structure. GRU controls the retention and forgetting of information by updating and resetting the gates. The specific calculation process adopts the standard GRU structure, which will not be elaborated here.

[0200] This dynamic update mechanism can accurately track the status evolution of each responsible party, providing a basis for the final determination of responsibility.

[0201] In step S64, based on the knowledge-enhanced fact vector and the status tracking vector of the responsible parties involved, the case element information corresponding to the fact vector is output.

[0202] The case information includes three parts:

[0203] The first part consists of case element labels, which are used to identify the types of legal elements involved in the factual unit. The types of legal elements depend on the specific legal field and task requirements. Taking the aforementioned contract dispute case as an example, common element types include contract formation, performance period, notice of intent, contract termination, damages, and grounds for exemption from liability.

[0204] The case element labels here are predicted using a multi-label classifier:

[0205] ;

[0206] in, For the state tracking vector of the main responsible party involved in this fact, The Sigmoid function is used to output multi-label probabilities. and These are the weight matrix and bias vector of the classifier, respectively.

[0207] The second part is the legal provision citation relationship, which is used to identify the legal provisions corresponding to the factual units. This part realizes automatic tracing from the facts of the case to the legal basis. This is due to the legal provision layer attention weight calculated in step S61. This directly reflects the relevance of each legal provision to the current facts. Therefore, the top N legal provisions with the highest weight can be directly selected as the cited legal provisions.

[0208] Information on liable parties, including their types. The types of liable parties can be classified based on the state vectors of each party, and the output types may include: principal debtor, joint and several liability party, supplementary liability party, guarantor, etc.

[0209] After processing all facts in step S6 above, a complete sequence of case element extraction results is obtained, where each output contains case element labels, legal citation relationships, and information on the responsible party.

[0210] This completes all the steps of the legal case element extraction method based on the re-attention mechanism, realizing a complete processing flow from legal document input to structured case element output.

[0211] Exemplary System

[0212] Figure 3The illustration depicts a legal case element extraction system based on a re-attention mechanism according to an embodiment of this application, comprising: a receiving module for receiving legal documents to be processed; a parsing module for parsing the legal documents into a hierarchical structure including at least a factual layer and a legal provision layer; a loading module for loading a pre-constructed hierarchical state slot matrix, the matrix containing legal provision layer state slots with legal provision information; an encoding module for encoding the factual layer into a sequence of fact vectors, each fact vector containing time features, responsible party features, and textual semantic features; a subject tracking module for identifying all responsible parties involved in the legal documents and creating an independent state tracking vector for each responsible party; and a processing module for processing each fact vector in the fact vector sequence sequentially in chronological order, the processing including: using the fact vector as a query vector, reading relevant information from the legal provision layer state slots through an attention mechanism to obtain a legal provision knowledge vector associated with the fact vector; performing vector fusion of the legal provision knowledge vector and the fact vector to generate a knowledge-enhanced fact vector; identifying the responsible parties involved in the fact vector and updating the state tracking vector of the corresponding responsible party based on the knowledge-enhanced fact vector; and outputting case element information corresponding to the fact vector based on the knowledge-enhanced fact vector and the state tracking vector of the involved responsible parties.

[0213] In one example, the hierarchical structure also includes a clause layer, which consists of normative paragraphs containing clause citation timestamps extracted from legal documents; the hierarchical state slot matrix also includes clause layer state slots, which are obtained by encoding the clause layer, with each clause layer state slot associated with a corresponding clause citation timestamp; reading relevant information also includes reading from the clause layer state slots; obtaining the legal provision knowledge vector associated with the fact vector specifically includes: using the fact vector as the query vector, performing attention calculations on the legal provision layer state slots and clause layer state slots respectively to obtain the legal provision attention vector and the clause attention vector; and performing gating fusion of the legal provision attention vector and the clause attention vector to obtain the legal provision knowledge vector.

[0214] In one example, the attention calculation for the clause-level state slots includes: obtaining a key vector and a value vector for each clause-level state slot through a linear transformation; calculating the similarity between the query vector and each key vector; calculating the time difference between the temporal features of the fact vector and the clause reference timestamp corresponding to each clause-level state slot; obtaining the statutory period of the clause corresponding to each clause-level state slot; calculating a temporal bias term representing the comparison result between the time interval and the statutory period based on the time difference and the statutory period; performing Softmax normalization on the sum of the temporal bias term and the corresponding similarity to obtain the attention weight of each clause-level state slot; and performing a weighted summation of all value vectors based on the attention weights corresponding to each clause-level state slot to obtain the clause attention vector.

[0215] In one example, gating fusion includes: concatenating the legal provision attention vector with the clause attention vector to obtain a concatenated vector; performing a linear transformation on the concatenated vector and inputting it into a Sigmoid activation function to calculate a gating value; and performing a weighted summation of the legal provision attention vector and the clause attention vector using the gating value to obtain a legal provision knowledge vector.

[0216] In one example, the parameters of the legal provision layer state slot are fixed.

[0217] In one example, updating the state tracking vector of the corresponding responsible subject based on the knowledge-enhanced fact vector includes: taking the knowledge-enhanced fact vector and the state tracking vector of the responsible subject at the previous moment as input, and calculating the updated state tracking vector through a preset recurrent neural network unit.

[0218] In one example, the case element information includes: case element tags, which identify the types of legal elements involved in the factual unit; legal citation relationships, which identify the legal provisions corresponding to the factual unit; and information on the responsible party, which includes the type of responsible party.

[0219] Exemplary electronic devices

[0220] Figure 4 A block diagram of an electronic device according to an embodiment of this application is illustrated.

[0221] like Figure 4 As shown, the electronic device includes one or more processors and memory.

[0222] A processor can be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and can control other components in an electronic device to perform desired functions.

[0223] The memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.

[0224] In one example, the electronic device may also include input devices and output devices, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).

[0225] Of course, for the sake of simplicity, Figure 3Only some of the components of the electronic device relevant to this application are shown in this illustration; components such as buses, input / output interfaces, etc., are omitted. In addition, the electronic device may include any other suitable components depending on the specific application.

[0226] Exemplary computer-readable media

[0227] Embodiments of this application may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps described in the "Exemplary Methods" section above according to the various embodiments of this application.

[0228] Computer-readable storage media may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0229] The basic principles of this application have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this application are merely examples and not limitations, and should not be considered as essential features of each embodiment of this application. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the application to the necessity of employing the aforementioned specific details for implementation.

[0230] The block diagrams of devices, apparatuses, devices, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.

[0231] It should also be noted that in the apparatus, equipment, and methods of this application, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions of this application.

[0232] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this application. Therefore, this application is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0233] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this application to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A method for extracting legal case elements based on a re-attention mechanism, characterized in that, include: Receive pending legal documents; The legal document is parsed into a hierarchical structure that includes at least a factual layer and a legal provision layer; Load a pre-built hierarchical state slot matrix, the matrix containing legal provision layer state slots with legal provision information; The fact layer is encoded into a sequence of fact vectors, each fact vector containing time features, responsible entity features, and textual semantic features; Identify all responsible parties involved in the legal documents and create an independent status tracking vector for each responsible party; Each fact vector in the fact vector sequence is processed sequentially in chronological order, the processing including: Using the fact vector as the query vector, relevant information is read from the legal provision layer state slot through an attention mechanism to obtain the legal provision knowledge vector associated with the fact vector; The legal knowledge vector and the fact vector are fused to generate a knowledge-enhanced fact vector. Identify the responsible parties involved in the fact vector, and update the status tracking vector of the corresponding responsible party based on the knowledge-enhanced fact vector; Based on the knowledge-enhanced fact vector and the status tracking vector of the responsible parties involved, the case element information corresponding to the fact vector is output.

2. The legal case element extraction method based on re-attention mechanism according to claim 1, characterized in that: The hierarchical structure also includes a clause layer, which consists of normative paragraphs extracted from the legal document and containing clause reference timestamps; The hierarchical state slot matrix also includes clause layer state slots, which are obtained by encoding the clause layer. Each clause layer state slot is associated with a corresponding clause reference timestamp. The reading of relevant information also includes reading from the term layer status slot; The process of obtaining the legal knowledge vector associated with the fact vector specifically includes: Using the fact vector as the query vector, attention calculations are performed on the state slots of the legal provisions layer and the state slots of the clause layer to obtain the legal provision attention vector and the clause attention vector. The legal provision attention vector and the clause attention vector are gated and fused to obtain the legal provision knowledge vector.

3. The legal case element extraction method based on the re-attention mechanism according to claim 2, characterized in that, Attention calculation for the term layer state slots includes: Each of the aforementioned clause layer state slots is transformed linearly to obtain a key vector and a value vector; Calculate the similarity between the query vector and each of the key vectors; Calculate the time difference between the temporal characteristics of the fact vector and the time stamp of the clause reference corresponding to each clause layer state slot; Obtain the statutory term of the clause corresponding to each clause layer status slot; Based on the time difference and the statutory period, calculate a time-series bias term representing the comparison result between the time interval and the statutory period; The sum of the temporal bias term and the corresponding similarity is Softmax normalized to obtain the attention weight of each clause layer state slot; The clause attention vector is obtained by weighting and summing all value vectors based on the attention weights corresponding to the state slots of each clause layer.

4. The legal case element extraction method based on re-attention mechanism according to claim 2, characterized in that, The gating fusion includes: The legal provision attention vector and the clause attention vector are concatenated to obtain the concatenated vector; The concatenated vector is linearly transformed and input into the Sigmoid activation function to calculate the gate value; The legal provision knowledge vector is obtained by weighted summing of the legal provision attention vector and the clause attention vector using the gating value.

5. The legal case element extraction method based on re-attention mechanism according to claim 1, characterized in that, The parameters of the state slot of the legal strip layer are fixed parameters.

6. The legal case element extraction method based on re-attention mechanism according to claim 1, characterized in that, The update of the state tracking vector of the corresponding responsible entity based on the knowledge-enhanced fact vector includes: The knowledge-enhanced fact vector and the state tracking vector of the responsible entity at the previous moment are used as inputs, and the updated state tracking vector is calculated by a preset recurrent neural network unit.

7. The legal case element extraction method based on re-attention mechanism according to claim 1, characterized in that, The case details include: Case element labels, which are used to identify the types of legal elements involved in a factual unit; Legal citation relationships, wherein the legal citation relationships are used to identify the legal provisions corresponding to the factual unit; and Information on the responsible party, including the type of the responsible party.

8. A legal case element extraction system based on a re-attention mechanism, characterized in that, include: The receiving module is used to receive legal documents to be processed; The parsing module is used to parse the legal document into a hierarchical structure that includes at least a factual layer and a legal provision layer; A loading module is used to load a pre-built hierarchical state slot matrix, the matrix containing legal provision layer state slots with legal provision information; The encoding module is used to encode the fact layer into a sequence of fact vectors, each fact vector containing time features, responsible subject features, and textual semantic features; The entity tracking module is used to identify all responsible parties involved in the legal documents and create an independent status tracking vector for each responsible party; The processing module is used to process each fact vector in the fact vector sequence sequentially in chronological order, the processing including: Using the fact vector as the query vector, relevant information is read from the legal provision layer state slot through an attention mechanism to obtain the legal provision knowledge vector associated with the fact vector; The legal knowledge vector and the fact vector are fused to generate a knowledge-enhanced fact vector. Identify the responsible parties involved in the fact vector, and update the status tracking vector of the corresponding responsible party based on the knowledge-enhanced fact vector; Based on the knowledge-enhanced fact vector and the status tracking vector of the responsible parties involved, the case element information corresponding to the fact vector is output.

9. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method as described in any one of claims 1 to 7.

10. A computer storage medium storing computer-executable instructions thereon, characterized in that: When the computer-executable instructions are executed by a processor, they implement the steps of the method as described in any one of claims 1 to 7.