Method for generating vector representation of legal cases, electronic device, and program product

CN122964258APending Publication Date: 2026-10-23XIAMEN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611169671.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-04
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0004]然而,现有方法仍存在以下技术缺陷:第一,现有方法通常针对特定法系设计,大陆法系偏重成文法的层次结构,普通法系依赖判例引用网络,导致单一法系方法跨场景迁移时性能显著下降

Benefits of technology

[0018]本公开技术方案的有益效果在于,通过对原始法律案例进行信息提取和语义编码得到其对应的连续语义嵌入向量,实现了对长篇幅法律文档的有效压缩和核心语义保留。接着,通过对连续语义嵌入向量进行逐层编码得到多层离散代码并构建法律层次结构,利用浅层离散代码表征粗粒度法律领域信息、深层离散代码表征细粒度事实细节信息,实现了法律文档从宏观领域到微观事实的层次化语义建模。在此基础上,根据每一层法律层次结构分别构建包含案例节点、指控节点和代码节点的关系图,再通过分别对每一层关系图进行信息聚合,更新各层关系图中各节点的特征表示。再将各层关系图更新后的案例节点的特征表示进行融合,并结合原始连续语义嵌入向量生成原始法律案例的目标向量表示,使得该目标向量表示同时蕴含了从粗粒度到细粒度的多层次法律语义信息以及案例间的关联关系信息,从而在统一框架下兼顾了大陆法系偏重的法律层次结构与普通法系偏重的案例引用网络,有效提升了法律案例检索在跨法系场景下的准确率和泛化能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122964258A_ABST
    Figure CN122964258A_ABST
Patent Text Reader

Abstract

The disclosure provides a legal case vector representation generation method, an electronic device and a program product, and relates to the technical field of computers. The legal case vector representation generation method comprises: performing information extraction on each original legal case to obtain a corresponding case summary, and performing semantic coding on the case summary to obtain a continuous semantic embedding vector corresponding to each original legal case; performing layer-by-layer coding on the continuous semantic embedding vector of each original legal case to obtain a corresponding multi-layer discrete code and construct a legal hierarchy; constructing a corresponding relationship graph according to each layer of the legal hierarchy; performing information aggregation on each layer relationship graph respectively, updating the feature representation of each node in each layer relationship graph; and fusing the feature representation of the case node after updating each layer relationship graph, and generating a target vector representation of the original legal case based on the fused feature representation of the case node and the continuous semantic embedding vector of the original legal case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more particularly to a method for generating vector representations of legal cases, an electronic device, and a program product. Background Technology

[0002] Legal case retrieval aims to identify precedents from a case database that are highly similar to current cases, and plays an important supporting role in legal reasoning and sentencing assistance in judicial trials.

[0003] In related technologies, legal case retrieval methods are mainly divided into two categories. One category is based on text semantic matching, which encodes legal documents and calculates similarity through pre-trained language models. The other category is based on citation networks or knowledge graphs, which perform inference retrieval by constructing citation relationships between cases.

[0004] However, existing methods still suffer from the following technical shortcomings: First, existing methods are typically designed for specific legal systems. Civil law systems emphasize the hierarchical structure of codified law, while common law systems rely on case law networks, leading to a significant performance degradation when migrating methods from a single legal system across different scenarios. Second, legal documents are lengthy and structurally complex, and existing retrieval models, limited by context windows, struggle to effectively handle the fine-grained semantic information within lengthy legal documents. Third, existing methods neglect the potential hierarchical organizational structure of legal documents, ranging from macro-level concepts to micro-level facts, failing to fully utilize this structural information to improve retrieval results.

[0005] Therefore, how to effectively process lengthy legal documents and uncover their hierarchical organizational structure in cross-legal contexts to achieve accurate and efficient legal case retrieval has become an urgent technical problem to be solved. Summary of the Invention

[0006] This disclosure provides a method for generating vector representations of legal cases, an electronic device, and a program product.

[0007] According to one aspect of this disclosure, a method for generating vector representations of legal cases is provided, comprising: Information is extracted from each original legal case to obtain a corresponding case summary, and the case summary is semantically encoded to obtain a continuous semantic embedding vector corresponding to each original legal case. The continuous semantic embedding vectors of each of the original legal cases are encoded layer by layer to obtain corresponding multi-layer discrete codes and construct a legal hierarchy structure. The legal hierarchy structure includes shallow discrete codes and deep discrete codes. The shallow discrete codes are used to represent the coarse-grained legal domain information of the original legal cases, and the deep discrete codes are used to represent the fine-grained factual details of the original legal cases. For each layer of the legal hierarchy, a corresponding relationship diagram is constructed. The nodes of the relationship diagram include case nodes, charge nodes, and code nodes corresponding to the multi-layer discrete code. Information is aggregated for each layer of the relationship graph, and the feature representations of each node in each layer of the relationship graph are updated. The feature representations of the updated case nodes in each layer of the relationship graph are fused together, and the target vector representation of the original legal case is generated based on the fused feature representations of the case nodes and the continuous semantic embedding vector of the original legal case.

[0008] In some embodiments of this disclosure, information is extracted from each original legal case to obtain a corresponding case summary, and the case summary is semantically encoded to obtain a continuous semantic embedding vector corresponding to each original legal case, including: For each original legal case, the original legal case is broken down into multiple sentences, and an importance score is calculated for each sentence. The importance score is a weighted sum of the sentence's term frequency-inverse document frequency score and legal keyword matching score. Select the top 100 sentences with the highest importance scores, and then combine the selected sentences with legal keywords that match the original legal case to form a prompt message; Based on the prompt information, a corresponding case summary is generated, and the case summary is encoded to obtain a high-dimensional semantic embedding vector; Principal component analysis and whitening are performed on the high-dimensional semantic vector to reduce its dimensionality and obtain the continuous semantic embedding vector of the original legal case.

