Method, device and equipment for recommending similar Chinese cases based on graph neural network
By constructing heterogeneous graphs and meta-paths based on graph neural networks, the problems of low efficiency and low accuracy in the retrieval of similar legal cases in existing technologies are solved, and efficient and accurate retrieval of legal case recommendations is achieved.
Patent Information
- Application Number
- CN202310893270.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-19
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2043-07-19
AI Technical Summary
Existing similar legal case retrieval methods cannot effectively utilize structural information and text information, resulting in low retrieval efficiency and low accuracy.
Construct a heterogeneous graph based on graph neural network. By obtaining legal hierarchy information and case information as nodes, and the relationship between laws and cases as edges, construct a meta-path, and obtain, transform and aggregate node features. Use the attention mechanism to learn heterogeneous graph representations and train a similar case recommendation graph neural network.
It improves the accuracy of similar case recommendations, can effectively integrate structural information and text information, and improves the efficiency and accuracy of legal case retrieval.
Smart Images

Figure CN116804997B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and apparatus for recommending similar Chinese cases based on a graph neural network. Background Art
[0002] The task of similar legal case retrieval aims to retrieve similar cases for a given new legal case description. Similar legal case retrieval can provide additional information support for the judgment of the target case. Given the huge number of previous cases, legal decision makers need to spend a lot of time and energy to find and judge similar legal cases, and this is inefficient. Therefore, there is an urgent need for automated tools to retrieve similar cases. Similar legal case retrieval systems can quickly obtain cases similar to the target case. The current mainstream research methods either only use structural information or only use text information. In terms of effect, they cannot meet the accuracy requirements of similar case recommendations and cannot fully utilize these two aspects of information. Therefore, the existing technology has the problem of poor adaptability. Summary of the Invention
[0003] Based on this, it is necessary to provide a Chinese similar case recommendation method, device, computer equipment and storage medium based on graph neural network that can improve the accuracy of recommendation of similar legal cases in response to the above technical problems.
[0004] A Chinese similar case recommendation method based on graph neural network, the method comprising:
[0005] Obtaining legal hierarchy system information and case information; the legal hierarchy system information includes legal overall text information, edition text information, chapter text information, section text information, and legal article text information;
[0006] A heterogeneous graph is constructed using the legal hierarchy information and the case information as nodes and the relationship information within legal articles, within cases, and between legal articles and cases as edges; the relationship information within legal articles, within cases, and between legal articles and cases includes information on affiliation between regulatory structures, information on similarity between legal articles, information on similarity between cases, and information on reference relationships between cases and legal articles;
[0007] Constructing a meta-path according to the heterogeneous graph, and generating a meta-path instance according to the meta-path; the meta-path includes case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case;
[0008] Node feature acquisition and node feature conversion are performed according to the instance of the meta-path, and heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node;
[0009] A pre-built similar case recommendation graph neural network is trained according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and similar cases are recommended using the trained similar case recommendation graph neural network.
[0010] In one embodiment, the method further includes: obtaining a vector representation of text information of each node according to the instance of the meta-path, and converting the vector representations of nodes of different types into the same latent vector space to obtain converted node features;
[0011] According to the conversion node features, a meta-path aggregation strategy based on an attention mechanism is used to learn the structural information reflected by different meta-path instances under a given meta-path, thereby obtaining a meta-path aggregation node feature;
[0012] According to the convergence node features within the meta-path, a meta-path convergence strategy based on an attention mechanism is used to learn the structural information reflected by different meta-paths to obtain the convergence node features between meta-paths;
[0013] The features of the aggregated nodes between the meta-paths are projected into the target space to obtain the final representation vector of the node.
[0014] In one embodiment, the method further includes: obtaining a vector representation of the text information of each node through a BERT model according to the instance of the meta-path:
[0015]
[0016] in, is the word sequence of node v of type A, It is the vector obtained after being processed by the BERT model. is a set of nodes of type A, d A The node representing A represents the dimension of the vector;
[0017] The vector representations of different types of nodes are transformed into the same latent vector space through linear transformation to obtain the transformed node features:
[0018]
[0019] in, is the transformed matrix, is the parameter matrix, and d′ represents the dimension of the transformed vector.
[0020] In one embodiment, the method further includes: given a meta-path P, for a meta-path instance P(v,u)=(t0, t1, ..., t n ), the vector representation of the meta-path instance is obtained through the decoder based on relational rotation:
[0021]
[0022]
[0023]
[0024] Among them, t i Represents a node on a meta-path instance, v and u are the end and starting points of the meta-path, and t n =v, t1=u, R i Is the connection t i-1 and t i The relationship, r i It is R i Rotation vector, o i represents the vector obtained by the i-th rotation, is the representation vector of the transformed meta-path instance P(v,u);
[0025] The structural information reflected by different meta-path instances is learned through the meta-path aggregation strategy based on the attention mechanism, and the converged node features within the meta-path are obtained.
[0026] In one embodiment, the method further includes: learning the structural information reflected by different meta-paths through the meta-path aggregation strategy based on the attention mechanism according to the convergence node features in the meta-path, and obtaining the convergence node features between the meta-paths. It represents the set of all meta-paths whose starting point or end point type is A, and M represents the number of different meta-paths.
[0027] In one embodiment, the method further includes: projecting the converged node features between the meta-paths into a target space to obtain a final representation vector of the node:
[0028]
[0029] in, is the final representation vector of the model for node v, d o is the vector dimension required by the task, is the parameter matrix and σ(·) is the activation function.
[0030] In one embodiment, the method further includes: obtaining a negative sample set by negative sample sampling;
[0031] Training a pre-built similar case recommendation graph neural network according to the final representation vector of the node and the negative sample set to obtain a trained similar case recommendation graph neural network;
[0032] Input the text representation and structural information of the new case into the trained similar case recommendation graph neural network to obtain the representation h of the new case new ;
[0033] According to the representation of the new case h new and representation of existing cases Calculate similarity probabilities;
[0034] Similar cases are recommended based on the similarity probability.
[0035] A Chinese similar case recommendation device based on a graph neural network, comprising:
[0036] An information acquisition module is used to acquire legal hierarchy system information and case information; the legal hierarchy system information includes legal overall text information, compilation text information, chapter text information, section text information and legal article text information;
[0037] a heterogeneous graph construction module for constructing a heterogeneous graph using the legal hierarchy information and the case information as nodes and the relationship information within legal articles, within cases, and between legal articles and cases as edges; the relationship information within legal articles, within cases, and between legal articles and cases includes information on affiliation between regulatory structures, information on similarity between legal articles, information on similarity between cases, and information on reference relationships between cases and legal articles;
[0038] a meta-path construction module, configured to construct a meta-path according to the heterogeneous graph and generate meta-path instances according to the meta-path; the meta-paths include case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case;
[0039] A heterogeneous graph learning module is used to obtain and transform node features based on the instances of the meta-path, perform heterogeneous graph representation learning through intra-meta-path aggregation strategy and inter-meta-path aggregation strategy, and obtain the final representation vector of the node;
[0040] The model training module is used to train the pre-built similar case recommendation graph neural network according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and recommend similar cases through the trained similar case recommendation graph neural network.
[0041] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0042] Obtaining legal hierarchy system information and case information; the legal hierarchy system information includes legal overall text information, edition text information, chapter text information, section text information, and legal article text information;
[0043] A heterogeneous graph is constructed using the legal hierarchy information and the case information as nodes and the relationship information within legal articles, within cases, and between legal articles and cases as edges; the relationship information within legal articles, within cases, and between legal articles and cases includes information on affiliation between regulatory structures, information on similarity between legal articles, information on similarity between cases, and information on reference relationships between cases and legal articles;
[0044] Constructing a meta-path according to the heterogeneous graph, and generating a meta-path instance according to the meta-path; the meta-path includes case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case;
[0045] Node feature acquisition and node feature conversion are performed according to the instance of the meta-path, and heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node;
[0046] A pre-built similar case recommendation graph neural network is trained according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and similar cases are recommended using the trained similar case recommendation graph neural network.
[0047] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0048] Obtaining legal hierarchy system information and case information; the legal hierarchy system information includes legal overall text information, edition text information, chapter text information, section text information, and legal article text information;
[0049] A heterogeneous graph is constructed using the legal hierarchy information and the case information as nodes and the relationship information within legal articles, within cases, and between legal articles and cases as edges; the relationship information within legal articles, within cases, and between legal articles and cases includes information on affiliation between regulatory structures, information on similarity between legal articles, information on similarity between cases, and information on reference relationships between cases and legal articles;
[0050] Constructing a meta-path according to the heterogeneous graph, and generating a meta-path instance according to the meta-path; the meta-path includes case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case;
[0051] Node feature acquisition and node feature conversion are performed according to the instance of the meta-path, and heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node;
[0052] A pre-built similar case recommendation graph neural network is trained according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and similar cases are recommended using the trained similar case recommendation graph neural network.
[0053] The above-mentioned Chinese similar case recommendation method, device, computer equipment and storage medium based on graph neural network constructs a heterogeneous graph with legal hierarchy system information and the case information as nodes, and relationship information within legal provisions, within cases, and between legal provisions and cases as edges, constructs meta-paths and generates instances of meta-paths, and then performs node feature acquisition and node feature conversion. The heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node. On the one hand, the present invention can obtain the text information of legal case documents and regulations. On the other hand, through the heterogeneous graph and the designed meta-path, the structural information within the legal provisions, within the cases, and between the legal provisions and cases is integrated. The mined structural information can be integrated with the text information, thereby improving the accuracy of similar case recommendations. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 1. A flowchart of a method for recommending similar Chinese cases based on a graph neural network in one embodiment;
[0055] Figure 2 A schematic diagram of a heterogeneous graph constructed in a specific embodiment;
[0056] Figure 3 1 is a structural block diagram of a Chinese similar case recommendation device based on a graph neural network in one embodiment;
[0057] Figure 4 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0059] In one embodiment, Figure 1 As shown in FIG, a Chinese similar case recommendation method based on graph neural network is provided, which includes the following steps:
[0060] Step 102: Obtain legal hierarchy information and case information.
[0061] The heterogeneous graph proposed in this paper consists of two parts: case documents and a hierarchy of legal provisions. Case documents include basic case information, court analysis, and the ruling. The legal hierarchy is a collection of laws (entire articles), volumes, chapters, sections, and clauses. A complete law can be divided into multiple volumes, each of which can be divided into multiple chapters. Chapters and sections can be divided in a similar manner. However, not all legal structures contain all subordinate structures. For example, some laws have chapters that only contain legal provisions, but no sections.
[0062] The method of the present invention considers both the structural information and textual information of case documents and legal systems. The links between case documents and regulations can serve as a supplement to the embedded legal domain knowledge generated by the model.
[0063] Step 104 , constructing a heterogeneous graph with the legal hierarchy information and case information as nodes and the relationship information within legal provisions, within cases, and between legal provisions and cases as edges.
[0064] The definition of heterogeneous graph is as follows: Let graph in is the set of graph nodes, and ε is the set of graph edges. Suppose the graph has a point type mapping function and edge type mapping function in and are sets of vertex and edge types respectively, then is a heterogeneous graph if and only if
[0065] In this embodiment, Figure 2As shown, act, chapter, topic, section, article, and d represent law (referring to a complete set of laws), volume, chapter, section, article, and case, respectively. There are four types of edges in the figure: (1) Subordinate relationships between legal structures: Use black solid arrows to represent subordinate relationships between legal structures. This type of edge indicates that the upper structure in the legal article contains the lower structure, or the lower structure is subordinate to the upper structure. These edges are related to the actual structure of the law or regulation, so they are known. (2) Similarity relationships between legal articles: Use black dotted lines to represent the similarity relationships between legal articles of different laws and regulations. This type of edge indicates that there is a similarity relationship between two connected legal articles. This relationship is artificially calibrated. (3) Similarity relationships between cases: Use the first dotted line to represent the similarity relationship between disciplinary cases. This type of edge indicates that there is a similarity relationship between two connected cases. This relationship is artificially calibrated. (4) Reference relationship between cases and articles: The second dotted line represents the reference relationship between cases and articles. This type of edge indicates that the violation in the case meets the disciplinary conditions in the related article, or that the related case needs to be referred to when judging the case. This relationship is artificially marked.
[0066] Step 106: construct a meta-path according to the heterogeneous graph, and generate a meta-path instance according to the meta-path.
[0067] The meta-path P is defined as A path where A1, A2, ..., A l+1 For nodes, R1, R2, ..., R l Used to describe the relationship between nodes. Meta path is used to describe the relationship between A1 and A l+1 Composite relationship Compound operators that represent relations.
[0068] Based on the meta-path, we define the instance of the meta-path. The instance of the meta-path is defined as a sequence of nodes with the same node type and edge type as the meta-path, denoted as p. For example, for the meta-path is an instance of P. In addition, it is defined that P(u, v) represents an instance of a meta-path connecting nodes u and v.
[0069] Different forms of meta-paths have different semantic meanings and can be used to express different types of information in heterogeneous graphs. To represent the constructed heterogeneous network, it is necessary to manually select multiple meta-paths that have an impact on the task, thereby fully utilizing the structural information in the heterogeneous graph. The following is a detailed description of the constructed meta-paths:
[0070] (1) Case-Law-Case
[0071] Because a legal article in a regulation specifies the punishment for a certain behavior, if two cases both reference the same article, they can be considered to contain similar violations and, therefore, to be similar. This meta-path helps capture the structural information of cases that reference the same article, thus constructing a meta-path of case-article-case.
[0072] (2) Case-Case-Case
[0073] There is reason to believe that when two cases are similar to the same case, the two cases are likely to be similar. This meta-path can help obtain structural information about the similarities between two cases, so the case-case-case meta-path is constructed.
[0074] (3) Case-Law-Law-Case
[0075] It is known that there is a similarity between the articles of different laws and regulations, which indicates that the violations described in the two articles are similar. It can be considered that the two different cases referring to these two similar articles are likely to be similar. This meta-path can obtain the similarity relationship between cases referring to different laws and regulations, so the meta-path of case-article-article-case is constructed.
[0076] (4) Case-Article-Section-Article-Case
[0077] The same section specifies the penalties for the same type of violation. That is, within the same section, different articles describe similar types of violations. Therefore, if two cases reference two articles belonging to the same section, the violations described in these two cases are of the same type. This meta-path captures the similarity between the types of behavior in the cases, thus constructing the meta-path of case-article-section-article-case.
[0078] In step 108 , node features are acquired and converted based on the meta-path instances, and heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node.
[0079] Generating vector representations of nodes in heterogeneous graphs requires three steps: node content transformation, intra-meta-path aggregation, and inter-meta-path aggregation. Because heterogeneous graphs contain multiple node types, node content transformation is required to project the features of heterogeneous nodes into the same vector space. Intra-meta-path aggregation is then applied to each meta-path instance to capture and integrate meta-path instance information. Furthermore, inter-meta-path aggregation is applied to aggregate information from all types of meta-paths to obtain the final node embedding. Both aggregation strategies employ an attention mechanism to fuse information differently depending on the contribution of the meta-path instance or meta-path.
[0080] This paper proposes a representation learning method for heterogeneous graphs that considers both the characteristics of the nodes themselves and the structural information of the heterogeneous graph when vectorizing the representation of heterogeneous graph nodes. Specifically, the structural information of the heterogeneous graph is reflected by meta-paths. Using an attention mechanism, the model can not only capture the content characteristics of each node on a meta-path, but also consider the influence of other meta-paths.
[0081] In step 110 , a pre-built similar case recommendation graph neural network is trained according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and similar cases are recommended using the trained similar case recommendation graph neural network.
[0082] The trained model can output vector representations of new cases and past cases, and then calculate similarity.
[0083] In the above-mentioned Chinese similar case recommendation method based on graph neural network, a heterogeneous graph is constructed with legal hierarchy information and the case information as nodes, and relationship information within legal provisions, within cases, and between legal provisions and cases as edges. A meta-path is constructed and instances of the meta-path are generated, and then node features are acquired and converted. The heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node. On the one hand, the present invention can obtain the text information of legal case documents and regulations. On the other hand, through the heterogeneous graph and the designed meta-path, the structural information within the legal provisions, within the cases, and between the legal provisions and cases is integrated. The mined structural information can be integrated with the text information, thereby improving the accuracy of similar case recommendations.
[0084] In one embodiment, it also includes: obtaining the vector representation of the text information of each node according to the instance of the meta-path, and converting the vector representations of nodes of different types into the same latent vector space to obtain the converted node features; learning the structural information reflected by different meta-path instances under a given meta-path through the meta-path aggregation strategy based on the attention mechanism according to the converted node features, and obtaining the intra-meta-path aggregation node features; learning the structural information reflected by different meta-paths through the inter-meta-path aggregation strategy according to the intra-meta-path aggregation node features, and obtaining the inter-meta-path aggregation node features; projecting the inter-meta-path aggregation node features into the target space to obtain the final representation vector of the node.
[0085] In one embodiment, the method further includes: obtaining a vector representation of the text information of each node through a BERT model according to an instance of the meta-path:
[0086]
[0087] in, is the word sequence of node v of type A, It is the vector obtained after being processed by the BERT model. is a set of nodes of type A, d A The node representing A represents the dimension of the vector;
[0088] The vector representations of different types of nodes are transformed into the same latent vector space through linear transformation to obtain the transformed node features:
[0089]
[0090] in, is the word sequence of node v of type A. In this task, there are four types of nodes, corresponding to act, chapter, section, and fact. is the vector obtained after the text is processed by the BERT model, d A The node representing A represents the dimension of the vector, and because all types of text are processed by BERT, the dimension is equal to 768.
[0091] The input of the BERT model is a word sequence with CLS and SEP added before and after. In the BERT model, each word in the word sequence is assigned an initialized vector representation embedding, and then the vector representation of each word is obtained through a multi-layer Transformer decoder. It is worth noting that when obtaining the output, only the representation h of the first token is taken. CLS , which is the representation of CLS. There are two reasons for this: (1) After training the multi-layer Transformer decoder in the BERT model, the representation of each token in the last layer contains the semantic information of all words. (2) CLS does not contain special meaning at first. After the information is transmitted through the multi-layer self-attention mechanism, the weight given to each word by CLS is the same. In other words, the choice of h CLS The semantic representation as a sequence can fairly integrate the semantic information of all words.
[0092] Heterogeneous graphs contain multiple types of nodes, and the vector representations of each node may have different dimensions. Even if they share the same dimensions, these vectors may exist in different feature spaces. For example, the text representation of a case obtained by the BERT model and the text representation of a legal provision are not in the same feature space. Therefore, to process the representations of different node types within a unified framework, it is first necessary to transform the content features of these different node types into the same feature space.
[0093] In one embodiment, the method further includes: given a meta-path P, for a meta-path instance P(v,u)=(t0, t1, ..., t n ), the vector representation of the meta-path instance is obtained through the decoder based on relational rotation:
[0094]
[0095]
[0096]
[0097] Among them, t i Represents a node on a meta-path instance, v and u are the end and starting points of the meta-path, and t n =v, t1=u, R i Is the connection t i-1 and t i The relationship, r i It is R i Rotation vector, o i represents the vector obtained by the i-th rotation, is the representation vector of the transformed meta-path instance P(v,u);
[0098] For a target node, its representation is not only related to its own characteristics, but also to the meta-path it is in. The information of the meta-path should be transmitted to the target node through some method, and finally the representation of the node when given the meta-path P is obtained.
[0099] The information on the meta-path needs to be transferred to the target node. Obviously, different meta-path instances contribute differently to the task. Meta-path instances that provide more information should be given a larger share of the node representation. For example, in this task, if we want to predict the similarity between two cases, we want to highlight meta-path instances that connect similar cases and give them a larger share of the node representation. We use the attention mechanism to calculate the importance of different meta-path instances to the target node. Then, we have:
[0100]
[0101]
[0102]
[0103] in, Indicates the similarity between P(v,u) and node v, or Indicates the contribution of P(v,u) to node v, || represents the operator for concatenating two vectors, is the parameterized attention vector of the meta-path P, which is used to learn the attention weights of different meta-path instances. The calculated contribution is weighted and normalized. Specifically, for each neighbor based on the meta-path The corresponding meta-path instance calculates the contribution to the target node Then normalize it through the softmax function. Perform weighted summation and finally obtain the representation of node v through an activation function σ(·)
[0104] Of course, this attention mechanism can also be extended to multiple attention heads. Multiple attention heads have been shown to allow the model to simultaneously focus on information from different representation subspaces at different locations. Alternatively, a single attention head only focuses on information in one subspace. By introducing multiple attention heads, more information from complex heterogeneous graphs can be learned, avoiding the instability and high variance of the training process caused by the model only paying attention to one aspect, thereby improving the model's performance. Specifically, by independently applying the attention mechanism K times and then concatenating their results, we obtain:
[0105]
[0106] in, Represents the result of the k-th attention parameter operation.
[0107] In summary, assuming the target node type is A and the target node is v, then Given a heterogeneous graph, the vector representation of all nodes after projection and the set of all meta-paths whose start or end point is type A The heterogeneous graph representation method based on meta-path convergence generates M vector representations for different meta-paths for v, which are recorded as If we do not consider multiple attention heads, then For any vector representation Represents the meta-path P i All instances of v are aggregated through the attention mechanism, and the meta-path itself can reflect a type of structural information, so It can be regarded as the meta-path P i The reflected structural information is aggregated into the representation of node v.
[0108] In one embodiment, the method further includes: learning the structural information reflected by different meta-paths through the meta-path aggregation strategy according to the convergence node characteristics within the meta-path, and obtaining the convergence node characteristics between the meta-paths. It represents the set of all meta-paths whose starting point or end point type is A, and M represents the number of different meta-paths.
[0109] By using a meta-path aggregation strategy, we can obtain the structural information expressed by each meta-path. However, this structural information is also distributed across M vectors. If we want to obtain a vector that can express all the structural information to represent the target node, we can solve this problem by using an attention-based meta-path aggregation strategy.
[0110] An intuitive idea is to Each vector in is averaged element-wise, but this means that each meta-path contributes equally to the task. In order to distinguish the importance of each meta-path, the attention mechanism is used again to calculate the weights of different meta-paths for a certain type of node, and then perform the weighted summation.
[0111] For a given node type For each node Can generate To represent the structural information learned from different types of meta-paths, for type A nodes, there are Group First, calculate the meta path Aggregate the average value across all nodes:
[0112]
[0113] in, and are parameter matrices and vectors. Then, we use the attention mechanism to aggregate all types of meta-path information:
[0114]
[0115]
[0116]
[0117] in, is a learnable attention vector used to describe the meta-path P i The importance of type A nodes is normalized by the softmax function to obtain That is, P i The relative importance of type A nodes is finally obtained by a weighted summation of all types of meta-paths. A vector representation of all meta-paths with a starting or ending point type of A converging to the target node v.
[0118] In one embodiment, the method further includes: projecting the converged node features between the meta-paths into the target space to obtain a final representation vector of the node:
[0119]
[0120] in, is the final representation vector of the model for node v, d o is the vector dimension required by the task, is the parameter matrix and σ(·) is the activation function.
[0121] In one embodiment, the method further includes: obtaining a negative sample set by negative sample sampling; training a pre-built similar case recommendation graph neural network according to the final representation vector of the node and the negative sample set to obtain a trained similar case recommendation graph neural network; inputting the text representation and structural information of the new case into the trained similar case recommendation graph neural network to obtain a representation h of the new case. new ; According to the new case representation h new and representation of existing cases Calculate similarity probability and recommend similar cases based on similarity probability.
[0122] In the context of heterogeneous graph neural networks, the task of this invention is a typical link prediction task. Specifically, it is necessary to predict the connection between new and old cases by training the mutual connection between existing cases. In order to train the model, negative examples are obtained through a negative sample sampling method. Specifically, the positive example set Ω is first constructed using cases with similar relationships. + ={(u, v)| <fact u, fact v >}, then find Ω + The complement of all arbitrary cases combined with each other constitutes the negative sample set Ω - The model is trained using the following loss function:
[0123]
[0124] Among them, h v , h u , h v′ , h u′ is the representation of the corresponding node in the heterogeneous graph, σ(·) is the sigmoid function, represents the training loss.
[0125] During prediction, the text representation and structural information of the new case are input to obtain the representation h new , then for each existing case Both can calculate similar probabilities:
[0126] pu=σhu T ·hnew
[0127] Then, we can get the set of all probabilities After sorting by size, the old cases corresponding to each probability can be recommended.
[0128] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0129] In one embodiment, Figure 3 As shown, a Chinese similar case recommendation device based on graph neural network is provided, including: an information acquisition module 302, a heterogeneous graph construction module 304, a meta-path construction module 306, a heterogeneous graph learning module 308 and a model training and use module 310, wherein:
[0130] The information acquisition module 302 is used to acquire legal hierarchy system information and case information; the legal hierarchy system information includes the overall legal text information, the text information of the edition, the text information of the chapter, the text information of the section and the text information of the legal article;
[0131] Heterogeneous graph construction module 304 is configured to construct a heterogeneous graph using legal hierarchy information and case information as nodes and relationship information within legal articles, within cases, and between legal articles and cases as edges. The relationship information within legal articles, within cases, and between legal articles and cases includes information on subordinate relationships between legal structures, similarity relationships between legal articles, similarity relationships between cases, and reference relationships between cases and legal articles.
[0132] A meta-path construction module 306 is configured to construct a meta-path based on the heterogeneous graph and generate meta-path instances based on the meta-path; the meta-paths include case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case.
[0133] Heterogeneous graph learning module 308, used to obtain and transform node features based on meta-path instances, perform heterogeneous graph representation learning through intra-meta-path aggregation strategy and inter-meta-path aggregation strategy, and obtain the final representation vector of the node;
[0134] The model training module 310 is used to train the pre-built similar case recommendation graph neural network according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and recommend similar cases through the trained similar case recommendation graph neural network.
[0135] The heterogeneous graph learning module 308 is further used to obtain the vector representation of the text information of each node based on the instance of the meta-path, and transform the vector representations of different types of nodes into the same latent vector space to obtain the transformed node features;
[0136] According to the transformation node features, the meta-path aggregation strategy based on the attention mechanism is used to learn the structural information reflected by different meta-path instances under a given meta-path, and obtain the meta-path aggregation node features;
[0137] According to the characteristics of the converged nodes in the meta-path, the structural information reflected by different meta-paths is learned through the inter-meta-path convergence strategy, and the characteristics of the converged nodes between meta-paths are obtained;
[0138] The node features aggregated between meta-paths are projected into the target space to obtain the final representation vector of the node.
[0139] The heterogeneous graph learning module 308 is further configured to obtain a vector representation of the text information of each node through the BERT model based on the instance of the meta-path:
[0140]
[0141] in, is the word sequence of node v of type A, It is the vector obtained after being processed by the BERT model. is a set of nodes of type A, d A The node representing A represents the dimension of the vector;
[0142] The vector representations of different types of nodes are transformed into the same latent vector space through linear transformation to obtain the transformed node features:
[0143]
[0144] in, is the transformed matrix, is the parameter matrix, and d′ represents the dimension of the transformed vector.
[0145] The heterogeneous graph learning module 308 is further used to, given a meta-path P, for a meta-path instance P(v,u)=(t0, t1, ..., t n ), the vector representation of the meta-path instance is obtained through the decoder based on relational rotation:
[0146]
[0147]
[0148]
[0149] Among them, t i Represents a node on a meta-path instance, v and u are the end and starting points of the meta-path, and t n =v, t1=u, R i Is the connection t i-1 and t i The relationship, r i It is R i Rotation vector, o i represents the vector obtained by the i-th rotation, is the representation vector of the transformed meta-path instance P(v,u);
[0150] The structural information reflected by different meta-path instances is learned through the meta-path aggregation strategy based on the attention mechanism, and the converged node features within the meta-path are obtained.
[0151] The heterogeneous graph learning module 308 is also used to learn the structural information reflected by different meta-paths through the meta-path aggregation strategy according to the convergence node characteristics within the meta-path, and obtain the convergence node characteristics between the meta-paths. It represents the set of all meta-paths whose starting point or end point type is A, and M represents the number of different meta-paths.
[0152] The heterogeneous graph learning module 308 is also used to project the converged node features between the meta-paths into the target space to obtain the final representation vector of the node:
[0153]
[0154] in, is the final representation vector of the model for node v, d o is the vector dimension required by the task, is the parameter matrix and σ(·) is the activation function.
[0155] The model training module 310 is further configured to obtain a negative sample set by negative sample sampling; train the pre-built similar case recommendation graph neural network according to the final representation vector of the node and the negative sample set to obtain a trained similar case recommendation graph neural network; input the text representation and structural information of the new case into the trained similar case recommendation graph neural network to obtain the representation h of the new case. new ; According to the new case representation h new and representation of existing cases Calculate similarity probability and recommend similar cases based on similarity probability.
[0156] For the specific limitations of the Chinese similar case recommendation device based on graph neural network, please refer to the limitations of the Chinese similar case recommendation method based on graph neural network above, which will not be repeated here. Each module in the above-mentioned Chinese similar case recommendation device based on graph neural network can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0157] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, memory, network interface, display screen and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for recommending similar Chinese cases based on a graph neural network is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.
[0158] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0159] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiment when executing the computer program.
[0160] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiment are implemented.
[0161] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0162] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0163] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A Chinese similar case recommendation method based on graph neural network, characterized by: The method comprises: Obtaining legal hierarchy system information and case information; the legal hierarchy system information includes legal overall text information, edition text information, chapter text information, section text information, and legal article text information; A heterogeneous graph is constructed using the legal hierarchy information and the case information as nodes and the relationship information within legal articles, within cases, and between legal articles and cases as edges; the relationship information within legal articles, within cases, and between legal articles and cases includes information on affiliation between regulatory structures, information on similarity between legal articles, information on similarity between cases, and information on reference relationships between cases and legal articles; Constructing a meta-path according to the heterogeneous graph, and generating a meta-path instance according to the meta-path; the meta-path includes case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case; Node feature acquisition and node feature conversion are performed according to the instance of the meta-path, and heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node; Training a pre-built similar case recommendation graph neural network according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and recommending similar cases using the trained similar case recommendation graph neural network; The node features are acquired and converted according to the instance of the meta-path, and heterogeneous graph representation learning is performed through the intra-meta-path aggregation strategy and the inter-meta-path aggregation strategy to obtain the final representation vector of the node, including: Obtaining a vector representation of the text information of each node according to the instance of the meta-path, and transforming the vector representations of different types of nodes into the same latent vector space to obtain transformed node features; According to the conversion node features, a meta-path aggregation strategy based on an attention mechanism is used to learn the structural information reflected by different meta-path instances under a given meta-path, thereby obtaining a meta-path aggregation node feature; According to the convergence node features within the meta-path, a meta-path convergence strategy based on an attention mechanism is used to learn the structural information reflected by different meta-paths to obtain the convergence node features between the meta-paths; The features of the aggregated nodes between the meta-paths are projected into the target space to obtain the final representation vector of the node.
2. The method according to claim 1, characterized in that The vector representation of the text information of each node is obtained according to the instance of the meta-path, and the vector representations of different types of nodes are converted into the same latent vector space to obtain the converted node features, including: Based on the meta-path instance, the BERT model is used to obtain the vector representation of the text information of each node: in, Is of type Node The word sequence, It is the vector obtained after being processed by the BERT model. , Is of type The node set of express The nodes represent the dimension of the vector; The vector representations of different types of nodes are transformed into the same latent vector space through linear transformation to obtain the transformed node features: in, is the transformed matrix, is the parameter matrix, Indicates the dimension of the transformed vector.
3. The method according to claim 2, characterized in that According to the conversion node features, the structural information reflected by different meta-path instances under a given meta-path is learned through a meta-path aggregation strategy based on an attention mechanism, and the meta-path aggregation node features are obtained, including: Given a meta path , for meta-path instances , the vector representation of the meta-path instance is obtained through the decoder based on relational rotation: in, Represents a node on a meta-path instance, are the end and starting points of the meta-path, , is connected and relationship, yes Rotation vector, Indicates the The vector obtained by rotation is is the transformed meta path instance The representation vector of The structural information reflected by different meta-path instances is learned through the meta-path aggregation strategy based on the attention mechanism, and the meta-path aggregation node features are obtained. .
4. The method according to claim 3, characterized in that According to the convergence node features within the meta-path, the structural information reflected by different meta-paths is learned through the meta-path convergence strategy based on the attention mechanism, and the convergence node features between meta-paths are obtained, including: According to the convergence node features in the meta-path, the structural information reflected by different meta-paths is learned through the meta-path convergence strategy based on the attention mechanism, and the convergence node features between meta-paths are obtained. , Indicates that all starting points or end points are of type The set of meta-paths, Indicates the number of different meta-paths.
5. The method according to claim 4, characterized in that Project the converged node features between the meta-paths into the target space to obtain the final representation vector of the node, including: Project the converged node features between the meta-paths into the target space to obtain the final representation vector of the node: in, Is the model node The final representation vector of is the vector dimension required by the task, is the parameter matrix, is the activation function.
6. The method according to claim 1, wherein A pre-built similar case recommendation graph neural network is trained according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and similar case recommendations are performed using the trained similar case recommendation graph neural network, including: Obtain a negative sample set by negative sample sampling; Training a pre-built similar case recommendation graph neural network according to the final representation vector of the node and the negative sample set to obtain a trained similar case recommendation graph neural network; Input the text representation and structural information of the new case into the trained similar case recommendation graph neural network to obtain the representation of the new case ; According to the new case and representation of existing cases , calculate similarity probability; Similar cases are recommended based on the similarity probability.
7. A Chinese similar case recommendation device based on graph neural network, characterized in that: The device comprises: An information acquisition module is used to acquire legal hierarchy system information and case information; the legal hierarchy system information includes legal overall text information, compilation text information, chapter text information, section text information and legal article text information; a heterogeneous graph construction module for constructing a heterogeneous graph using the legal hierarchy information and the case information as nodes and the relationship information within legal articles, within cases, and between legal articles and cases as edges; the relationship information within legal articles, within cases, and between legal articles and cases includes information on affiliation between regulatory structures, information on similarity between legal articles, information on similarity between cases, and information on reference relationships between cases and legal articles; a meta-path construction module, configured to construct a meta-path according to the heterogeneous graph and generate meta-path instances according to the meta-path; the meta-paths include case-article-case, case-case-case, case-article-article-case, and case-article-section-article-case; A heterogeneous graph learning module is used to obtain and transform node features based on the instances of the meta-path, perform heterogeneous graph representation learning through intra-meta-path aggregation strategy and inter-meta-path aggregation strategy, and obtain the final representation vector of the node; A model training module is used to train a pre-built similar case recommendation graph neural network according to the final representation vector of the node to obtain a trained similar case recommendation graph neural network, and recommend similar cases using the trained similar case recommendation graph neural network; The heterogeneous graph learning module is further used to: Obtaining a vector representation of the text information of each node according to the instance of the meta-path, and transforming the vector representations of different types of nodes into the same latent vector space to obtain transformed node features; According to the conversion node features, a meta-path aggregation strategy based on an attention mechanism is used to learn the structural information reflected by different meta-path instances under a given meta-path, thereby obtaining a meta-path aggregation node feature; According to the convergence node features within the meta-path, a meta-path convergence strategy based on an attention mechanism is used to learn the structural information reflected by different meta-paths to obtain the convergence node features between the meta-paths; The features of the aggregated nodes between the meta-paths are projected into the target space to obtain the final representation vector of the node.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Heterogeneous information network recommendation method for automatically extracting meta path
CN116304310A
Prediction method and system based on heterogeneous graph neural network model
WO2021179838A1