Judicial information retrieval method and system based on graph neural network
Through a judicial information retrieval method based on graph neural networks, a subgraph of legal facts and problem cases is constructed. By utilizing topological enhancement and global attention mechanisms, the problems of inaccurate and low efficiency in legal case retrieval in existing technologies are solved, and efficient and accurate legal case retrieval is achieved.
Patent Information
- Application Number
- CN202510764240.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-06-10
AI Technical Summary
Existing legal case retrieval methods have difficulty effectively capturing deep semantic associations when processing complex legal texts, resulting in inaccurate and inefficient retrieval results, especially in industrial application scenarios with massive data and real-time retrieval needs.
A judicial information retrieval method based on graph neural networks is adopted. Key information is extracted through named entity recognition and relationship extraction tools, and a subgraph of legal facts and problem cases is constructed. Topological enhancement and multi-level loss functions are used to guide model training. A global attention mechanism is introduced for feature extraction and aggregation, and cosine similarity is calculated for similarity measurement.
It achieves efficient and accurate retrieval of legal cases, enables a deeper understanding of the semantic structure of cases, and improves retrieval accuracy and efficiency, especially maintaining retrieval accuracy and efficiency in complex legal issues in multiple fields.
Smart Images

Figure CN120632121A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a judicial information retrieval method and system based on graph neural network. Background Art
[0002] Existing legal case retrieval methods can be primarily categorized into two categories: statistical models and language models. Statistical models focus on measuring term frequency as a measure of case similarity, combining the frequency of keyword occurrence with its distribution across a document collection to determine the relevance of a particular case to the query case. While this approach is simple and straightforward, it often overlooks the semantic associations and contextual relationships between words in legal language. Language models represent case texts as vectors using a case text representation strategy and perform nearest neighbor searches in a high-dimensional space to determine case similarity. Common case text representation strategies include sentence, paragraph, and full-text levels. Although language models achieve higher accuracy than traditional statistical models, they ignore the structural information of legal cases. Furthermore, the length of legal case texts often exceeds most input limits, necessitating the use of text segmentation methods for processing, resulting in a loss of global legal information. Currently, few methods exist that comprehensively consider the information structure of legal case texts and accurately identify legal case semantics.
[0003] Furthermore, most existing legal case retrieval methods rely on traditional statistical and language models, which typically directly input the raw text of legal documents into the system for analysis. However, research has found that raw legal documents often contain a large amount of complex legal terminology, lengthy sentence structures, and intricate paragraph relationships. This makes it difficult for retrieval systems to accurately capture the deep semantic connections between legal cases, thereby affecting the accuracy and relevance of retrieval results. Legal case retrieval methods need to exploit the structural information and deep semantic connections of case texts. Secondly, an analysis of current language models reveals that traditional language models typically rely on vector representations of text and nearest neighbor searches to measure case similarity. While this approach improves semantic matching capabilities to some extent, its effectiveness is still limited by the text representation strategy. This is particularly true when processing long and complex legal texts. The model consumes significant computational resources, has slow retrieval speeds, and has limitations in multi-level semantic understanding. In industrial applications facing massive amounts of legal data and real-time retrieval requirements, the efficiency and scalability issues of traditional methods become particularly prominent. Legal case retrieval methods need to address the problem of efficient retrieval of complex legal texts. Especially when dealing with complex legal issues across multiple domains, few legal case retrieval methods can balance retrieval accuracy and efficiency. Summary of the Invention
[0004] In order to solve the above-mentioned problems, the present invention provides a judicial information retrieval method and system based on graph neural network.
[0005] In a first aspect, the present invention provides a judicial information retrieval method based on a graph neural network, which adopts the following technical solutions: A judicial information retrieval method based on graph neural network, comprising: Obtain judicial case text data; Named entity recognition and relationship extraction tools are used to extract key information from judicial case text data, resulting in a legal fact case subgraph and a legal issue case subgraph. A topology-based enhancement method is used to enhance the structural information of the legal fact case subgraph and the legal issue case subgraph. A multi-level loss function system is used to integrate cross-subgraph comparison loss and structural consistency loss to guide model training. Using graph neural networks, we introduce a global attention mechanism to extract and aggregate features from the legal fact case subgraph and the legal issue case subgraph to obtain graph embedding vectors. Aggregate the graph embedding vector through the readout function to obtain the final embedding vector; By calculating the cosine similarity between the query case embedding vector and the sample case embedding vector, all cases are similarity measured and ranked.
[0006] Furthermore, the method uses named entity recognition and relationship extraction tools to extract key information from judicial case text data to obtain a legal fact case subgraph and a legal issue case subgraph, including using the named entity recognition tool jieba and the relationship extraction tool OpenNRE to extract key information from the legal case text, creating nodes and edges of the graph based on the key information, and obtaining a legal fact case subgraph and a legal issue case subgraph.
[0007] Furthermore, the structural information of the legal fact case subgraph and the legal problem case subgraph is enhanced through a topology enhancement-based method, including converting the text in the nodes and edges into a token form that can be recognized by the model, and then inputting the token into the DeBERTa model for encoding to obtain node and edge features; performing standardization and normalization on the graph-level features and inputting them into the MLP to obtain the embedding of global information.
[0008] Furthermore, the multi-level loss function system is based on the comprehensive cross-subgraph comparison loss and structural consistency loss to guide model training, including setting a cross-subgraph comparison loss function to identify the implicit relationship between legal facts and legal issues, and setting a structural consistency loss function to dynamically adjust the node connection weights to match the content of similar cases and maintain convergence in the structural form of the legal relationship network, which is expressed as: , in, and represents the dynamic weight, stands for Jensen-Shannon divergence, which measures the difference in distribution between the fact structure of the current case and the typical structure of the same type. and Represent the adjacency matrices of the case fact subgraph and question subgraph of the training samples, and The structural prototype adjacency matrices representing the case fact subgraph and question subgraph respectively.
[0009] Furthermore, the graph neural network introduces a global attention mechanism to extract and aggregate features of the legal fact case subgraph and the legal issue case subgraph to obtain a graph embedding vector, including aggregating important features in the global scope through the global attention mechanism, the features representing the nodes themselves, and integrating the information of global nodes and their connecting edges. At the same time, graph-level information is incorporated into the aggregation process to obtain node features. The feature update formula for each node is as follows: , in, is the updated node feature, is the initial feature of node v, Represents graph-level features, Represents the characteristics of the connecting edge, N (v) is the set of all nodes, is the global attention weight, W s 、 W g 、 W e and W vu They are the weight matrices for node update, graph-level features, edge feature updates, and node association updates, and ReLU represents the activation function.
[0010] Furthermore, the introduction of the global attention mechanism extracts and aggregates features of the legal fact case subgraph and the legal problem case subgraph to obtain a graph embedding vector. The method also includes performing an average pooling operation on the node features based on the global attention weight to obtain a global node feature. Combining the representation of the node feature and the global node feature, a complete graph representation, i.e., a graph embedding vector, is generated for each of the fact subgraph and the problem subgraph. The local node feature representation is: in, and are the node sets in the case subgraph and the problem subgraph respectively, and It is the global representation of the graph after pooling.
[0011] Furthermore, the method calculates the cosine similarity between the query case embedding vector and the sample case embedding vector to measure and sort all cases. This includes calculating the embedding vector of the legal fact subgraph and the embedding vector of the question subgraph for each case, comparing the similarity between the query case embedding vector and the sample case embedding vector using cosine similarity, sorting all cases by similarity, and returning the case with the highest similarity as: , in, and are graph-level features of the legal fact graph and legal issue graph, and It is a complete graphical representation of the legal facts graph and the legal issues graph.
[0012] The second aspect is a judicial information retrieval system based on graph neural network, including: The data acquisition module is configured to acquire judicial case text data; The graph feature module is configured to extract key information from judicial case text data using named entity recognition and relationship extraction to obtain a legal fact case subgraph and a legal issue case subgraph. The structural information of the legal fact case subgraph and the legal issue case subgraph is enhanced using a topology enhancement-based method. Model training is guided by a multi-level loss function system that combines cross-subgraph comparison loss and structural consistency loss. The embedding module is configured to extract and aggregate features of the legal fact case subgraph and the legal issue case subgraph based on the graph neural network and introduce a global attention mechanism to obtain a graph embedding vector; the graph embedding vector is aggregated through a readout function to obtain a final embedding vector; The retrieval module is configured to measure and rank the similarity of all cases by calculating the cosine similarity between the embedding vector of the query case and the embedding vector of the sample case.
[0013] In a third aspect, the present invention provides a computer-readable storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device for a judicial information retrieval method based on a graph neural network.
[0014] In a fourth aspect, the present invention provides a terminal device comprising a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; the computer-readable storage medium is used to store multiple instructions, and the instructions are suitable for being loaded and executed by the processor to implement the judicial information retrieval method based on graph neural network.
[0015] In summary, the present invention has the following beneficial technical effects: (1) In this paper, we combine artificial intelligence and graph neural network technology to propose an innovative model for legal case retrieval. This model uses graph learning algorithms, language model technology, and contrastive learning methods to effectively encode the complex relational structure in legal documents, thereby achieving accurate matching and retrieval of relevant cases.
[0016] (2) The legal case retrieval model proposed in this paper effectively addresses the shortcomings of traditional legal retrieval methods in processing long texts by introducing a graph attention network. This model can achieve more efficient and accurate case matching and reasoning under limited judicial resources, thereby better helping legal practitioners quickly find relevant cases.
[0017] (3) It solves the problem of insufficient understanding of the semantic structure of cases in existing legal retrieval systems. By constructing a structure based on the legal semantic graph, the model can more deeply capture the logical relationship between the various elements in the legal document, and through knowledge distillation technology, this semantic information can be efficiently transmitted to each layer of the model, thereby greatly improving the accuracy and efficiency of legal case retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a schematic diagram of a judicial information retrieval method based on a graph neural network according to Example 1 of the present invention. DETAILED DESCRIPTION
[0019] The present invention will be further described in detail below with reference to the accompanying drawings.
[0020] Example 1 Reference Figure 1 , a judicial information retrieval method based on a graph neural network in this embodiment includes: Obtain judicial case text data; Extract key information from judicial case text data to obtain legal fact case subgraphs and legal issue case subgraphs; The structural information of the legal fact case subgraph and the legal issue case subgraph is enhanced through a topology enhancement method. Use pre-trained language models to encode case text and structural information, and introduce global feature information; Design a multi-level loss function system that integrates cross-subgraph comparison loss and structural consistency loss to guide model training; Using a graph neural network model, we introduce a global attention mechanism to extract and aggregate features from the legal fact case subgraph and the legal issue case subgraph to obtain a graph embedding vector. Aggregate the graph embedding vector through the readout function to obtain the final embedding vector; By calculating the cosine similarity between the query case embedding vector and the sample case embedding vector, all cases are similarity measured and ranked.
[0021] Specifically, the following operations are included: S1. Extract triples from case texts through entity recognition and relationship extraction tools, construct structural information of cases from the two aspects of legal facts and legal issues, and convert each legal case into a legal fact case subgraph and a legal issue case subgraph.
[0022] S2. A topological enhancement method is introduced to perform structural optimization on the fact subgraph and the problem subgraph based on two core association relationships in legal knowledge, namely the hierarchical structure of legal provisions and the citation relationship between cases and legal provisions.
[0023] S3. Encode the extracted case text and structural information using a pre-trained language model to generate feature vectors for nodes and edges. Introduce graph-level global features into each subgraph to capture the global information of the graph and improve the expressiveness of node representation. Set global nodes based on the global features.
[0024] S4. Design a multi-level loss function system to guide the model to effectively distinguish cases similar to the query case from those dissimilar to the query case by integrating cross-subgraph comparison loss and structural consistency loss.
[0025] S5. An edge-graph attention layer is applied to the two subgraphs of legal cases. By aggregating node and edge feature vectors, the representation of each node is updated, and a more expressive graph embedding is learned through a global attention mechanism. A readout function is used to aggregate the graph-level global features and the average of all node feature vectors to form the final graph embedding.
[0026] The step S1 specifically includes: S1.1: Use a named entity recognition tool (jieba) and a relation extraction tool (OpenNRE) to extract key information from legal case text. This information includes entities in the case (such as parties and events) and the relationships between them. The extraction results are represented as triples (h, r, t), where h and t represent entities, and r represents the relationship between them.
[0027] S1.2: Create graph nodes based on the entities in the triples, create edges between the nodes based on the relationships in the triples, and construct two subgraphs for each case, a legal fact graph G describing the facts of the case. lf and a legal issue diagram G describing the legal issues of the case li .
[0028] S1.3: Legal Facts Subgraph G lfThe node types include parties, specific behaviors, and physical evidence. The edge types include party-specific behaviors, party-physical evidence, and specific behaviors-physical evidence relationships. li Node types include "dispute focus", "legal provisions", and "legal concepts". Edge types include "dispute-legal provision" relationships.
[0029] The step S2 specifically includes: S2.1: In the fact subgraph, match relevant legal provisions from the legal document library based on the key actions described in the case (e.g., "intentional injury" or "property damage"). Add legal provision nodes and connect them with "Case-Law Provision" edges to form a hybrid graph structure.
[0030] S2.2: In the problem subgraph, add legal article hierarchical nodes and encode the legal article hierarchical relationships in the legal article library (such as "general provisions-specific provisions-specific provisions") as directed edges to form a legal article logical link.
[0031] S2.3: Calculate the number of connected components, clustering degree, diameter, average path length, and density of the legal fact subgraph and legal issue subgraph respectively as the global features F of the two subgraphs. glf and F gli .
[0032] The step S3 specifically includes: S3.1: First, convert the text in the nodes and edges into a token form that the model can recognize, and then input the token into the DeBERTa model for encoding to obtain node and edge features. uv The text attribute encoding is processed as follows: in, 、 、 are node u, node v and edge e respectively uv Tokenizer represents the process of converting text information into Tokens, and DeBERTa is a pre-trained language model.
[0033] S3.2: Graph-level features Fg lf and Fg li Perform standardization and normalization, and input it into the MLP to obtain the embedding of global information. Set a global node in the legal fact graph and the legal issue graph respectively, and use the embedding as the feature of the global node. The calculation formula is as follows: in, and Represent the mean and variance of feature F respectively, represents standardized and normalized features, h Represents the feature embedding of the global node.
[0034] The step S4 specifically includes: A multi-level loss function system is designed, integrating cross-subgraph comparison loss and structural consistency loss, so that the model can not only grasp the comparison of case features, but also maintain the legal structure paradigm, forming an embedding space that conforms to the laws of judicial cognition.
[0035] S4.1 Design a cross-subgraph comparison loss function to identify implicit connections between legal facts and legal issues.
[0036] , in, and is the embedding of the fact subgraph and question subgraph of the training sample case, is the temperature coefficient, controlling the discrimination between similar cases, Representative j The embedding of the problem subgraph of the training sample, N Represents the total number of sample cases in the training batch.
[0037] S4.2 Design a structural consistency loss function to dynamically adjust the node connection weights so that similar cases not only match in content but also maintain convergence in the structural form of the legal relationship network.
[0038] , in, and represents the dynamic weight, stands for Jensen-Shannon divergence, which measures the difference in distribution between the fact structure of the current case and the typical structure of the same type. and Represent the adjacency matrices of the case fact subgraph and question subgraph of the training samples, and The structural prototype adjacency matrices representing the case fact subgraph and question subgraph respectively.
[0039] S4.3 combines cross-subgraph contrast loss and structural consistency loss to form a multi-level loss function.
[0040]
[0041] The step S5 specifically includes: The edge graph attention layer is the core of the method, which is used to effectively aggregate information about nodes and their neighboring nodes and edges in graph neural networks. It introduces the global attention mechanism of Transformer to effectively capture information about non-neighboring nodes.
[0042] S5.1: The global attention mechanism aggregates important features globally. The representation of a node not only considers its own features, but also integrates information about global nodes and their connected edges, and incorporates graph-level information into the aggregation process. The feature update formula for each node is as follows: , in, is the updated node feature, is the initial feature of node v, Represents graph-level features, Represents the characteristics of the connecting edge, N (v) is the set of all nodes, is the global attention weight, W s 、 W g 、 W e and W vu They are the weight matrices for node update, graph-level features, edge feature updates, and node association updates, and ReLU represents the activation function.
[0043] S5.2: is the global attention weight, which is calculated by the query-key dot product. The global attention weight is calculated as follows: , Among them, Softmax converts the weight value into a probability value between 0 and 1. Representative Node i In the l The query vector for the layer. node j In the l The key vector of the layer, and represents the learnable weight matrix, d represents the feature dimension, Represents edge coding.
[0044] , in, is the edge feature on the path, W edge is the projection matrix, L is the path length.
[0045] S5.3 For each node v in graph G i , whose eigenvector is , use the average pooling operation to average the feature vectors of all nodes: in, and are the node sets in the case subgraph and the problem subgraph respectively, and It is the global representation of the graph after pooling.
[0046] S5.4 Combine the representations of node features and global node features to generate a complete graph representation for the fact subgraph and the question subgraph respectively , in, and are graph-level features of the legal fact graph and legal issue graph, and It is a complete graphical representation of the legal facts graph and the legal issues graph.
[0047] S5.5 Calculate the embedding vector of the legal fact subgraph and the question subgraph for each case, and use cosine similarity to compare the similarity between the embedding vector of the query case and the embedding vector of the sample case.
[0048] , Sort all cases by similarity and return the case with the highest similarity.
[0049] A computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded and executed by a processor of a terminal device, a judicial information retrieval method based on a graph neural network.
[0050] A terminal device includes a processor and a computer-readable storage medium, wherein the processor is used to implement various instructions; the computer-readable storage medium is used to store multiple instructions, and the instructions are suitable for being loaded and executed by the processor to implement the judicial information retrieval method based on graph neural network.
[0051] The above are all preferred embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A judicial information retrieval method based on graph neural network, characterized in that: include: Obtain judicial case text data; Named entity recognition and relationship extraction tools are used to extract key information from judicial case text data, resulting in a legal fact case subgraph and a legal issue case subgraph. A topology-based enhancement method is used to enhance the structural information of the legal fact case subgraph and the legal issue case subgraph. A multi-level loss function system is used to integrate cross-subgraph comparison loss and structural consistency loss to guide model training. A global attention mechanism is introduced to extract and aggregate features of the legal fact case subgraph and the legal issue case subgraph to obtain a graph embedding vector. Aggregate the graph embedding vector through the readout function to obtain the final embedding vector; By calculating the cosine similarity between the query case embedding vector and the sample case embedding vector, all cases are similarity measured and ranked.
2. A judicial information retrieval method based on graph neural network according to claim 1, characterized in that: The method uses named entity recognition and relationship extraction tools to extract key information from judicial case text data to obtain a legal fact case subgraph and a legal issue case subgraph, including using the named entity recognition tool jieba and the relationship extraction tool OpenNRE to extract key information from the legal case text, creating nodes and edges of the graph based on the key information, and obtaining a legal fact case subgraph and a legal issue case subgraph.
3. A judicial information retrieval method based on graph neural network according to claim 2, characterized in that: The structural information of the legal fact case subgraph and the legal issue case subgraph is enhanced through a topology enhancement-based method, including converting the text in the nodes and edges into a token form that can be recognized by the model, and then inputting the token into the DeBERTa model for encoding to obtain node and edge features; performing standardization and normalization on the graph-level features and inputting them into the MLP to obtain the embedding of global information.
4. A judicial information retrieval method based on graph neural network according to claim 3, characterized in that: The multi-level loss function system is based on the comprehensive cross-subgraph comparison loss and structural consistency loss to guide model training. This includes setting a cross-subgraph comparison loss function to identify the implicit relationship between legal facts and legal issues, and setting a structural consistency loss function to dynamically adjust the node connection weights to match the content of similar cases and maintain convergence in the structural form of the legal relationship network. It is expressed as: , in, and represents the dynamic weight, stands for Jensen-Shannon divergence, which measures the difference in the distribution of the fact structure of the current case and the typical structure of the same type. and Represent the adjacency matrices of the case fact subgraph and question subgraph of the training samples, and The structural prototype adjacency matrices representing the case fact subgraph and question subgraph respectively.
5. A judicial information retrieval method based on graph neural network according to claim 4, characterized in that: The global attention mechanism is introduced to extract and aggregate features of the legal fact case subgraph and the legal issue case subgraph to obtain a graph embedding vector. This includes aggregating important features in the global scope through the global attention mechanism, the features representing the nodes themselves, and integrating the information of global nodes and their connecting edges. At the same time, graph-level information is incorporated into the aggregation process to obtain node features. The feature update formula for each node is as follows: , in, is the updated node feature, is the initial feature of node v, Represents graph-level features, Represents the characteristics of the connecting edge, N (v) is the set of all nodes, is the global attention weight, W s 、 W g 、 W e and W vu They are the weight matrices for node update, graph-level features, edge feature updates, and node association updates, and ReLU represents the activation function.
6. A judicial information retrieval method based on graph neural network according to claim 5, characterized in that: The global attention mechanism is introduced to extract and aggregate features of the legal fact case subgraph and the legal problem case subgraph to obtain a graph embedding vector. The global attention mechanism also includes performing an average pooling operation on the node features based on the global attention weight to obtain a global node feature. Combining the representation of the node feature and the global node feature, a complete graph representation, i.e., a graph embedding vector, is generated for each of the fact subgraph and the problem subgraph. The local node feature representation is: in, and are the node sets in the case subgraph and the problem subgraph respectively, and It is the global representation of the graph after pooling.
7. The judicial information retrieval method based on graph neural network according to claim 6 is characterized in that: The method measures and ranks all cases by calculating the cosine similarity between the query case embedding vector and the sample case embedding vector, including calculating the legal fact subgraph embedding vector and the question subgraph embedding vector of each case, comparing the similarity between the query case embedding vector and the sample case embedding vector using cosine similarity, ranking all cases by similarity, and returning the case with the highest similarity as: , in, and are graph-level features of the legal fact graph and legal issue graph, and It is a complete graphical representation of the legal facts graph and the legal issues graph.
8. A judicial information retrieval system based on graph neural network, characterized by: include: The data acquisition module is configured to acquire judicial case text data; The graph feature module is configured to extract key information from judicial case text data using named entity recognition and relationship extraction tools to obtain legal fact case subgraphs and legal issue case subgraphs. The structural information of the legal fact case subgraphs and legal issue case subgraphs is enhanced using a topology enhancement-based method. Model training is guided by a multi-level loss function system that integrates cross-subgraph comparison loss and structural consistency loss. The embedding module is configured to introduce a global attention mechanism to extract and aggregate features of the legal fact case subgraph and the legal issue case subgraph to obtain a graph embedding vector; the graph embedding vector is aggregated through a readout function to obtain a final embedding vector; The retrieval module is configured to measure and rank the similarity of all cases by calculating the cosine similarity between the embedding vector of the query case and the embedding vector of the sample case.
9. A computer-readable storage medium storing a plurality of instructions, characterized in that: The instructions are suitable for being loaded by a processor of a terminal device and executing the method according to claim 1 .
10. A terminal device comprising a processor and a computer-readable storage medium, wherein the processor is configured to implement various instructions; and the computer-readable storage medium is configured to store a plurality of instructions, wherein: The instructions are suitable for being loaded by a processor and for executing the method according to claim 1 .
Citation Information
Patent Citations
Algorithm and device for obtaining community based on graph auto-encoder self-supervised training
CN116304367A
Graph contrast learning-based citation network classification method
CN118861794A
Data identification method based on structured semantic knowledge enhancement
CN119597915A
System and method for molecular property prediction using hypergraph message passing neural network (HMPNN)
EP4120138A1
Dynamic presentation of searchable contextual actions and data
US20220309037A1