[0009] In some embodiments of this disclosure, the continuous semantic embedding vectors of each of the original legal cases are encoded layer by layer to obtain corresponding multi-layer discrete codes, including: Multi-layer residual quantization is performed on the continuous semantic embedding vectors of each of the original legal cases, encoding the continuous semantic embedding vectors layer by layer into multi-layer discrete codes. In the multi-layer residual quantization process, for the first layer, the continuous semantic embedding vectors of the original legal cases are mapped by a multi-layer perceptron as the residual. Based on the residual of the current layer, the codebook entry with the closest distance to the residual of the current layer is selected from the codebook corresponding to the current layer. The index of the codebook entry is used as the discrete code of the current layer. The selected codebook entry is transformed according to the learnable scaling factor and learnable bias term corresponding to the current layer to obtain the quantization vector of the current layer. The residual of the current layer is subtracted from the quantization vector to obtain the quantization residual of the current layer. The quantization residual of the current layer is input to the residual amplification unit for processing to obtain the input residual of the next layer, until the discrete codes of all layers are obtained.

[0010] In some embodiments of this disclosure, the residual amplification unit includes a layer normalization layer and a multilayer perceptron with skip connections.

[0011] In some embodiments of this disclosure, a corresponding relationship diagram is constructed for each layer of the legal hierarchy, including: For each layer of the legal hierarchy, an undirected graph containing case nodes, charge nodes, and code nodes is constructed; Construct connection edges between the case node and the charge node, between the case node and the code node, between the charge nodes, and between the code nodes to obtain the relationship graph corresponding to this layer.

[0012] In some embodiments of this disclosure, information aggregation is performed on each layer of the relationship graph, and the feature representation of each node in each layer of the relationship graph is updated, including: For each layer of the relational graph, the residual after processing by the residual amplification unit of each layer is used as the initial feature of the case node and the command node, and the selected codebook entry of that layer is used as the initial feature of the code node. A graph attention network is used to perform multiple rounds of message passing on case nodes, charge nodes, and code nodes in each layer of the relation graph to determine the updated feature representation of each case node in the corresponding relation graph. The updated feature representations of the case nodes and the feature representations of the charge nodes in the previous layer relationship graph are added to the initial features of the corresponding nodes in the current layer relationship graph and then used for message passing in the current layer relationship graph.

[0013] In some embodiments of this disclosure, the feature representations of the updated case nodes in each layer of the relationship graph are fused, and a target vector representation of the original legal case is generated based on the fused feature representations of the case nodes and the continuous semantic embedding vector of the original legal case, including: The feature representations of the case nodes after updating the relationship graphs of each layer are concatenated in order from shallow to deep to obtain the hierarchical feature concatenation vector. The hierarchical feature concatenation vector is concatenated with the continuous semantic embedding vector of the original legal case to obtain the target vector representation of the original legal case.

[0014] In some embodiments of this disclosure, the method for generating vector representations of legal cases further includes: In response to the received query case, construct the target vector representation corresponding to the query case; Based on the similarity between the target vector representation of the case to be queried and the target vector representation of each legal case in the case library, the legal case retrieval results are determined and output.

[0015] According to another aspect of this disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, such that the processor performs a vector representation generation method for legal cases according to any embodiment of this disclosure.

[0016] According to another aspect of this disclosure, a readable storage medium is provided, wherein executable instructions are stored therein, which, when executed by a processor, are used to implement a vector representation generation method for legal cases according to any embodiment of this disclosure.

[0017] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a vector representation generation method for legal cases according to any embodiment of this disclosure.

[0018] The beneficial effect of this disclosed technical solution lies in obtaining corresponding continuous semantic embedding vectors by extracting information and semantically encoding the original legal cases, thereby achieving effective compression and preservation of core semantics in lengthy legal documents. Next, by layer-by-layer encoding the continuous semantic embedding vectors, multi-layer discrete codes are obtained, and a legal hierarchy structure is constructed. Shallow discrete codes represent coarse-grained legal domain information, while deep discrete codes represent fine-grained factual details, achieving hierarchical semantic modeling of legal documents from macro-domain to micro-factual level. Based on this, a relationship graph containing case nodes, charge nodes, and code nodes is constructed according to each layer of the legal hierarchy structure. Then, by aggregating information from each layer of the relationship graph, the feature representations of each node in each layer of the relationship graph are updated. The feature representations of the updated case nodes in each layer of the relationship graph are then fused together and combined with the original continuous semantic embedding vector to generate the target vector representation of the original legal case. This target vector representation contains multi-level legal semantic information from coarse to fine granular and information on the relationships between cases. Thus, under a unified framework, it takes into account both the legal hierarchy structure emphasized by the civil law system and the case citation network emphasized by the common law system, effectively improving the accuracy and generalization ability of legal case retrieval in cross-legal system scenarios. Attached Figure Description

[0019] The accompanying drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0020] Figure 1 This is a flowchart illustrating a method for generating vector representations of legal cases according to one embodiment of this disclosure.

[0021] Figure 2This is a flowchart illustrating step S110 of a method for generating a vector representation of a legal case according to one embodiment of the present disclosure.

[0022] Figure 3 This is a flowchart illustrating step S130 of a method for generating a vector representation of a legal case according to one embodiment of the present disclosure. Figure 4 This is a flowchart illustrating step S140 of a method for generating a vector representation of a legal case according to one embodiment of the present disclosure.

[0023] Figure 5 This is a flowchart illustrating step S150 of a method for generating a vector representation of a legal case according to one embodiment of the present disclosure.

[0024] Figure 6 This is a schematic diagram of the process of case retrieval in a vector representation generation method for legal cases according to one embodiment of the present disclosure.

[0025] Figure 7 This is a schematic block diagram of the structure of a vector representation generation apparatus according to one embodiment of the present disclosure.

[0026] Figure 8 This is a schematic block diagram of an electronic device according to one embodiment of the present disclosure. Detailed Implementation

[0027] The present disclosure will now be described in further detail with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are for illustrative purposes only and are not intended to limit the scope of the disclosure. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present disclosure are shown in the accompanying drawings.

[0028] It should be noted that, where there is no conflict, the embodiments and features described in this disclosure can be combined with each other. The technical solutions of this disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0029] Existing technologies are difficult to transfer effectively across legal systems and cannot fully explore the potential legal hierarchy in long legal documents, ranging from macro-level legal concepts to micro-level factual details, resulting in low search accuracy and generalization ability.

