Law literature retrieval method and system based on knowledge graph

By utilizing the BERT model and a legal thesaurus to identify synonyms in legal literature and optimizing the ternary combination process, the problem of low efficiency in constructing legal literature knowledge graphs is solved, and efficient legal literature retrieval is achieved.

CN120910239APending Publication Date: 2025-11-07OCEAN UNIV OF CHINA
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511015513.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-23
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

Existing technologies, when constructing legal literature knowledge graphs, suffer from low merging efficiency due to the large number of similar words and the use of fixed context-based semantic analysis.

Method used

We use the pre-trained language model BERT to extract legal entities and relations, combine it with a thesaurus of legal terms to determine whether there are synonyms in the triples, determine the number of elements in the relation vector by the number of synonym characters and frequency, calculate the similarity and merge the triples to construct a legal knowledge graph.

Benefits of technology

It improves the efficiency of constructing legal literature knowledge graphs, reduces the time for extracting relation vectors, and enhances the efficiency of ternary combination and merging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910239A_ABST
    Figure CN120910239A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of information retrieval and artificial intelligence, in particular to a law literature retrieval method and system based on a knowledge graph. Then, according to characters of the similar words and the occurrence frequency of the similar words in the law literature, the number of elements in the relation vector for extracting the upper and lower books is determined, so that the time for extracting the relation vector by adopting a language model can be effectively shortened, and the efficiency of ternary combination merging is improved; and thus, the construction efficiency of the law literature knowledge graph is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of information retrieval and artificial intelligence technology, and in particular to a legal document retrieval method and system based on a knowledge graph. BACKGROUND

[0002] In the prior art, after constructing a triple, the triple is generally subjected to operations such as merging semantics and the like. In the operation of merging semantics, the triple with similar semantics is generally merged by using a context-based semantic analysis method. However, for a specific type of legal document, there are many similar words in the legal document, and the similarity of different similar words is difficult to determine. The use of the fixed context-based semantic analysis method in the prior art will result in low efficiency of merging. SUMMARY

[0003] To solve the above technical problems, the present application provides a legal document retrieval method and system based on a knowledge graph, which is used to solve the problems in the prior art.

[0004] According to an aspect of the present application, a legal document retrieval method based on a knowledge graph is provided, comprising the following steps:

[0005] S1: constructing a legal knowledge graph for legal document retrieval;

[0006] S11: constructing a legal document corpus;

[0007] S12: constructing a legal knowledge graph based on the legal document corpus;

[0008] The S12 is specifically: using a pre-trained language model to extract legal entities and relationships from the legal document corpus, to generate legal entity vectors and relationship vectors; and constructing a legal knowledge graph based on the legal entity vectors and relationship vectors;

[0009] The construction of the legal knowledge graph based on the legal entity vectors and relationship vectors is specifically:

[0010] Sa: constructing a triple based on the legal entity vectors and relationship vectors;

[0011] Sb: merging similar triples;

[0012] Sc: constructing a triple into a graph structure;

[0013] Sd: constructing a legal knowledge graph based on the graph structure;

[0014] S2: parsing a user instruction into entities and relationships in the legal knowledge graph to form a user instruction knowledge graph;

[0015] S3: calculating the similarity between the user instruction knowledge graph and the legal knowledge graph, thereby obtaining a retrieval result;

[0016] S4: displaying the literature corresponding to the legal knowledge graph through a user interaction interface.

[0017] Preferably, the Sb is specifically:

[0018] Using the legal field synonym library to determine whether there is a synonym in the triple; if there is no synonym, the original triple is taken as the final triple, and if there is a synonym, the number n of characters of the synonym in the triple is obtained;

[0019] After detecting that there is a synonym in the triple, the relationship vector of the context in which the synonym is located is extracted;

[0020] According to the different number of characters of the synonym, the number of elements in the relationship vector of the context in which the synonym is located is different;

[0021] The corresponding relationship formula between the number n of characters of the synonym and the number S of elements in the relationship vector is:

[0022] S = round(a ln n - b e f );

[0023] In the formula, round() is an integer function, f is the frequency of the synonym appearing in the legal literature, and a and b are coefficients;

[0024] The similarity between different relationship vectors is calculated; and the triples with high similarity and a set threshold are merged.

[0025] Preferably, in the Sc, the entity is taken as a node, and the relationship is taken as an edge, and the triples are constructed into a graph structure.

[0026] Preferably, in the Sd, the graph structure is stored in a Neo4j graph database, thereby completing the construction of the legal knowledge graph.

[0027] Preferably, the S2 is specifically:

[0028] Text cleaning and word segmentation operations are performed on the user instruction;

[0029] Entities and relationships in the user instruction are parsed.

[0030] Preferably, the text cleaning is used to remove irrelevant characters, and the word segmentation operation is specifically: for Chinese user instructions, the jieba word segmentation tool is used for word segmentation, and for English user instructions, the nltk word segmentation tool is used for word segmentation.

[0031] Preferably, in S2, the similarity between the user instruction knowledge graph and the legal knowledge graph is calculated by using cosine similarity.

[0032] Preferably, in Sb, the synonym library is a legal synonym dictionary.

[0033] Preferably, after detecting the existence of a synonym in a triple, the relationship vector of the context in which the synonym is located is extracted, specifically: the relationship vector of the context in which the synonym is located is extracted based on a GPT language model.

[0034] According to another aspect of the present application, a legal document retrieval system based on a knowledge graph is provided, which adopts the legal document retrieval method based on a knowledge graph described above, and the system comprises:

[0035] A legal knowledge graph construction module is configured to construct a legal knowledge graph for legal document retrieval.

[0036] A user instruction knowledge graph construction module is configured to parse the user instruction into entities and relationships in the legal knowledge graph, thereby forming a user instruction knowledge graph.

[0037] A similarity calculation module is configured to calculate the similarity between the user instruction knowledge graph and the legal knowledge graph, thereby obtaining a retrieval result.

[0038] A result display module is configured to display the documents corresponding to the legal knowledge graph through a user interaction interface.

[0039] The present application has the following technical effects:

[0040] In the construction of the legal document knowledge graph, firstly, it is determined whether there is a similar word in a triple, and then the number of elements in the relationship vector of the context is determined according to the characters of the similar word and the frequency of the similar word appearing in the legal document, which can effectively reduce the time of extracting the relationship vector by using the language model, improve the efficiency of triple merging, and further improve the construction efficiency of the legal document knowledge graph. BRIEF DESCRIPTION OF DRAWINGS

[0041] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0042] Figure 1 is a flowchart of the legal document retrieval method based on a knowledge graph provided by the embodiments of the present application;

[0043] Figure 2 is a flowchart of constructing a legal knowledge graph based on the legal entity vector and the relationship vector provided by the embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme of the present application will be described clearly and completely below. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the present application.

[0045] Embodiment 1, Figure 1 A flowchart of a legal document retrieval method based on a knowledge graph is shown, which comprises the following steps:

[0046] S1: constructing a legal knowledge graph for legal document retrieval;

[0047] The knowledge graph for legal document retrieval is specifically:

[0048] S11: constructing a legal document corpus;

[0049] The legal document corpus includes digitized resources and paper document scanning resources, as well as a user legal document database;

[0050] S12: constructing a legal knowledge graph according to the legal document corpus;

[0051] In this step, S12 is specifically: using a pre-trained language model to perform legal entity extraction and relationship extraction on the legal document database to generate a legal entity vector and a relationship vector; and constructing a legal knowledge graph based on the legal entity vector and the relationship vector;