[0030] To address this, this disclosure proposes the following technical solution: First, by extracting information and semantically encoding the original legal cases, corresponding continuous semantic embedding vectors are obtained, achieving effective compression and preservation of core semantics in lengthy legal documents. Next, by layer-by-layer encoding the continuous semantic embedding vectors, multi-layer discrete codes are obtained, constructing a legal hierarchy. Shallow discrete codes represent coarse-grained legal domain information, while deep discrete codes represent fine-grained factual details, achieving hierarchical semantic modeling of legal documents from macro-domain to micro-factual level. Based on this, a relationship graph containing case nodes, charge nodes, and code nodes is constructed according to each layer of the legal hierarchy. Then, by aggregating information from each layer of the relationship graph, the feature representations of each node in each layer are updated. The feature representations of the updated case nodes in each layer of the relationship graph are then fused together and combined with the original continuous semantic embedding vector to generate the target vector representation of the original legal case. This target vector representation contains multi-level legal semantic information from coarse to fine granular and information on the relationships between cases. Thus, under a unified framework, it takes into account both the legal hierarchy structure emphasized by the civil law system and the case citation network emphasized by the common law system, effectively improving the accuracy and generalization ability of legal case retrieval in cross-legal system scenarios.

[0031] Figure 1 This is a flowchart illustrating a method for generating vector representations of legal cases according to one embodiment of this disclosure. This method for generating vector representations of legal cases can be applied to one or more electronic devices such as smartphones, tablets, laptops, or desktop computers, and can also be applied to servers.

[0032] like Figure 1 As shown, the vector representation generation method for this legal case preferably includes steps S110 to S150, which are described in detail below.

[0033] In step S110, information is extracted from each original legal case to obtain a corresponding case summary, and the case summary is semantically encoded to obtain a continuous semantic embedding vector corresponding to each original legal case.

[0034] The original legal case refers to legal document data containing the original text of the case and a set of charge tags, where the charge tags are the legal offenses or categories of illegal acts involved in the case. In one example, let This represents a collection of original legal case documents, with each original legal case... Includes its original text and a set of accusation labels ,in This is the set of all charge categories.

[0035] Case summaries are concise, fluent, coherent text fragments that retain the core legal semantics, generated by compressing key information and extracting semantics from the original legal case.

[0036] In some embodiments of this disclosure, step S110 preferably includes steps S111 to S114, please refer to... Figure 2 .

[0037] In step S111, for each original legal case, the original legal case is split into multiple sentences, and the importance score of each sentence is calculated. The importance score is a weighted sum of the sentence's word frequency-inverse document frequency score and legal keyword matching score.

[0038] In step S112, the first preset number of sentences with the highest importance scores are selected, and the selected sentences are combined with legal keywords that match the original legal case to form a prompt message.

[0039] In step S113, a corresponding case summary is generated based on the prompt information, and the case summary is encoded to obtain a high-dimensional semantic embedding vector.

[0040] In step S114, principal component analysis and whitening are performed on the high-dimensional semantic vector to reduce the dimensionality and obtain the continuous semantic embedding vector of the original legal case.

[0041] In this implementation, the original text of each legal case is first... Split into multiple sentences ,in For the original text The number of sentences obtained from the split. In one example, punctuation marks such as periods, question marks, and exclamation marks, which indicate sentence boundaries, can be used as delimiters to segment the original legal case into a sequence of sentences.

[0042] Next, an importance score is calculated for each sentence, which is a weighted average of two parts. The first part is the sentence's term frequency-inverse document frequency (TF-IDF) score, which measures the sentence's importance within the original text of the original legal case. In one example, the TF-IDF value of each word in the sentence is calculated, and the average of all the TF-IDF values ​​is taken to obtain the sentence's TF-IDF score. The second part is the sentence's legal keyword matching score. In one example, the number of words in the sentence that belong to a preset set of legal keywords is counted, and this number is used as the legal keyword matching score.

[0043] The importance score of a sentence can be obtained by weighting and summing the scores of the two parts according to the pre-set weights.

[0044] In one example, the sentence The importance score can be calculated using the following formula: in, The average TF-IDF score, For sentences The number of legal keywords that match the preset set of legal keywords, hyperparameter Used to balance the contributions of these two parts.

[0045] Next, all sentences are sorted from highest to lowest importance score. A pre-defined number of sentences with the highest importance score (this number can be adjusted based on the specific application scenario or document length) are selected. All legal keywords matching the original legal case for these selected sentences are then concatenated to form a prompt message. This prompt message integrates the key facts and legal keywords described in the most important sentence from the original legal case.

[0046] Then, the prompt is input into a pre-trained large language model, enabling the model to reorganize and integrate overlapping information based on the input, while preserving the core legal semantics, thereby generating a concise, fluent, and coherent case summary. .

[0047] Subsequently, a pre-trained embedding model was used to summarize the case. Encode to obtain a high-dimensional semantic embedding vector. To reduce the size of high-dimensional semantic embedding vectors The risk of overfitting introduced by this high-dimensional semantic embedding vector Further principal component analysis and whitening were performed to reduce its dimensionality to [value missing]. : Thus, by performing principal component analysis on the high-dimensional semantic embedding vector, at least 95% of the principal components with variance are retained, while redundant noise dimensions are removed. Then, the retained principal components are whitened, i.e., linear transformations are used to remove linear correlations between dimensions and normalize the variances of each dimension, ultimately yielding a dimensionality-reduced continuous semantic embedding vector. The dimension of this continuous semantic embedding vector is significantly lower than that of the original high-dimensional semantic embedding vector, while retaining the main discriminative components in the original semantic information.

[0048] In one implementation, each charge label The same embedding model and PCA-whitening process were also used for coding to obtain the charge embedding. ,in V This represents a set of accusation tags. This represents a d-dimensional vector.

[0049] Please continue to refer to this. Figure 1 In step S120, the continuous semantic embedding vectors of each of the original legal cases are encoded layer by layer to obtain corresponding multi-layer discrete codes and construct a legal hierarchy structure. The legal hierarchy structure includes shallow discrete codes and deep discrete codes. The shallow discrete codes are used to represent the coarse-grained legal domain information of the original legal cases, and the deep discrete codes are used to represent the fine-grained factual details of the original legal cases.

[0050] Among them, the multi-layer discrete code is a sequence of discrete encoded values ​​obtained at each layer after a single continuous semantic embedding vector is processed by multi-layer residual quantization. The discrete code of each layer is used to index the corresponding entry in the codebook of that layer.

[0051] The legal hierarchy is a semantic organization architecture constructed from coarse-grained to fine-grained levels through multiple layers of discrete code, including shallow discrete code and deep discrete code. Shallow discrete code represents coarse-grained legal domain information, while deep discrete code represents fine-grained factual details.

[0052] In some embodiments of this disclosure, the continuous semantic embedding vectors of each original legal case are encoded layer by layer to obtain corresponding multi-layer discrete codes. This includes: performing multi-layer residual quantization processing on the continuous semantic embedding vectors of each original legal case, and encoding the continuous semantic embedding vectors layer by layer into multi-layer discrete codes. In the multi-layer residual quantization processing, for the first layer, the continuous semantic embedding vectors of the original legal cases are mapped by a multi-layer perceptron as residuals. Based on the residuals of the current layer, a codebook entry with the closest distance to the residuals of the current layer is selected from the codebook corresponding to the current layer. The index of the codebook entry is used as the discrete code of the current layer. The selected codebook entry is transformed according to the learnable scaling factor and learnable bias term corresponding to the current layer to obtain the quantization vector of the current layer. The residuals of the current layer are subtracted from the quantization vector to obtain the quantization residuals of the current layer. The quantization residuals of the current layer are input to a residual amplification unit for processing to obtain the input residuals of the next layer, until the discrete codes of all layers are obtained.

[0053] In this implementation, an encoder-only residual quantization module is used. The continuous semantic embedding vector is mapped by a multilayer perceptron and used as the initial residual of the first layer. Then, in each quantization layer, the codebook entry closest to the current layer residual is selected from the corresponding codebook and its index is used as the discrete code. The entry is transformed using a learnable scaling factor and a learnable bias term to obtain a quantization vector. The difference between the current layer residual and the quantization vector is calculated to obtain the quantization residual. The quantization residual is then input into the residual amplification unit for reshaping and amplification and used as the input residual of the next layer. This process is iterated until the discrete codes of all layers are obtained, thereby constructing a potential legal hierarchy structure.

[0054] Specifically, continuous semantic embedding vectors are converted into discrete ID sequences. ,in, To quantize the number of layers. Each Index No. Layer Codebook One of the entries, This refers to the codebook size.

[0055] In the first layer, the initial residual Calculate using the following formula: in This represents the mapping function of a multilayer perceptron.

[0056] For the l Layer, based on the residual of the current layer Select the closest codebook entry from the codebook corresponding to that layer to obtain the discrete code for that layer: The quantization vector is: Next, to enhance the expressive power of the quantization representation and align the codebook space with the statistical distribution of the residuals of each quantization layer, the selected codebook entry is multiplied element-wise by the learnable scaling factor corresponding to the current layer, and then element-wise added to the learnable bias term corresponding to the current layer to obtain the quantization vector of the current layer. In one example, the quantization vector is obtained by transforming the codebook entry according to the following formula. : in, and It is the first The learnable parameters of the layer represent the scaling factor and the bias term, respectively.

[0057] The quantization residual of the current layer is The residual is then input into the residual amplification unit for processing to obtain the input residual for the next layer. for: The RAU (Residual Amplification Unit) is a lightweight residual modulation module used to reshape and amplify residual signals. This facilitates the separation of difficult negative samples at deeper levels and promotes uniform utilization of the codebook through diverse residual directions and amplitudes.

[0058] Thus, by employing multi-layer residual quantization processing to explicitly map continuous semantic embeddings into a hierarchical codebook structure, hierarchical semantic modeling from coarse-grained to fine-grained is achieved, effectively capturing multi-layered semantic information in legal documents, ranging from macro-level legal concepts to micro-level factual details. Simultaneously, by introducing learnable scaling factors and learnable bias terms to transform codebook entries, the codebook space is precisely aligned with the statistical distribution of residuals at each quantization layer, enhancing the expressive power of the quantization representation. Furthermore, the reshaping and amplification of quantization residuals through residual amplification units not only enhances the semantic richness of cross-quantization layer residual signals but also promotes the uniform utilization of deeper codebook entries.

[0059] In some embodiments of this disclosure, the residual amplification unit includes a layer normalization layer. and multilayer perceptron with skip connections .

[0060] In this implementation, RAU is defined as: The Multilayer Perceptron (MLP) is a two-layer network structure. The first layer has an output dimension smaller than the input dimension, used for dimensionality reduction and compression of the input. The second layer has an output dimension equal to the input dimension, used to restore the reduced features to their original dimensions. The first and second layers of the MLP use a non-linear transformation with no bias term between them, namely: Based on the aforementioned residual amplification unit, it first inputs the quantized residual into a multilayer perceptron. In the multilayer perceptron, the dimensionality of the quantized residual is first reduced through a first fully connected layer, then nonlinearly transformed using a Swish activation function, and finally restored to its original dimension through a second fully connected layer, yielding the output of the multilayer perceptron. The output of this multilayer perceptron is the result of a nonlinear transformation of the input quantized residual.

[0061] Next, the input quantization residual is added to the output of the multilayer perceptron to achieve a skip connection. This skip connection allows the quantization residual to be directly passed to subsequent processing and superimposed on the features after nonlinear transformation, thereby enhancing the feature representation capability while maintaining the stable flow of the gradient.

[0062] Then, the result after the skip connection is input into the layer normalization layer for normalization. This layer normalizes the input by calculating the mean and variance of its input along the feature dimension, and uses the mean and variance to standardize the input so that its output has a stable distribution along the feature dimension. The output of the layer normalization layer is then used as the input residual for the next layer.