[0052] The pre-trained language model is a BERT model; BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language representation model based on a Transformer architecture, which can understand the context information in legal literature text by pre-training a deep bidirectional Transformer model. Unlike traditional unidirectional language models (such as GPT), the BERT model simultaneously considers the left and right context of the word during the pre-training process, thereby better capturing the semantics and context of the word; the BERT model is widely used in legal entity and relationship extraction, and the embodiment adopts the BERT model to extract legal entities and relationships, and vectorizes the legal entities and relationships, that is, generates legal entity vectors and corresponding relationship vectors, which can significantly improve the automated processing capability of legal text and can realize high-precision entity recognition and relationship classification.

[0053] Exemplarily, the legal entity extraction can be legal provisions, cases, regulations, and institutions, etc.; for example, the legal provision is “Article XX of the Criminal Law”, the case is “Zhang San v. Li Si case”, the regulation is “Civil Code”, and the institution is “the Supreme People's Court”; the relationship extraction is specifically extracting the relationship between entities; for example, a case quotes a legal provision, a legal provision explains a concept, and a case applies a regulation;

[0054] As shown in the accompanying Figure 2 , the constructing a legal knowledge graph based on the legal entity vector and the relationship vector specifically comprises:

[0055] Sa: constructing a triple based on the legal entity vector and the relationship vector;

[0056] Combining the extracted entities and relationships into triples (head entity, relationship, tail entity), such as (“A”, “implements”, “theft behavior”);

[0057] Sb: merging similar triples;

[0058] In fact, in the prior art, after constructing triples in the process of constructing a knowledge graph, the triples are generally subjected to merging semantic similarity and other operations, wherein, in the merging semantic similarity operation process, the triples with similar semantics are generally merged based on context semantic analysis and the like; however, for this specific type of legal literature, since there are many similar words in legal literature, the similarity judgment of different similar words is different, and the fixed context semantic analysis in the prior art will result in low merging efficiency, therefore, the embodiment proposes a new triple merging scheme;

[0059] Specifically, the Sb specifically comprises:

[0060] Use a thesaurus in the legal field to determine if there are synonyms in the triples; if there are no synonyms, use the original triples as the final triples; if there are synonyms, get the number of characters n of the synonyms in the triples.

[0061] In this step, the thesaurus is the "Dictionary of Legal Thesaurus";

[0062] For example, if a triple contains the relation "reference", and the dictionary of legal thesaurus indicates that it contains the synonym "citation", then the triple contains a synonym with a character count of 2.

[0063] After detecting the presence of synonyms in the triples, the relation vector of the context in which the synonyms are located is extracted;

[0064] Among them, the relation vector of the context of the synonym is extracted based on the GPT language model;

[0065] Furthermore, depending on the number of characters in a synonym, the number of elements extracted from the relation vector of the context in which the synonym is located varies.

[0066] Specifically, the correspondence between the number of synonym characters n and the number of elements S in the relation vector is as follows:

[0067] S = round(a·ln nb·e) f );

[0068] In the formula, round() is the floor function, f is the frequency of the synonym in legal literature, and a and b are coefficients;

[0069] The frequency of a word in legal literature can be obtained by statistically analyzing the frequency of the word in a predetermined number of legal literatures of different types and influence factors.

[0070] Calculate the similarity between different relation vectors;

[0071] Among them, the cosine similarity of different relation vectors is used as a representation of the similarity between relation vectors;

[0072] Merge triples with high similarity to a set threshold;

[0073] In this step, we first determine whether there are similar words in the triples, and then determine the number of elements to extract from the relation vector of the upper and lower parts of the text based on the characters of the similar words and the frequency of the similar words in legal literature. This can effectively reduce the time of extracting relation vectors using language models and improve the efficiency of triple combination merging.

[0074] Sc: Construct a graph structure from triples;

[0075] The knowledge graph is usually stored in the form of a graph, containing nodes and edges, each node can contain attributes such as the name, type, vector representation, etc. of an entity; the edge contains the type and possible vector representation of the relationship, so in this step, the entity is taken as the node and the relationship is taken as the edge, and the triple is constructed into a graph structure;

[0076] Sd: constructing a legal knowledge graph based on the graph structure;