[0063] In this way, the residual amplification unit reshapes and amplifies the quantized residual signal through lightweight nonlinear transformation, which enhances the semantic richness of the residual signal across the quantization layer, helps to separate difficult negative samples at a deeper level, and promotes the uniform utilization of the codebook through diversified residual directions and amplitudes, effectively avoiding the codebook collapse problem.

[0064] Please continue to refer to this. Figure 1 In step S130, a corresponding relationship diagram is constructed according to each layer of the legal hierarchy. The nodes of the relationship diagram include case nodes, charge nodes, and code nodes corresponding to the multi-layer discrete code.

[0065] In this implementation, an undirected relational graph is constructed for each quantization layer of the legal hierarchy. Three types of nodes are defined in the graph: case nodes, charge nodes, and code nodes. The node features are initialized using the residuals and codebook vectors from each quantization layer. Simultaneously, connecting edges are constructed between nodes, thus forming a complete graph topology that includes explicit legal attributes and latent semantic concepts.

[0066] In some embodiments of this disclosure, step S130 preferably includes steps S131 to S132, please refer to... Figure 3 .

[0067] In step S131, for each layer of the legal hierarchy, an undirected graph containing case nodes, charge nodes, and code nodes is constructed.

[0068] In step S132, connection edges are constructed between the case node and the charge node, between the case node and the code node, between the charge nodes, and between the code nodes to obtain the relationship graph corresponding to this layer.

[0069] In this implementation, for each quantification layer in the legal hierarchy... Construct an undirected graph , where the node set It includes three types of nodes: case nodes , accusation node and code ID node (i.e., code nodes).

[0070] Specifically, each original legal case is added to the node set as a case node, meaning each original legal case corresponds to a unique case node in each level of the relationship graph. Each accusation label category is added to the node set as an accusation node, meaning each possible accusation label corresponds to a unique accusation node in each level of the relationship graph. All discrete codes in the current level codebook are added to the node set as code nodes, meaning each indexable codebook entry in the current level codebook corresponds to a code node in the relationship graph, and the codebook size is the total number of code nodes.

[0071] For each original legal case, obtain the accusation label carried by that original legal case itself. In the relationship graph, establish a first edge (i.e., case-accusation edge) between the case node corresponding to the original legal case and the accusation node corresponding to the accusation label. If an original legal case carries multiple accusation labels, then establish a first edge between the case node and the accusation node corresponding to each accusation label respectively. The first edge is an undirected edge, used to introduce the legal characterization information of the case into the graph structure.

[0072] For each original legal case, obtain its discrete code at the current layer. In the relationship graph, establish a second edge (i.e., case-code edge) between the case node corresponding to the original legal case and the code node corresponding to the discrete code. When two original legal cases have the same discrete code at the current layer, the two case nodes are connected to the same code node through the second edge, forming a two-hop path of case node A-code node-case node B, thus establishing an indirect semantic association between the two original legal cases.

[0073] Then establish the third side between the charge node and the fourth side between the code node.

[0074] Specifically, the semantic similarity between each accusation node is first calculated. For any two accusation nodes, the continuous semantic embedding vectors of the accusation labels corresponding to the two accusation nodes are obtained (which can be obtained based on the aforementioned encoding method), i.e., after encoding by the pre-trained embedding model and dimensionality reduction through principal component analysis and whitening. Next, the cosine similarity between the continuous semantic embedding vectors of the two accusation nodes is calculated as the semantic similarity between the two accusation nodes. For each accusation node, the semantic similarity between the accusation node and all other accusation nodes is sorted in descending order, and the second-to-last predetermined number of other accusation nodes with the highest semantic similarity are selected. A third edge is then established between the accusation node and each of the selected accusation nodes.

[0075] Similarly, for code nodes, the semantic similarity between each code node is first calculated. For any two code nodes, the quantization vectors of the codebook entries corresponding to these two code nodes are obtained. These quantization vectors are vectors obtained after transforming the corresponding codebook entries in this layer of the codebook using a learnable scaling factor and a learnable bias term. The cosine similarity between the two quantization vectors is calculated as the semantic similarity between the two code nodes. For each code node, the semantic similarity between this code node and all other code nodes is sorted in descending order. The top three preset number of other code nodes with the highest semantic similarity are selected, and a fourth edge is established between this code node and each of the selected code nodes.

[0076] Ultimately, the set of nodes consisting of the aforementioned case nodes, charge nodes, and code nodes, together with the set of edges consisting of the aforementioned first edge, second edge, third edge, and fourth edge, together form the undirected relation graph of this layer.

[0077] Thus, by introducing the accusation label information of the original legal cases into the graph structure through the first side, the case nodes can aggregate legal qualitative knowledge; by establishing the connection between the case nodes and code nodes through the second side, the original legal cases sharing the same discrete code can establish a two-hop path through the code nodes, thus reconstructing the implicit semantic reference relationship between different original legal cases in the context of civil law systems without explicit reference networks, effectively bridging the differences in the form of case association between different legal systems; by establishing the connection between semantically similar accusation nodes and between code nodes through the third and fourth sides, the semantic connection in the graph structure is enriched, enabling semantically similar legal concepts to exchange information.

[0078] Please continue to refer to this. Figure 1 In step S140, information aggregation is performed on each layer of the relationship graph, and the feature representation of each node in each layer of the relationship graph is updated.

[0079] In this implementation, for each layer of the relational graph, the initial features of each case node and the charge node are set as the residual of that layer, and the initial features of each code node are set as the quantization vector of that layer. The graph attention network performs multiple rounds of message passing on each node, and each node aggregates the feature information of its neighboring nodes to update its own feature representation.

[0080] In some embodiments of this disclosure, step S140 preferably includes steps S141 to S143, please refer to... Figure 4 .

[0081] In step S141, for each layer of the relational graph, the residual after processing by the residual amplification unit of each layer is used as the initial feature of the case node and the command node, and the selected codebook entry of that layer is used as the initial feature of the code node.

[0082] In step S142, a graph attention network is used to perform multiple rounds of message passing on the case nodes, charge nodes, and code nodes in each layer of the relationship graph to determine the updated feature representation of each case node in the corresponding relationship graph.

[0083] In step S143, the updated feature representations of the case nodes and the feature representations of the charge nodes in the previous layer relationship graph are added to the initial features of the corresponding nodes in the current layer relationship graph and then used for message passing in the current layer relationship graph.

[0084] In this implementation, for each layer of the relationship diagram A graph neural network encoder is applied for information propagation. Specifically, a graph attention network is used as a variant of the GNN. Let... Indicates the first Layer nodes The initial features, for case nodes or charge nodes, are set as the residuals after processing by the residual amplification unit of that layer. For a code node, its initial characteristic is set to the selected codebook entry of that layer. .

[0085] Then, after setting the initial features of each node, a graph attention network is used to perform multiple rounds of message passing on each node. Let... Represents a node exist After The feature representation after the GNN layer has the following initial state: After the graph operations described above, the updated feature representations of the case nodes and charge nodes in the l-th layer are directly added to the l-th layer. In the layer relationship diagram. Therefore, the first... The initial features of the nodes in the layer relationship graph are: in The number of GNN layers applied to each graph. Corresponding nodes in different layers are matched one-to-one to ensure that features in each layer are directly aligned.

[0086] No. The node representation of a multilayer GNN is calculated as follows: in, Relationship diagram Middle node The set of neighbors, GNN is a graph attention network layer.

[0087] After passing through K layers of messages, extract each case node. In the relationship diagram Updated feature representation .

[0088] Thus, by using a graph attention network to perform multiple rounds of message passing through the relationship graph at each layer, the feature representation of each node can fully absorb the semantic information of its neighboring nodes. By adaptively assigning attention weights to different neighboring nodes, the graph attention network enables the model to focus on neighboring nodes with higher semantic relevance to the current node during information aggregation, thereby improving the quality of information aggregation and the accuracy of retrieval.

[0089] In one implementation, all layers of the graph share the same graph attention network parameters. That is, for message passing at each layer of the graph, the same set of network weights is used for linear transformation of neighbor node features, calculation of attention scores, and updating of node feature representations. In this way, by sharing parameters, the number of model parameters is reduced while forcing all abstraction layers to maintain a consistent semantic message passing pattern.

[0090] Please continue to refer to this. Figure 1 In step S150, the feature representations of the updated case nodes in each layer of the relationship graph are fused, and the target vector representation of the original legal case is generated based on the fused feature representations of the case nodes and the continuous semantic embedding vector of the original legal case.

[0091] In this implementation, after the message transmission of each layer of the relationship graph is completed, the feature representations of case nodes at different levels are fused to obtain the target vector representation of each original legal case.

[0092] In some embodiments of this disclosure, step S150 preferably includes steps S151 to S152, please refer to... Figure 5 .

[0093] In step S151, the feature representations of the updated case nodes in each layer relationship graph are concatenated in order from shallow to deep to obtain a hierarchical feature concatenation vector.

[0094] In step S152, the hierarchical feature concatenation vector is concatenated with the continuous semantic embedding vector of the original legal case to obtain the target vector representation of the original legal case.

[0095] In this implementation, for each original legal case, after aggregating the information in the relationship graph across all layers, the updated feature representation of the case node corresponding to that original legal case is extracted from each layer of the relationship graph. The extracted case node features from each layer are then concatenated in order from shallowest to deepest. For example, the feature representations of the case node at layer 0, layer 1, ..., layer L-1 are concatenated end-to-end in sequence to obtain the corresponding hierarchical feature concatenation vector.

[0096] Then, the feature concatenation vector of this level is concatenated with the continuous semantic embedding vector of the original legal case to obtain the target vector representation corresponding to the original legal case.

[0097] In one example, the original legal case Target vector representation The feature representations of the case nodes output by all layers of the graph neural network are concatenated and then compared with the corresponding continuous semantic embedding vectors. The combination yields: Where ‖ denotes vector concatenation operation. For the first The feature representation of the case nodes output by the layered graph neural network. This is the dimensionality-reduced continuous semantic embedding vector.

[0098] In this way, the generated target vector representation integrates coarse-grained semantic signals (from the shallow layer) and fine-grained discriminative features (from the deep layer), providing a multi-perspective semantic representation for subsequent legal case retrieval.

[0099] In some embodiments of this disclosure, the method for generating the vector representation of the legal case preferably further includes steps S610 to S620, please refer to... Figure 6 .

[0100] In step S610, in response to the received query case, a target vector representation corresponding to the query case is constructed.

[0101] In step S620, the legal case retrieval results are determined and output based on the similarity between the target vector representation corresponding to the case to be queried and the target vector representation of each legal case in the case library.

[0102] In this implementation, in response to the received query case, it is input into a pre-trained legal case retrieval model (which can execute the vector representation generation method for legal cases as described above). First, the legal summary extraction module extracts information and performs dimensionality reduction encoding on the query case to obtain a continuous semantic embedding vector of the query case. Second, the hierarchical semantic modeling module performs multi-layer residual quantization processing on the continuous semantic embedding vector to obtain multi-layer discrete codes and residuals. Finally, the case relationship learning module constructs a relationship graph based on the discrete codes of each layer, and uses a graph neural network for multi-round message passing to concatenate the updated feature representations of the case nodes at each layer with the continuous semantic embedding vector to generate the target vector representation of the query case.

[0103] Next, the target vector representations of all historical legal cases stored in the pre-built case library are obtained, and the cosine similarity between the target vector representation of the case to be queried and the target vector representation of each historical legal case in the case library is calculated.

[0104] All calculated cosine similarity scores are sorted in descending order, and a predetermined number of historical legal cases are selected from the top-ranked ones. These are then output as the legal case retrieval results to assist legal professionals in case analysis, judgment prediction, or legal reasoning.

[0105] In this way, the case to be queried and the cases in the case library follow the exact same processing flow, ensuring that the target vector representations generated by the two are in the same semantic space, and that the similarity calculation results are comparable and reliable.