[0077] Storing the graph structure into a Neo4j graph database, thereby completing the construction of the legal knowledge graph.

[0078] S2: parsing the user instruction into entities and relationships in the legal knowledge graph to form a user instruction knowledge graph;

[0079] Specifically, S2 is:

[0080] Text cleaning and word segmentation operations are performed on the user instruction;

[0081] The text cleaning is used to remove irrelevant characters such as punctuation marks, extra spaces, etc., and the word segmentation operation is specifically: for a Chinese user instruction, the jieba word segmentation tool is used for word segmentation, and for an English user instruction, the nltk word segmentation tool is used for word segmentation;

[0082] The entities and relationships in the user instruction are parsed;

[0083] The parsing of the entities and relationships in the user instruction is the same as the above step, and both use BERT parsing.

[0084] S3: calculating the similarity between the user instruction knowledge graph and the legal knowledge graph, thereby obtaining a retrieval result;

[0085] In this step, the cosine similarity is also used to calculate the similarity between the user instruction knowledge graph and the legal knowledge graph.

[0086] S4: displaying the literature corresponding to the legal knowledge graph through a user interaction interface.

[0087] In embodiment 2, the present application also provides a legal literature retrieval system based on a knowledge graph, which uses the legal literature retrieval method based on a knowledge graph in embodiment 1, and the system comprises:

[0088] A legal knowledge graph construction module for constructing a legal knowledge graph for legal literature retrieval;

[0089] A user instruction knowledge graph construction module for parsing the user instruction into entities and relationships in the legal knowledge graph to form a user instruction knowledge graph;

[0090] a similarity calculation module, configured to calculate a similarity between the user instruction knowledge graph and the legal knowledge graph, so as to obtain a retrieval result;

[0091] a result display module, configured to display the literature corresponding to the legal knowledge graph through a user interaction interface.

[0092] In embodiment 3, the application further provides an electronic device, including one or more processors and a memory.

[0093] The processor can be a central processing unit (CPU) or other forms of processing units having data processing and / or instruction execution capabilities, and can control other components in the electronic device to perform desired functions.

[0094] The memory can include one or more computer program products, which can include various forms of computer readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM), cache memory, and the like. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, and the like. One or more computer program instructions can be stored on the computer readable storage medium, and the processor can run the program instructions to implement the knowledge graph-based legal literature retrieval method of any embodiment of the application described above and / or other desired functions. Various contents such as initial external parameters, threshold values, and the like can also be stored in the computer readable storage medium.

[0095] In one example, the electronic device can further include input devices and output devices, which are interconnected through a bus system and / or other forms of connection mechanism (not shown). The input devices can include, for example, a keyboard, a mouse, and the like. The output devices can output various information to the outside, including pre-warning prompt information, braking force, and the like. The output devices can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.

[0096] Of course, components such as buses, input / output interfaces, and the like are omitted for simplicity. In addition, the electronic device can include any other appropriate components according to specific application cases.

[0097] In addition to the above method and device, the embodiments of the application can also be a computer program product, which includes computer program instructions that, when executed by a processor, cause the processor to implement the functions of the knowledge graph-based legal literature retrieval method provided by any embodiment of the application.

[0098] The computer program product can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server.

[0099] In addition, the embodiments of the present application can also be a computer readable storage medium, which stores computer program instructions, and the computer program instructions make the processor realize the knowledge graph-based legal document retrieval method provided by any embodiment of the present application when the processor runs.

[0100] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (non-exhaustive list) of readable storage medium include: electrical connection with one or more conductive wires, portable disk, hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.

[0101] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present application.

Claims