[0106] In some embodiments of this disclosure, a decoupled two-stage training strategy is employed. In the first stage, the parameters of the legal summary extraction module are fixed, and the hierarchical semantic modeling module is trained by minimizing the contrastive loss and codebook commitment loss to learn discriminative quantized semantic representations. In the second stage, the parameters of both the legal summary extraction module and the hierarchical semantic modeling module are fixed, and the case relationship learning module is trained by minimizing the information-noise contrastive estimation loss function. The same graph neural network parameters are shared across the relationship graphs of different quantization layers, thereby generating the final context-aware representation.

[0107] Specifically, for the l-th layer, the contrast loss Defined as: in The triple consists of an anchor point, a positive sample, and a hard negative sample. For similarity functions (such as cosine similarity). This is a boundary hyperparameter. The contrastive loss ensures that the similarity between positive samples and anchor points is at least higher than the boundary value compared to negative samples. Samples that violate this constraint pass The function applies a penalty.

[0108] To construct an effective triplet, for each anchor point, hard negative samples are selected from the top-k nearest neighbors in the PCA-whitening space, i.e., those samples that are highly similar to the anchor point but are actually unrelated.

[0109] At the same time, this publicly available application codebook promises loss, making the quantization vector input residual Alignment: in Here, β is the gradient stopping operator, and β is the balance coefficient. The first term of this loss function encourages the codebook vector to approximate a continuous residual, while the second term prevents excessive fluctuations in the encoder output, ensuring training stability.

[0110] To facilitate efficient training of deeper codebooks, this disclosure applies an exponential scaling factor γ to the loss function. In one example, the total loss of the hierarchical semantic modeling module is: in This is a constant hyperparameter. This scaling factor ensures that, with the same model parameter settings, the most discriminative semantic information is guided to be captured in the final codebook, thereby achieving fine-grained differentiation of difficult samples.

[0111] The training objective of the case relationship learning module still adopts contrastive learning, but uses the InfoNCE loss function: in For anchor point cases, the target vector representation is given. The target vector representation for positive sample cases. It is a set of negative samples (including hard negative samples). For temperature hyperparameters, The cosine similarity function is used. The selection strategy for positive and negative samples is the same as that of the hierarchical semantic modeling module, that is, for each anchor point, hard negative samples are selected from the top-k nearest neighbors in the PCA-whitening space.

[0112] Thus, through the aforementioned decoupled training strategy, the hierarchical semantic modeling module learns stable discrete semantic representations without being disturbed by graph reasoning. Secondly, the case relationship learning module models relationships based on fixed, high-quality semantic features, avoiding the coupling optimization problems that may arise from joint training.

[0113] Based on any of the above embodiments, this disclosure also provides a vector representation generation apparatus for legal cases.

[0114] Figure 7This is a schematic block diagram of a vector representation generation apparatus for a legal case according to one embodiment of the present disclosure.

[0115] like Figure 7 As shown, the vector representation generation device for this legal case includes: The legal summary extraction module 710 is used to extract information from each original legal case to obtain the corresponding case summary, and to perform semantic encoding on the case summary to obtain the continuous semantic embedding vector corresponding to each original legal case.

[0116] The hierarchical semantic modeling module 720 is used to encode the continuous semantic embedding vectors of each of the original legal cases layer by layer to obtain the corresponding multi-layer discrete codes and construct a legal hierarchy structure. The legal hierarchy structure includes shallow discrete codes and deep discrete codes. The shallow discrete codes are used to represent the coarse-grained legal domain information of the original legal cases, and the deep discrete codes are used to represent the fine-grained factual details of the original legal cases.

[0117] The case relationship learning module 730 is used to construct a corresponding relationship graph for each layer of the legal hierarchy, wherein the nodes of the relationship graph include case nodes, charge nodes, and code nodes corresponding to the multi-layer discrete codes; to aggregate information for each layer of the relationship graph and update the feature representation of each node in each layer of the relationship graph; to fuse the updated feature representations of the case nodes in each layer of the relationship graph, and to generate the target vector representation of the original legal case based on the fused feature representations of the case nodes and the continuous semantic embedding vector of the original legal case.

[0118] In some embodiments of this disclosure, the vector representation generation apparatus for legal cases further includes a case retrieval module 740, which is used to construct a target vector representation corresponding to the received case to be queried in response to the received case to be queried; and to determine and output the legal case retrieval result based on the similarity between the target vector representation corresponding to the case to be queried and the target vector representations of each legal case in the case library.

[0119] The vector representation generation device for the aforementioned legal cases can be in the form of computer software, and the various modules of the vector representation generation device for the aforementioned legal cases can be implemented through computer software modules.

[0120] Based on any of the above embodiments, this disclosure also provides an electronic device that can execute the vector representation generation method for legal cases according to any of the embodiments described above.

[0121] Figure 8 This is a schematic block diagram of an electronic device 1000 according to one embodiment of the present disclosure.

[0122] The hardware architecture of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnect buses and bridges, depending on the specific application of the hardware and overall design constraints. Bus 1100 connects various circuits, including one or more processors 1200, memory 1300, and / or hardware modules. Bus 1100 can also connect various other circuits 1400, such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.

[0123] Bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, this diagram uses only one connection line, but this does not imply that there is only one bus or one type of bus.

[0124] This disclosure also provides a readable storage medium storing a computer program that, when executed by a processor, is used to implement the methods described above. A "readable storage medium" can be any means capable of containing, storing, communicating, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples of a readable storage medium include: an electrical connection with one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable read-only memory (CDROM), etc.

[0125] This disclosure also provides a computer program product, the methods of which can be implemented wholly or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented wholly or partially as a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, all or part of the processes or functions of this disclosure are performed.

[0126] Computer programs or instructions can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any available medium capable of access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or it can include both volatile and non-volatile types of storage media.

[0127] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0128] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0129] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0130] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0131] In the description of this specification, the references to terms such as "one embodiment / mode," "some embodiments / modes," "example," "specific example," or "some examples," etc., refer to specific features, structures, or characteristics described in connection with that embodiment / mode or example, which are included in at least one embodiment / mode or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment / mode or example. Moreover, the specific features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments / modes or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments / modes or examples described in this specification, as well as the features of different embodiments / modes or examples.

[0132] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0133] Those skilled in the art should understand that the above embodiments are merely for illustrating the present disclosure and are not intended to limit the scope of the disclosure. Those skilled in the art can make other changes or modifications based on the above disclosure, and these changes or modifications still fall within the scope of the present disclosure.

Claims

1. A method for generating vector representations of legal cases, characterized in that, include: Information is extracted from each original legal case to obtain a corresponding case summary, and the case summary is semantically encoded to obtain a continuous semantic embedding vector corresponding to each original legal case. The continuous semantic embedding vectors of each of the original legal cases are encoded layer by layer to obtain corresponding multi-layer discrete codes and construct a legal hierarchy structure. The legal hierarchy structure includes shallow discrete codes and deep discrete codes. The shallow discrete codes are used to represent the coarse-grained legal domain information of the original legal cases, and the deep discrete codes are used to represent the fine-grained factual details of the original legal cases. For each layer of the legal hierarchy, a corresponding relationship diagram is constructed. The nodes of the relationship diagram include case nodes, charge nodes, and code nodes corresponding to the multi-layer discrete code. Information is aggregated for each layer of the relationship graph, and the feature representations of each node in each layer of the relationship graph are updated. as well as The feature representations of the updated case nodes in each layer of the relationship graph are fused together, and the target vector representation of the original legal case is generated based on the fused feature representations of the case nodes and the continuous semantic embedding vector of the original legal case.

2. The method for generating vector representations of legal cases as described in claim 1, characterized in that, Information is extracted from each original legal case to obtain a corresponding case summary, and the case summary is semantically encoded to obtain a continuous semantic embedding vector corresponding to each original legal case, including: For each original legal case, the original legal case is broken down into multiple sentences, and an importance score is calculated for each sentence. The importance score is a weighted sum of the sentence's term frequency-inverse document frequency score and legal keyword matching score. Select the top 100 sentences with the highest importance scores, and then combine the selected sentences with legal keywords that match the original legal case to form a prompt message; Based on the provided prompts, a corresponding case summary is generated, and the case summary is encoded to obtain a high-dimensional semantic embedding vector; and Principal component analysis and whitening are performed on the high-dimensional semantic vector to reduce its dimensionality and obtain the continuous semantic embedding vector of the original legal case.

3. The method for generating vector representations of legal cases as described in claim 1, characterized in that, The continuous semantic embedding vectors of each of the original legal cases are encoded layer by layer to obtain the corresponding multi-layer discrete codes, including: Multi-layer residual quantization is performed on the continuous semantic embedding vectors of each of the original legal cases, encoding the continuous semantic embedding vectors layer by layer into multi-layer discrete codes. In the multi-layer residual quantization process, for the first layer, the continuous semantic embedding vectors of the original legal cases are mapped by a multi-layer perceptron as the residual. Based on the residual of the current layer, the codebook entry with the closest distance to the residual of the current layer is selected from the codebook corresponding to the current layer. The index of the codebook entry is used as the discrete code of the current layer. The selected codebook entry is transformed according to the learnable scaling factor and learnable bias term corresponding to the current layer to obtain the quantization vector of the current layer. The residual of the current layer is subtracted from the quantization vector to obtain the quantization residual of the current layer. The quantization residual of the current layer is input to the residual amplification unit for processing to obtain the input residual of the next layer, until the discrete codes of all layers are obtained.

4. The method for generating vector representations of legal cases as described in claim 3, characterized in that, The residual amplification unit includes a layer normalization layer and a multilayer perceptron with skip connections.

5. The method for generating vector representations of legal cases as described in claim 1, characterized in that, Based on each layer of the legal hierarchy, a corresponding relationship diagram is constructed, including: For each layer of the legal hierarchy, construct an undirected graph containing case nodes, charge nodes, and code nodes; and Construct connection edges between the case node and the charge node, between the case node and the code node, between the charge nodes, and between the code nodes to obtain the relationship graph corresponding to this layer.

6. The method for generating vector representations of legal cases as described in claim 3, characterized in that, Information is aggregated for each layer of the relationship graph, and the feature representations of each node in each layer of the relationship graph are updated, including: For each layer of the relational graph, the residual after processing by the residual amplification unit of each layer is used as the initial feature of the case node and the command node, and the selected codebook entry of that layer is used as the initial feature of the code node. A graph attention network is used to perform multi-round message passing on case nodes, charge nodes, and code nodes in each layer of the relation graph to determine the updated feature representation of each case node in the corresponding relation graph; and The updated feature representations of the case nodes and the feature representations of the charge nodes in the previous layer relationship graph are added to the initial features of the corresponding nodes in the current layer relationship graph and then used for message passing in the current layer relationship graph.

7. The method for generating vector representations of legal cases as described in claim 1, characterized in that, The updated feature representations of case nodes from each layer of the relationship graph are fused, and based on the fused feature representations of the case nodes and the continuous semantic embedding vector of the original legal case, a target vector representation of the original legal case is generated, including: The updated feature representations of case nodes in each layer of the relationship graph are concatenated in order from shallowest to deepest to obtain a hierarchical feature concatenation vector; and The hierarchical feature concatenation vector is concatenated with the continuous semantic embedding vector of the original legal case to obtain the target vector representation of the original legal case.

8. The method for generating vector representations of legal cases as described in any one of claims 1-7, characterized in that, The method for generating vector representations of legal cases also includes: In response to the received query case, construct the target vector representation corresponding to the query case; and Based on the similarity between the target vector representation of the case to be queried and the target vector representation of each legal case in the case library, the legal case retrieval results are determined and output.

9. An electronic device, characterized in that, include: The memory stores execution instructions; as well as A processor that executes execution instructions stored in the memory, causing the processor to perform the vector representation generation method for legal cases according to any one of claims 1 to 8.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the vector representation generation method for legal cases as described in any one of claims 1 to 8.