1. A method for retrieving legal documents based on a knowledge graph, characterized in that, The method comprises the following steps: S1: constructing a legal knowledge graph for legal document retrieval; S11: constructing a legal document corpus; S12: constructing a legal knowledge graph according to the legal document corpus; The S12 is specifically: using a pre-trained language model to extract legal entities and relationships from the legal document corpus, and generating legal entity vectors and relationship vectors; based on the legal entity vectors and relationship vectors, a legal knowledge graph is constructed; Based on the legal entity vectors and relationship vectors, the legal knowledge graph is constructed specifically as follows: Sa: constructing a triple based on the legal entity vectors and relationship vectors; Sb: merging similar triples; Sc: constructing triples into a graph structure; Sd: based on the graph structure, the construction of the legal knowledge graph is realized; S2: parsing the user instruction into entities and relationships in the legal knowledge graph to form a user instruction knowledge graph; S3: calculating the similarity between the user instruction knowledge graph and the legal knowledge graph to obtain a retrieval result; S4: displaying the documents corresponding to the legal knowledge graph through a user interaction interface. 2.The knowledge graph-based legal document retrieval method according to claim 1, characterized in that, The Sb is specifically: Using a legal field synonym library to determine whether there is a synonym in the triple; if there is no synonym, the original triple is taken as the final triple; if there is a synonym, the number n of characters of the synonym in the triple is obtained; After detecting that there is a synonym in the triple, the relationship vector of the context in which the synonym is located is extracted; According to the different number of characters of the synonym, the number of elements in the relationship vector of the context in which the synonym is located is different; The corresponding relationship between the number n of characters of the synonym and the number S of elements in the relationship vector is as follows: S = round(a • ln n - b • e f ); In the formula, round() is an integer function, f is the frequency of the synonym appearing in the legal document, and a and b are coefficients; Calculate the similarity between different relationship vectors; merge the triples with high similarity and the set threshold. 3.The knowledge graph-based legal document retrieval method according to claim 1, characterized in that, In the Sc, the triple is constructed into a graph structure with entities as nodes and relationships as edges. 4.The knowledge graph-based legal document retrieval method according to claim 2, characterized in that, In the Sd, the graph structure is stored in a Neo4j graph database, thereby completing the construction of the legal knowledge graph. 5.The knowledge graph-based legal document retrieval method according to claim 1, characterized in that, The S2 is specifically: Text cleaning and word segmentation operations are performed on the user instruction; Parsing the entities and relationships in the user instruction. 6.The knowledge graph-based legal document retrieval method according to claim 5, characterized in that, The text cleaning is used to remove irrelevant characters, and the word segmentation operation is specifically: using the jieba word segmentation tool for Chinese user instructions and the nltk word segmentation tool for English user instructions. 7.The knowledge graph-based legal document retrieval method according to claim 1, characterized in that, In the S2, the cosine similarity is used to calculate the similarity between the user instruction knowledge graph and the legal knowledge graph. 8.The knowledge graph-based legal document retrieval method according to claim 2, characterized in that, In the Sb, the synonym library is a legal synonym dictionary. 9.The knowledge graph-based legal document retrieval method of claim 1, wherein, After detecting that there is a synonym in the triple, the relationship vector of the context in which the synonym is located is extracted specifically by using a GPT language model.

10. A legal document retrieval system based on a knowledge graph, the system employing the legal document retrieval method based on a knowledge graph according to any one of claims 1-9, characterized in that, The system comprises: A legal knowledge graph construction module for constructing a legal knowledge graph for legal document retrieval; A user instruction knowledge graph construction module for parsing a user instruction into entities and relationships in the legal knowledge graph to form a user instruction knowledge graph. The similarity calculation module is configured to calculate the similarity between the user instruction knowledge graph and the legal knowledge graph, thereby obtaining a search result. The result display module is configured to display the literature corresponding to the legal knowledge graph through a user interaction interface.

Citation Information

Patent Citations

  • Knowledge graph construction method and system and storage medium

    CN114117070A

  • Document retrieval method and system based on knowledge graph, terminal and storage medium

    CN116881436A

  • Method and system for constructing knowledge graph by extracting triples from large model, and medium

    CN117273132A

  • Method for constructing legal knowledge graph

    CN117349448A

  • Generating Answer Variants Based on Tables of a Corpus

    US20170351677A1